refactor: 重构目录结构并适配 SwiftUI onChange 新语法

This commit is contained in:
Junhui Chen 2025-09-09 12:20:15 +08:00
parent a3c4806271
commit 347c662a83
11 changed files with 20 additions and 16 deletions

View File

@ -109,7 +109,11 @@
- 完成 SharedUI 与 Core 的第 13 步迁移: - 完成 SharedUI 与 Core 的第 13 步迁移:
- SharedUI`LottieView.swift``GIFView.swift``SVGImage.swift``SheetModal.swift` 已迁移至 `wake/SharedUI/...`(当前均放在 `Animation/` 分组,后续可按需细分 `Media/``Modals/`)。 - SharedUI`LottieView.swift``GIFView.swift``SVGImage.swift``SheetModal.swift` 已迁移至 `wake/SharedUI/...`(当前均放在 `Animation/` 分组,后续可按需细分 `Media/``Modals/`)。
- Core`Router.swift` 已迁至 `Core/Navigation/``NetworkService.swift` 已迁至 `Core/Network/``Theme.swift``Typography.swift` 已迁至 `Core/DesignSystem/` - Core`Router.swift` 已迁至 `Core/Navigation/``NetworkService.swift` 已迁至 `Core/Network/``Theme.swift``Typography.swift` 已迁至 `Core/DesignSystem/`
- 待迁移:`Performance.swift``Core/Diagnostics/``APIConfig.swift``Core/Network/`
- 2025-09-09 11:30 +08: 更新 structure-1
- 已完成 `Performance.swift``Core/Diagnostics/``APIConfig.swift``Core/Network/`
- 已完成 `SVGImageHtml.swift``SharedUI/Media/`
- 待优化(可选):将 `GIFView.swift``SVGImage.swift``SharedUI/Animation/` 细分到 `SharedUI/Media/`;将 `SheetModal.swift``SharedUI/Animation/` 移至 `SharedUI/Modals/`
## structure-1 目录重构计划与迁移步骤 ## structure-1 目录重构计划与迁移步骤

View File

@ -193,7 +193,7 @@ struct BlindBoxView: View {
object: nil object: nil
) )
} }
.onChange(of: viewModel.blindGenerate?.status) { status in .onChange(of: viewModel.blindGenerate?.status) { _, status in
guard let status = status?.lowercased() else { return } guard let status = status?.lowercased() else { return }
if status == "unopened" { if status == "unopened" {
Perf.event("BlindBox_Status_Unopened") Perf.event("BlindBox_Status_Unopened")
@ -203,22 +203,22 @@ struct BlindBoxView: View {
withAnimation { self.animationPhase = .loading } withAnimation { self.animationPhase = .loading }
} }
} }
.onChange(of: animationPhase) { phase in .onChange(of: animationPhase) { _, phase in
if phase != .loading { if phase != .loading {
// VM // VM
} }
} }
.onChange(of: viewModel.videoURL) { url in .onChange(of: viewModel.videoURL) { _, url in
if !url.isEmpty { if !url.isEmpty {
withAnimation { self.animationPhase = .ready } withAnimation { self.animationPhase = .ready }
} }
} }
.onChange(of: viewModel.imageURL) { url in .onChange(of: viewModel.imageURL) { _, url in
if !url.isEmpty { if !url.isEmpty {
withAnimation { self.animationPhase = .ready } withAnimation { self.animationPhase = .ready }
} }
} }
.onChange(of: viewModel.didBootstrap) { done in .onChange(of: viewModel.didBootstrap) { _, done in
guard done else { return } guard done else { return }
// loading ready // loading ready
let initialStatus = viewModel.blindGenerate?.status.lowercased() ?? "" let initialStatus = viewModel.blindGenerate?.status.lowercased() ?? ""

View File

@ -99,20 +99,20 @@ public struct MultiImageUploader<Content: View>: View {
} }
} }
} }
.onChange(of: isImagePickerPresented) { newValue in .onChange(of: isImagePickerPresented) { _, newValue in
if newValue { if newValue {
showingImagePicker = true showingImagePicker = true
} }
} }
.onChange(of: showingImagePicker) { newValue in .onChange(of: showingImagePicker) { _, newValue in
if !newValue { if !newValue {
isImagePickerPresented = false isImagePickerPresented = false
} }
} }
.onChange(of: selectedImages) { newValue in .onChange(of: selectedImages) { _, newValue in
selectedImagesBinding = newValue selectedImagesBinding = newValue
} }
.onChange(of: needsViewUpdate) { _ in .onChange(of: needsViewUpdate) { _, _ in
// Trigger view update // Trigger view update
} }
} }

View File

@ -111,7 +111,7 @@ struct MediaUploadDemo: View {
dismissButton: .default(Text("确定")) dismissButton: .default(Text("确定"))
) )
} }
.onChange(of: uploadManager.uploadStatus) { _ in .onChange(of: uploadManager.uploadStatus) { _, _ in
// //
let allFinished = uploadManager.uploadStatus.values.allSatisfy { status in let allFinished = uploadManager.uploadStatus.values.allSatisfy { status in
if case .completed = status { return true } if case .completed = status { return true }

View File

@ -85,7 +85,7 @@ struct MediaUploadView: View {
// //
mediaPickerView mediaPickerView
} }
.onChange(of: uploadManager.uploadResults) { newResults in .onChange(of: uploadManager.uploadResults) { _, newResults in
handleUploadCompletion(results: newResults) handleUploadCompletion(results: newResults)
} }
} }

View File

@ -291,7 +291,7 @@ struct UserInfo: View {
isKeyboardVisible = isVisible isKeyboardVisible = isVisible
} }
} }
.onChange(of: isTextFieldFocused) { newValue in .onChange(of: isTextFieldFocused) { _, newValue in
withAnimation(.easeInOut(duration: 0.2)) { withAnimation(.easeInOut(duration: 0.2)) {
isKeyboardVisible = newValue isKeyboardVisible = newValue
} }

View File

@ -156,7 +156,7 @@ public struct AvatarPicker: View {
} }
) )
} }
.onChange(of: uploadManager.uploadStatus) { status in .onChange(of: uploadManager.uploadStatus) { _, status in
print("🔄 Upload status changed: ", status) print("🔄 Upload status changed: ", status)
// //

View File

@ -109,11 +109,11 @@ struct SubscribeView: View {
await store.loadProducts() await store.loadProducts()
await store.refreshEntitlements() await store.refreshEntitlements()
} }
.onChange(of: store.isPurchasing) { newValue in .onChange(of: store.isPurchasing) { _, newValue in
// Bind purchasing state to button loading // Bind purchasing state to button loading
isLoading = newValue isLoading = newValue
} }
.onChange(of: store.errorMessage) { newValue in .onChange(of: store.errorMessage) { _, newValue in
if let message = newValue, !message.isEmpty { if let message = newValue, !message.isEmpty {
errorText = message errorText = message
showErrorAlert = true showErrorAlert = true