feat: 登录页面
This commit is contained in:
parent
9e0a4a92c3
commit
cc305aa84a
Binary file not shown.
@ -16,15 +16,32 @@ struct LoginView: View {
|
||||
var body: some View {
|
||||
ZStack {
|
||||
// 背景
|
||||
Color(.systemBackground)
|
||||
Color(red: 1.0, green: 0.67, blue: 0.15) // FFAA26 in RGB (1.0, 0.67, 0.15)
|
||||
.edgesIgnoringSafeArea(.all)
|
||||
|
||||
// 主要内容
|
||||
VStack(spacing: 24) {
|
||||
VStack(alignment: .leading, spacing: 4) {
|
||||
Text("Hi, I'm MeMo!")
|
||||
.font(.largeTitle)
|
||||
.fontWeight(.semibold)
|
||||
.foregroundColor(.black)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
.padding(.leading, 24)
|
||||
.padding(.top, 44) // Add some top padding for the status bar
|
||||
|
||||
Text("Welcome~")
|
||||
.font(.largeTitle)
|
||||
.fontWeight(.semibold)
|
||||
.foregroundColor(.black)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
.padding(.leading, 24)
|
||||
.padding(.bottom, 20)
|
||||
|
||||
Spacer()
|
||||
appHeaderView() // 应用标题
|
||||
}
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topLeading)
|
||||
VStack(spacing: 16) {
|
||||
// appHeaderView()
|
||||
Spacer() // 应用标题
|
||||
signInButton() // 登录按钮
|
||||
Spacer()
|
||||
termsAndPrivacyView() // 服务条款和隐私政策
|
||||
}
|
||||
.padding()
|
||||
@ -68,48 +85,78 @@ struct LoginView: View {
|
||||
|
||||
/// 苹果登录按钮
|
||||
private func signInButton() -> some View {
|
||||
SignInWithAppleButton(
|
||||
onRequest: { request in
|
||||
// 生成随机数用于安全验证
|
||||
let nonce = String.randomURLSafeString(length: 32)
|
||||
self.currentNonce = nonce
|
||||
Button(action: {
|
||||
// This will be handled by the SignInWithAppleButton
|
||||
}) {
|
||||
ZStack {
|
||||
// Invisible SignInWithAppleButton for functionality
|
||||
SignInWithAppleButton(
|
||||
onRequest: { request in
|
||||
let nonce = String.randomURLSafeString(length: 32)
|
||||
self.currentNonce = nonce
|
||||
request.requestedScopes = [.fullName, .email]
|
||||
request.nonce = self.sha256(nonce)
|
||||
},
|
||||
onCompletion: handleAppleSignIn
|
||||
)
|
||||
.frame(width: 0, height: 0)
|
||||
.opacity(0)
|
||||
|
||||
// 配置登录请求
|
||||
request.requestedScopes = [.fullName, .email] // 请求用户全名和邮箱
|
||||
request.nonce = self.sha256(nonce) // 设置nonce
|
||||
},
|
||||
onCompletion: handleAppleSignIn // 登录完成处理
|
||||
)
|
||||
.signInWithAppleButtonStyle(.black) // 按钮样式
|
||||
// Custom button appearance
|
||||
HStack {
|
||||
Image(systemName: "applelogo")
|
||||
Text("Continue with Apple")
|
||||
// .font(.headline)
|
||||
}
|
||||
.frame(maxWidth: .infinity)
|
||||
.padding(.vertical, 12)
|
||||
.padding(.horizontal, 24)
|
||||
.foregroundColor(.black)
|
||||
.background(Color.white)
|
||||
.cornerRadius(25)
|
||||
.overlay(
|
||||
RoundedRectangle(cornerRadius: 25)
|
||||
.stroke(Color.black, lineWidth: 1)
|
||||
)
|
||||
}
|
||||
}
|
||||
.frame(height: 50)
|
||||
.padding(.horizontal, 40)
|
||||
.cornerRadius(10)
|
||||
}
|
||||
|
||||
/// 服务条款和隐私政策链接
|
||||
private func termsAndPrivacyView() -> some View {
|
||||
VStack(spacing: 8) {
|
||||
VStack(spacing: 4) {
|
||||
Text("By continuing, you agree to our")
|
||||
.font(.caption)
|
||||
.foregroundColor(.secondary)
|
||||
.multilineTextAlignment(.center)
|
||||
.padding(.horizontal, 24)
|
||||
|
||||
HStack(spacing: 16) {
|
||||
Button("Terms of Service") {
|
||||
openURL("https://yourwebsite.com/terms")
|
||||
}
|
||||
.font(.caption)
|
||||
.font(.caption2)
|
||||
.foregroundColor(.blue)
|
||||
|
||||
Text("•")
|
||||
Text("and")
|
||||
.foregroundColor(.secondary)
|
||||
.font(.caption)
|
||||
.multilineTextAlignment(.center)
|
||||
|
||||
Button("Privacy Policy") {
|
||||
openURL("https://yourwebsite.com/privacy")
|
||||
}
|
||||
.font(.caption)
|
||||
.font(.caption2)
|
||||
.foregroundColor(.blue)
|
||||
}
|
||||
.padding(.top, 4)
|
||||
}
|
||||
.lineLimit(2)
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
.frame(maxWidth: .infinity)
|
||||
.padding(.horizontal, 24)
|
||||
.padding(.bottom, 24)
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user