Bark/Controller/BarkSplitViewController.swift
2024-09-02 16:19:42 +08:00

63 lines
2.5 KiB
Swift
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// BarkSplitViewController.swift
// Bark
//
// Created by sidguan on 2024/6/30.
// Copyright © 2024 Fin. All rights reserved.
//
import Material
import UIKit
class BarkSplitViewController: UISplitViewController {
override func viewDidLoad() {
super.viewDidLoad()
// oneOverSecondary
// primary
self.preferredDisplayMode = .oneBesideSecondary
self.delegate = self
}
let sectionViewController = BarkNavigationController(
rootViewController: SectionViewController_iPad(viewModel: SectionViewModel())
)
let homeViewController = BarkNavigationController(
rootViewController: HomeViewController(viewModel: HomeViewModel())
)
// Compact snackBarController
let snackBarController: StateStorageTabBarController = {
let tabBarController = StateStorageTabBarController()
tabBarController.tabBar.tintColor = BKColor.grey.darken4
tabBarController.viewControllers = [
BarkNavigationController(rootViewController: HomeViewController(viewModel: HomeViewModel())),
BarkNavigationController(rootViewController: MessageListViewController(viewModel: MessageListViewModel())),
BarkNavigationController(rootViewController: MessageSettingsViewController(viewModel: MessageSettingsViewModel()))
]
let tabBarItems = [
UITabBarItem(title: NSLocalizedString("service"), image: UIImage(named: "baseline_gite_black_24pt"), tag: 0),
UITabBarItem(title: NSLocalizedString("historyMessage"), image: Icon.history, tag: 1),
UITabBarItem(title: NSLocalizedString("settings"), image: UIImage(named: "baseline_manage_accounts_black_24pt"), tag: 2)
]
for (index, viewController) in tabBarController.viewControllers!.enumerated() {
viewController.tabBarItem = tabBarItems[index]
}
return tabBarController
}()
func initViewControllers() {
self.viewControllers = [sectionViewController, homeViewController]
}
}
extension BarkSplitViewController: UISplitViewControllerDelegate {
func primaryViewController(forExpanding splitViewController: UISplitViewController) -> UIViewController? {
sectionViewController
}
func primaryViewController(forCollapsing splitViewController: UISplitViewController) -> UIViewController? {
snackBarController
}
}