Compare commits
No commits in common. "dcd1b4ad94f355dc42a5f386baec0a3667d83483" and "85765928b4591bc1853c426f3ee4dd01f87bc1c0" have entirely different histories.
dcd1b4ad94
...
85765928b4
|
@ -106,15 +106,7 @@ class AuxiliarySceneDelegate: UIResponder, UIWindowSceneDelegate, TuskerSceneDel
|
||||||
|
|
||||||
private func timelineViewController(for timeline: Timeline, mastodonController: MastodonController) -> UIViewController {
|
private func timelineViewController(for timeline: Timeline, mastodonController: MastodonController) -> UIViewController {
|
||||||
switch timeline {
|
switch timeline {
|
||||||
// todo: hashtag controllers need whole objects which must be fetched asynchronously, and that endpoint only exists in mastodon v4
|
// todo: list/hashtag controllers need whole objects which must be fetched asynchronously
|
||||||
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)
|
|
||||||
}
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return TimelineViewController(for: timeline, mastodonController: mastodonController)
|
return TimelineViewController(for: timeline, mastodonController: mastodonController)
|
||||||
}
|
}
|
||||||
|
|
|
@ -238,7 +238,7 @@ class MainSceneDelegate: UIResponder, UIWindowSceneDelegate, TuskerSceneDelegate
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func createAppUI() -> AccountSwitchableViewController {
|
func createAppUI() -> TuskerRootViewController {
|
||||||
let mastodonController = window!.windowScene!.session.mastodonController!
|
let mastodonController = window!.windowScene!.session.mastodonController!
|
||||||
mastodonController.initialize()
|
mastodonController.initialize()
|
||||||
|
|
||||||
|
|
|
@ -11,18 +11,14 @@ import ScreenCorners
|
||||||
import UserAccounts
|
import UserAccounts
|
||||||
import ComposeUI
|
import ComposeUI
|
||||||
|
|
||||||
protocol AccountSwitchableViewController: TuskerRootViewController {
|
|
||||||
var isFastAccountSwitcherActive: Bool { get }
|
|
||||||
}
|
|
||||||
|
|
||||||
class AccountSwitchingContainerViewController: UIViewController {
|
class AccountSwitchingContainerViewController: UIViewController {
|
||||||
|
|
||||||
private var currentAccountID: String
|
private var currentAccountID: String
|
||||||
private(set) var root: AccountSwitchableViewController
|
private(set) var root: TuskerRootViewController
|
||||||
|
|
||||||
private var userActivities: [String: NSUserActivity] = [:]
|
private var userActivities: [String: NSUserActivity] = [:]
|
||||||
|
|
||||||
init(root: AccountSwitchableViewController, for account: UserAccountInfo) {
|
init(root: TuskerRootViewController, for account: UserAccountInfo) {
|
||||||
self.currentAccountID = account.id
|
self.currentAccountID = account.id
|
||||||
self.root = root
|
self.root = root
|
||||||
|
|
||||||
|
@ -39,7 +35,7 @@ class AccountSwitchingContainerViewController: UIViewController {
|
||||||
embedChild(root)
|
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
|
let oldRoot = self.root
|
||||||
if direction == .none {
|
if direction == .none {
|
||||||
oldRoot.removeViewAndController()
|
oldRoot.removeViewAndController()
|
||||||
|
@ -152,11 +148,8 @@ extension AccountSwitchingContainerViewController: TuskerRootViewController {
|
||||||
|
|
||||||
func handleStatusBarTapped(xPosition: CGFloat) -> StatusBarTapActionResult {
|
func handleStatusBarTapped(xPosition: CGFloat) -> StatusBarTapActionResult {
|
||||||
loadViewIfNeeded()
|
loadViewIfNeeded()
|
||||||
if root.isFastAccountSwitcherActive {
|
// TODO: check if fast account switcher is being presented?
|
||||||
return .stop
|
return root.handleStatusBarTapped(xPosition: xPosition)
|
||||||
} else {
|
|
||||||
return root.handleStatusBarTapped(xPosition: xPosition)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ import Duckable
|
||||||
import ComposeUI
|
import ComposeUI
|
||||||
|
|
||||||
@available(iOS 16.0, *)
|
@available(iOS 16.0, *)
|
||||||
extension DuckableContainerViewController: AccountSwitchableViewController {
|
extension DuckableContainerViewController: TuskerRootViewController {
|
||||||
func stateRestorationActivity() -> NSUserActivity? {
|
func stateRestorationActivity() -> NSUserActivity? {
|
||||||
var activity = (child as? TuskerRootViewController)?.stateRestorationActivity()
|
var activity = (child as? TuskerRootViewController)?.stateRestorationActivity()
|
||||||
if let compose = duckedViewController as? ComposeHostingController,
|
if let compose = duckedViewController as? ComposeHostingController,
|
||||||
|
@ -52,8 +52,4 @@ extension DuckableContainerViewController: AccountSwitchableViewController {
|
||||||
func handleStatusBarTapped(xPosition: CGFloat) -> StatusBarTapActionResult {
|
func handleStatusBarTapped(xPosition: CGFloat) -> StatusBarTapActionResult {
|
||||||
(child as? TuskerRootViewController)?.handleStatusBarTapped(xPosition: xPosition) ?? .continue
|
(child as? TuskerRootViewController)?.handleStatusBarTapped(xPosition: xPosition) ?? .continue
|
||||||
}
|
}
|
||||||
|
|
||||||
var isFastAccountSwitcherActive: Bool {
|
|
||||||
(child as? AccountSwitchableViewController)?.isFastAccountSwitcherActive ?? false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -610,15 +610,3 @@ extension MainSplitViewController: FastAccountSwitcherViewControllerDelegate {
|
||||||
return cellRect.contains(point)
|
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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -363,13 +363,3 @@ extension MainTabBarViewController: BackgroundableViewController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension MainTabBarViewController: AccountSwitchableViewController {
|
|
||||||
var isFastAccountSwitcherActive: Bool {
|
|
||||||
if let fastAccountSwitcher {
|
|
||||||
return !fastAccountSwitcher.view.isHidden
|
|
||||||
} else {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue