Compare commits

..

No commits in common. "dcd1b4ad94f355dc42a5f386baec0a3667d83483" and "85765928b4591bc1853c426f3ee4dd01f87bc1c0" have entirely different histories.

6 changed files with 8 additions and 49 deletions

View File

@ -106,15 +106,7 @@ class AuxiliarySceneDelegate: UIResponder, UIWindowSceneDelegate, TuskerSceneDel
private func timelineViewController(for timeline: Timeline, mastodonController: MastodonController) -> UIViewController {
switch timeline {
// todo: hashtag controllers need whole objects which must be fetched asynchronously, and that endpoint only exists in mastodon v4
case .list(id: let id):
let req = ListMO.fetchRequest(id: id)
if let list = try? mastodonController.persistentContainer.viewContext.fetch(req).first {
return ListTimelineViewController(for: List(id: id, title: list.title), mastodonController: mastodonController)
} else {
return TimelineViewController(for: timeline, mastodonController: mastodonController)
}
// todo: list/hashtag controllers need whole objects which must be fetched asynchronously
default:
return TimelineViewController(for: timeline, mastodonController: mastodonController)
}

View File

@ -238,7 +238,7 @@ class MainSceneDelegate: UIResponder, UIWindowSceneDelegate, TuskerSceneDelegate
}
}
func createAppUI() -> AccountSwitchableViewController {
func createAppUI() -> TuskerRootViewController {
let mastodonController = window!.windowScene!.session.mastodonController!
mastodonController.initialize()

View File

@ -11,18 +11,14 @@ import ScreenCorners
import UserAccounts
import ComposeUI
protocol AccountSwitchableViewController: TuskerRootViewController {
var isFastAccountSwitcherActive: Bool { get }
}
class AccountSwitchingContainerViewController: UIViewController {
private var currentAccountID: String
private(set) var root: AccountSwitchableViewController
private(set) var root: TuskerRootViewController
private var userActivities: [String: NSUserActivity] = [:]
init(root: AccountSwitchableViewController, for account: UserAccountInfo) {
init(root: TuskerRootViewController, for account: UserAccountInfo) {
self.currentAccountID = account.id
self.root = root
@ -39,7 +35,7 @@ class AccountSwitchingContainerViewController: UIViewController {
embedChild(root)
}
func setRoot(_ newRoot: AccountSwitchableViewController, for account: UserAccountInfo, animating direction: AnimationDirection) {
func setRoot(_ newRoot: TuskerRootViewController, for account: UserAccountInfo, animating direction: AnimationDirection) {
let oldRoot = self.root
if direction == .none {
oldRoot.removeViewAndController()
@ -152,12 +148,9 @@ extension AccountSwitchingContainerViewController: TuskerRootViewController {
func handleStatusBarTapped(xPosition: CGFloat) -> StatusBarTapActionResult {
loadViewIfNeeded()
if root.isFastAccountSwitcherActive {
return .stop
} else {
// TODO: check if fast account switcher is being presented?
return root.handleStatusBarTapped(xPosition: xPosition)
}
}
}
extension AccountSwitchingContainerViewController: BackgroundableViewController {

View File

@ -11,7 +11,7 @@ import Duckable
import ComposeUI
@available(iOS 16.0, *)
extension DuckableContainerViewController: AccountSwitchableViewController {
extension DuckableContainerViewController: TuskerRootViewController {
func stateRestorationActivity() -> NSUserActivity? {
var activity = (child as? TuskerRootViewController)?.stateRestorationActivity()
if let compose = duckedViewController as? ComposeHostingController,
@ -52,8 +52,4 @@ extension DuckableContainerViewController: AccountSwitchableViewController {
func handleStatusBarTapped(xPosition: CGFloat) -> StatusBarTapActionResult {
(child as? TuskerRootViewController)?.handleStatusBarTapped(xPosition: xPosition) ?? .continue
}
var isFastAccountSwitcherActive: Bool {
(child as? AccountSwitchableViewController)?.isFastAccountSwitcherActive ?? false
}
}

View File

@ -610,15 +610,3 @@ extension MainSplitViewController: FastAccountSwitcherViewControllerDelegate {
return cellRect.contains(point)
}
}
extension MainSplitViewController: AccountSwitchableViewController {
var isFastAccountSwitcherActive: Bool {
if isCollapsed {
return tabBarViewController.isFastAccountSwitcherActive
} else if let fastAccountSwitcher {
return !fastAccountSwitcher.view.isHidden
} else {
return false
}
}
}

View File

@ -363,13 +363,3 @@ extension MainTabBarViewController: BackgroundableViewController {
}
}
}
extension MainTabBarViewController: AccountSwitchableViewController {
var isFastAccountSwitcherActive: Bool {
if let fastAccountSwitcher {
return !fastAccountSwitcher.view.isHidden
} else {
return false
}
}
}