diff --git a/client/lib/controls/page.dart b/client/lib/controls/page.dart index 8912d17b0..c5c543fd2 100644 --- a/client/lib/controls/page.dart +++ b/client/lib/controls/page.dart @@ -113,11 +113,19 @@ class PageControl extends StatelessWidget { // offstage List offstageWidgets = offstageView != null ? offstageView.children - .where((c) => c.isVisible) + .where((c) => + c.isVisible && c.type != ControlType.floatingActionButton) .map((c) => createControl(offstage, c.id, disabled)) .toList() : []; + List fab = offstageView != null + ? offstageView.children + .where((c) => + c.isVisible && c.type == ControlType.floatingActionButton) + .toList() + : []; + var column = Column( mainAxisAlignment: mainAlignment, crossAxisAlignment: crossAlignment, @@ -147,6 +155,9 @@ class PageControl extends StatelessWidget { ...offstageWidgets, const ScreenSize() ]), + floatingActionButton: fab.isNotEmpty + ? createControl(offstage, fab.first.id, disabled) + : null, ), ); }); diff --git a/sdk/python/flet/page.py b/sdk/python/flet/page.py index ae63947cd..7f736cd09 100644 --- a/sdk/python/flet/page.py +++ b/sdk/python/flet/page.py @@ -20,6 +20,7 @@ ) from flet.control_event import ControlEvent from flet.embed_json_encoder import EmbedJsonEncoder +from flet.floating_action_button import FloatingActionButton from flet.protocol import Command from flet.snack_bar import SnackBar from flet.theme import Theme @@ -342,6 +343,16 @@ def splash(self): def splash(self, value: Optional[Control]): self.__offstage.splash = value + # floating_action_button + @property + def floating_action_button(self): + return self.__offstage.floating_action_button + + @floating_action_button.setter + @beartype + def floating_action_button(self, value: Optional[FloatingActionButton]): + self.__offstage.floating_action_button = value + # banner @property def banner(self): @@ -492,6 +503,7 @@ def __init__( ) self.__clipboard = Clipboard() + self.__fab = None self.__banner = None self.__snack_bar = None self.__dialog = None @@ -504,6 +516,8 @@ def _get_children(self): children = [] if self.__clipboard: children.append(self.__clipboard) + if self.__fab: + children.append(self.__fab) if self.__banner: children.append(self.__banner) if self.__snack_bar: @@ -529,6 +543,16 @@ def splash(self): def splash(self, value: Optional[Control]): self.__splash = value + # floating_action_button + @property + def floating_action_button(self): + return self.__fab + + @floating_action_button.setter + @beartype + def floating_action_button(self, value: Optional[FloatingActionButton]): + self.__fab = value + # banner @property def banner(self): diff --git a/sdk/python/playground/buttons.py b/sdk/python/playground/buttons.py index db422cbfb..d7be7c30b 100644 --- a/sdk/python/playground/buttons.py +++ b/sdk/python/playground/buttons.py @@ -24,6 +24,7 @@ def main(page: Page): page.title = "Buttons Example" page.theme_mode = "light" page.padding = 50 + page.floating_action_button = FloatingActionButton(icon=icons.ADD) page.add( Column( @@ -113,6 +114,9 @@ def main(page: Page): bgcolor="blue", tooltip="Beep... Beep... Beep...", ), + IconButton( + icon=icons.SEND_ROUNDED, icon_color="white", bgcolor="green" + ), ] ), ],