mirror of
https://github.com/Finb/Bark.git
synced 2025-12-08 21:36:01 +00:00
添加 BarkTabBarController
This commit is contained in:
parent
b973ccf3f1
commit
2954e2b70e
@ -99,6 +99,7 @@
|
||||
06802E5320ECC40C00767047 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 0661A549204FDA4100965E4E /* Assets.xcassets */; };
|
||||
06840DBB272298FB001B3193 /* BKColor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06840DBA272298FB001B3193 /* BKColor.swift */; };
|
||||
06885EB6247FB9880004A303 /* MessageSettingsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06885EB5247FB9880004A303 /* MessageSettingsViewController.swift */; };
|
||||
0689CF4C2C7484A7007203A6 /* BarkTabBarController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0689CF4B2C7484A7007203A6 /* BarkTabBarController.swift */; };
|
||||
068EC15827ED99C900D5D11E /* ServerListViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 068EC15727ED99C900D5D11E /* ServerListViewController.swift */; };
|
||||
068EC15A27ED99E700D5D11E /* ServerListViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 068EC15927ED99E700D5D11E /* ServerListViewModel.swift */; };
|
||||
068F66B3247BD84C00DAD25A /* MessageListViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 068F66B2247BD84C00DAD25A /* MessageListViewController.swift */; };
|
||||
@ -327,6 +328,7 @@
|
||||
0683487220510FB20024B6DA /* UserNotificationsUI.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UserNotificationsUI.framework; path = System/Library/Frameworks/UserNotificationsUI.framework; sourceTree = SDKROOT; };
|
||||
06840DBA272298FB001B3193 /* BKColor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BKColor.swift; sourceTree = "<group>"; };
|
||||
06885EB5247FB9880004A303 /* MessageSettingsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageSettingsViewController.swift; sourceTree = "<group>"; };
|
||||
0689CF4B2C7484A7007203A6 /* BarkTabBarController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BarkTabBarController.swift; sourceTree = "<group>"; };
|
||||
068EC15727ED99C900D5D11E /* ServerListViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ServerListViewController.swift; sourceTree = "<group>"; };
|
||||
068EC15927ED99E700D5D11E /* ServerListViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ServerListViewModel.swift; sourceTree = "<group>"; };
|
||||
068F66B2247BD84C00DAD25A /* MessageListViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageListViewController.swift; sourceTree = "<group>"; };
|
||||
@ -456,6 +458,7 @@
|
||||
1E73F99D2C282822002BF649 /* SectionViewController-iPad.swift */,
|
||||
1EFB545E2C32514000B8E51B /* SectionViewModel-iPad.swift */,
|
||||
1EFB545C2C314A6800B8E51B /* BarkSplitViewController.swift */,
|
||||
0689CF4B2C7484A7007203A6 /* BarkTabBarController.swift */,
|
||||
);
|
||||
path = Controller;
|
||||
sourceTree = "<group>";
|
||||
@ -1179,6 +1182,7 @@
|
||||
0603706B20E20A7C00F4CA05 /* String+Extension.swift in Sources */,
|
||||
068F66B3247BD84C00DAD25A /* MessageListViewController.swift in Sources */,
|
||||
1E73F99E2C282822002BF649 /* SectionViewController-iPad.swift in Sources */,
|
||||
0689CF4C2C7484A7007203A6 /* BarkTabBarController.swift in Sources */,
|
||||
06BBB8B72567AC140076F63E /* MessageSettingsViewModel.swift in Sources */,
|
||||
06BBB8C12567B3EF0076F63E /* BaseTableViewCell.swift in Sources */,
|
||||
0661A543204FDA4100965E4E /* AppDelegate.swift in Sources */,
|
||||
|
||||
@ -9,7 +9,6 @@
|
||||
import CloudKit
|
||||
import CrashReporter
|
||||
import IQKeyboardManagerSwift
|
||||
import Material
|
||||
import UIKit
|
||||
import UserNotifications
|
||||
|
||||
@ -83,25 +82,10 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
|
||||
splitViewController.initViewControllers()
|
||||
self.window?.rootViewController = BarkSnackbarController(rootViewController: splitViewController)
|
||||
} else {
|
||||
let tabBarController = StateStorageTabBarController()
|
||||
tabBarController.tabBar.tintColor = BKColor.grey.darken4
|
||||
|
||||
let tabBarController = BarkTabBarController()
|
||||
self.window?.rootViewController = BarkSnackbarController(
|
||||
rootViewController: tabBarController
|
||||
)
|
||||
|
||||
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]
|
||||
}
|
||||
}
|
||||
|
||||
// 需先配置好 tabBarController 的 viewControllers,显示时会默认显示上次打开的页面
|
||||
|
||||
@ -12,33 +12,14 @@ import UIKit
|
||||
@available(iOS 14, *)
|
||||
class BarkSplitViewController: UISplitViewController {
|
||||
let sectionViewController = SectionViewController_iPad(viewModel: SectionViewModel())
|
||||
// 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
|
||||
}()
|
||||
// Compact 下替换显示成 BarkTabBarController
|
||||
let compactController = BarkTabBarController()
|
||||
|
||||
func initViewControllers() {
|
||||
self.setViewController(sectionViewController, for: .primary)
|
||||
// 设置默认打开页面
|
||||
let index: Int = Settings[.selectedViewControllerIndex] ?? 0
|
||||
self.setViewController(sectionViewController.viewControllers[index], for: .secondary)
|
||||
self.setViewController(snackBarController, for: .compact)
|
||||
self.setViewController(compactController, for: .compact)
|
||||
}
|
||||
}
|
||||
|
||||
30
Controller/BarkTabBarController.swift
Normal file
30
Controller/BarkTabBarController.swift
Normal file
@ -0,0 +1,30 @@
|
||||
//
|
||||
// BarkTabBarController.swift
|
||||
// Bark
|
||||
//
|
||||
// Created by huangfeng on 2024/8/20.
|
||||
// Copyright © 2024 Fin. All rights reserved.
|
||||
//
|
||||
|
||||
import Material
|
||||
import UIKit
|
||||
|
||||
class BarkTabBarController: StateStorageTabBarController {
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
self.tabBar.tintColor = BKColor.grey.darken4
|
||||
|
||||
self.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 self.viewControllers!.enumerated() {
|
||||
viewController.tabBarItem = tabBarItems[index]
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user