103 lines
3.3 KiB
Swift
103 lines
3.3 KiB
Swift
//
|
|
// TuskerRootViewController.swift
|
|
// Tusker
|
|
//
|
|
// Created by Shadowfacts on 6/24/20.
|
|
// Copyright © 2020 Shadowfacts. All rights reserved.
|
|
//
|
|
|
|
import UIKit
|
|
import ComposeUI
|
|
|
|
@MainActor
|
|
protocol TuskerRootViewController: UIViewController, StateRestorableViewController, StatusBarTappableViewController {
|
|
func compose(editing draft: Draft?, animated: Bool, isDucked: Bool)
|
|
func select(route: TuskerRoute, animated: Bool)
|
|
func getTabController(tab: MainTabBarViewController.Tab) -> UIViewController?
|
|
func getNavigationDelegate() -> TuskerNavigationDelegate?
|
|
func getNavigationController() -> NavigationControllerProtocol
|
|
func performSearch(query: String)
|
|
func presentPreferences(completion: (() -> Void)?)
|
|
}
|
|
|
|
//extension TuskerRootViewController {
|
|
// func select(route: NewRoute, animated: Bool) {
|
|
// doApply(components: route.components, animated: animated)
|
|
// }
|
|
//
|
|
// private func doApply(components: ArraySlice<RouteComponent>, animated: Bool) {
|
|
// guard let first = components.first else {
|
|
// return
|
|
// }
|
|
// doApply(component: first, animated: animated) {
|
|
// self.doApply(components: components.dropFirst(), animated: animated)
|
|
// }
|
|
// }
|
|
//
|
|
// private func doApply(component: RouteComponent, animated: Bool, completion: @escaping () -> Void) {
|
|
// switch component {
|
|
// case .topLevelItem(let rootRoute):
|
|
// select(route: rootRoute)
|
|
// completion()
|
|
// case .popToRoot:
|
|
// _ = getNavigationController().popToRootViewController(animated: animated)
|
|
// completion()
|
|
// case .push(<#T##(MastodonController) -> UIViewController#>)
|
|
// }
|
|
// }
|
|
//}
|
|
|
|
enum TuskerRoute {
|
|
case timelines
|
|
case notifications
|
|
case myProfile
|
|
case explore
|
|
case bookmarks
|
|
case list(id: String)
|
|
}
|
|
|
|
//struct NewRoute: ExpressibleByArrayLiteral {
|
|
// let components: [RouteComponent]
|
|
//
|
|
// init(arrayLiteral elements: RouteComponent...) {
|
|
// self.components = elements
|
|
// }
|
|
//
|
|
// static var timelines: Self { [.topLevelItem(.timelines)] }
|
|
// static var explore: Self { [.topLevelItem(.explore)] }
|
|
// static var myProfile: Self { [.topLevelItem(.myProfile)] }
|
|
// static var bookmarks: Self { [.topLevelItem(.explore), .push({ BookmarksViewController(mastodonController: $0) })] }
|
|
// static func profile(accountID: String) -> Self { [.topLevelItem(.timelines), .push({ ProfileViewController(accountID: accountID, mastodonController: $0) })] }
|
|
//}
|
|
//
|
|
//enum RouteComponent {
|
|
// case topLevelItem(RootRoute)
|
|
// case popToRoot
|
|
// case push((MastodonController) -> UIViewController)
|
|
// case present(UIViewController)
|
|
//}
|
|
//
|
|
//enum RootRoute {
|
|
// case timelines
|
|
// case explore
|
|
// case myProfile
|
|
//}
|
|
//
|
|
@MainActor
|
|
protocol NavigationControllerProtocol: UIViewController {
|
|
var viewControllers: [UIViewController] { get set }
|
|
var topViewController: UIViewController? { get }
|
|
@discardableResult
|
|
func popToRootViewController(animated: Bool) -> [UIViewController]?
|
|
func pushViewController(_ vc: UIViewController, animated: Bool)
|
|
}
|
|
|
|
extension UINavigationController: NavigationControllerProtocol {
|
|
}
|
|
|
|
extension SplitNavigationController: NavigationControllerProtocol {
|
|
var topViewController: UIViewController? {
|
|
viewControllers.last
|
|
}
|
|
}
|