a8a9ad64f3
- Imports de CoreData que faltaban (MemberImportVisibility) en AccountsView, ImportDataView, ChartsContainerView y AddSourceView. - Aislamiento MainActor: IsolatedDefaultValues en el target de la app, LinearGradient @MainActor, WatchSyncMessage nonisolated, closures de ReviewPromptService/MonthlyCheckInStore/AppIntents. - Warnings de valores sin usar (SnapshotGapDetector, DashboardLayoutStore, OnboardingView, GoalEditorView, CoreDataStack, SettingsViewModel). - foregroundColor→foregroundStyle, cornerRadius→clipShape, navigationBarLeading/Trailing→topBarLeading/Trailing, Task.sleep(nanoseconds:)→sleep(for:), NavigationLink(isActive:)→ navigationDestination(isPresented:). Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01F1u4K16xy7eQVtgsYNZ9Vn
142 lines
4.8 KiB
Swift
142 lines
4.8 KiB
Swift
import SwiftUI
|
|
|
|
/// Shown before onboarding on a fresh install when iCloud is available.
|
|
/// Lets the user choose between restoring from iCloud or starting fresh.
|
|
struct OnboardingICloudCheckView: View {
|
|
/// Called when the user decides to start fresh (no iCloud restore).
|
|
let onSkip: () -> Void
|
|
|
|
@AppStorage("cloudSyncEnabled") private var cloudSyncEnabled = false
|
|
@State private var showRestartPrompt = false
|
|
|
|
var body: some View {
|
|
if showRestartPrompt {
|
|
restartPromptView
|
|
} else {
|
|
checkView
|
|
}
|
|
}
|
|
|
|
// MARK: - Check View
|
|
|
|
private var checkView: some View {
|
|
VStack {
|
|
Spacer()
|
|
|
|
VStack(spacing: 28) {
|
|
ZStack {
|
|
Circle()
|
|
.fill(Color.appPrimary.opacity(0.12))
|
|
.frame(width: 140, height: 140)
|
|
Circle()
|
|
.fill(Color.appPrimary.opacity(0.22))
|
|
.frame(width: 100, height: 100)
|
|
Image(systemName: "icloud.fill")
|
|
.font(.system(size: 50))
|
|
.foregroundStyle(Color.appPrimary)
|
|
}
|
|
|
|
VStack(spacing: 14) {
|
|
Text(String(localized: "icloud_check_title"))
|
|
.font(.title.weight(.bold))
|
|
.multilineTextAlignment(.center)
|
|
|
|
Text(String(localized: "icloud_check_description"))
|
|
.font(.body)
|
|
.foregroundStyle(.secondary)
|
|
.multilineTextAlignment(.center)
|
|
.padding(.horizontal, 40)
|
|
}
|
|
}
|
|
|
|
Spacer()
|
|
Spacer()
|
|
|
|
VStack(spacing: 12) {
|
|
Button {
|
|
cloudSyncEnabled = true
|
|
showRestartPrompt = true
|
|
} label: {
|
|
Label("Restore from iCloud", systemImage: "icloud.and.arrow.down")
|
|
.font(.headline)
|
|
.foregroundStyle(.white)
|
|
.frame(maxWidth: .infinity)
|
|
.padding()
|
|
.background(Color.appPrimary)
|
|
.clipShape(RoundedRectangle(cornerRadius: AppConstants.UI.cornerRadius))
|
|
}
|
|
|
|
Button {
|
|
onSkip()
|
|
} label: {
|
|
Text("Start Fresh")
|
|
.font(.subheadline)
|
|
.foregroundStyle(.secondary)
|
|
}
|
|
}
|
|
.padding(.horizontal, 24)
|
|
.padding(.bottom, 40)
|
|
}
|
|
.background(AppBackground())
|
|
}
|
|
|
|
// MARK: - Restart Prompt View
|
|
|
|
private var restartPromptView: some View {
|
|
VStack {
|
|
Spacer()
|
|
|
|
VStack(spacing: 28) {
|
|
ZStack {
|
|
Circle()
|
|
.fill(Color.positiveGreen.opacity(0.12))
|
|
.frame(width: 140, height: 140)
|
|
Circle()
|
|
.fill(Color.positiveGreen.opacity(0.22))
|
|
.frame(width: 100, height: 100)
|
|
Image(systemName: "checkmark.icloud.fill")
|
|
.font(.system(size: 50))
|
|
.foregroundStyle(Color.positiveGreen)
|
|
}
|
|
|
|
VStack(spacing: 14) {
|
|
Text(String(localized: "icloud_enabled_title"))
|
|
.font(.title.weight(.bold))
|
|
.multilineTextAlignment(.center)
|
|
|
|
Text(String(localized: "icloud_enabled_description"))
|
|
.font(.body)
|
|
.foregroundStyle(.secondary)
|
|
.multilineTextAlignment(.center)
|
|
.padding(.horizontal, 40)
|
|
}
|
|
}
|
|
|
|
Spacer()
|
|
Spacer()
|
|
|
|
// "Got it" just acknowledges — the user must close and reopen manually.
|
|
// The button stays active so it doesn't look broken.
|
|
Button {
|
|
// No-op: user needs to close and reopen the app.
|
|
// Nothing to navigate to; this session has no CloudKit container.
|
|
} label: {
|
|
Text("Got it")
|
|
.font(.headline)
|
|
.foregroundStyle(.white)
|
|
.frame(maxWidth: .infinity)
|
|
.padding()
|
|
.background(Color.positiveGreen)
|
|
.clipShape(RoundedRectangle(cornerRadius: AppConstants.UI.cornerRadius))
|
|
}
|
|
.padding(.horizontal, 24)
|
|
.padding(.bottom, 40)
|
|
}
|
|
.background(AppBackground())
|
|
}
|
|
}
|
|
|
|
#Preview {
|
|
OnboardingICloudCheckView(onSkip: {})
|
|
}
|