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

Added AlertDialog.inset_padding property #1899

Merged
merged 2 commits into from
Oct 5, 2023
Merged

Conversation

all-mute
Copy link
Contributor

@all-mute all-mute commented Oct 2, 2023

Added AlertDialog.inset_paddin property to manage padding of Alert Dialog. On mobile phones with small width of screen, Dialog looks very thin. All pytests passed.

Usage example:
import flet as ft

def main(page: ft.Page):
page.title = "AlertDialog examples"

dlg = ft.AlertDialog(
    title=ft.Text("Hello, you!"), on_dismiss=lambda e: print("Dialog dismissed!"), inset_padding=ft.padding.symmetric(vertical=0, horizontal=0)
)

def close_dlg(e):
    dlg_modal.open = False
    page.update()

dlg_modal = ft.AlertDialog(
    modal=True,
    title=ft.Text("Please confirm"),
    content=ft.Text("Do you really want to delete all those files?"),
    actions=[
        ft.TextButton("Yes", on_click=close_dlg),
        ft.TextButton("No", on_click=close_dlg),
    ],
    actions_alignment=ft.MainAxisAlignment.END,
    on_dismiss=lambda e: print("Modal dialog dismissed!"),
)

def open_dlg(e):
    page.dialog = dlg
    dlg.open = True
    page.update()

def open_dlg_modal(e):
    page.dialog = dlg_modal
    dlg_modal.open = True
    page.update()

page.add(
    ft.ElevatedButton("Open dialog", on_click=open_dlg),
    ft.ElevatedButton("Open modal dialog", on_click=open_dlg_modal),
)

ft.app(target=main)

@CLAassistant
Copy link

CLAassistant commented Oct 2, 2023

CLA assistant check
All committers have signed the CLA.

@all-mute
Copy link
Contributor Author

all-mute commented Oct 2, 2023

idk what happend here. I have never pull requested before, sorry if i missed something obvious)

consol log from appveyor:
Build started git clone -q --branch=main https://github.com/all-mute/flet_ad_inset.git /home/appveyor/projects/flet-ad-inset git checkout -qf e8874044798b3a01ee5d898[2](https://ci.appveyor.com/project/all-mute/flet-ad-inset/build/job/vgp9s9m98fqtmqc2#L2)[3](https://ci.appveyor.com/project/all-mute/flet-ad-inset/build/job/vgp9s9m98fqtmqc2#L3)5f99073e3dfb5[4](https://ci.appveyor.com/project/all-mute/flet-ad-inset/build/job/vgp9s9m98fqtmqc2#L4)3 Configuring 'stack' Enabling Python 3.10.12 Running "install" scripts if ($env:APPVEYOR_REPO_TAG_NAME) { $v = $env:APPVEYOR_REPO_TAG_NAME.replace("v", "") } else { $cv = [version](git describe --abbrev=0).substring(1) $v = "$($cv.major).$($cv.minor+1).0+$($env:APPVEYOR_BUILD_NUMBER)" } Update-AppveyorBuild -Version $v fatal: No names found, cannot describe anything. InvalidOperation: Line | 4 | $cv = [version](git describe --abbrev=0).substring(1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | You cannot call a method on a null-valued expression. Command exited with code 12[8](https://ci.appveyor.com/project/all-mute/flet-ad-inset/build/job/vgp9s9m98fqtmqc2#L8) Build failed

@FeodorFitsner
Copy link
Contributor

Thanks for your PR!

See the error here: https://ci.appveyor.com/project/flet-dev/flet/builds/48173018/job/jxeql1n2x1h46xq1#L224
It's because AlertDialog.insetPadding expects non-nullable EdgeInsets while parseEdgeInsets() returns nullable EdgeInsets?.

Solution would be providing default value if parse function returns null:

insetPadding: parseEdgeInsets(widget.control, "insetPadding") ?? EdgeInsets.symmetric(horizontal: 40.0, vertical: 24.0),

Please fix.

@FeodorFitsner FeodorFitsner merged commit 4bfdb62 into flet-dev:main Oct 5, 2023
@ndonkoHenri
Copy link
Contributor

Dont forget to update the online docs too.

zrr1999 pushed a commit to zrr1999/flet that referenced this pull request Jul 17, 2024
* insetPadding property of AlertDialog

* fixed error with nullable padding
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.

4 participants