Add battery percentage display to launcher clock panel#4320
Add battery percentage display to launcher clock panel#4320Jack251970 wants to merge 8 commits intodevfrom
Conversation
Co-authored-by: Jack251970 <53996452+Jack251970@users.noreply.github.com>
- Add PowerStatus NuGet package (v1.0.3) - Add UseBattery setting to Settings.cs - Add BatteryText property and update periodic timer in MainViewModel - Add BatteryBox TextBlock to ClockPanel in MainWindow.xaml - Add BaseBatteryBox and BatteryBox styles to Base.xaml and all theme files - Add UseBattery toggle and preview to SettingsPaneTheme - Add Battery localization string to en.xaml Co-authored-by: Jack251970 <53996452+Jack251970@users.noreply.github.com>
- Remove BaseBatteryBox and BatteryBox style definitions from Base.xaml - Remove BatteryBox style overrides from all theme files - Update BatteryBox TextBlock in MainWindow.xaml to use ClockBox style - Update BatteryBox TextBlock in SettingsPaneTheme.xaml to use ClockBox style Co-authored-by: Jack251970 <53996452+Jack251970@users.noreply.github.com>
Restructure ClockPanel in MainWindow.xaml by grouping the Clock and Date TextBlocks in a vertical StackPanel and placing the Battery TextBlock in a separate vertical StackPanel with a left margin. This enhances the visual alignment and separation between the clock/date and battery displays.
|
🥷 Code experts: jjw24 jjw24, Jack251970 have most 👩💻 activity in the files. See details
Activity based on git-commit:
Knowledge based on git-blame:
Activity based on git-commit:
Knowledge based on git-blame:
Activity based on git-commit:
Knowledge based on git-blame:
Activity based on git-commit:
Knowledge based on git-blame:
Activity based on git-commit:
Knowledge based on git-blame:
Activity based on git-commit:
Knowledge based on git-blame:
Activity based on git-commit:
Knowledge based on git-blame:
Activity based on git-commit:
Knowledge based on git-blame: ✨ Comment |
|
Be a legend 🏆 by adding a before and after screenshot of the changes you made, especially if they are around UI/UX. |
There was a problem hiding this comment.
1 issue found across 8 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="Flow.Launcher/SettingPages/Views/SettingsPaneTheme.xaml">
<violation number="1" location="Flow.Launcher/SettingPages/Views/SettingsPaneTheme.xaml:352">
P2: Battery preview layout does not match the real launcher layout, so the settings preview becomes misleading when battery is enabled.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
There was a problem hiding this comment.
Pull request overview
Adds an optional battery percentage indicator to the launcher’s clock panel, controlled by a new setting, to address the request in #3221.
Changes:
- Introduces a
UseBatteryuser setting and adds a corresponding toggle in the theme/settings UI. - Adds
BatteryTexttoMainViewModeland renders it inMainWindowalongside the clock/date. - Adds the
PowerStatusNuGet dependency and updates lockfile/localization strings.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
Flow.Launcher/packages.lock.json |
Locks new PowerStatus dependency and updates resolved package versions. |
Flow.Launcher/Flow.Launcher.csproj |
Adds PowerStatus package reference. |
Flow.Launcher.Infrastructure/UserSettings/Settings.cs |
Adds persisted UseBattery setting. |
Flow.Launcher/ViewModel/MainViewModel.cs |
Polls power status and exposes BatteryText for binding. |
Flow.Launcher/MainWindow.xaml |
Updates clock panel layout and adds battery text binding. |
Flow.Launcher/SettingPages/Views/SettingsPaneTheme.xaml |
Adds settings toggle and theme preview BatteryBox. |
Flow.Launcher/SettingPages/ViewModels/SettingsPaneThemeViewModel.cs |
Adds UseBattery binding and preview BatteryText. |
Flow.Launcher/Languages/en.xaml |
Adds Battery localization key (English). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
📝 WalkthroughWalkthroughAdds an optional battery-percentage display beside clock/date: new Settings flag, UI elements and localization, a PowerStatus dependency, ViewModel properties to fetch/format battery percentage, and settings toggle integration. Changes
Sequence DiagramsequenceDiagram
participant User
participant Settings
participant MainWindow
participant MainViewModel
participant PowerStatusProvider
User->>MainWindow: Toggle "Show Battery" (UI)
MainWindow->>Settings: Set UseBattery = true/false
MainWindow->>MainViewModel: Notify setting change / bind update
MainViewModel->>PowerStatusProvider: Request battery status (if UseBattery)
PowerStatusProvider-->>MainViewModel: Return battery proportion/value
MainViewModel->>MainWindow: Update BatteryText (e.g., "75%")
MainWindow-->>User: Render BatteryBox with BatteryText
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@Flow.Launcher/Languages/en.xaml`:
- Line 331: The localized resource dictionaries are missing the "Battery" key
used by SettingsPaneTheme.xaml via {DynamicResource Battery}; add a
<system:String x:Key="Battery">Battery</system:String> entry (translated
appropriately) to each of the other 27 language XAML files (all non-English
resource dictionaries) so the DynamicResource resolves for all locales; ensure
the key name is exactly "Battery" and place it alongside the other top-level
strings in each language file so no locale shows a missing/blank header.
In `@Flow.Launcher/MainWindow.xaml`:
- Around line 302-323: The right-hand StackPanel that holds BatteryBox currently
has a fixed Margin="8 0 0 0" which leaves a gap even when Settings.UseBattery is
false; update the XAML so the left margin is conditional – either remove the
fixed Margin and apply it via a Style/DataTrigger on that StackPanel (targeting
the StackPanel containing BatteryBox) that sets Margin="8 0 0 0" only when
Settings.UseBattery is true, or bind the Margin to Settings.UseBattery using a
converter that returns "8 0 0 0" when true and "0 0 0 0" when false; reference
the StackPanel (the one with Margin currently defined), the BatteryBox TextBlock
and Settings.UseBattery to locate and apply the change.
ℹ️ Review info
Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: a8401153-82bd-490e-a3ff-0319593291cc
📒 Files selected for processing (8)
Flow.Launcher.Infrastructure/UserSettings/Settings.csFlow.Launcher/Flow.Launcher.csprojFlow.Launcher/Languages/en.xamlFlow.Launcher/MainWindow.xamlFlow.Launcher/SettingPages/ViewModels/SettingsPaneThemeViewModel.csFlow.Launcher/SettingPages/Views/SettingsPaneTheme.xamlFlow.Launcher/ViewModel/MainViewModel.csFlow.Launcher/packages.lock.json
Changed default Margin in Base.xaml styles from "0 0 0 3" or "0 0 0 0" to "0 1.5 0 1.5" for better vertical alignment and spacing in both the main and BaseDateBox styles. Trigger-based margin and font size settings remain unchanged.
Separated BatteryBox into its own StackPanel with margin for improved alignment and spacing in MainWindow.xaml and SettingsPaneTheme.xaml. Updated the battery icon glyph in SettingsPaneTheme.xaml for a refreshed visual appearance.
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
Flow.Launcher/Themes/Base.xaml (1)
134-146:⚠️ Potential issue | 🟡 MinorBase margin normalization is currently bypassed by theme overrides
Line 134 and Line 146 standardize spacing in
BaseClockBox/BaseDateBox, butFlow.Launcher/Themes/SlimLight.xaml:198-224still overrides these margins (including trigger margins), so clock/date/battery alignment will remain inconsistent when users switch to SlimLight.Consider aligning SlimLight’s
ClockBox/DateBoxmargins with this new base spacing model so the battery layout behaves consistently across themes.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@Flow.Launcher/Themes/Base.xaml` around lines 134 - 146, The BaseClockBox and BaseDateBox styles now normalize margins and trigger margins, but SlimLight's ClockBox/DateBox styles still override those margins (including trigger margins) causing inconsistent alignment; update the SlimLight theme styles that define ClockBox and DateBox (the Style entries in SlimLight.xaml around the ClockBox/DateBox definitions) to either remove the hardcoded Margin/FontSize trigger overrides or align their Margin and DataTrigger values with the BaseClockBox/BaseDateBox conventions so they inherit the base spacing model and produce consistent clock/date/battery alignment across themes.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@Flow.Launcher/Themes/Base.xaml`:
- Around line 134-146: The BaseClockBox and BaseDateBox styles now normalize
margins and trigger margins, but SlimLight's ClockBox/DateBox styles still
override those margins (including trigger margins) causing inconsistent
alignment; update the SlimLight theme styles that define ClockBox and DateBox
(the Style entries in SlimLight.xaml around the ClockBox/DateBox definitions) to
either remove the hardcoded Margin/FontSize trigger overrides or align their
Margin and DataTrigger values with the BaseClockBox/BaseDateBox conventions so
they inherit the base spacing model and produce consistent clock/date/battery
alignment across themes.
ℹ️ Review info
Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 0fe65895-2577-4a45-93a4-b72e7eab8577
📒 Files selected for processing (3)
Flow.Launcher/MainWindow.xamlFlow.Launcher/SettingPages/Views/SettingsPaneTheme.xamlFlow.Launcher/Themes/Base.xaml
🚧 Files skipped from review as they are similar to previous changes (2)
- Flow.Launcher/MainWindow.xaml
- Flow.Launcher/SettingPages/Views/SettingsPaneTheme.xaml
|
Please ensure you test that this change does not increase memory usage. |
CHANGES
This pull request adds support for displaying battery status in the application's UI, allowing users to toggle its visibility alongside the clock and date. It introduces a new dependency for battery information and updates both the settings and UI to accommodate this feature.
Resolve #3221.
TODO
TEST
Summary by cubic
Adds an optional battery percentage next to the clock/date with a toggle in Theme settings, updated via the existing timer using PowerStatus. Resolves #3221.
Summary of changes
Written for commit db03adc. Summary will update on new commits.