feat: 更新依赖和项目配置,优化代码结构
- 在Package.swift中注释掉旧的swift-composable-architecture依赖,并添加swift-case-paths依赖。 - 在Podfile中将iOS平台版本更新至16.0,并移除QCloudCOSXML/Transfer依赖,改为使用QCloudCOSXML。 - 更新Podfile.lock以反映依赖变更,确保项目依赖的准确性。 - 新增架构分析需求文档,明确项目架构评估和改进建议。 - 在多个文件中实现async/await语法,提升异步操作的可读性和性能。 - 更新日志输出方法,确保在调试模式下提供一致的调试信息。 - 优化多个视图组件,提升用户体验和代码可维护性。
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import SwiftUI
|
||||
import ComposableArchitecture
|
||||
import Combine
|
||||
|
||||
struct RecoverPasswordView: View {
|
||||
let store: StoreOf<RecoverPasswordFeature>
|
||||
@@ -13,7 +14,7 @@ struct RecoverPasswordView: View {
|
||||
|
||||
// 验证码倒计时状态
|
||||
@State private var countdown: Int = 0
|
||||
@State private var countdownTimer: Timer?
|
||||
private let timer = Timer.publish(every: 1, on: .main, in: .common).autoconnect()
|
||||
|
||||
// 计算确认按钮是否可用
|
||||
private var isConfirmButtonEnabled: Bool {
|
||||
@@ -32,7 +33,7 @@ struct RecoverPasswordView: View {
|
||||
} else if countdown > 0 {
|
||||
return "\(countdown)s"
|
||||
} else {
|
||||
return "recover_password.get_code".localized
|
||||
return NSLocalizedString("recover_password.get_code", comment: "")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,7 +67,7 @@ struct RecoverPasswordView: View {
|
||||
.frame(height: 60)
|
||||
|
||||
// 标题
|
||||
Text("recover_password.title".localized)
|
||||
Text(NSLocalizedString("recover_password.title", comment: ""))
|
||||
.font(.system(size: 28, weight: .medium))
|
||||
.foregroundColor(.white)
|
||||
.padding(.bottom, 80)
|
||||
@@ -85,7 +86,7 @@ struct RecoverPasswordView: View {
|
||||
|
||||
TextField("", text: $email)
|
||||
.placeholder(when: email.isEmpty) {
|
||||
Text("recover_password.placeholder_email".localized)
|
||||
Text(NSLocalizedString("recover_password.placeholder_email", comment: ""))
|
||||
.foregroundColor(.white.opacity(0.6))
|
||||
}
|
||||
.foregroundColor(.white)
|
||||
@@ -108,7 +109,7 @@ struct RecoverPasswordView: View {
|
||||
HStack {
|
||||
TextField("", text: $verificationCode)
|
||||
.placeholder(when: verificationCode.isEmpty) {
|
||||
Text("recover_password.placeholder_verification_code".localized)
|
||||
Text(NSLocalizedString("recover_password.placeholder_verification_code", comment: ""))
|
||||
.foregroundColor(.white.opacity(0.6))
|
||||
}
|
||||
.foregroundColor(.white)
|
||||
@@ -158,7 +159,7 @@ struct RecoverPasswordView: View {
|
||||
if isNewPasswordVisible {
|
||||
TextField("", text: $newPassword)
|
||||
.placeholder(when: newPassword.isEmpty) {
|
||||
Text("recover_password.placeholder_new_password".localized)
|
||||
Text(NSLocalizedString("recover_password.placeholder_new_password", comment: ""))
|
||||
.foregroundColor(.white.opacity(0.6))
|
||||
}
|
||||
.foregroundColor(.white)
|
||||
@@ -166,7 +167,7 @@ struct RecoverPasswordView: View {
|
||||
} else {
|
||||
SecureField("", text: $newPassword)
|
||||
.placeholder(when: newPassword.isEmpty) {
|
||||
Text("recover_password.placeholder_new_password".localized)
|
||||
Text(NSLocalizedString("recover_password.placeholder_new_password", comment: ""))
|
||||
.foregroundColor(.white.opacity(0.6))
|
||||
}
|
||||
.foregroundColor(.white)
|
||||
@@ -211,7 +212,7 @@ struct RecoverPasswordView: View {
|
||||
.progressViewStyle(CircularProgressViewStyle(tint: .white))
|
||||
.scaleEffect(0.8)
|
||||
}
|
||||
Text(store.isResetLoading ? "recover_password.resetting".localized : "recover_password.confirm_button".localized)
|
||||
Text(store.isResetLoading ? NSLocalizedString("recover_password.resetting", comment: "") : NSLocalizedString("recover_password.confirm_button", comment: ""))
|
||||
.font(.system(size: 18, weight: .semibold))
|
||||
.foregroundColor(.white)
|
||||
}
|
||||
@@ -244,15 +245,13 @@ struct RecoverPasswordView: View {
|
||||
newPassword = ""
|
||||
isNewPasswordVisible = false
|
||||
countdown = 0
|
||||
stopCountdown()
|
||||
|
||||
#if DEBUG
|
||||
email = "exzero@126.com"
|
||||
store.send(.emailChanged(email))
|
||||
#endif
|
||||
}
|
||||
.onDisappear {
|
||||
stopCountdown()
|
||||
countdown = 0
|
||||
}
|
||||
.onChange(of: email) { newEmail in
|
||||
store.send(.emailChanged(newEmail))
|
||||
@@ -275,24 +274,20 @@ struct RecoverPasswordView: View {
|
||||
onBack()
|
||||
}
|
||||
}
|
||||
.onReceive(timer) { _ in
|
||||
if countdown > 0 {
|
||||
countdown -= 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Private Methods
|
||||
|
||||
private func startCountdown() {
|
||||
countdown = 60
|
||||
countdownTimer = Timer.scheduledTimer(withTimeInterval: 1.0, repeats: true) { _ in
|
||||
if countdown > 0 {
|
||||
countdown -= 1
|
||||
} else {
|
||||
stopCountdown()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func stopCountdown() {
|
||||
countdownTimer?.invalidate()
|
||||
countdownTimer = nil
|
||||
countdown = 0
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user