From 960e4d676a426fde6628b8b72891624f088676f8 Mon Sep 17 00:00:00 2001 From: Federico Imberti <66013290+FI-153@users.noreply.github.com> Date: Mon, 15 Dec 2025 16:16:26 +0100 Subject: [PATCH] Hide battery settings on desktops If the computer is a desktop the battery settings are not shown. Instead a message is presented --- .../Contents.json | 12 ++ .../battery.100percent.slash.svg | 121 ++++++++++++++++++ DynamicIsland/Localizable.xcstrings | 3 + .../components/Settings/SettingsView.swift | 45 ++++--- 4 files changed, 164 insertions(+), 17 deletions(-) create mode 100644 DynamicIsland/Assets.xcassets/battery.100percent.slash.symbolset/Contents.json create mode 100644 DynamicIsland/Assets.xcassets/battery.100percent.slash.symbolset/battery.100percent.slash.svg diff --git a/DynamicIsland/Assets.xcassets/battery.100percent.slash.symbolset/Contents.json b/DynamicIsland/Assets.xcassets/battery.100percent.slash.symbolset/Contents.json new file mode 100644 index 0000000..67a74cd --- /dev/null +++ b/DynamicIsland/Assets.xcassets/battery.100percent.slash.symbolset/Contents.json @@ -0,0 +1,12 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + }, + "symbols" : [ + { + "filename" : "battery.100percent.slash.svg", + "idiom" : "universal" + } + ] +} diff --git a/DynamicIsland/Assets.xcassets/battery.100percent.slash.symbolset/battery.100percent.slash.svg b/DynamicIsland/Assets.xcassets/battery.100percent.slash.symbolset/battery.100percent.slash.svg new file mode 100644 index 0000000..f777610 --- /dev/null +++ b/DynamicIsland/Assets.xcassets/battery.100percent.slash.symbolset/battery.100percent.slash.svg @@ -0,0 +1,121 @@ + + + + + + + + + + Weight/Scale Variations + Ultralight + Thin + Light + Regular + Medium + Semibold + Bold + Heavy + Black + + + + + + + + + + + Design Variations + Symbols are supported in up to nine weights and three scales. + For optimal layout with text and other symbols, vertically align + symbols with the adjacent text. + + + + + + Margins + Leading and trailing margins on the left and right side of each symbol + can be adjusted by modifying the x-location of the margin guidelines. + Modifications are automatically applied proportionally to all + scales and weights. + + + + Exporting + Symbols should be outlined when exporting to ensure the + design is preserved when submitting to Xcode. + Template v.7.0 + Requires Xcode 17 or greater + Generated from + Typeset at 100.0 points + Small + Medium + Large + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/DynamicIsland/Localizable.xcstrings b/DynamicIsland/Localizable.xcstrings index 07f523e..cb18ea6 100644 --- a/DynamicIsland/Localizable.xcstrings +++ b/DynamicIsland/Localizable.xcstrings @@ -3866,6 +3866,9 @@ } } } + }, + "Battery settings and informations are only available on MacBooks" : { + }, "Battery Status" : { "localizations" : { diff --git a/DynamicIsland/components/Settings/SettingsView.swift b/DynamicIsland/components/Settings/SettingsView.swift index 7e3aa50..ab5c487 100644 --- a/DynamicIsland/components/Settings/SettingsView.swift +++ b/DynamicIsland/components/Settings/SettingsView.swift @@ -1047,23 +1047,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")