mirror of
https://github.com/StikDebug/StikDebug.git
synced 2026-10-16 04:20:30 +00:00
58 lines
1.5 KiB
Swift
58 lines
1.5 KiB
Swift
//
|
|
// StikDebugApp.swift
|
|
// StikDebug
|
|
//
|
|
// Created by Stephen on 3/26/25.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
@main
|
|
struct StikDebugApp: App {
|
|
@Environment(\.scenePhase) private var scenePhase
|
|
@State private var shouldAttemptTunnelReconnect = false
|
|
|
|
init() {
|
|
AppBootstrapper.configure()
|
|
}
|
|
|
|
var body: some Scene {
|
|
WindowGroup {
|
|
MainTabView()
|
|
.task {
|
|
await downloadMissingDeveloperDiskImageFiles()
|
|
}
|
|
.onChange(of: scenePhase) { _, newPhase in
|
|
handleScenePhaseChange(newPhase)
|
|
}
|
|
}
|
|
}
|
|
|
|
private func handleScenePhaseChange(_ newPhase: ScenePhase) {
|
|
switch newPhase {
|
|
case .background:
|
|
shouldAttemptTunnelReconnect = true
|
|
case .active:
|
|
if shouldAttemptTunnelReconnect {
|
|
shouldAttemptTunnelReconnect = false
|
|
startTunnelInBackground(showErrorUI: false)
|
|
}
|
|
default:
|
|
break
|
|
}
|
|
}
|
|
|
|
private func downloadMissingDeveloperDiskImageFiles() async {
|
|
do {
|
|
try await DeveloperDiskImageService.shared.downloadMissingFiles()
|
|
} catch {
|
|
await MainActor.run {
|
|
showAlert(
|
|
title: "An Error has Occurred",
|
|
message: "[Download DDI Error]: \(error.localizedDescription)",
|
|
showOk: true
|
|
)
|
|
}
|
|
}
|
|
}
|
|
}
|