feat: 登录页面

This commit is contained in:
jinyaqiu 2025-08-18 20:18:08 +08:00
parent 9e0a4a92c3
commit cc305aa84a
2 changed files with 70 additions and 23 deletions

View File

@ -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)
}