import SwiftUI struct ContentView: View { @StateObject private var session = AuthSessionStore() private let restoresSession: Bool @MainActor init(session: AuthSessionStore? = nil, restoresSession: Bool = true) { _session = StateObject(wrappedValue: session ?? AuthSessionStore()) self.restoresSession = restoresSession } var body: some View { Group { switch session.state { case .checking: ProgressView() .tint(.red) .frame(maxWidth: .infinity, maxHeight: .infinity) .background(Color(uiColor: .systemBackground)) .accessibilityLabel("Checking sign-in") case .signedOut: SignInView(session: session) case .signedIn: MainTabView() } } .task { guard restoresSession else { return } await session.restoreSession() } } } struct ContentView_Previews: PreviewProvider { static var previews: some View { ContentView( session: AuthSessionStore(initialState: .signedOut), restoresSession: false ) } }