从 iOS 17 Observation 迁移至 iOS 16 兼容的 Combine 架构
将最低部署版本降至 iOS 16,以 ObservableObject 替换 @Observable,新增导航与 UI 兼容层,并补充登录冒烟 UI 测试。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@ -12,12 +12,12 @@ import UniformTypeIdentifiers
|
||||
|
||||
/// 相册管理页面,展示相册列表、筛选和新建相册入口。
|
||||
struct AlbumListView: View {
|
||||
@Environment(AccountContext.self) private var accountContext
|
||||
@Environment(AssetsAPI.self) private var assetsAPI
|
||||
@Environment(ToastCenter.self) private var toastCenter
|
||||
@EnvironmentObject private var accountContext: AccountContext
|
||||
@Environment(\.assetsAPI) private var assetsAPI
|
||||
@EnvironmentObject private var toastCenter: ToastCenter
|
||||
@Environment(\.globalLoading) private var globalLoading
|
||||
|
||||
@State private var viewModel = AlbumListViewModel()
|
||||
@StateObject private var viewModel = AlbumListViewModel()
|
||||
@State private var showCreateSheet = false
|
||||
@State private var newAlbumName = ""
|
||||
@State private var newAlbumRemark = ""
|
||||
@ -158,12 +158,12 @@ struct AlbumListView: View {
|
||||
|
||||
/// 相册详情页面,展示图片/视频列表并支持封面、删除和编辑。
|
||||
struct AlbumDetailView: View {
|
||||
@Environment(AccountContext.self) private var accountContext
|
||||
@Environment(AssetsAPI.self) private var assetsAPI
|
||||
@Environment(ToastCenter.self) private var toastCenter
|
||||
@EnvironmentObject private var accountContext: AccountContext
|
||||
@Environment(\.assetsAPI) private var assetsAPI
|
||||
@EnvironmentObject private var toastCenter: ToastCenter
|
||||
@Environment(\.globalLoading) private var globalLoading
|
||||
|
||||
@State private var viewModel: AlbumDetailViewModel
|
||||
@StateObject private var viewModel: AlbumDetailViewModel
|
||||
@State private var actionFile: AlbumFileItem?
|
||||
@State private var previewFile: AlbumFileItem?
|
||||
@State private var showRenameSheet = false
|
||||
@ -174,7 +174,7 @@ struct AlbumDetailView: View {
|
||||
|
||||
/// 初始化相册详情页面。
|
||||
init(folderId: Int, summary: AlbumFolderItem? = nil) {
|
||||
_viewModel = State(initialValue: AlbumDetailViewModel(folderId: folderId, summary: summary))
|
||||
_viewModel = StateObject(wrappedValue: AlbumDetailViewModel(folderId: folderId, summary: summary))
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
@ -282,7 +282,7 @@ struct AlbumDetailView: View {
|
||||
}
|
||||
}
|
||||
.pickerStyle(.segmented)
|
||||
.onChange(of: viewModel.selectedTab) { _, tab in
|
||||
.onChange(of: viewModel.selectedTab) { tab in
|
||||
Task { await viewModel.selectTab(tab, api: assetsAPI, scenicId: accountContext.currentScenic?.id) }
|
||||
}
|
||||
}
|
||||
@ -378,14 +378,14 @@ struct AlbumTrailerEntryView: View {
|
||||
|
||||
/// 相册预览上传页面,负责选择相册、本地文件和提交上传。
|
||||
struct AlbumTrailerUploadView: View {
|
||||
@Environment(AccountContext.self) private var accountContext
|
||||
@Environment(AssetsAPI.self) private var assetsAPI
|
||||
@Environment(OSSUploadService.self) private var uploadService
|
||||
@Environment(ToastCenter.self) private var toastCenter
|
||||
@EnvironmentObject private var accountContext: AccountContext
|
||||
@Environment(\.assetsAPI) private var assetsAPI
|
||||
@Environment(\.ossUploadService) private var uploadService
|
||||
@EnvironmentObject private var toastCenter: ToastCenter
|
||||
@Environment(\.dismiss) private var dismiss
|
||||
@Environment(\.globalLoading) private var globalLoading
|
||||
|
||||
@State private var viewModel = AlbumTrailerViewModel()
|
||||
@StateObject private var viewModel = AlbumTrailerViewModel()
|
||||
@State private var selectedItems: [PhotosPickerItem] = []
|
||||
|
||||
let initialFolderId: Int?
|
||||
@ -412,7 +412,7 @@ struct AlbumTrailerUploadView: View {
|
||||
toastCenter.show(message)
|
||||
}
|
||||
}
|
||||
.onChange(of: selectedItems) { _, items in
|
||||
.onChange(of: selectedItems) { items in
|
||||
Task { await loadPickedFiles(items) }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user