Advance UIKit rewrite with AMap integration and core UI modules.
Integrate高德 SDK with simulator-safe build flags, add map views for operating area and punch points, refactor main tabs and key feature screens to UIKit with Diffable lists, and document Swift concurrency defaults in AGENTS.md. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@ -164,6 +164,7 @@ enum AppRouteViewControllerFactory {
|
||||
}
|
||||
}
|
||||
|
||||
/// 将首页路由编码为 URI 字符串。
|
||||
private static func homeRouteURI(_ route: HomeRoute) -> String {
|
||||
if case let .modulePlaceholder(uri, _) = route {
|
||||
return uri
|
||||
@ -175,6 +176,7 @@ enum AppRouteViewControllerFactory {
|
||||
@MainActor
|
||||
/// 首页路由 ViewController 工厂,供 `UIKitAppNavigation` 复用。
|
||||
enum HomeRouteViewControllerFactory {
|
||||
/// 创建实例。
|
||||
static func make(for route: HomeRoute) -> UIViewController {
|
||||
AppRouteViewControllerFactory.makeViewController(for: route, services: AppServices.shared)
|
||||
}
|
||||
|
||||
@ -29,19 +29,47 @@ enum AppTab: String, CaseIterable, Identifiable, Hashable {
|
||||
}
|
||||
}
|
||||
|
||||
var systemImage: String {
|
||||
/// 选中态 TabBar 图标资源名。
|
||||
var selectedImageName: String {
|
||||
switch self {
|
||||
case .home:
|
||||
"house"
|
||||
"TabHomeSelected"
|
||||
case .orders:
|
||||
"doc.text"
|
||||
"TabOrderSelected"
|
||||
case .statistics:
|
||||
"chart.bar"
|
||||
"TabDataSelected"
|
||||
case .profile:
|
||||
"person"
|
||||
"TabProfileSelected"
|
||||
}
|
||||
}
|
||||
|
||||
/// 未选中态 TabBar 图标资源名。
|
||||
var unselectedImageName: String {
|
||||
switch self {
|
||||
case .home:
|
||||
"TabHomeUnselected"
|
||||
case .orders:
|
||||
"TabOrderUnselected"
|
||||
case .statistics:
|
||||
"TabDataUnselected"
|
||||
case .profile:
|
||||
"TabProfileUnselected"
|
||||
}
|
||||
}
|
||||
|
||||
/// 构建系统 TabBarItem,供 `UITabBarController` 使用。
|
||||
func makeTabBarItem() -> UITabBarItem {
|
||||
let unselectedImage = UIImage(named: unselectedImageName)?.withRenderingMode(.alwaysOriginal)
|
||||
let selectedImage = UIImage(named: selectedImageName)?.withRenderingMode(.alwaysOriginal)
|
||||
let item = UITabBarItem(
|
||||
title: title,
|
||||
image: unselectedImage,
|
||||
selectedImage: selectedImage
|
||||
)
|
||||
item.accessibilityIdentifier = "main.tab.\(rawValue)"
|
||||
return item
|
||||
}
|
||||
|
||||
/// 构建 Tab 根页面 ViewController。
|
||||
func makeRootViewController(services: AppServices) -> UIViewController {
|
||||
switch self {
|
||||
|
||||
@ -53,6 +53,7 @@ final class AppRouter {
|
||||
|
||||
private let routers: [AppTab: RouterPath]
|
||||
|
||||
/// 初始化实例。
|
||||
init() {
|
||||
var builtRouters: [AppTab: RouterPath] = [:]
|
||||
for tab in AppTab.allCases {
|
||||
|
||||
@ -13,8 +13,7 @@ final class TabNavigationController: UINavigationController, UINavigationControl
|
||||
private let services: AppServices
|
||||
private var isSyncingStack = false
|
||||
|
||||
weak var tabBarHost: MainTabBarController?
|
||||
|
||||
/// 初始化实例。
|
||||
init(tab: AppTab, services: AppServices) {
|
||||
self.appTab = tab
|
||||
self.services = services
|
||||
@ -43,15 +42,7 @@ final class TabNavigationController: UINavigationController, UINavigationControl
|
||||
pushViewController(viewController, animated: animated)
|
||||
}
|
||||
|
||||
func navigationController(
|
||||
_ navigationController: UINavigationController,
|
||||
willShow viewController: UIViewController,
|
||||
animated: Bool
|
||||
) {
|
||||
let isRoot = viewController === viewControllers.first
|
||||
tabBarHost?.setCustomTabBarHidden(!isRoot, animated: animated)
|
||||
}
|
||||
|
||||
/// navigationController相关逻辑。
|
||||
func navigationController(
|
||||
_ navigationController: UINavigationController,
|
||||
didShow viewController: UIViewController,
|
||||
@ -60,6 +51,7 @@ final class TabNavigationController: UINavigationController, UINavigationControl
|
||||
syncRouterPathFromStack()
|
||||
}
|
||||
|
||||
/// 注册NavigationBridge。
|
||||
private func registerNavigationBridge() {
|
||||
switch appTab {
|
||||
case .home:
|
||||
@ -71,6 +63,7 @@ final class TabNavigationController: UINavigationController, UINavigationControl
|
||||
}
|
||||
}
|
||||
|
||||
/// 同步FromRouterPath状态。
|
||||
private func syncFromRouterPath() {
|
||||
guard !isSyncingStack else { return }
|
||||
|
||||
@ -79,6 +72,7 @@ final class TabNavigationController: UINavigationController, UINavigationControl
|
||||
let currentDepth = max(viewControllers.count - 1, 0)
|
||||
|
||||
if targetDepth > currentDepth {
|
||||
// Router 路径变深:按路径依次 push 缺失页面
|
||||
for index in currentDepth..<targetDepth {
|
||||
let route = routerPath.path[index]
|
||||
let viewController = AppRouteViewControllerFactory.makeViewController(for: route, services: services)
|
||||
@ -89,6 +83,7 @@ final class TabNavigationController: UINavigationController, UINavigationControl
|
||||
}
|
||||
|
||||
if targetDepth < currentDepth {
|
||||
// Router 路径变浅:pop 至目标深度
|
||||
if targetDepth == 0 {
|
||||
popToRootViewController(animated: true)
|
||||
} else if targetDepth < viewControllers.count {
|
||||
@ -97,6 +92,7 @@ final class TabNavigationController: UINavigationController, UINavigationControl
|
||||
}
|
||||
}
|
||||
|
||||
/// 同步RouterPathFromStack状态。
|
||||
private func syncRouterPathFromStack() {
|
||||
guard !isSyncingStack else { return }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user