47 lines
1.6 KiB
Swift
47 lines
1.6 KiB
Swift
//
|
||
// UIKitAppNavigation.swift
|
||
// suixinkan
|
||
//
|
||
// Created by Codex on 2026/6/26.
|
||
//
|
||
|
||
import UIKit
|
||
|
||
@MainActor
|
||
/// UIKit 导航协调器,供 AppRouter、推送和 UI Test 复用。
|
||
enum UIKitAppNavigation {
|
||
weak static var homeNavigationController: UINavigationController?
|
||
weak static var profileNavigationController: UINavigationController?
|
||
|
||
/// Push 首页子模块页面。
|
||
static func pushHomeRoute(_ route: HomeRoute, animated: Bool = true) {
|
||
let viewController = AppRouteViewControllerFactory.makeViewController(for: route, services: AppServices.shared)
|
||
homeNavigationController?.pushViewController(viewController, animated: animated)
|
||
}
|
||
|
||
/// Push 个人中心子页面。
|
||
static func pushProfileRoute(_ route: ProfileRoute, animated: Bool = true) {
|
||
let viewController = AppRouteViewControllerFactory.makeViewController(
|
||
for: .profile(route),
|
||
services: AppServices.shared
|
||
)
|
||
profileNavigationController?.pushViewController(viewController, animated: animated)
|
||
}
|
||
}
|
||
|
||
extension AppRouter {
|
||
/// 同步路由栈并执行 UIKit push。
|
||
func navigateHome(_ route: HomeRoute, animated: Bool = true) {
|
||
select(.home)
|
||
router(for: .home).navigate(to: .home(route))
|
||
UIKitAppNavigation.pushHomeRoute(route, animated: animated)
|
||
}
|
||
|
||
/// 同步路由栈并执行 UIKit push。
|
||
func navigateProfile(_ route: ProfileRoute, animated: Bool = true) {
|
||
select(.profile)
|
||
router(for: .profile).navigate(to: .profile(route))
|
||
UIKitAppNavigation.pushProfileRoute(route, animated: animated)
|
||
}
|
||
}
|