import SwiftUI import UIKit struct OnboardingView: View { @Binding var onboardingCompleted: Bool @State private var currentPage = 0 @State private var selectedCurrency = Locale.current.currency?.identifier ?? "EUR" @State private var useSampleData = false @AppStorage("calmModeEnabled") private var calmModeEnabled = true @AppStorage("cloudSyncEnabled") private var cloudSyncEnabled = false @State private var showingImportSheet = false @State private var showingAddSource = false private let pages: [OnboardingPage] = [ OnboardingPage( icon: "chart.line.uptrend.xyaxis", title: String(localized: "onboarding_clarity_title"), description: String(localized: "onboarding_clarity_desc"), color: .appPrimary ), OnboardingPage( icon: "checkmark.circle.fill", title: String(localized: "onboarding_habit_title"), description: String(localized: "onboarding_habit_desc"), color: .positiveGreen ), OnboardingPage( icon: "leaf.fill", title: String(localized: "onboarding_calm_title"), description: String(localized: "onboarding_calm_desc"), color: .appSecondary ), OnboardingPage( icon: "flag.checkered", title: String(localized: "onboarding_goals_title"), description: String(localized: "onboarding_goals_desc"), color: .appWarning ) ] var body: some View { VStack { // Pages TabView(selection: $currentPage) { ForEach(0.. Void let onAddSource: () -> Void var body: some View { ScrollView { VStack(spacing: 28) { Spacer().frame(height: 8) // Header VStack(spacing: 10) { Image("BrandMark") .resizable() .scaledToFit() .frame(width: 64, height: 64) Text(String(localized: "onboarding_quickstart_title")) .font(.title.weight(.bold)) Text(String(localized: "onboarding_quickstart_subtitle")) .font(.subheadline) .foregroundColor(.secondary) .multilineTextAlignment(.center) .padding(.horizontal, 30) } // Primary CTA — Add first source VStack(spacing: 10) { Button(action: onAddSource) { Label(String(localized: "onboarding_add_first_source"), systemImage: "plus.circle.fill") .font(.headline) .frame(maxWidth: .infinity) .padding() .background(Color.appPrimary) .foregroundColor(.white) .cornerRadius(AppConstants.UI.cornerRadius) } Button(action: onImport) { Label(String(localized: "onboarding_import_data"), systemImage: "square.and.arrow.down") .font(.subheadline) .frame(maxWidth: .infinity) .padding(.vertical, 12) .background(Color.appPrimary.opacity(0.1)) .foregroundColor(.appPrimary) .cornerRadius(AppConstants.UI.cornerRadius) } } // Secondary options VStack(spacing: 10) { HStack { Text("Currency") Spacer() Picker("Currency", selection: $selectedCurrency) { ForEach(CurrencyPicker.commonCodes, id: \.self) { code in Text(code).tag(code) } } .pickerStyle(.menu) } .padding() .background(Color.gray.opacity(0.1)) .cornerRadius(12) VStack(alignment: .leading, spacing: 6) { Toggle("Focus Mode (recommended)", isOn: $calmModeEnabled) Text("Shows returns since your last check-in instead of daily noise. You can change this anytime in Settings.") .font(.caption) .foregroundColor(.secondary) } .padding() .background(Color.gray.opacity(0.1)) .cornerRadius(12) Toggle("Sync with iCloud (optional)", isOn: $cloudSyncEnabled) .padding() .background(Color.gray.opacity(0.1)) .cornerRadius(12) } Spacer().frame(height: 8) } .padding(.horizontal, 24) } } } // MARK: - First Launch Welcome struct WelcomeView: View { @Binding var showWelcome: Bool let userName: String? @AppStorage("cloudSyncEnabled") private var cloudSyncEnabled = false var body: some View { VStack(spacing: 24) { Spacer() Image(systemName: "hand.wave.fill") .font(.system(size: 60)) .foregroundColor(.appPrimary) VStack(spacing: 8) { if let name = userName { Text("Welcome back, \(name)!") .font(.title.weight(.bold)) } else { Text("Welcome!") .font(.title.weight(.bold)) } Text(cloudSyncEnabled ? "Your investment data has been synced from iCloud." : "Your investment data stays on this device.") .font(.subheadline) .foregroundColor(.secondary) .multilineTextAlignment(.center) } Spacer() Button { withAnimation { showWelcome = false } } label: { Text("Continue") .font(.headline) .foregroundColor(.white) .frame(maxWidth: .infinity) .padding() .background(Color.appPrimary) .cornerRadius(AppConstants.UI.cornerRadius) } .padding(.horizontal, 24) .padding(.bottom, 40) } .background(Color(.systemBackground)) } } #Preview { OnboardingView(onboardingCompleted: .constant(false)) .environmentObject(AccountStore(iapService: IAPService())) }