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:
@ -9,14 +9,14 @@ import SwiftUI
|
||||
|
||||
/// 数据 Tab 根视图,展示订单统计汇总和每日明细。
|
||||
struct StatisticsView: View {
|
||||
@Environment(AccountContext.self) private var accountContext
|
||||
@Environment(PermissionContext.self) private var permissionContext
|
||||
@Environment(StatisticsAPI.self) private var statisticsAPI
|
||||
@Environment(ToastCenter.self) private var toastCenter
|
||||
@EnvironmentObject private var accountContext: AccountContext
|
||||
@EnvironmentObject private var permissionContext: PermissionContext
|
||||
@Environment(\.statisticsAPI) private var statisticsAPI
|
||||
@EnvironmentObject private var toastCenter: ToastCenter
|
||||
@Environment(\.globalLoading) private var globalLoading
|
||||
@Environment(\.horizontalSizeClass) private var horizontalSizeClass
|
||||
|
||||
@State private var viewModel = StatisticsViewModel()
|
||||
@StateObject private var viewModel = StatisticsViewModel()
|
||||
|
||||
private var currentScenicId: Int? {
|
||||
accountContext.currentScenic?.id
|
||||
@ -33,7 +33,7 @@ struct StatisticsView: View {
|
||||
var body: some View {
|
||||
Group {
|
||||
if currentScenicId == nil {
|
||||
ContentUnavailableView(
|
||||
AppContentUnavailableView(
|
||||
"缺少经营上下文",
|
||||
systemImage: "chart.bar.doc.horizontal",
|
||||
description: Text("请先在首页选择景区后查看数据看板。")
|
||||
@ -59,10 +59,10 @@ struct StatisticsView: View {
|
||||
.navigationTitle("数据")
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
.task { await reload() }
|
||||
.onChange(of: accountContext.currentScenic?.id) { _, _ in
|
||||
.onChange(of: accountContext.currentScenic?.id) { _ in
|
||||
Task { await reload() }
|
||||
}
|
||||
.onChange(of: permissionContext.currentRole?.id) { _, _ in
|
||||
.onChange(of: permissionContext.currentRole?.id) { _ in
|
||||
Task { await reload() }
|
||||
}
|
||||
}
|
||||
@ -171,7 +171,7 @@ struct StatisticsView: View {
|
||||
.frame(maxWidth: .infinity)
|
||||
.frame(minHeight: 280)
|
||||
} else if viewModel.dailyItems.isEmpty {
|
||||
ContentUnavailableView("暂无数据", systemImage: "tray", description: Text("可切换时间范围或下拉刷新。"))
|
||||
AppContentUnavailableView("暂无数据", systemImage: "tray", description: Text("可切换时间范围或下拉刷新。"))
|
||||
.frame(minHeight: 280)
|
||||
} else {
|
||||
VStack(spacing: 0) {
|
||||
@ -318,9 +318,9 @@ struct StatisticsView: View {
|
||||
#Preview {
|
||||
NavigationStack {
|
||||
StatisticsView()
|
||||
.environment(AccountContext())
|
||||
.environment(PermissionContext())
|
||||
.environment(StatisticsAPI(client: APIClient()))
|
||||
.environment(ToastCenter())
|
||||
.environmentObject(AccountContext())
|
||||
.environmentObject(PermissionContext())
|
||||
.environment(\.statisticsAPI, StatisticsAPI(client: APIClient()))
|
||||
.environmentObject(ToastCenter())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user