From 9a37f74941bcfd3405b4df721ffdc9f1c7908a48 Mon Sep 17 00:00:00 2001 From: Harry-KNIGHT Date: Tue, 28 Nov 2023 21:33:38 +0100 Subject: [PATCH] feat: turn methods private and fix text moving depending on number text from slider feat: change indentation to spacebar --- .../ControlScreens/StatusBarView.swift | 52 ++++++++++++++----- 1 file changed, 39 insertions(+), 13 deletions(-) diff --git a/ControlRoom/Simulator UI/ControlScreens/StatusBarView.swift b/ControlRoom/Simulator UI/ControlScreens/StatusBarView.swift index b3aa9bb..4d8015f 100644 --- a/ControlRoom/Simulator UI/ControlScreens/StatusBarView.swift +++ b/ControlRoom/Simulator UI/ControlScreens/StatusBarView.swift @@ -110,8 +110,16 @@ struct StatusBarView: View { .pickerStyle(.radioGroup) VStack(spacing: 0) { - Text("Current battery percentage: \(Int(round(batteryLevel)))%") - Slider(value: $batteryLevel, in: 0...100, onEditingChanged: levelChanged, minimumValueLabel: Text("0%"), maximumValueLabel: Text("100%")) { + Text("Current battery percentage: \(Int(round(batteryLevel)))%") + .font(.callout.monospacedDigit()) + + Slider( + value: $batteryLevel, + in: 0...100, + onEditingChanged: levelChanged, + minimumValueLabel: Text("0%"), + maximumValueLabel: Text("100%") + ) { Text("Level:") } } @@ -125,12 +133,14 @@ struct StatusBarView: View { } } + // MARK: Private methods + /// Changes the system clock to a new value. - func setTime() { + private func setTime() { SimCtl.overrideStatusBarTime(simulator.udid, time: time) } - func setAppleTime() { + private func setAppleTime() { let calendar = Calendar.current var components = calendar.dateComponents([.year, .month, .day], from: Date.now) components.hour = 9 @@ -145,29 +155,43 @@ struct StatusBarView: View { /// 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. - func updateWiFiData() { - SimCtl.overrideStatusBarWiFi(simulator.udid, network: dataNetwork, - wifiMode: wiFiMode, wifiBars: wiFiBar) + private func updateWiFiData() { + SimCtl.overrideStatusBarWiFi( + simulator.udid, + network: dataNetwork, + wifiMode: wiFiMode, + wifiBars: wiFiBar + ) } - func updateCellularData() { - SimCtl.overrideStatusBarCellular(simulator.udid, cellMode: cellularMode, - cellBars: cellularBar, carrier: carrierName) + private func updateCellularData() { + SimCtl.overrideStatusBarCellular( + simulator.udid, + cellMode: cellularMode, + cellBars: cellularBar, + carrier: carrierName + ) } /// Sends battery updates all at once; simctl gets unhappy if we send them individually. - func updateBattery() { - SimCtl.overrideStatusBarBattery(simulator.udid, level: Int(batteryLevel), state: batteryState) + private func updateBattery() { + SimCtl.overrideStatusBarBattery( + simulator.udid, + level: Int(batteryLevel), + state: batteryState + ) } /// Triggered when the user adjusts the battery level. - func levelChanged(_ isEditing: Bool) { + private func levelChanged(_ isEditing: Bool) { if isEditing == false { updateBattery() } } } +// MARK: Preview + struct StatusBarViewView_Previews: PreviewProvider { static var previews: some View { StatusBarView(simulator: .example) @@ -175,6 +199,8 @@ struct StatusBarViewView_Previews: PreviewProvider { } } +// MARK: Extensions + extension SimCtl.StatusBar.DataNetwork { var displayName: String { switch self {