From 976169e85810274c3742a152de67f7f8d71a9e0c Mon Sep 17 00:00:00 2001 From: C4ndyF1sh <128715345+C4ndyF1sh@users.noreply.github.com> Date: Mon, 14 Apr 2025 23:14:48 +0200 Subject: [PATCH] Add check if 17.4+ is installed --- StikJIT/StikJITApp.swift | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/StikJIT/StikJITApp.swift b/StikJIT/StikJITApp.swift index e55f222..cb190b0 100644 --- a/StikJIT/StikJITApp.swift +++ b/StikJIT/StikJITApp.swift @@ -34,7 +34,6 @@ func httpGet(_ urlString: String, result: @escaping (String?) -> Void) { if let data = data, let httpResponse = response as? HTTPURLResponse { if httpResponse.statusCode == 200 { print("Response: \(httpResponse.statusCode)") - if let dataString = String(data: data, encoding: .utf8) { result(dataString) } @@ -214,6 +213,8 @@ struct HeartbeatApp: App { window.overrideUserInterfaceStyle = .unspecified } } + + // Removed the version check from here since it now runs inside LoadingView.onAppear. } func newVerCheck() { @@ -251,7 +252,8 @@ struct HeartbeatApp: App { var body: some Scene { WindowGroup { if isLoading2 { - LoadingView() + // Pass bindings to LoadingView for alert handling and version check. + LoadingView(showAlert: $show_alert, alertTitle: $alert_title, alertMessage: $alert_string) .onAppear { dnsChecker.checkDNS() @@ -589,6 +591,10 @@ func startHeartbeatInBackground() { } struct LoadingView: View { + @Binding var showAlert: Bool + @Binding var alertTitle: String + @Binding var alertMessage: String + @State private var animate = false @Environment(\.colorScheme) private var colorScheme @AppStorage("customAccentColor") private var customAccentColorHex: String = "" @@ -641,6 +647,14 @@ struct LoadingView: View { .shadow(color: accentColor.opacity(0.4), radius: 10, x: 0, y: 0) .onAppear { animate = true + + // iOS Version Check: if the device is running iOS lower than 17.4, + // set the alert bindings so that the alert is shown. + if #unavailable(iOS 17.4) { + alertTitle = "Unsupported OS Version" + alertMessage = "StikJIT only supports iOS/iPadOS 17.4 and above.\nYou're running an older version." + showAlert = true + } } Text("Loading...")