Files
KisaniCal/KisaniCal/Views/ProfileSetupView.swift
Robin Kutesa d424a2a814 Clear demo data, namespace storage by user, add profile setup
- Remove all personal sampleTasks from TaskViewModel (tasks start empty)
- Namespace UserDefaults keys by Apple ID for task and workout data isolation
- Add ProfileSetupView for name capture after first Sign in with Apple
- Add updateDisplayName() to AuthManager
- Route to ProfileSetupView when user has no display name yet

Co-Authored-By: Kutesir <tqwyy79vzn@privaterelay.appleid.com>
2026-06-01 01:31:55 +03:00

86 lines
3.3 KiB
Swift

import SwiftUI
struct ProfileSetupView: View {
@ObservedObject private var auth = AuthManager.shared
@Environment(\.colorScheme) private var cs
@State private var name = ""
@FocusState private var focused: Bool
var body: some View {
ZStack {
AppColors.background(cs).ignoresSafeArea()
VStack(spacing: 0) {
Spacer()
VStack(spacing: 24) {
ZStack {
RoundedRectangle(cornerRadius: 24)
.fill(AppColors.accentSoft)
.frame(width: 88, height: 88)
Image(systemName: "person.fill")
.font(.system(size: 36, weight: .light))
.foregroundColor(AppColors.accent)
}
VStack(spacing: 8) {
Text("What's your name?")
.font(AppFonts.sans(26, weight: .bold))
.foregroundColor(AppColors.text(cs))
Text("This is how you'll appear in the app.")
.font(AppFonts.sans(15))
.foregroundColor(AppColors.text2(cs))
.multilineTextAlignment(.center)
}
}
Spacer()
VStack(spacing: 16) {
TextField("Your name", text: $name)
.font(AppFonts.sans(17))
.foregroundColor(AppColors.text(cs))
.padding(.horizontal, 18)
.padding(.vertical, 16)
.background(
RoundedRectangle(cornerRadius: 14)
.fill(Color(uiColor: cs == .dark ? .secondarySystemBackground : .systemGray6))
)
.padding(.horizontal, 28)
.focused($focused)
.submitLabel(.done)
.onSubmit { save() }
Button(action: save) {
Text("Continue")
.font(AppFonts.sans(17, weight: .semibold))
.foregroundColor(.white)
.frame(maxWidth: .infinity)
.frame(height: 54)
.background(
RoundedRectangle(cornerRadius: 14)
.fill(name.trimmingCharacters(in: .whitespaces).isEmpty
? AppColors.accent.opacity(0.4)
: AppColors.accent)
)
}
.disabled(name.trimmingCharacters(in: .whitespaces).isEmpty)
.padding(.horizontal, 28)
Button("Skip for now") {
auth.updateDisplayName("User")
}
.font(AppFonts.sans(14))
.foregroundColor(AppColors.text3(cs))
}
.padding(.bottom, 56)
}
}
.onAppear { focused = true }
}
private func save() {
auth.updateDisplayName(name)
}
}