Add battery percentage display option in menu bar icon - #17
Conversation
|
@srimanachanta Kindly review this MR. |
|
"Hey! @srimanachanta Just a quick heads-up: I've submitted 6 modular PRs (PRs #17 through #22) to break down a larger set of features and make the review process much easier for you. Because a few of these PRs touch the same core files (like Once you merge a PR, if GitHub flags any of my remaining open PRs with conflicts, just let me know or leave them be—I will actively monitor the repo and locally rebase my remaining branches against your updated
Thanks for maintaining Stasis! Let me know if you need any adjustments. |
| if shouldShowOutsidePercentage { | ||
| Text("\(batteryLevel)%") | ||
| .font(.system(size: 10, weight: .medium)) | ||
| .monospacedDigit() |
There was a problem hiding this comment.
Why was monospacedDigit removed? This will lead to UI shifts on percentage changes. This is a regression
| if showPercentage { | ||
| if shouldShowOutsidePercentage { | ||
| Text("\(batteryLevel)%") | ||
| .font(.system(size: 10, weight: .medium)) |
There was a problem hiding this comment.
Is there a reason for changing the font from 10 medium → NSFont.menuBarFont(ofSize: 11)? It changes the visual balance against the 12pt battery icon, and the weight drop reduces legibility at menu bar size.
| .foregroundStyle(.white) | ||
| .shadow(color: .black, radius: 0.5) | ||
| .shadow(color: .black, radius: 0.5) | ||
| .shadow(color: .black, radius: 0.5) |
There was a problem hiding this comment.
Can be moved back to the group level once previous comment is addressed.
b5b5bd6 to
88b6032
Compare
|
@srimanachanta I've applied the feedback from your review. Replaced the toggles with a Picker, removed the obsolete outline shadow with the 3 layered shadows, changed the font to |
…on when on battery
Restructures the inside-icon mode as a punch-out battery indicator:
- Fill colors by state:
critical → red (white foreground)
LPM → yellow (black foreground)
charging → green (white foreground)
otherwise → .primary, foreground knocked out to the menu bar
- Percentage text sits inside the body with a small charging glyph
(bolt / rotated powerplug) to its right, both sized to fit within
the battery body rather than overlaying it.
- Knockout uses .blendMode(.destinationOut) within a compositingGroup
so the digits show the menu bar background through the fill in the
normal/discharging case.
- Hidden / outside-icon modes keep the original centered-glyph layout.
Use plain case names as rawValue so persisted preferences are stable across label changes, and replace the runtime LocalizedStringKey lookup with explicit Text literals so the strings are extractable for localization.
…p stale strings Change the default PercentageDisplayLocation to .nextToIcon so users upgrading from the prior boolean see the same behavior they had before. Rename the picker label to 'Show percentage' for brevity, and remove two stale entries from the localization catalog.
The digit is rendered with monospaced glyphs and is purely numeric, so route it through Text(verbatim:) to avoid registering '%lld' as a translatable string.
88b6032 to
c75038c
Compare
This pull request introduces new customization options for how the battery percentage is displayed in the menu bar icon, allowing users to choose whether the percentage appears inside the icon when on battery, and/or outside the icon when powered. It updates the settings UI, underlying logic, and localization strings to support these options.
Battery Percentage Display Customization:
showBatteryPercentageInsideIconOnBatteryandshowBatteryPercentageOutsideIconWhenPowered, enabling users to control whether the battery percentage appears inside the icon while on battery and outside the icon when plugged in, respectively.StatusBarContentViewandBatteryIndicatorViewto respect these new settings, including logic to determine when to show the percentage inside or outside the icon based on charging state and user preferences. [1] [2] [3] [4]Settings UI Enhancements:
GeneralSettingsViewto include toggles for the new settings, with appropriate enabling/disabling logic based on related settings. Updated the settings section description to reflect the new options. [1] [2]Localization Updates: