从 iOS 17 Observation 迁移至 iOS 16 兼容的 Combine 架构

将最低部署版本降至 iOS 16,以 ObservableObject 替换 @Observable,新增导航与 UI 兼容层,并补充登录冒烟 UI 测试。

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

View File

@ -9,15 +9,15 @@ import SwiftUI
///
struct ScheduleManagementView: View {
@Environment(AccountContext.self) private var accountContext
@Environment(ScheduleAPI.self) private var scheduleAPI
@EnvironmentObject private var accountContext: AccountContext
@Environment(\.scheduleAPI) private var scheduleAPI
@Environment(\.globalLoading) private var globalLoading
@State private var viewModel = ScheduleManagementViewModel()
@StateObject private var viewModel = ScheduleManagementViewModel()
var body: some View {
VStack(spacing: 0) {
if accountContext.currentScenic?.id == nil {
ContentUnavailableView("缺少景区", systemImage: "calendar.badge.exclamationmark", description: Text("请选择景区后再查看排班。"))
AppContentUnavailableView("缺少景区", systemImage: "calendar.badge.exclamationmark", description: Text("请选择景区后再查看排班。"))
.frame(maxWidth: .infinity, maxHeight: .infinity)
} else {
ScrollView {
@ -96,7 +96,7 @@ struct ScheduleManagementView: View {
Text(viewModel.selectedDate.scheduleDayText)
.font(.system(size: AppMetrics.FontSize.body, weight: .semibold))
if viewModel.items.isEmpty {
ContentUnavailableView("当天暂无日程", systemImage: "calendar")
AppContentUnavailableView("当天暂无日程", systemImage: "calendar")
.frame(minHeight: 180)
} else {
ForEach(viewModel.items) { item in
@ -126,10 +126,10 @@ struct ScheduleManagementView: View {
///
struct ScheduleAddView: View {
@Environment(\.dismiss) private var dismiss
@Environment(AccountContext.self) private var accountContext
@Environment(ScheduleAPI.self) private var scheduleAPI
@EnvironmentObject private var accountContext: AccountContext
@Environment(\.scheduleAPI) private var scheduleAPI
@Environment(\.globalLoading) private var globalLoading
@State private var viewModel = ScheduleAddViewModel()
@StateObject private var viewModel = ScheduleAddViewModel()
@State private var date = Date()
@State private var startTime = Date()
@State private var endTime = Calendar.current.date(byAdding: .hour, value: 1, to: Date()) ?? Date()