
- 修改Package.swift以支持iOS 15和macOS 12。 - 更新swift-tca-architecture-guidelines.mdc中的alwaysApply设置为false。 - 注释掉AppDelegate中的NIMSDK导入,移除不再使用的NIMConfigurationManager和NIMSessionManager文件。 - 添加新的API相关文件,包括EMailLoginFeature、IDLoginFeature和相关视图,增强登录功能。 - 更新APIConstants和APIEndpoints以反映新的API路径。 - 添加本地化支持文件,包含英文和中文简体的本地化字符串。 - 新增字体管理和安全工具类,支持AES和DES加密。 - 更新Xcode项目配置,调整版本号和启动画面设置。
89 lines
3.2 KiB
Swift
89 lines
3.2 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("login.agreement_policy".localized)
|
|
|
|
// 设置默认颜色
|
|
attributedString.foregroundColor = Color(hex: 0x666666)
|
|
|
|
// 找到并设置 "用户协议" 的样式和链接
|
|
if let userServiceRange = attributedString.range(of: "login.agreement".localized) {
|
|
attributedString[userServiceRange].foregroundColor = Color(hex: 0x8A4FFF)
|
|
attributedString[userServiceRange].underlineStyle = .single
|
|
attributedString[userServiceRange].link = URL(string: "user-service-agreement")
|
|
}
|
|
|
|
// 找到并设置 "隐私政策" 的样式和链接
|
|
if let privacyPolicyRange = attributedString.range(of: "login.policy".localized) {
|
|
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: {
|
|
print("User Service Agreement tapped")
|
|
},
|
|
onPrivacyPolicyTapped: {
|
|
print("Privacy Policy tapped")
|
|
}
|
|
)
|
|
|
|
UserAgreementView(
|
|
isAgreed: .constant(true),
|
|
onUserServiceTapped: {
|
|
print("User Service Agreement tapped")
|
|
},
|
|
onPrivacyPolicyTapped: {
|
|
print("Privacy Policy tapped")
|
|
}
|
|
)
|
|
}
|
|
.padding()
|
|
.background(Color.gray.opacity(0.1))
|
|
}
|