Pull-to-refresh on page 2 reloads device storage and cleanup data, then calls statusService.refresh. Pages 0 and 1 retain backup and clean actions respectively. Co-Authored-By: Kutesir <kutesir@provoc.ug> Co-Authored-By: Sentry <sentry@provoc.ug>
55 lines
1.9 KiB
Swift
55 lines
1.9 KiB
Swift
import SwiftUI
|
|
import Photos
|
|
|
|
@main
|
|
struct NASBackupApp: App {
|
|
@UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
|
|
|
|
@StateObject private var store = ConnectionStore.shared
|
|
@StateObject private var engine = BackupEngine.shared
|
|
@StateObject private var lanMonitor = LANMonitor.shared
|
|
@StateObject private var statusService = BackupStatusService.shared
|
|
@StateObject private var coordinator = AutoBackupCoordinator.shared
|
|
|
|
var body: some Scene {
|
|
WindowGroup {
|
|
RootView()
|
|
.environmentObject(store)
|
|
.environmentObject(engine)
|
|
.environmentObject(lanMonitor)
|
|
.environmentObject(statusService)
|
|
.environmentObject(coordinator)
|
|
.preferredColorScheme(store.appearanceMode.resolvedScheme)
|
|
}
|
|
}
|
|
}
|
|
|
|
struct RootView: View {
|
|
@EnvironmentObject var store: ConnectionStore
|
|
@EnvironmentObject var lanMonitor: LANMonitor
|
|
|
|
var body: some View {
|
|
Group {
|
|
if store.savedConnection == nil {
|
|
ConnectView()
|
|
} else if !store.isSessionActive {
|
|
LoginView()
|
|
} else if store.savedConnection?.remotePath == "/" {
|
|
FolderSetupView()
|
|
} else if !store.onboardingPhotoShown {
|
|
PhotoPermissionView()
|
|
} else {
|
|
MainTabView()
|
|
}
|
|
}
|
|
.animation(.spring(response: 0.4, dampingFraction: 0.85), value: store.isSessionActive)
|
|
.animation(.spring(response: 0.4, dampingFraction: 0.85), value: store.savedConnection?.remotePath)
|
|
.animation(.spring(response: 0.4, dampingFraction: 0.85), value: store.onboardingPhotoShown)
|
|
.task(id: store.isSessionActive) {
|
|
guard store.isSessionActive, let conn = store.savedConnection else { return }
|
|
await lanMonitor.checkNASReachability(host: conn.host, port: conn.port)
|
|
}
|
|
}
|
|
}
|
|
|