Skip to content

Commit

Permalink
FAB
Browse files Browse the repository at this point in the history
  • Loading branch information
FeodorFitsner committed May 6, 2022
1 parent 218f5ca commit 5cb537a
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 1 deletion.
13 changes: 12 additions & 1 deletion client/lib/controls/page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,19 @@ class PageControl extends StatelessWidget {
// offstage
List<Widget> 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<Control> fab = offstageView != null
? offstageView.children
.where((c) =>
c.isVisible && c.type == ControlType.floatingActionButton)
.toList()
: [];

var column = Column(
mainAxisAlignment: mainAlignment,
crossAxisAlignment: crossAlignment,
Expand Down Expand Up @@ -147,6 +155,9 @@ class PageControl extends StatelessWidget {
...offstageWidgets,
const ScreenSize()
]),
floatingActionButton: fab.isNotEmpty
? createControl(offstage, fab.first.id, disabled)
: null,
),
);
});
Expand Down
24 changes: 24 additions & 0 deletions sdk/python/flet/page.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -492,6 +503,7 @@ def __init__(
)

self.__clipboard = Clipboard()
self.__fab = None
self.__banner = None
self.__snack_bar = None
self.__dialog = None
Expand All @@ -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:
Expand All @@ -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):
Expand Down
4 changes: 4 additions & 0 deletions sdk/python/playground/buttons.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -113,6 +114,9 @@ def main(page: Page):
bgcolor="blue",
tooltip="Beep... Beep... Beep...",
),
IconButton(
icon=icons.SEND_ROUNDED, icon_color="white", bgcolor="green"
),
]
),
],
Expand Down

0 comments on commit 5cb537a

Please sign in to comment.