flet icon indicating copy to clipboard operation
flet copied to clipboard

`DropdownMenu` Control

Open ndonkoHenri opened this issue 7 months ago • 3 comments

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.
  • Bug Fixes:
    • Fixed a typo in AnimationCurve enum from FAST_OUT_SLOWIN to FAST_OUT_SLOW_IN.
  • Enhancements:
    • Enhanced FormFieldControl to support additional properties such as icon_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, and hint_max_lines.
    • Updated InputDecoration and InputDecorationTheme to include new properties for better customization of form fields.
    • Refactored Dropdown, TextField, and DropdownMenu controls to utilize the new properties and enhancements in FormFieldControl.

ndonkoHenri avatar Jul 13 '24 06:07 ndonkoHenri