Modern Apps git
git clone https://git.maproj.org/Modern-Apps.git
cov/c3 ▾

Modern-Apps.git / apple / FindFamily / FindFamilyiOS / App / RootView.swift

RootView.swift27 lines · 1020 BRaw
1import SwiftUI
2
3/// Top level switch between the permissions gate and the main UI.
4struct RootView: View {
5 @StateObject private var permissions = PermissionsController()
6 @State private var showDataClearedNotice = !UserDefaults.standard.bool(forKey: Self.dataClearedNoticeKey)
7
8 private static let dataClearedNoticeKey = "dataClearedNoticeShown_v1"
9
10 var body: some View {
11 Group {
12 if permissions.hasForeground && permissions.hasBackground {
13 MainView()
14 } else {
15 PermissionsGate(controller: permissions)
16 }
17 }
18 .onAppear { permissions.refresh() }
19 .alert("Data Cleared", isPresented: $showDataClearedNotice) {
20 Button("OK") {
21 UserDefaults.standard.set(true, forKey: Self.dataClearedNoticeKey)
22 }
23 } message: {
24 Text("All data has been reset as significant improvements to core systems have been made. We apologize for the inconvenience.")
25 }
26 }
27}