```python
import flet as ft
def main(page: ft.Page):
page.horizontal_alignment = ft.CrossAxisAlignment.CENTER
page.vertical_alignment = ft.MainAxisAlignment.CENTER
page.navigation_bar = ft.NavigationBar(
destinations=[
ft.NavigationBarDestination("one", icon=ft.icons.ADD, tooltip="one"),
ft.NavigationBarDestination("two", icon=ft.icons.TWO_K, tooltip="two"),
],
)
page.add(
ft.SegmentedButton(
selected={"0"},
selected_icon=ft.Icon(ft.icons.CHECK),
segments=[
ft.Segment(
value="0",
icon=ft.Icon(ft.icons.LOOKS_ONE),
label=ft.Text("I am Text", size=16),
tooltip="tooltip from text",
),
ft.Segment(
value="2",
icon=ft.Icon(ft.icons.LOOKS_3),
label=ft.Text(
"I am Class",
size=16,
tooltip=ft.Tooltip(
message="tooltip from class",
padding=3,
border_radius=10,
gradient=ft.LinearGradient(
colors=[ft.colors.RED, ft.colors.BLUE]
),
),
),
),
],
)
)
ft.app(main)
```
Summary by Sourcery
Fix tooltip handling in Segment and NavigationBarDestination to accept only string values and update plugin registrations for platform-specific screen_retriever plugins.
Bug Fixes:
Ensure Segment and NavigationBarDestination components only accept string values for tooltips, preventing potential runtime errors.
Enhancements:
Refactor tooltip handling in various components to decode JSON strings, improving consistency and reliability.
Chores:
Update plugin registration for screen_retriever to platform-specific plugins across Linux, Windows, and macOS, ensuring correct plugin usage.
Fixes #4324
Test Code
```python import flet as ft def main(page: ft.Page): page.horizontal_alignment = ft.CrossAxisAlignment.CENTER page.vertical_alignment = ft.MainAxisAlignment.CENTER page.navigation_bar = ft.NavigationBar( destinations=[ ft.NavigationBarDestination("one", icon=ft.icons.ADD, tooltip="one"), ft.NavigationBarDestination("two", icon=ft.icons.TWO_K, tooltip="two"), ], ) page.add( ft.SegmentedButton( selected={"0"}, selected_icon=ft.Icon(ft.icons.CHECK), segments=[ ft.Segment( value="0", icon=ft.Icon(ft.icons.LOOKS_ONE), label=ft.Text("I am Text", size=16), tooltip="tooltip from text", ), ft.Segment( value="2", icon=ft.Icon(ft.icons.LOOKS_3), label=ft.Text( "I am Class", size=16, tooltip=ft.Tooltip( message="tooltip from class", padding=3, border_radius=10, gradient=ft.LinearGradient( colors=[ft.colors.RED, ft.colors.BLUE] ), ), ), ), ], ) ) ft.app(main) ```
Summary by Sourcery
Fix tooltip handling in
Segment
andNavigationBarDestination
to accept only string values and update plugin registrations for platform-specificscreen_retriever
plugins.Bug Fixes:
Segment
andNavigationBarDestination
components only accept string values for tooltips, preventing potential runtime errors.Enhancements:
Chores:
screen_retriever
to platform-specific plugins across Linux, Windows, and macOS, ensuring correct plugin usage.