Add login flow, session routing, and MainTab shell aligned with reference UI.

Implement token-based root routing, Android-matched login screen, five-slot MainTabBar with scan action, and placeholder tab pages.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-07-06 15:12:34 +08:00
parent e290656322
commit b7d74905b7
70 changed files with 1588 additions and 48 deletions

View File

@ -0,0 +1,73 @@
//
// TabNavigationController.swift
// suixinkan
//
import UIKit
/// Tab
final class TabNavigationController: UINavigationController {
let appTab: AppTab
init(tab: AppTab) {
self.appTab = tab
super.init(nibName: nil, bundle: nil)
delegate = self
navigationBar.prefersLargeTitles = false
setViewControllers([tab.makeRootViewController()], animated: false)
}
@available(*, unavailable)
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func pushViewController(_ viewController: UIViewController, animated: Bool) {
viewController.hidesBottomBarWhenPushed = viewControllers.count > 0
updateNavigationBarVisibility(for: viewController, animated: animated)
super.pushViewController(viewController, animated: animated)
}
override func setViewControllers(_ viewControllers: [UIViewController], animated: Bool) {
if let topViewController = viewControllers.last {
updateNavigationBarVisibility(for: topViewController, animated: animated)
}
super.setViewControllers(viewControllers, animated: animated)
}
override func popViewController(animated: Bool) -> UIViewController? {
let poppedViewController = super.popViewController(animated: animated)
if !animated, let topViewController {
updateNavigationBarVisibility(for: topViewController, animated: false)
}
return poppedViewController
}
override func popToRootViewController(animated: Bool) -> [UIViewController]? {
let poppedViewControllers = super.popToRootViewController(animated: animated)
if !animated, let topViewController {
updateNavigationBarVisibility(for: topViewController, animated: false)
}
return poppedViewControllers
}
private func shouldHideNavigationBar(for viewController: UIViewController) -> Bool {
viewController is HomeViewController
}
private func updateNavigationBarVisibility(for viewController: UIViewController, animated: Bool) {
setNavigationBarHidden(shouldHideNavigationBar(for: viewController), animated: animated)
}
}
extension TabNavigationController: UINavigationControllerDelegate {
func navigationController(
_ navigationController: UINavigationController,
willShow viewController: UIViewController,
animated: Bool
) {
updateNavigationBarVisibility(for: viewController, animated: animated)
}
}