Compare commits
2 Commits
85765928b4
...
dcd1b4ad94
Author | SHA1 | Date |
---|---|---|
Shadowfacts | dcd1b4ad94 | |
Shadowfacts | 3394c2126c |
|
@ -106,7 +106,15 @@ 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: list/hashtag controllers need whole objects which must be fetched asynchronously
|
// 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)
|
||||||
|
}
|
||||||
|
|
||||||
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() -> TuskerRootViewController {
|
func createAppUI() -> AccountSwitchableViewController {
|
||||||
let mastodonController = window!.windowScene!.session.mastodonController!
|
let mastodonController = window!.windowScene!.session.mastodonController!
|
||||||
mastodonController.initialize()
|
mastodonController.initialize()
|
||||||
|
|
||||||
|
|
|
@ -11,14 +11,18 @@ 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: TuskerRootViewController
|
private(set) var root: AccountSwitchableViewController
|
||||||
|
|
||||||
private var userActivities: [String: NSUserActivity] = [:]
|
private var userActivities: [String: NSUserActivity] = [:]
|
||||||
|
|
||||||
init(root: TuskerRootViewController, for account: UserAccountInfo) {
|
init(root: AccountSwitchableViewController, for account: UserAccountInfo) {
|
||||||
self.currentAccountID = account.id
|
self.currentAccountID = account.id
|
||||||
self.root = root
|
self.root = root
|
||||||
|
|
||||||
|
@ -35,7 +39,7 @@ class AccountSwitchingContainerViewController: UIViewController {
|
||||||
embedChild(root)
|
embedChild(root)
|
||||||
}
|
}
|
||||||
|
|
||||||
func setRoot(_ newRoot: TuskerRootViewController, for account: UserAccountInfo, animating direction: AnimationDirection) {
|
func setRoot(_ newRoot: AccountSwitchableViewController, for account: UserAccountInfo, animating direction: AnimationDirection) {
|
||||||
let oldRoot = self.root
|
let oldRoot = self.root
|
||||||
if direction == .none {
|
if direction == .none {
|
||||||
oldRoot.removeViewAndController()
|
oldRoot.removeViewAndController()
|
||||||
|
@ -148,8 +152,11 @@ extension AccountSwitchingContainerViewController: TuskerRootViewController {
|
||||||
|
|
||||||
func handleStatusBarTapped(xPosition: CGFloat) -> StatusBarTapActionResult {
|
func handleStatusBarTapped(xPosition: CGFloat) -> StatusBarTapActionResult {
|
||||||
loadViewIfNeeded()
|
loadViewIfNeeded()
|
||||||
// TODO: check if fast account switcher is being presented?
|
if root.isFastAccountSwitcherActive {
|
||||||
return root.handleStatusBarTapped(xPosition: xPosition)
|
return .stop
|
||||||
|
} 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: TuskerRootViewController {
|
extension DuckableContainerViewController: AccountSwitchableViewController {
|
||||||
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,4 +52,8 @@ extension DuckableContainerViewController: TuskerRootViewController {
|
||||||
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,3 +610,15 @@ 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,3 +363,13 @@ extension MainTabBarViewController: BackgroundableViewController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extension MainTabBarViewController: AccountSwitchableViewController {
|
||||||
|
var isFastAccountSwitcherActive: Bool {
|
||||||
|
if let fastAccountSwitcher {
|
||||||
|
return !fastAccountSwitcher.view.isHidden
|
||||||
|
} else {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue