From 197e4e52c9090c8e9e69c79b927c63d87f53b9cb Mon Sep 17 00:00:00 2001 From: Stossy11 <69031796+stossy11@users.noreply.github.com> Date: Sat, 29 Mar 2025 15:56:41 +1100 Subject: [PATCH] Fix mounting DDI UI --- StikJIT/StikJITApp.swift | 9 +++++++++ StikJIT/Utilities/mountDDI.swift | 6 ++---- StikJIT/Views/SettingsView.swift | 8 ++++---- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/StikJIT/StikJITApp.swift b/StikJIT/StikJITApp.swift index 464b759..3524042 100644 --- a/StikJIT/StikJITApp.swift +++ b/StikJIT/StikJITApp.swift @@ -162,6 +162,15 @@ class MountingProgress: ObservableObject { } } + func progressCallback(progress: size_t, total: size_t, context: UnsafeMutableRawPointer?) { + let percentage = Double(progress) / Double(total) * 100.0 + print("Mounting progress: \(percentage)%") + + DispatchQueue.main.async { + self.mountProgress = percentage + } + } + func pubMount() { mount() } private func mount() { diff --git a/StikJIT/Utilities/mountDDI.swift b/StikJIT/Utilities/mountDDI.swift index 319003a..3f665de 100644 --- a/StikJIT/Utilities/mountDDI.swift +++ b/StikJIT/Utilities/mountDDI.swift @@ -15,10 +15,7 @@ typealias ImageMounterHandle = OpaquePointer typealias LockdowndClientHandle = OpaquePointer func progressCallback(progress: size_t, total: size_t, context: UnsafeMutableRawPointer?) { - let percentage = Double(progress) / Double(total) * 100.0 - print("Mounting progress: \(percentage)%") - - MountingProgress.shared.mountProgress = percentage + MountingProgress.shared.progressCallback(progress: progress, total: total, context: context) } func readFile(path: String) -> Data? { @@ -50,6 +47,7 @@ func htons(_ value: UInt16) -> UInt16 { } func isMounted() -> Bool { + return false // MARK: REMEMBER THIS var addr = sockaddr_in() memset(&addr, 0, MemoryLayout.size) addr.sin_family = sa_family_t(AF_INET) diff --git a/StikJIT/Views/SettingsView.swift b/StikJIT/Views/SettingsView.swift index 484ff5a..a1c033c 100644 --- a/StikJIT/Views/SettingsView.swift +++ b/StikJIT/Views/SettingsView.swift @@ -180,7 +180,7 @@ struct SettingsView: View { .foregroundColor(.primary) .padding(.bottom, 4) - if self.mounted { + if self.mounted || (mountProg.mountProgress == 100) { HStack { Spacer() Text("✓ Developer Disk Image Mounted Sucessfully!") @@ -199,7 +199,7 @@ struct SettingsView: View { .font(.system(.caption, design: .rounded)) .foregroundColor(.secondary) Spacer() - Text("\(Int(MountingProgress.shared.mountProgress))%") + Text("\(Int(mountProg.mountProgress))%") .font(.system(.caption, design: .rounded)) .foregroundColor(.secondary) } @@ -212,8 +212,8 @@ struct SettingsView: View { RoundedRectangle(cornerRadius: 6) .fill(Color.green) - .frame(width: geometry.size.width * CGFloat(MountingProgress.shared.mountProgress), height: 10) - .animation(.linear(duration: 0.3), value: MountingProgress.shared.mountProgress) + .frame(width: geometry.size.width * CGFloat(mountProg.mountProgress), height: 10) + .animation(.linear(duration: 0.3), value: mountProg.mountProgress) } } .frame(height: 10)