Migrate from iOS 17 Observation to iOS 16-compatible Combine architecture.

Lower deployment target to iOS 16, replace @Observable with ObservableObject, add navigation and UI compatibility shims, and include login smoke UI tests.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-06-26 10:16:35 +08:00
parent c32a610ee0
commit 26f4d0e671
127 changed files with 2320 additions and 1465 deletions

View File

@ -11,12 +11,12 @@ import SwiftUI
///
struct PaymentCollectionView: View {
@Environment(AccountContext.self) private var accountContext
@Environment(PaymentAPI.self) private var paymentAPI
@Environment(ToastCenter.self) private var toastCenter
@EnvironmentObject private var accountContext: AccountContext
@Environment(\.paymentAPI) private var paymentAPI
@EnvironmentObject private var toastCenter: ToastCenter
@Environment(\.globalLoading) private var globalLoading
@State private var viewModel = PaymentCollectionViewModel()
@StateObject private var viewModel = PaymentCollectionViewModel()
@State private var showingAmountSheet = false
@State private var pollingTask: Task<Void, Never>?
@State private var speaker = PaymentVoiceSpeaker()
@ -56,12 +56,12 @@ struct PaymentCollectionView: View {
.onDisappear {
pollingTask?.cancel()
}
.onChange(of: viewModel.errorMessage) { _, message in
.onChange(of: viewModel.errorMessage) { message in
if let message {
toastCenter.show(message)
}
}
.onChange(of: viewModel.status) { _, status in
.onChange(of: viewModel.status) { status in
if case .success(let item) = status {
speaker.speak("收款到账\(item.orderAmount)")
}
@ -256,11 +256,11 @@ struct PaymentCollectionView: View {
///
struct PaymentCollectionRecordView: View {
@Environment(AccountContext.self) private var accountContext
@Environment(PaymentAPI.self) private var paymentAPI
@Environment(ToastCenter.self) private var toastCenter
@EnvironmentObject private var accountContext: AccountContext
@Environment(\.paymentAPI) private var paymentAPI
@EnvironmentObject private var toastCenter: ToastCenter
@Environment(\.globalLoading) private var globalLoading
@State private var viewModel = PaymentCollectionRecordViewModel()
@StateObject private var viewModel = PaymentCollectionRecordViewModel()
var body: some View {
List {
@ -304,7 +304,7 @@ struct PaymentCollectionRecordView: View {
await viewModel.load(api: paymentAPI, scenicId: accountContext.currentScenic?.id)
}
}
.onChange(of: viewModel.errorMessage) { _, message in
.onChange(of: viewModel.errorMessage) { message in
if let message {
toastCenter.show(message)
}
@ -314,9 +314,8 @@ struct PaymentCollectionRecordView: View {
/// 使 TTS
@MainActor
@Observable
final class PaymentVoiceSpeaker {
@ObservationIgnored private let synthesizer = AVSpeechSynthesizer()
private let synthesizer = AVSpeechSynthesizer()
///
func speak(_ text: String) {