Fix mounting DDI UI

This commit is contained in:
Stossy11 2025-03-29 15:56:41 +11:00
parent daf7bc2e0c
commit 197e4e52c9
3 changed files with 15 additions and 8 deletions

View file

@ -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() {

View file

@ -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<sockaddr_in>.size)
addr.sin_family = sa_family_t(AF_INET)

View file

@ -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)