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:
2026-06-26 15:16:12 +08:00
parent 9edf993432
commit d99a5b1bf8
124 changed files with 5195 additions and 1536 deletions

View File

@ -13,8 +13,9 @@ import AMapLocationKit
import AMapSearchKit
import MAMapKit
/// SDK Key
enum AMapBootstrap {
/// App `apiKey` Key
/// App API Key
static func configure(apiKey: String) {
guard !apiKey.isEmpty else { return }
@ -30,7 +31,9 @@ enum AMapBootstrap {
}
}
#else
/// SDK
enum AMapBootstrap {
///
static func configure(apiKey: String) {}
}
#endif

View File

@ -67,6 +67,7 @@ final class AppServices {
accountContext.profile?.userId
}
///
private init() {
let client = APIClient()
let tokenStore = SessionTokenStore()

View File

@ -8,7 +8,7 @@
#if DEBUG
import UIKit
/// UI Test TabBar XCUITest push
/// UI Test Tab push
@MainActor
enum AppUITestRouteDriver {
private static var didApply = false

View File

@ -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)
}

View File

@ -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 {

View File

@ -53,6 +53,7 @@ final class AppRouter {
private let routers: [AppTab: RouterPath]
///
init() {
var builtRouters: [AppTab: RouterPath] = [:]
for tab in AppTab.allCases {

View File

@ -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 }

View File

@ -106,6 +106,7 @@ final class ToastOverlayView: UIView {
nil
}
/// Views
private func configureViews() {
bannerView.backgroundColor = AppDesign.primary
bannerView.isHidden = true
@ -134,6 +135,7 @@ final class ToastOverlayView: UIView {
])
}
/// Presentation
private func refreshPresentation(animated: Bool) {
guard let message = toastCenter?.message, !message.isEmpty else {
hideBanner(animated: animated)
@ -144,6 +146,7 @@ final class ToastOverlayView: UIView {
showBanner(animated: animated)
}
/// Banner
private func showBanner(animated: Bool) {
guard bannerView.isHidden || bannerView.alpha < 1 else { return }
@ -162,6 +165,7 @@ final class ToastOverlayView: UIView {
}
}
/// Banner
private func hideBanner(animated: Bool) {
guard !bannerView.isHidden else { return }

View File

@ -14,6 +14,7 @@ final class RootViewController: UIViewController {
private var currentChild: UIViewController?
private let restoringView = UIView()
///
init(services: AppServices = .shared) {
self.services = services
super.init(nibName: nil, bundle: nil)
@ -24,6 +25,7 @@ final class RootViewController: UIViewController {
fatalError("init(coder:) has not been implemented")
}
///
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .systemBackground
@ -38,11 +40,13 @@ final class RootViewController: UIViewController {
configurePushNotifications()
}
/// Toast Loading window
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
attachGlobalOverlays()
}
///
private func bootstrapSession() {
Task {
await services.globalLoading.withLoading {
@ -62,16 +66,19 @@ final class RootViewController: UIViewController {
}
}
///
private func configurePushNotifications() {
services.configurePushNotifications()
}
/// Toast Loading window
private func attachGlobalOverlays() {
guard let window = view.window else { return }
services.toastCenter.attachToWindow(window)
services.globalLoading.attachToWindow(window)
}
///
private func handleSessionPhaseChange() {
mountChild(for: services.appSession.phase)
@ -82,6 +89,7 @@ final class RootViewController: UIViewController {
}
Task { await reloadScenicSpotContextIfNeeded() }
case .loggedOut:
//
services.accountContext.reset()
services.permissionContext.reset()
services.scenicSpotContext.reset()
@ -93,6 +101,7 @@ final class RootViewController: UIViewController {
}
}
/// ID
private func reloadScenicSpotContextIfNeeded() async {
guard services.appSession.isLoggedIn else {
services.scenicSpotContext.reset()
@ -104,6 +113,7 @@ final class RootViewController: UIViewController {
)
}
/// Tab
private func mountChild(for phase: AuthPhase) {
let nextChild: UIViewController
switch phase {
@ -130,6 +140,7 @@ final class RootViewController: UIViewController {
currentChild = nextChild
}
///
private func restoringViewController() -> UIViewController {
let controller = UIViewController()
controller.view.backgroundColor = .systemBackground