refactor: 重构目录结构并适配 SwiftUI onChange 新语法
This commit is contained in:
parent
a3c4806271
commit
347c662a83
@ -109,7 +109,11 @@
|
||||
- 完成 SharedUI 与 Core 的第 1–3 步迁移:
|
||||
- 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/`。
|
||||
- 待迁移:`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 目录重构计划与迁移步骤
|
||||
|
||||
|
||||
@ -193,7 +193,7 @@ struct BlindBoxView: View {
|
||||
object: nil
|
||||
)
|
||||
}
|
||||
.onChange(of: viewModel.blindGenerate?.status) { status in
|
||||
.onChange(of: viewModel.blindGenerate?.status) { _, status in
|
||||
guard let status = status?.lowercased() else { return }
|
||||
if status == "unopened" {
|
||||
Perf.event("BlindBox_Status_Unopened")
|
||||
@ -203,22 +203,22 @@ struct BlindBoxView: View {
|
||||
withAnimation { self.animationPhase = .loading }
|
||||
}
|
||||
}
|
||||
.onChange(of: animationPhase) { phase in
|
||||
.onChange(of: animationPhase) { _, phase in
|
||||
if phase != .loading {
|
||||
// 仅用于迁移前清理;现倒计时在 VM 中管理
|
||||
}
|
||||
}
|
||||
.onChange(of: viewModel.videoURL) { url in
|
||||
.onChange(of: viewModel.videoURL) { _, url in
|
||||
if !url.isEmpty {
|
||||
withAnimation { self.animationPhase = .ready }
|
||||
}
|
||||
}
|
||||
.onChange(of: viewModel.imageURL) { url in
|
||||
.onChange(of: viewModel.imageURL) { _, url in
|
||||
if !url.isEmpty {
|
||||
withAnimation { self.animationPhase = .ready }
|
||||
}
|
||||
}
|
||||
.onChange(of: viewModel.didBootstrap) { done in
|
||||
.onChange(of: viewModel.didBootstrap) { _, done in
|
||||
guard done else { return }
|
||||
// 根据首帧状态决定初始动画态,避免先显示 loading 再跳到 ready 的割裂感
|
||||
let initialStatus = viewModel.blindGenerate?.status.lowercased() ?? ""
|
||||
@ -99,20 +99,20 @@ public struct MultiImageUploader<Content: View>: View {
|
||||
}
|
||||
}
|
||||
}
|
||||
.onChange(of: isImagePickerPresented) { newValue in
|
||||
.onChange(of: isImagePickerPresented) { _, newValue in
|
||||
if newValue {
|
||||
showingImagePicker = true
|
||||
}
|
||||
}
|
||||
.onChange(of: showingImagePicker) { newValue in
|
||||
.onChange(of: showingImagePicker) { _, newValue in
|
||||
if !newValue {
|
||||
isImagePickerPresented = false
|
||||
}
|
||||
}
|
||||
.onChange(of: selectedImages) { newValue in
|
||||
.onChange(of: selectedImages) { _, newValue in
|
||||
selectedImagesBinding = newValue
|
||||
}
|
||||
.onChange(of: needsViewUpdate) { _ in
|
||||
.onChange(of: needsViewUpdate) { _, _ in
|
||||
// Trigger view update
|
||||
}
|
||||
}
|
||||
|
||||
@ -111,7 +111,7 @@ struct MediaUploadDemo: View {
|
||||
dismissButton: .default(Text("确定"))
|
||||
)
|
||||
}
|
||||
.onChange(of: uploadManager.uploadStatus) { _ in
|
||||
.onChange(of: uploadManager.uploadStatus) { _, _ in
|
||||
// 检查是否所有上传都已完成或失败
|
||||
let allFinished = uploadManager.uploadStatus.values.allSatisfy { status in
|
||||
if case .completed = status { return true }
|
||||
|
||||
@ -85,7 +85,7 @@ struct MediaUploadView: View {
|
||||
// 媒体选择器
|
||||
mediaPickerView
|
||||
}
|
||||
.onChange(of: uploadManager.uploadResults) { newResults in
|
||||
.onChange(of: uploadManager.uploadResults) { _, newResults in
|
||||
handleUploadCompletion(results: newResults)
|
||||
}
|
||||
}
|
||||
|
||||
@ -291,7 +291,7 @@ struct UserInfo: View {
|
||||
isKeyboardVisible = isVisible
|
||||
}
|
||||
}
|
||||
.onChange(of: isTextFieldFocused) { newValue in
|
||||
.onChange(of: isTextFieldFocused) { _, newValue in
|
||||
withAnimation(.easeInOut(duration: 0.2)) {
|
||||
isKeyboardVisible = newValue
|
||||
}
|
||||
|
||||
@ -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)
|
||||
|
||||
// 检查是否有待处理的上传
|
||||
|
||||
@ -109,11 +109,11 @@ struct SubscribeView: View {
|
||||
await store.loadProducts()
|
||||
await store.refreshEntitlements()
|
||||
}
|
||||
.onChange(of: store.isPurchasing) { newValue in
|
||||
.onChange(of: store.isPurchasing) { _, newValue in
|
||||
// Bind purchasing state to button loading
|
||||
isLoading = newValue
|
||||
}
|
||||
.onChange(of: store.errorMessage) { newValue in
|
||||
.onChange(of: store.errorMessage) { _, newValue in
|
||||
if let message = newValue, !message.isEmpty {
|
||||
errorText = message
|
||||
showErrorAlert = true
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user