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 { var body: some View {
ZStack { ZStack {
// //
Color(.systemBackground) Color(red: 1.0, green: 0.67, blue: 0.15) // FFAA26 in RGB (1.0, 0.67, 0.15)
.edgesIgnoringSafeArea(.all) .edgesIgnoringSafeArea(.all)
VStack(alignment: .leading, spacing: 4) {
// Text("Hi, I'm MeMo!")
VStack(spacing: 24) { .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() Spacer()
appHeaderView() // }
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topLeading)
VStack(spacing: 16) {
// appHeaderView()
Spacer() //
signInButton() // signInButton() //
Spacer()
termsAndPrivacyView() // termsAndPrivacyView() //
} }
.padding() .padding()
@ -68,48 +85,78 @@ struct LoginView: View {
/// ///
private func signInButton() -> some View { private func signInButton() -> some View {
SignInWithAppleButton( Button(action: {
onRequest: { request in // This will be handled by the SignInWithAppleButton
// }) {
let nonce = String.randomURLSafeString(length: 32) ZStack {
self.currentNonce = nonce // 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)
// // Custom button appearance
request.requestedScopes = [.fullName, .email] // HStack {
request.nonce = self.sha256(nonce) // nonce Image(systemName: "applelogo")
}, Text("Continue with Apple")
onCompletion: handleAppleSignIn // // .font(.headline)
) }
.signInWithAppleButtonStyle(.black) // .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) .frame(height: 50)
.padding(.horizontal, 40) .padding(.horizontal, 40)
.cornerRadius(10)
} }
/// ///
private func termsAndPrivacyView() -> some View { private func termsAndPrivacyView() -> some View {
VStack(spacing: 8) { VStack(spacing: 4) {
Text("By continuing, you agree to our") Text("By continuing, you agree to our")
.font(.caption) .font(.caption)
.foregroundColor(.secondary) .foregroundColor(.secondary)
.multilineTextAlignment(.center)
.padding(.horizontal, 24)
HStack(spacing: 16) { HStack(spacing: 16) {
Button("Terms of Service") { Button("Terms of Service") {
openURL("https://yourwebsite.com/terms") openURL("https://yourwebsite.com/terms")
} }
.font(.caption) .font(.caption2)
.foregroundColor(.blue) .foregroundColor(.blue)
Text("") Text("and")
.foregroundColor(.secondary) .foregroundColor(.secondary)
.font(.caption)
.multilineTextAlignment(.center)
Button("Privacy Policy") { Button("Privacy Policy") {
openURL("https://yourwebsite.com/privacy") openURL("https://yourwebsite.com/privacy")
} }
.font(.caption) .font(.caption2)
.foregroundColor(.blue) .foregroundColor(.blue)
} }
.padding(.top, 4)
} }
.lineLimit(2)
.fixedSize(horizontal: false, vertical: true)
.frame(maxWidth: .infinity)
.padding(.horizontal, 24)
.padding(.bottom, 24) .padding(.bottom, 24)
} }