2018-08-21 21:17:25 +00:00
|
|
|
//
|
|
|
|
// MainTabBarViewController.swift
|
|
|
|
// Tusker
|
|
|
|
//
|
2019-02-08 18:41:19 +00:00
|
|
|
// Created by Shadowfacts on 8/21/18.
|
2018-08-21 21:17:25 +00:00
|
|
|
// Copyright © 2018 Shadowfacts. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
import UIKit
|
2023-04-16 17:23:13 +00:00
|
|
|
import ComposeUI
|
2018-08-21 21:17:25 +00:00
|
|
|
|
2019-01-05 17:59:55 +00:00
|
|
|
class MainTabBarViewController: UITabBarController, UITabBarControllerDelegate {
|
2020-01-05 20:25:07 +00:00
|
|
|
|
2024-01-28 19:03:14 +00:00
|
|
|
private let mastodonController: MastodonController
|
2020-06-24 20:40:45 +00:00
|
|
|
|
|
|
|
private var composePlaceholder: UIViewController!
|
2020-06-30 02:21:03 +00:00
|
|
|
|
2024-02-23 04:32:38 +00:00
|
|
|
#if !os(visionOS)
|
2022-11-28 20:21:05 +00:00
|
|
|
private var fastAccountSwitcher: FastAccountSwitcherViewController!
|
2021-06-06 22:30:46 +00:00
|
|
|
private var fastSwitcherIndicator: FastAccountSwitcherIndicatorView!
|
|
|
|
private var fastSwitcherConstraints: [NSLayoutConstraint] = []
|
2024-02-23 04:32:38 +00:00
|
|
|
#endif
|
2021-06-06 22:30:46 +00:00
|
|
|
|
2020-06-30 02:21:03 +00:00
|
|
|
var selectedTab: Tab {
|
|
|
|
return Tab(rawValue: selectedIndex)!
|
|
|
|
}
|
2018-08-21 21:17:25 +00:00
|
|
|
|
2020-01-08 03:19:38 +00:00
|
|
|
override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
|
|
|
|
if UIDevice.current.userInterfaceIdiom == .phone {
|
|
|
|
return .portrait
|
|
|
|
} else {
|
|
|
|
return .all
|
|
|
|
}
|
|
|
|
}
|
2020-01-05 20:25:07 +00:00
|
|
|
|
|
|
|
init(mastodonController: MastodonController) {
|
|
|
|
self.mastodonController = mastodonController
|
|
|
|
|
|
|
|
super.init(nibName: nil, bundle: nil)
|
|
|
|
}
|
|
|
|
|
|
|
|
required init?(coder: NSCoder) {
|
|
|
|
fatalError("init(coder:) has not been implemented")
|
2020-01-18 23:56:36 +00:00
|
|
|
}
|
2020-01-05 20:25:07 +00:00
|
|
|
|
2018-08-21 21:17:25 +00:00
|
|
|
override func viewDidLoad() {
|
|
|
|
super.viewDidLoad()
|
2022-05-13 21:10:18 +00:00
|
|
|
|
|
|
|
stateRestorationLogger.info("MainTabBarViewController: viewDidLoad, selectedIndex=\(self.selectedIndex, privacy: .public)")
|
2018-08-21 21:17:25 +00:00
|
|
|
|
2019-01-05 17:59:55 +00:00
|
|
|
self.delegate = self
|
|
|
|
|
2020-06-24 20:40:45 +00:00
|
|
|
composePlaceholder = UIViewController()
|
|
|
|
composePlaceholder.title = "Compose"
|
|
|
|
composePlaceholder.tabBarItem.image = UIImage(systemName: "pencil")
|
|
|
|
|
2019-01-05 17:59:55 +00:00
|
|
|
viewControllers = [
|
2022-11-19 18:11:29 +00:00
|
|
|
embedInNavigationController(Tab.timelines.createViewController(mastodonController)),
|
2020-06-24 20:40:45 +00:00
|
|
|
embedInNavigationController(Tab.notifications.createViewController(mastodonController)),
|
|
|
|
composePlaceholder,
|
|
|
|
embedInNavigationController(Tab.explore.createViewController(mastodonController)),
|
|
|
|
embedInNavigationController(Tab.myProfile.createViewController(mastodonController)),
|
2019-01-05 17:59:55 +00:00
|
|
|
]
|
2020-11-10 00:39:42 +00:00
|
|
|
|
2024-02-23 04:32:38 +00:00
|
|
|
#if !os(visionOS)
|
2020-11-10 00:39:42 +00:00
|
|
|
fastAccountSwitcher = FastAccountSwitcherViewController()
|
|
|
|
fastAccountSwitcher.delegate = self
|
|
|
|
fastAccountSwitcher.view.translatesAutoresizingMaskIntoConstraints = false
|
|
|
|
|
|
|
|
tabBar.addGestureRecognizer(fastAccountSwitcher.createSwitcherGesture())
|
|
|
|
let tapRecognizer = UITapGestureRecognizer(target: self, action: #selector(tabBarTapped))
|
|
|
|
tapRecognizer.cancelsTouchesInView = false
|
|
|
|
tabBar.addGestureRecognizer(tapRecognizer)
|
2020-12-15 03:16:16 +00:00
|
|
|
|
2021-06-06 22:30:46 +00:00
|
|
|
if findMyProfileTabBarButton() != nil {
|
|
|
|
fastSwitcherIndicator = FastAccountSwitcherIndicatorView()
|
|
|
|
fastSwitcherIndicator.translatesAutoresizingMaskIntoConstraints = false
|
|
|
|
view.addSubview(fastSwitcherIndicator)
|
|
|
|
}
|
2024-02-23 04:32:38 +00:00
|
|
|
#endif
|
2021-06-06 22:30:46 +00:00
|
|
|
|
2020-12-15 03:16:16 +00:00
|
|
|
tabBar.isSpringLoaded = true
|
2022-05-13 21:10:18 +00:00
|
|
|
}
|
|
|
|
|
2024-02-23 04:32:38 +00:00
|
|
|
// Fast account switcher is not supported on visionOS
|
|
|
|
#if !os(visionOS)
|
2022-05-01 15:53:12 +00:00
|
|
|
override func viewDidLayoutSubviews() {
|
|
|
|
super.viewDidLayoutSubviews()
|
2021-06-06 22:30:46 +00:00
|
|
|
|
2022-05-01 15:53:12 +00:00
|
|
|
// i hate that we have to do this so often :S
|
|
|
|
// but doing it only in viewWillAppear makes it not appear initially
|
|
|
|
// doing it in viewWillAppear inside a DispatchQueue.main.async works initially but then it disappears when long-pressed
|
2021-06-06 22:30:46 +00:00
|
|
|
repositionFastSwitcherIndicator()
|
|
|
|
}
|
|
|
|
|
|
|
|
override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
|
|
|
|
super.traitCollectionDidChange(previousTraitCollection)
|
|
|
|
|
|
|
|
repositionFastSwitcherIndicator()
|
|
|
|
}
|
2023-10-20 02:50:20 +00:00
|
|
|
#endif
|
2021-06-06 22:30:46 +00:00
|
|
|
|
2023-05-28 21:25:49 +00:00
|
|
|
func select(tab: Tab, dismissPresented: Bool) {
|
2023-02-25 18:55:46 +00:00
|
|
|
if tab == .compose {
|
|
|
|
compose(editing: nil)
|
|
|
|
} else {
|
|
|
|
// when switching tabs, dismiss the currently presented VC
|
|
|
|
// otherwise the selected tab changes behind the presented VC
|
2023-05-28 21:25:49 +00:00
|
|
|
if presentedViewController != nil && dismissPresented {
|
2023-02-25 18:55:46 +00:00
|
|
|
dismiss(animated: true) {
|
|
|
|
self.selectedIndex = tab.rawValue
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
stateRestorationLogger.info("MainTabBarViewController: selecting \(String(describing: tab), privacy: .public)")
|
|
|
|
selectedIndex = tab.rawValue
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
override func show(_ vc: UIViewController, sender: Any?) {
|
|
|
|
if let nav = selectedViewController as? UINavigationController {
|
|
|
|
nav.pushViewController(vc, animated: true)
|
|
|
|
} else {
|
|
|
|
present(vc, animated: true)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-02-23 04:32:38 +00:00
|
|
|
#if !os(visionOS)
|
2021-06-06 22:30:46 +00:00
|
|
|
private func repositionFastSwitcherIndicator() {
|
|
|
|
guard let myProfileButton = findMyProfileTabBarButton() else {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
NSLayoutConstraint.deactivate(fastSwitcherConstraints)
|
2023-05-28 21:18:13 +00:00
|
|
|
let isPortrait = view.bounds.width < view.bounds.height
|
|
|
|
if traitCollection.horizontalSizeClass == .compact && isPortrait {
|
2021-06-06 22:30:46 +00:00
|
|
|
fastSwitcherConstraints = [
|
|
|
|
fastSwitcherIndicator.centerYAnchor.constraint(equalTo: myProfileButton.centerYAnchor, constant: -4),
|
|
|
|
// tab bar button image width is 30
|
|
|
|
fastSwitcherIndicator.leftAnchor.constraint(equalTo: myProfileButton.centerXAnchor, constant: 15 + 2),
|
|
|
|
]
|
|
|
|
} else {
|
|
|
|
fastSwitcherConstraints = [
|
|
|
|
fastSwitcherIndicator.centerYAnchor.constraint(equalTo: myProfileButton.centerYAnchor),
|
|
|
|
fastSwitcherIndicator.trailingAnchor.constraint(equalTo: myProfileButton.trailingAnchor),
|
|
|
|
]
|
|
|
|
}
|
|
|
|
NSLayoutConstraint.activate(fastSwitcherConstraints)
|
|
|
|
}
|
2024-02-23 04:32:38 +00:00
|
|
|
#endif
|
2021-06-06 22:30:46 +00:00
|
|
|
|
|
|
|
private func findMyProfileTabBarButton() -> UIView? {
|
|
|
|
let tabBarButtons = tabBar.subviews.filter { String(describing: type(of: $0)).lowercased().contains("button") }
|
|
|
|
// sanity check that there is 1 button per VC
|
|
|
|
guard tabBarButtons.count == viewControllers!.count,
|
|
|
|
let myProfileButton = tabBarButtons.last else {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return myProfileButton
|
|
|
|
}
|
|
|
|
|
2024-02-23 04:32:38 +00:00
|
|
|
#if !os(visionOS)
|
2020-11-10 00:39:42 +00:00
|
|
|
@objc private func tabBarTapped(_ recognizer: UITapGestureRecognizer) {
|
|
|
|
fastAccountSwitcher.hide()
|
2018-08-21 21:17:25 +00:00
|
|
|
}
|
2024-02-23 04:32:38 +00:00
|
|
|
#endif
|
2018-08-21 21:17:25 +00:00
|
|
|
|
2023-02-25 18:55:46 +00:00
|
|
|
@objc func handleComposeKeyCommand() {
|
|
|
|
compose(editing: nil)
|
|
|
|
}
|
|
|
|
|
2018-10-06 14:38:36 +00:00
|
|
|
func embedInNavigationController(_ vc: UIViewController) -> UINavigationController {
|
|
|
|
if let vc = vc as? UINavigationController {
|
|
|
|
return vc
|
|
|
|
} else {
|
2022-06-10 03:33:31 +00:00
|
|
|
let nav = EnhancedNavigationViewController(rootViewController: vc)
|
|
|
|
return nav
|
2018-10-06 14:38:36 +00:00
|
|
|
}
|
2018-10-01 01:28:22 +00:00
|
|
|
}
|
2018-08-31 02:30:19 +00:00
|
|
|
|
2019-01-05 17:59:55 +00:00
|
|
|
func tabBarController(_ tabBarController: UITabBarController, shouldSelect viewController: UIViewController) -> Bool {
|
2020-06-24 20:40:45 +00:00
|
|
|
if viewController == composePlaceholder {
|
2023-02-25 18:55:46 +00:00
|
|
|
compose(editing: nil)
|
2019-01-05 17:59:55 +00:00
|
|
|
return false
|
|
|
|
}
|
2023-10-20 02:50:20 +00:00
|
|
|
if selectedIndex != NSNotFound,
|
|
|
|
viewController == viewControllers![selectedIndex],
|
2020-07-03 23:36:48 +00:00
|
|
|
let nav = viewController as? UINavigationController,
|
|
|
|
nav.viewControllers.count == 1,
|
|
|
|
let scrollableVC = nav.viewControllers.first as? TabBarScrollableViewController {
|
|
|
|
scrollableVC.tabBarScrollToTop()
|
|
|
|
return false
|
|
|
|
}
|
2019-01-05 17:59:55 +00:00
|
|
|
return true
|
|
|
|
}
|
2020-06-30 02:21:03 +00:00
|
|
|
|
|
|
|
func setViewController(_ viewController: UIViewController, forTab tab: Tab) {
|
|
|
|
viewControllers![tab.rawValue] = viewController
|
|
|
|
}
|
|
|
|
|
|
|
|
func viewController(for tab: Tab) -> UIViewController {
|
|
|
|
return viewControllers![tab.rawValue]
|
|
|
|
}
|
2019-09-16 01:15:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
extension MainTabBarViewController {
|
2020-06-24 20:40:45 +00:00
|
|
|
enum Tab: Int, Hashable, CaseIterable {
|
2019-09-16 01:15:32 +00:00
|
|
|
case timelines
|
|
|
|
case notifications
|
|
|
|
case compose
|
2019-12-17 05:22:25 +00:00
|
|
|
case explore
|
2019-09-16 01:15:32 +00:00
|
|
|
case myProfile
|
2020-06-24 20:40:45 +00:00
|
|
|
|
2024-01-26 16:02:40 +00:00
|
|
|
@MainActor
|
2020-06-24 20:40:45 +00:00
|
|
|
func createViewController(_ mastodonController: MastodonController) -> UIViewController {
|
|
|
|
switch self {
|
|
|
|
case .timelines:
|
|
|
|
return TimelinesPageViewController(mastodonController: mastodonController)
|
|
|
|
case .notifications:
|
|
|
|
return NotificationsPageViewController(mastodonController: mastodonController)
|
|
|
|
case .compose:
|
2023-04-16 17:47:48 +00:00
|
|
|
return ComposeHostingController(draft: nil, mastodonController: mastodonController)
|
2020-06-24 20:40:45 +00:00
|
|
|
case .explore:
|
|
|
|
return ExploreViewController(mastodonController: mastodonController)
|
|
|
|
case .myProfile:
|
2020-07-05 20:17:56 +00:00
|
|
|
return MyProfileViewController(mastodonController: mastodonController)
|
2020-06-24 20:40:45 +00:00
|
|
|
}
|
|
|
|
}
|
2019-09-16 01:15:32 +00:00
|
|
|
}
|
2019-09-16 01:00:57 +00:00
|
|
|
|
2020-06-24 20:40:45 +00:00
|
|
|
func getTabController(tab: Tab) -> UIViewController? {
|
2019-09-16 01:00:57 +00:00
|
|
|
if tab == .compose {
|
2020-06-24 20:40:45 +00:00
|
|
|
return nil
|
2019-09-16 01:00:57 +00:00
|
|
|
} else {
|
2021-05-24 23:07:47 +00:00
|
|
|
// viewWControllers array is setup in viewDidLoad
|
|
|
|
loadViewIfNeeded()
|
2020-06-24 20:40:45 +00:00
|
|
|
return viewControllers![tab.rawValue]
|
2019-09-16 01:00:57 +00:00
|
|
|
}
|
|
|
|
}
|
2020-06-24 20:40:45 +00:00
|
|
|
}
|
|
|
|
|
2024-02-23 04:32:38 +00:00
|
|
|
#if !os(visionOS)
|
2020-11-10 00:39:42 +00:00
|
|
|
extension MainTabBarViewController: FastAccountSwitcherViewControllerDelegate {
|
2022-05-01 15:53:12 +00:00
|
|
|
func fastAccountSwitcherAddToViewHierarchy(_ fastAccountSwitcher: FastAccountSwitcherViewController) {
|
2024-04-01 14:28:40 +00:00
|
|
|
fastAccountSwitcher.view.translatesAutoresizingMaskIntoConstraints = false
|
2022-05-01 15:53:12 +00:00
|
|
|
view.addSubview(fastAccountSwitcher.view)
|
|
|
|
NSLayoutConstraint.activate([
|
|
|
|
fastAccountSwitcher.accountsStack.bottomAnchor.constraint(equalTo: fastAccountSwitcher.view.bottomAnchor),
|
|
|
|
|
|
|
|
fastAccountSwitcher.view.leadingAnchor.constraint(equalTo: view.leadingAnchor),
|
|
|
|
fastAccountSwitcher.view.trailingAnchor.constraint(equalTo: view.trailingAnchor),
|
|
|
|
fastAccountSwitcher.view.topAnchor.constraint(equalTo: view.topAnchor),
|
|
|
|
fastAccountSwitcher.view.bottomAnchor.constraint(equalTo: tabBar.topAnchor),
|
2024-04-01 14:28:40 +00:00
|
|
|
|
|
|
|
// The safe area insets don't automatically propagate for some reason, so do it ourselves.
|
|
|
|
fastAccountSwitcher.view.safeAreaLayoutGuide.leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor),
|
|
|
|
fastAccountSwitcher.view.safeAreaLayoutGuide.trailingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.trailingAnchor),
|
2022-05-01 15:53:12 +00:00
|
|
|
])
|
|
|
|
}
|
|
|
|
|
2020-11-10 00:39:42 +00:00
|
|
|
func fastAccountSwitcher(_ fastAccountSwitcher: FastAccountSwitcherViewController, triggerZoneContains point: CGPoint) -> Bool {
|
2021-06-06 22:30:46 +00:00
|
|
|
guard let myProfileButton = findMyProfileTabBarButton() else {
|
2020-11-10 00:39:42 +00:00
|
|
|
return false
|
|
|
|
}
|
2022-05-01 15:53:12 +00:00
|
|
|
let locationInButton = myProfileButton.convert(point, from: tabBar)
|
2020-11-10 00:39:42 +00:00
|
|
|
return myProfileButton.bounds.contains(locationInButton)
|
|
|
|
}
|
|
|
|
}
|
2024-02-23 04:32:38 +00:00
|
|
|
#endif
|
2020-11-10 00:39:42 +00:00
|
|
|
|
2022-11-09 03:14:40 +00:00
|
|
|
extension MainTabBarViewController: TuskerNavigationDelegate {
|
|
|
|
var apiController: MastodonController! { mastodonController }
|
|
|
|
}
|
|
|
|
|
2023-02-23 02:38:12 +00:00
|
|
|
extension MainTabBarViewController: StateRestorableViewController {
|
2022-11-23 16:35:25 +00:00
|
|
|
func stateRestorationActivity() -> NSUserActivity? {
|
2022-11-28 20:21:05 +00:00
|
|
|
var activity: NSUserActivity?
|
|
|
|
if let presentedNav = presentedViewController as? UINavigationController,
|
2023-04-16 17:47:48 +00:00
|
|
|
let compose = presentedNav.viewControllers.first as? ComposeHostingController {
|
2023-04-16 17:47:06 +00:00
|
|
|
let draft = compose.controller.draft
|
|
|
|
activity = UserActivityManager.editDraftActivity(id: draft.id, accountID: draft.accountID)
|
2023-02-25 18:55:46 +00:00
|
|
|
} else if let vc = (selectedViewController as! UINavigationController).topViewController as? StateRestorableViewController {
|
|
|
|
activity = vc.stateRestorationActivity()
|
|
|
|
}
|
|
|
|
if activity == nil {
|
|
|
|
stateRestorationLogger.fault("MainTabBarViewController: Unable to create state restoration activity, couldn't find StateRestorableViewController")
|
2022-11-23 16:35:25 +00:00
|
|
|
}
|
2022-11-28 20:21:05 +00:00
|
|
|
return activity
|
2022-11-23 16:35:25 +00:00
|
|
|
}
|
2023-02-25 18:55:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
extension MainTabBarViewController: TuskerRootViewController {
|
|
|
|
func select(route: TuskerRoute, animated: Bool) {
|
|
|
|
switch route {
|
|
|
|
case .timelines:
|
2023-05-28 21:25:49 +00:00
|
|
|
select(tab: .timelines, dismissPresented: true)
|
2023-02-25 18:55:46 +00:00
|
|
|
case .notifications:
|
2023-05-28 21:25:49 +00:00
|
|
|
select(tab: .notifications, dismissPresented: true)
|
2023-02-23 02:38:12 +00:00
|
|
|
case .myProfile:
|
2023-05-28 21:25:49 +00:00
|
|
|
select(tab: .myProfile, dismissPresented: true)
|
2023-02-25 18:55:46 +00:00
|
|
|
case .explore:
|
2023-05-28 21:25:49 +00:00
|
|
|
select(tab: .explore, dismissPresented: true)
|
2023-02-25 18:55:46 +00:00
|
|
|
case .bookmarks:
|
2023-05-28 21:25:49 +00:00
|
|
|
select(tab: .explore, dismissPresented: true)
|
2023-02-25 18:55:46 +00:00
|
|
|
getNavigationController().pushViewController(BookmarksViewController(mastodonController: mastodonController), animated: animated)
|
|
|
|
case .list(id: let id):
|
2023-05-28 21:25:49 +00:00
|
|
|
select(tab: .explore, dismissPresented: true)
|
2023-02-25 18:55:46 +00:00
|
|
|
if let list = mastodonController.getCachedList(id: id) {
|
|
|
|
let nav = getNavigationController()
|
|
|
|
_ = nav.popToRootViewController(animated: animated)
|
|
|
|
nav.pushViewController(ListTimelineViewController(for: list, mastodonController: mastodonController), animated: animated)
|
2023-02-23 02:38:12 +00:00
|
|
|
}
|
2022-11-23 16:35:25 +00:00
|
|
|
}
|
|
|
|
}
|
2023-02-25 18:55:46 +00:00
|
|
|
|
|
|
|
func getNavigationDelegate() -> TuskerNavigationDelegate? {
|
|
|
|
return self
|
2020-06-24 20:40:45 +00:00
|
|
|
}
|
2019-09-16 01:00:57 +00:00
|
|
|
|
2023-02-25 18:55:46 +00:00
|
|
|
func getNavigationController() -> NavigationControllerProtocol {
|
|
|
|
return (selectedViewController as! UINavigationController)
|
2019-09-16 01:00:57 +00:00
|
|
|
}
|
2021-05-24 23:07:47 +00:00
|
|
|
|
|
|
|
func performSearch(query: String) {
|
|
|
|
guard let exploreNavController = getTabController(tab: .explore) as? UINavigationController,
|
|
|
|
let exploreController = exploreNavController.viewControllers.first as? ExploreViewController else {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2023-05-28 21:25:49 +00:00
|
|
|
select(tab: .explore, dismissPresented: true)
|
2021-05-24 23:07:47 +00:00
|
|
|
exploreNavController.popToRootViewController(animated: false)
|
|
|
|
|
|
|
|
// setting searchController.isActive directly doesn't work until the view has loaded/appeared for the first time
|
|
|
|
if exploreController.isViewLoaded {
|
|
|
|
exploreController.searchController.isActive = true
|
|
|
|
} else {
|
|
|
|
exploreController.searchControllerStatusOnAppearance = true
|
|
|
|
// we still need to load the view so that we can setup the search query
|
|
|
|
exploreController.loadViewIfNeeded()
|
|
|
|
}
|
|
|
|
|
|
|
|
exploreController.searchController.searchBar.text = query
|
|
|
|
exploreController.resultsController.performSearch(query: query)
|
|
|
|
}
|
2022-04-30 15:46:14 +00:00
|
|
|
|
|
|
|
func presentPreferences(completion: (() -> Void)?) {
|
|
|
|
present(PreferencesNavigationController(mastodonController: mastodonController), animated: true, completion: completion)
|
|
|
|
}
|
2022-11-02 00:49:07 +00:00
|
|
|
|
|
|
|
func handleStatusBarTapped(xPosition: CGFloat) -> StatusBarTapActionResult {
|
|
|
|
guard presentedViewController == nil else {
|
|
|
|
return .stop
|
|
|
|
}
|
|
|
|
guard let vc = viewController(for: selectedTab) as? StatusBarTappableViewController else {
|
|
|
|
return .continue
|
|
|
|
}
|
|
|
|
return vc.handleStatusBarTapped(xPosition: xPosition)
|
|
|
|
}
|
2018-08-21 21:17:25 +00:00
|
|
|
}
|
2020-10-27 02:55:58 +00:00
|
|
|
|
|
|
|
extension MainTabBarViewController: BackgroundableViewController {
|
|
|
|
func sceneDidEnterBackground() {
|
|
|
|
if let selectedVC = selectedViewController as? BackgroundableViewController {
|
|
|
|
selectedVC.sceneDidEnterBackground()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-05-10 15:41:59 +00:00
|
|
|
|
|
|
|
extension MainTabBarViewController: AccountSwitchableViewController {
|
|
|
|
var isFastAccountSwitcherActive: Bool {
|
2024-02-23 04:32:38 +00:00
|
|
|
#if os(visionOS)
|
|
|
|
return false
|
|
|
|
#else
|
2023-05-10 15:41:59 +00:00
|
|
|
if let fastAccountSwitcher {
|
|
|
|
return !fastAccountSwitcher.view.isHidden
|
|
|
|
} else {
|
|
|
|
return false
|
|
|
|
}
|
2024-02-23 04:32:38 +00:00
|
|
|
#endif
|
2023-05-10 15:41:59 +00:00
|
|
|
}
|
|
|
|
}
|