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

@ -47,25 +47,34 @@ enum LivePushNetworkState: Equatable {
protocol LivePushAdapter {
var name: String { get }
var isAvailable: Bool { get }
/// prepare
func prepare(pushURL: URL) async throws
/// start
func start() async throws
/// stop
func stop() async throws
/// dispose
func dispose() async
}
/// AVFoundation 便
protocol LivePermissionProviding {
/// camera
func cameraPermission() async -> LivePushPermissionState
/// microphone
func microphonePermission() async -> LivePushPermissionState
}
/// NWPathMonitor 便
protocol LiveNetworkMonitoring: AnyObject {
var currentState: LivePushNetworkState { get }
/// start
func start(_ onChange: @escaping @Sendable (LivePushNetworkState) -> Void)
/// stop
func stop()
}
/// LivePushReadiness
enum LivePushReadinessError: LocalizedError, Equatable {
case missingPushURL
case invalidPushURL
@ -89,32 +98,41 @@ enum LivePushReadinessError: LocalizedError, Equatable {
}
}
/// UnsupportedLivePushAdapter
struct UnsupportedLivePushAdapter: LivePushAdapter {
let name = "未接入推流 SDK"
let isAvailable = false
/// prepare
func prepare(pushURL: URL) async throws {
throw LivePushReadinessError.sdkUnavailable
}
/// start
func start() async throws {
throw LivePushReadinessError.sdkUnavailable
}
/// stop
func stop() async throws {}
/// dispose
func dispose() async {}
}
/// SystemLivePermission
struct SystemLivePermissionProvider: LivePermissionProviding {
/// camera
func cameraPermission() async -> LivePushPermissionState {
await permission(for: .video)
}
/// microphone
func microphonePermission() async -> LivePushPermissionState {
await permission(for: .audio)
}
/// permission
private func permission(for mediaType: AVMediaType) async -> LivePushPermissionState {
switch AVCaptureDevice.authorizationStatus(for: mediaType) {
case .authorized:
@ -130,6 +148,7 @@ struct SystemLivePermissionProvider: LivePermissionProviding {
}
}
/// SystemLiveNetworkMonitor
final class SystemLiveNetworkMonitor: LiveNetworkMonitoring {
var onChange: (() -> Void)?
@ -137,6 +156,7 @@ final class SystemLiveNetworkMonitor: LiveNetworkMonitoring {
private let queue = DispatchQueue(label: "com.suixinkan.live.network")
private(set) var currentState: LivePushNetworkState = .unknown
/// start
func start(_ onChange: @escaping @Sendable (LivePushNetworkState) -> Void) {
monitor.pathUpdateHandler = { [weak self] path in
let state = Self.state(from: path)
@ -146,10 +166,12 @@ final class SystemLiveNetworkMonitor: LiveNetworkMonitoring {
monitor.start(queue: queue)
}
/// stop
func stop() {
monitor.cancel()
}
/// state
private static func state(from path: NWPath) -> LivePushNetworkState {
guard path.status == .satisfied else { return .unavailable }
if path.usesInterfaceType(.wifi) { return .wifi }
@ -177,6 +199,7 @@ final class LivePushReadinessViewModel {
private let adapter: any LivePushAdapter
private var pushURL: URL?
///
init(
permissionProvider: any LivePermissionProviding = SystemLivePermissionProvider(),
networkMonitor: any LiveNetworkMonitoring = SystemLiveNetworkMonitor(),
@ -190,6 +213,7 @@ final class LivePushReadinessViewModel {
self.networkState = networkMonitor.currentState
}
///
func configure(pushURL rawValue: String) {
let value = rawValue.liveTrimmed
guard !value.isEmpty else {
@ -206,6 +230,7 @@ final class LivePushReadinessViewModel {
errorMessage = nil
}
/// startMonitoring
func startMonitoring() {
networkState = networkMonitor.currentState
networkMonitor.start { [weak self] state in
@ -215,10 +240,12 @@ final class LivePushReadinessViewModel {
}
}
/// stopMonitoring
func stopMonitoring() {
networkMonitor.stop()
}
/// refreshPermissions
func refreshPermissions() async {
async let camera = permissionProvider.cameraPermission()
async let microphone = permissionProvider.microphonePermission()
@ -226,6 +253,7 @@ final class LivePushReadinessViewModel {
microphonePermission = await microphone
}
/// runDiagnostics
func runDiagnostics() throws {
do {
try validateReadiness()
@ -240,6 +268,7 @@ final class LivePushReadinessViewModel {
errorMessage = nil
}
/// prepare
func prepare() async throws {
try validateReadiness()
guard let pushURL else { throw LivePushReadinessError.missingPushURL }
@ -253,6 +282,7 @@ final class LivePushReadinessViewModel {
}
}
/// start
func startPush() async throws {
try validateReadiness()
guard adapter.isAvailable else {
@ -265,11 +295,13 @@ final class LivePushReadinessViewModel {
errorMessage = nil
}
/// stop
func stopPush() async {
try? await adapter.stop()
running = false
}
/// dispose
func dispose() async {
stopMonitoring()
await adapter.dispose()
@ -277,6 +309,7 @@ final class LivePushReadinessViewModel {
prepared = false
}
/// Readiness
private func validateReadiness() throws {
guard pushURL != nil else {
throw LivePushReadinessError.missingPushURL