Skip to content

Conversation

@Vetle444
Copy link
Contributor

@Vetle444 Vetle444 commented Feb 6, 2026

Added StatusBarHandler to provide per-page control over Android status bar appearance, with support for both modal and non-modal pages.

Problem

Previously, status bar color and icon style were set globally across the entire app. When navigating between pages with different backgrounds (e.g., a photo capture page with transparent status bar, then a regular page with colored background), the status bar couldn't adapt automatically. This was especially problematic in modal navigation scenarios.

Solution

Introduced two new properties on ContentPage:

  • StatusBarColor: Sets the status bar background color for each page
  • StatusBarStyle: Controls icon color (Clock, battery, etc.)
    • Auto - Automatically determines light/dark icons based on background luminosity (default)
    • Light - Light icons for dark backgrounds
    • Dark - Dark icons for light backgrounds

The StatusBarHandler automatically detects modal vs non-modal pages and applies the correct implementation:

  • Non-modal pages: Sets color on Activity window
  • Modal pages: Tracks DialogFragment-to-ContentPage mapping and sets color on dialog window

Status bar updates dynamically in OnAppearing(), ensuring correct appearance as users navigate.

Platform Differences

Android only - iOS status bar is controlled differently through Info.plist and native APIs.

Files Changed

  • Added StatusBarHandler.cs - Core status bar management logic
  • Modified FragmentLifeCycleCallback.cs - Registers/unregisters DialogFragment mappings
  • Modified ContentPage.cs - Calls StatusBarHandler.TrySetStatusBarColor() in OnAppearing()
  • Modified ContentPage.Properties.cs - Added StatusBarColor and StatusBarStyle properties

Usage Example

<dui:ContentPage StatusBarColor="Transparent"
                 StatusBarStyle="Light"
                 Background="Black">
    <!-- Content -->
</dui:ContentPage>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants