flet
flet copied to clipboard
`DropdownMenu` Control
Closes https://github.com/flet-dev/flet/issues/1088
Test Code
import flet as ft
def main(page: ft.Page):
def handle_menu_change(e):
t.value = f"Selected color: {menu.value}"
page.update()
t = ft.Text("Dropdown Menu Example")
menu = ft.DropdownMenu(
label="Color",
expand=True,
expand_loose=True,
hint_text="Hint text",
helper_text="Pick a color",
# width=300,
enable_filter=True,
enable_search=True,
request_focus_on_tap=False,
hint_fade_duration=ft.Duration(seconds=500),
capitalization=ft.TextCapitalization.WORDS,
prefix=ft.Icon(ft.icons.COLOR_LENS),
prefix_icon=ft.cupertino_icons.SEARCH,
suffix=ft.Icon(ft.icons.PIN_END),
icon_color=ft.colors.RED,
active_indicator_border_side=ft.BorderSide(color=ft.colors.RED, width=2),
on_change=handle_menu_change,
options=[
ft.DropdownMenuOption(
key="red",
content=ft.Text("Red"),
prefix=ft.Icon(ft.icons.COLOR_LENS, color=ft.colors.RED),
),
ft.DropdownMenuOption(
key="green",
content=ft.Text("Green"),
prefix=ft.Icon(ft.icons.COLOR_LENS, color=ft.colors.GREEN),
),
ft.DropdownMenuOption(
key="blue",
content=ft.Text("Blue"),
prefix=ft.Icon(ft.icons.COLOR_LENS, color=ft.colors.BLUE),
),
],
)
page.add(t, menu)
ft.app(target=main)
Summary by Sourcery
This pull request introduces a new DropdownMenu
control with extensive customization options and enhances the FormFieldControl
to support additional properties for better form field customization. It also includes a bug fix for a typo in the AnimationCurve
enum.
-
New Features:
- Introduced a new
DropdownMenu
control with various customization options including prefix, suffix, helper, and error controls, as well as icon colors and text styles.
- Introduced a new
-
Bug Fixes:
- Fixed a typo in
AnimationCurve
enum fromFAST_OUT_SLOWIN
toFAST_OUT_SLOW_IN
.
- Fixed a typo in
-
Enhancements:
- Enhanced
FormFieldControl
to support additional properties such asicon_color
,prefix_icon_color
,suffix_icon_color
,focus_color
,align_label_with_hint
,floating_label_text_style
,active_indicator_border_side
,hint_fade_duration
,error_max_lines
,helper_max_lines
, andhint_max_lines
. - Updated
InputDecoration
andInputDecorationTheme
to include new properties for better customization of form fields. - Refactored
Dropdown
,TextField
, andDropdownMenu
controls to utilize the new properties and enhancements inFormFieldControl
.
- Enhanced