Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move system_overlay_style from AppBar to Theme #2667

Merged
merged 5 commits into from
Feb 17, 2024

Conversation

ndonkoHenri
Copy link
Contributor

@ndonkoHenri ndonkoHenri commented Feb 17, 2024

Test code:

import flet as ft

def main(page: ft.Page):
    page.theme = ft.Theme(
        system_overlay_style=ft.SystemOverlayStyle(
            status_bar_color=ft.colors.ORANGE_100,
            system_navigation_bar_color=ft.colors.GREEN_300,
            system_navigation_bar_divider_color=ft.colors.BLUE,
            status_bar_icon_brightness=ft.Brightness.DARK,
            system_navigation_bar_icon_brightness=ft.Brightness.DARK,
            status_bar_brightness=ft.Brightness.LIGHT,
        ),
    )
    page.dark_theme = ft.Theme(
        system_overlay_style=ft.SystemOverlayStyle(
            status_bar_color=ft.colors.ORANGE,
            system_navigation_bar_color=ft.colors.GREEN_800,
            system_navigation_bar_divider_color=ft.colors.BLUE,
            status_bar_icon_brightness=ft.Brightness.LIGHT,
            system_navigation_bar_icon_brightness=ft.Brightness.LIGHT,
            status_bar_brightness=ft.Brightness.DARK,
        ),
    )
    page.theme_mode = ft.ThemeMode.LIGHT

    def dark_light_mode_changed(e):
        if page.theme_mode == ft.ThemeMode.LIGHT:
            page.theme_mode = ft.ThemeMode.DARK
        else:
            page.theme_mode = ft.ThemeMode.LIGHT
        page.update()

    dark_mode_checkbox = ft.Switch(
        value=False, label="Dark Mode", on_change=dark_light_mode_changed
    )

    page.appbar = ft.AppBar(
        leading=ft.Icon(ft.icons.STYLE),
        title=ft.Text("Using SystemOverlayStyle"),
        bgcolor=ft.colors.BLUE_500,
    )
    page.add(ft.SafeArea(ft.Column([ft.Text("Body!"), dark_mode_checkbox])))


ft.app(target=main)

@ndonkoHenri ndonkoHenri added the enhancement Improvement/Optimization label Feb 17, 2024
@FeodorFitsner FeodorFitsner merged commit 8aa0f1b into main Feb 17, 2024
1 of 2 checks passed
@ndonkoHenri ndonkoHenri deleted the system-overlay-style branch February 21, 2024 01:52
zrr1999 pushed a commit to zrr1999/flet that referenced this pull request Jul 17, 2024
* move systemOverlayStyle to Theme

* Introduced SystemUiOverlayStyleTheme

* Using `AnnotatedRegion` to apply system overlay style

* Cleanup

---------

Co-authored-by: Feodor Fitsner <feodor@appveyor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improvement/Optimization
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants