从 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

@ -10,12 +10,12 @@ import SwiftUI
///
struct LiveManagementView: View {
@Environment(AccountContext.self) private var accountContext
@Environment(LiveAPI.self) private var liveAPI
@Environment(ToastCenter.self) private var toastCenter
@EnvironmentObject private var accountContext: AccountContext
@Environment(\.liveAPI) private var liveAPI
@EnvironmentObject private var toastCenter: ToastCenter
@Environment(\.globalLoading) private var globalLoading
@State private var viewModel = LiveManagementViewModel()
@StateObject private var viewModel = LiveManagementViewModel()
@State private var showAddPage = false
var body: some View {
@ -24,7 +24,7 @@ struct LiveManagementView: View {
ScrollView {
LazyVStack(spacing: AppMetrics.Spacing.medium) {
if viewModel.items.isEmpty {
ContentUnavailableView("暂无直播", systemImage: "dot.radiowaves.left.and.right")
AppContentUnavailableView("暂无直播", systemImage: "dot.radiowaves.left.and.right")
.frame(maxWidth: .infinity, minHeight: 280)
} else {
ForEach(viewModel.items) { item in
@ -231,9 +231,9 @@ private struct LiveSmallAction: View {
///
struct LiveAddView: View {
@Environment(AccountContext.self) private var accountContext
@Environment(LiveAPI.self) private var liveAPI
@Environment(ToastCenter.self) private var toastCenter
@EnvironmentObject private var accountContext: AccountContext
@Environment(\.liveAPI) private var liveAPI
@EnvironmentObject private var toastCenter: ToastCenter
@Environment(\.dismiss) private var dismiss
@State private var title = ""
@ -351,18 +351,18 @@ struct LiveAddView: View {
///
struct LiveDetailView: View {
@Environment(LiveAPI.self) private var liveAPI
@Environment(ToastCenter.self) private var toastCenter
@Environment(\.liveAPI) private var liveAPI
@EnvironmentObject private var toastCenter: ToastCenter
@Environment(\.globalLoading) private var globalLoading
@State private var viewModel: LiveDetailViewModel
@State private var playbackViewModel: LivePlaybackViewModel
@State private var pushReadinessViewModel = LivePushReadinessViewModel()
@StateObject private var viewModel: LiveDetailViewModel
@StateObject private var playbackViewModel: LivePlaybackViewModel
@StateObject private var pushReadinessViewModel = LivePushReadinessViewModel()
@State private var copied = false
let onChanged: () -> Void
init(initialDetail: LiveEntity, onChanged: @escaping () -> Void) {
_viewModel = State(initialValue: LiveDetailViewModel(detail: initialDetail))
_playbackViewModel = State(initialValue: LivePlaybackViewModel(live: initialDetail))
_viewModel = StateObject(wrappedValue: LiveDetailViewModel(detail: initialDetail))
_playbackViewModel = StateObject(wrappedValue: LivePlaybackViewModel(live: initialDetail))
self.onChanged = onChanged
}