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

CupertinoActionSheet and CupertinoActionSheetAction controls #2763

Merged
merged 7 commits into from
Mar 1, 2024

Conversation

ndonkoHenri
Copy link
Contributor

@ndonkoHenri ndonkoHenri commented Feb 27, 2024

Test Code:

import flet as ft


def main(page):
    page.window_always_on_top = True
    page.theme_mode = ft.ThemeMode.LIGHT
    page.horizontal_alignment = ft.CrossAxisAlignment.CENTER
    page.vertical_alignment = ft.MainAxisAlignment.CENTER

    bs = ft.CupertinoActionSheet(
        title=ft.Text("Title"),
        message=ft.Text("Message"),
        cancel=ft.CupertinoActionSheetAction(
            content=ft.Text("Cancel"),
            on_click=lambda e: page.close_bottom_sheet(),
        ),
        actions=[
            ft.CupertinoActionSheetAction(
                content=ft.Text("Default Action"),
                on_click=lambda e: print("Default clicked"),
                default=True,
            ),
            ft.CupertinoActionSheetAction(
                content=ft.Text("Normal Action"),
                on_click=lambda e: print("Normal Action clicked"),
            ),
            ft.CupertinoActionSheetAction(
                content=ft.Text("Destructive Action"),
                on_click=lambda e: print("Destructive Action clicked"),
                destructive=True,
            ),
        ],
        on_dismiss=lambda _: print("Dismissed"),
    )

    page.add(
        ft.OutlinedButton(
            "Open Bottom Sheet containing CupertinoActionSheet",
            on_click=lambda e: page.show_bottom_sheet(bs),
        )
    )


ft.app(main)

@ndonkoHenri ndonkoHenri mentioned this pull request Feb 27, 2024
6 tasks
@FeodorFitsner
Copy link
Contributor

So, you put Action Sheet inside of BottomSheet to make it work. Looking at Flutter example here: https://api.flutter.dev/flutter/cupertino/CupertinoActionSheet-class.html I see there is showCupertinoModalPopup() method to open it up, and it doesn't have background as with bottom sheet.

I think we need to implement there similar behavior as dialog/bottom-sheet?

@ndonkoHenri ndonkoHenri changed the title CupertinoActionSheet and CupertinoActionSheetButton controls CupertinoActionSheet and CupertinoActionSheetAction controls Feb 29, 2024
@ndonkoHenri
Copy link
Contributor Author

ndonkoHenri commented Feb 29, 2024

So, you put Action Sheet inside of BottomSheet to make it work.

I will not formulate it like this 🤔
That ActionSheet is a widget that can actually exist on its own. The bottom sheet I used is just for example purposes :)

I see there is showCupertinoModalPopup() method to open it up

Yeah, We could implement this separately.

@FeodorFitsner FeodorFitsner merged commit 366770e into main Mar 1, 2024
2 checks passed
@ndonkoHenri ndonkoHenri deleted the action-sheet branch March 1, 2024 19:14
zrr1999 pushed a commit to zrr1999/flet that referenced this pull request Jul 17, 2024
…t-dev#2763)

* add CupertinoActionSheetButton

* add CupertinoActionSheet

* rename CupertinoActionSheetButton to CupertinoActionSheetAction

* Converted to `StatelessWidget`s

* Make CupertinoActionSheet behave like BottomSheet

---------

Co-authored-by: Feodor Fitsner <[email protected]>
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