Files
e-party-iOS/yana/Views/Components/UserAgreementView.swift
edwinQQQ f9f3dec53f feat: 更新Podfile和Podfile.lock,移除Alamofire依赖并添加API认证机制文档
- 注释掉Podfile中的Alamofire依赖,更新Podfile.lock以反映更改。
- 在yana/APIs/API-README.md中新增自动认证Header机制的详细文档,描述其工作原理、实现细节及最佳实践。
- 在yana/yanaApp.swift中将print语句替换为debugInfo以增强调试信息的输出。
- 在API相关文件中实现用户认证状态检查和相关header的自动添加逻辑,提升API请求的安全性和用户体验。
- 更新多个文件中的日志输出,确保在DEBUG模式下提供详细的调试信息。
2025-07-11 16:53:46 +08:00

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: {
debugInfo("User Service Agreement tapped")
},
onPrivacyPolicyTapped: {
debugInfo("Privacy Policy tapped")
}
)
UserAgreementView(
isAgreed: .constant(true),
onUserServiceTapped: {
debugInfo("User Service Agreement tapped")
},
onPrivacyPolicyTapped: {
debugInfo("Privacy Policy tapped")
}
)
}
.padding()
.background(Color.gray.opacity(0.1))
}