From 9015562bad560ad8c6a3a612a043af82ea3e0e26 Mon Sep 17 00:00:00 2001 From: Edgar Story Date: Thu, 23 Jan 2025 22:58:21 +0000 Subject: [PATCH 1/3] Clear the status bar overrides Although being able to override the status bar is great, sometimes you may want it to reset to its original state. This PR adds a little button to wire up this UI button to the underlying command. --- ControlRoom/Controllers/SimCtl.swift | 4 ++++ ControlRoom/Simulator UI/ControlScreens/StatusBarView.swift | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/ControlRoom/Controllers/SimCtl.swift b/ControlRoom/Controllers/SimCtl.swift index ad7f28b..5ef4ebd 100644 --- a/ControlRoom/Controllers/SimCtl.swift +++ b/ControlRoom/Controllers/SimCtl.swift @@ -113,6 +113,10 @@ enum SimCtl: CommandLineCommandExecuter { ]))) } + static func clearStatusBarOverrides(_ simulator: String) { + execute(.statusBar(deviceId: simulator, operation: .clear)) + } + static func overrideStatusBarTime(_ simulator: String, time: Date) { // Use only time for now since ISO8601 parsing is broken since Xcode 15.3 // https://stackoverflow.com/a/59071895 diff --git a/ControlRoom/Simulator UI/ControlScreens/StatusBarView.swift b/ControlRoom/Simulator UI/ControlScreens/StatusBarView.swift index 4d8015f..cdd35fc 100644 --- a/ControlRoom/Simulator UI/ControlScreens/StatusBarView.swift +++ b/ControlRoom/Simulator UI/ControlScreens/StatusBarView.swift @@ -47,6 +47,8 @@ struct StatusBarView: View { DatePicker("Time:", selection: $time) Button("Set", action: setTime) Button("Set to 9:41", action: setAppleTime) + Spacer() + Button("Clear overrides", action: clearOverrides) } } @@ -153,6 +155,10 @@ struct StatusBarView: View { time = appleTime } + private func clearOverrides() { + SimCtl.clearStatusBarOverrides(simulator.udid) + } + /// Sends status bar updates all at once; simctl gets unhappy if we send them individually, but /// also for whatever reason prefers cellular data sent separately from WiFi. private func updateWiFiData() { From 72455db867c7207b72c73c1a6f63cd68ebd9dbcf Mon Sep 17 00:00:00 2001 From: Edgar Story Date: Thu, 23 Jan 2025 23:06:36 +0000 Subject: [PATCH 2/3] Reset the local UI state when reseting status bar overrides --- .../Simulator UI/ControlScreens/StatusBarView.swift | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ControlRoom/Simulator UI/ControlScreens/StatusBarView.swift b/ControlRoom/Simulator UI/ControlScreens/StatusBarView.swift index cdd35fc..c6e5e5f 100644 --- a/ControlRoom/Simulator UI/ControlScreens/StatusBarView.swift +++ b/ControlRoom/Simulator UI/ControlScreens/StatusBarView.swift @@ -157,6 +157,13 @@ struct StatusBarView: View { private func clearOverrides() { SimCtl.clearStatusBarOverrides(simulator.udid) + dataNetwork = .wifi + wiFiBar = .three + cellularMode = .active + cellularBar = .four + batteryLevel = 100.0 + batteryState = .charged + carrierName = "Carrier" } /// Sends status bar updates all at once; simctl gets unhappy if we send them individually, but From afc17fc394eb11756473001369df5b246508ea67 Mon Sep 17 00:00:00 2001 From: Edgar Story Date: Thu, 23 Jan 2025 23:07:38 +0000 Subject: [PATCH 3/3] Update the default battery state t charged This appears to be the default state that the simulator gets set to when resetting the status bar overrides --- ControlRoom/Simulator UI/ControlScreens/StatusBarView.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ControlRoom/Simulator UI/ControlScreens/StatusBarView.swift b/ControlRoom/Simulator UI/ControlScreens/StatusBarView.swift index c6e5e5f..29ece9e 100644 --- a/ControlRoom/Simulator UI/ControlScreens/StatusBarView.swift +++ b/ControlRoom/Simulator UI/ControlScreens/StatusBarView.swift @@ -37,7 +37,7 @@ struct StatusBarView: View { /// The current battery state of the device; must be "Charging", "Charged", or "Discharging" /// Note: "Charged" looks the same as "Discharging", so it's not included in this screen. - @State private var batteryState: SimCtl.StatusBar.BatteryState = .charging + @State private var batteryState: SimCtl.StatusBar.BatteryState = .charged var body: some View { ScrollView {