summaryrefslogtreecommitdiff
path: root/makima/ios/Sources/Makima/App/RootView.swift
blob: a7665e1abf2718308cd0ee61c0b1a6e8fa98261c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import SwiftUI

/// Top-level router: Onboarding until we have a validated ServerProfile + API
/// key, then Home.
struct RootView: View {
    @Environment(AuthStore.self) private var auth

    var body: some View {
        ZStack {
            Palette.background.ignoresSafeArea()

            switch auth.state {
            case .needsOnboarding, .error:
                OnboardingFlow()
                    .transition(.opacity)
            case .validating:
                ValidatingView()
                    .transition(.opacity)
            case .authenticated:
                HomeView()
                    .transition(.opacity)
            }
        }
        .animation(.easeInOut(duration: 0.25), value: auth.state)
    }
}

struct ValidatingView: View {
    var body: some View {
        VStack(spacing: 16) {
            Spacer()
            Logo(size: 80)
            ProgressView()
                .progressViewStyle(.circular)
                .tint(Palette.accent)
            Text("CONNECTING…")
                .font(Typography.navLabel)
                .tracking(2)
                .foregroundStyle(Palette.foregroundMuted)
            Spacer()
        }
    }
}