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

add barrier color as an option to showDialog function and python class #4236

Merged
merged 6 commits into from
Nov 4, 2024

Conversation

OwenMcDonnell
Copy link
Contributor

Description

The showDialog function in flutter accepts a barrierColor parameter to change (or make transparent) the modal barrier color. Addition of this option to Flet's AlertDialog resolves an issue mentioned in #4130.

Fixes #4130

Test Code

import flet as ft


def main(page: ft.Page):
    page.window.width = 450
    page.window.height = 450
    page.window.bgcolor = ft.colors.TRANSPARENT
    page.bgcolor = ft.colors.TRANSPARENT
    page.window.frameless = True
    page.window.center()

    def close_dialog(e):
        page.close(alert)
        page.update()

    alert = ft.AlertDialog(
        modal=True,
        title=ft.Text('Alert Dialog'),
        content=ft.Text('This is an alert dialog'),
        actions=[
            ft.TextButton('OK', on_click=close_dialog),
        ],
        shadow_color=ft.colors.TRANSPARENT,
        surface_tint_color=ft.colors.TRANSPARENT,
        barrier_color=ft.colors.TRANSPARENT
    )
    
    def open_dialog(e):


        page.open(alert)
        page.update()
    

    
    def close_app(e):
        page.window.close()
    
    page.add(
        ft.WindowDragArea(content=ft.Container(
                content=ft.Column(
                    controls=[
                        ft.ElevatedButton('Open dialog', on_click=open_dialog),
                        ft.ElevatedButton('Close app', on_click=close_app),
                        ],
                    alignment=ft.MainAxisAlignment.CENTER,
                    spacing=10,
                    ),
                bgcolor=ft.colors.SURFACE_CONTAINER_HIGHEST,
                border_radius=30,
                alignment=ft.alignment.center,
            ),
            expand=True
        )

    )


ft.app(target=main)

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • This change requires a documentation update

Checklist:

  • I signed the CLA.

  • My code follows the style guidelines of this project

  • I have performed a self-review of my own code

  • My changes generate no new warnings

  • I have made corresponding changes to the documentation (if applicable)

Screenshots (if applicable):

Additional details

@ndonkoHenri
Copy link
Contributor

I guess we can add this prop to showDialog in CupertinoAlertDialog, DatePicker and TimePicker too?

@FeodorFitsner FeodorFitsner merged commit 1d09aef into flet-dev:main Nov 4, 2024
2 checks passed
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.

page.window.frameless = True After that, the window does not have rounded corners
3 participants