Hide battery settings on desktops

If the computer is a desktop the battery settings are not shown. Instead a message is presented
This commit is contained in:
Federico Imberti 2025-12-15 16:16:26 +01:00 • committed by Hariharan Mudaliar
commit 33f4365e2b
No known key found for this signature in database
GPG key ID: 025583EB0BE5640E
4 changed files with 164 additions and 17 deletions

View file

@ -1064,23 +1064,34 @@ struct Charge: View {
var body: some View {
Form {
Section {
Defaults.Toggle("Show battery indicator", key: .showBatteryIndicator)
.settingsHighlight(id: highlightID("Show battery indicator"))
Defaults.Toggle("Show power status notifications", key: .showPowerStatusNotifications)
.settingsHighlight(id: highlightID("Show power status notifications"))
Defaults.Toggle("Play low battery alert sound", key: .playLowBatteryAlertSound)
.settingsHighlight(id: highlightID("Play low battery alert sound"))
} header: {
Text("General")
}
Section {
Defaults.Toggle("Show battery percentage", key: .showBatteryPercentage)
.settingsHighlight(id: highlightID("Show battery percentage"))
Defaults.Toggle("Show power status icons", key: .showPowerStatusIcons)
.settingsHighlight(id: highlightID("Show power status icons"))
} header: {
Text("Battery Information")
if BatteryActivityManager.shared.hasBattery() {
Section {
Defaults.Toggle("Show battery indicator", key: .showBatteryIndicator)
.settingsHighlight(id: highlightID("Show battery indicator"))
Defaults.Toggle("Show power status notifications", key: .showPowerStatusNotifications)
.settingsHighlight(id: highlightID("Show power status notifications"))
Defaults.Toggle("Play low battery alert sound", key: .playLowBatteryAlertSound)
.settingsHighlight(id: highlightID("Play low battery alert sound"))
} header: {
Text("General")
}
Section {
Defaults.Toggle("Show battery percentage", key: .showBatteryPercentage)
.settingsHighlight(id: highlightID("Show battery percentage"))
Defaults.Toggle("Show power status icons", key: .showPowerStatusIcons)
.settingsHighlight(id: highlightID("Show power status icons"))
} header: {
Text("Battery Information")
}
} else {
ContentUnavailableView {
VStack(spacing: 16) {
Image("battery.100percent.slash")
.font(.title)
Text("Battery settings and informations are only available on MacBooks")
.font(.title3)
}
}
}
}
.navigationTitle("Battery")