
- 在Package.swift中注释掉旧的swift-composable-architecture依赖,并添加swift-case-paths依赖。 - 在Podfile中将iOS平台版本更新至16.0,并移除QCloudCOSXML/Transfer依赖,改为使用QCloudCOSXML。 - 更新Podfile.lock以反映依赖变更,确保项目依赖的准确性。 - 新增架构分析需求文档,明确项目架构评估和改进建议。 - 在多个文件中实现async/await语法,提升异步操作的可读性和性能。 - 更新日志输出方法,确保在调试模式下提供一致的调试信息。 - 优化多个视图组件,提升用户体验和代码可维护性。
89 lines
3.3 KiB
Swift
89 lines
3.3 KiB
Swift
import SwiftUI
|
|
|
|
// MARK: - User Agreement View Component
|
|
struct UserAgreementView: View {
|
|
@Binding var isAgreed: Bool
|
|
let onUserServiceTapped: () -> Void
|
|
let onPrivacyPolicyTapped: () -> Void
|
|
|
|
var body: some View {
|
|
HStack(alignment: .center, spacing: 12) {
|
|
// 左侧勾选按钮
|
|
Button(action: {
|
|
isAgreed.toggle()
|
|
}) {
|
|
Image(systemName: isAgreed ? "checkmark.circle.fill" : "circle")
|
|
.font(.system(size: 22))
|
|
.foregroundColor(isAgreed ? Color(hex: 0x8A4FFF) : Color(hex: 0x666666))
|
|
}
|
|
|
|
// 右侧富文本
|
|
Text(createAttributedText())
|
|
.font(.system(size: 14))
|
|
.multilineTextAlignment(.leading)
|
|
.environment(\.openURL, OpenURLAction { url in
|
|
if url.absoluteString == "user-service-agreement" {
|
|
onUserServiceTapped()
|
|
return .handled
|
|
} else if url.absoluteString == "privacy-policy" {
|
|
onPrivacyPolicyTapped()
|
|
return .handled
|
|
}
|
|
return .systemAction
|
|
})
|
|
}
|
|
.frame(maxWidth: .infinity) // 占满可用宽度
|
|
.padding(.horizontal, 29) // 与登录按钮保持一致的边距
|
|
}
|
|
|
|
// MARK: - Private Methods
|
|
private func createAttributedText() -> AttributedString {
|
|
var attributedString = AttributedString(NSLocalizedString("login.agreement_policy", comment: ""))
|
|
|
|
// 设置默认颜色
|
|
attributedString.foregroundColor = Color(hex: 0x666666)
|
|
|
|
// 找到并设置 "用户协议" 的样式和链接
|
|
if let userServiceRange = attributedString.range(of: NSLocalizedString("login.agreement", comment: "")) {
|
|
attributedString[userServiceRange].foregroundColor = Color(hex: 0x8A4FFF)
|
|
attributedString[userServiceRange].underlineStyle = .single
|
|
attributedString[userServiceRange].link = URL(string: "user-service-agreement")
|
|
}
|
|
|
|
// 找到并设置 "隐私政策" 的样式和链接
|
|
if let privacyPolicyRange = attributedString.range(of: NSLocalizedString("login.policy", comment: "")) {
|
|
attributedString[privacyPolicyRange].foregroundColor = Color(hex: 0x8A4FFF)
|
|
attributedString[privacyPolicyRange].underlineStyle = .single
|
|
attributedString[privacyPolicyRange].link = URL(string: "privacy-policy")
|
|
}
|
|
|
|
return attributedString
|
|
}
|
|
}
|
|
|
|
//#Preview {
|
|
// VStack(spacing: 20) {
|
|
// UserAgreementView(
|
|
// isAgreed: .constant(true),
|
|
// onUserServiceTapped: {
|
|
// debugInfoSync("User Service Agreement tapped")
|
|
// },
|
|
// onPrivacyPolicyTapped: {
|
|
// debugInfoSync("Privacy Policy tapped")
|
|
// }
|
|
// )
|
|
//
|
|
// UserAgreementView(
|
|
// isAgreed: .constant(true),
|
|
// onUserServiceTapped: {
|
|
// debugInfoSync("User Service Agreement tapped")
|
|
// },
|
|
// onPrivacyPolicyTapped: {
|
|
// debugInfoSync("Privacy Policy tapped")
|
|
// }
|
|
// )
|
|
// }
|
|
// .padding()
|
|
// .background(Color.gray.opacity(0.1))
|
|
//}
|