|
| 1 | +import pytest |
| 2 | + |
| 3 | +import flet as ft |
| 4 | +import flet.testing as ftt |
| 5 | + |
| 6 | + |
| 7 | +@pytest.mark.asyncio(loop_scope="module") |
| 8 | +async def test_navigation_rail(flet_app: ftt.FletTestApp, request): |
| 9 | + flet_app.page.theme_mode = ft.ThemeMode.LIGHT |
| 10 | + await flet_app.assert_control_screenshot( |
| 11 | + request.node.name, |
| 12 | + ft.NavigationRail( |
| 13 | + height=400, |
| 14 | + selected_index=0, |
| 15 | + label_type=ft.NavigationRailLabelType.ALL, |
| 16 | + min_width=100, |
| 17 | + min_extended_width=400, |
| 18 | + group_alignment=-0.9, |
| 19 | + on_change=lambda e: print( |
| 20 | + "Selected destination:", e.control.selected_index |
| 21 | + ), |
| 22 | + leading=ft.FloatingActionButton( |
| 23 | + icon=ft.Icons.CREATE, |
| 24 | + content="Add", |
| 25 | + on_click=lambda e: print("FAB clicked!"), |
| 26 | + ), |
| 27 | + destinations=[ |
| 28 | + ft.NavigationRailDestination( |
| 29 | + icon=ft.Icons.FAVORITE_BORDER, |
| 30 | + selected_icon=ft.Icons.FAVORITE, |
| 31 | + label="First", |
| 32 | + ), |
| 33 | + ft.NavigationRailDestination( |
| 34 | + icon=ft.Icon(ft.Icons.BOOKMARK_BORDER), |
| 35 | + selected_icon=ft.Icon(ft.Icons.BOOKMARK), |
| 36 | + label="Second", |
| 37 | + ), |
| 38 | + ft.NavigationRailDestination( |
| 39 | + icon=ft.Icons.SETTINGS_OUTLINED, |
| 40 | + selected_icon=ft.Icon(ft.Icons.SETTINGS), |
| 41 | + label=ft.Text("Settings"), |
| 42 | + ), |
| 43 | + ], |
| 44 | + ), |
| 45 | + ) |
0 commit comments