Skip to content

Run a virtual iPhone on an Apple Silicon Mac.

Swift

Show the IPSW download in the machine's state as well

Jacky1f7ee80d2b64
diff --git a/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadMachineInspector.swift b/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadMachineInspector.swift
index dd9ae550..171bb97f 100644
--- a/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadMachineInspector.swift
+++ b/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadMachineInspector.swift
@@ -6,7 +6,8 @@ import SwiftUI
/// A machine's run state as the table and the inspector show it.
struct VPhoneLaunchpadMachineStateLabel: View {
let state: VPhoneLaunchpadMachineLibrary.RunState
- /// An export's progress, shown as a bar in place of the activity text.
+ /// An export's or a creation's IPSW download progress, shown as a bar in
+ /// place of the activity text, which becomes its help tag.
var progress: Double?
var body: some View {
@@ -101,7 +102,7 @@ struct VPhoneLaunchpadMachineInspector: View {
LabeledContent("State") {
VPhoneLaunchpadMachineStateLabel(
state: library.state(of: machine.path),
- progress: library.exports[machine.path]?.fraction,
+ progress: library.progress(of: machine.path),
)
}
if let started = library.startedAt[machine.path] {
diff --git a/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadMachineLibrary.swift b/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadMachineLibrary.swift
index 59374363..150c69aa 100644
--- a/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadMachineLibrary.swift
+++ b/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadMachineLibrary.swift
@@ -92,6 +92,12 @@ final class VPhoneLaunchpadMachineLibrary {
Set(machines.map(\.libraryRoot)).count > 1
}
+ /// The bar the state label shows in place of its text: an export's
+ /// progress, or the IPSW download of a creation.
+ func progress(of machine: Path) -> Double? {
+ exports[machine]?.fraction ?? creations[machine]?.downloadFraction
+ }
+
func state(of machine: Path) -> RunState {
if let creation = creations[machine], creation.isRunning, let step = creation.current {
return .busy(String(localized: "Creating: \(step.title)"))
diff --git a/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadMachinesView.swift b/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadMachinesView.swift
index 3ca28a77..a0ee7635 100644
--- a/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadMachinesView.swift
+++ b/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadMachinesView.swift
@@ -376,7 +376,7 @@ struct VPhoneLaunchpadMachinesView: View {
TableColumn("State") { machine in
VPhoneLaunchpadMachineStateLabel(
state: library.state(of: machine.path),
- progress: library.exports[machine.path]?.fraction,
+ progress: library.progress(of: machine.path),
)
}
.width(min: 150, ideal: 160)