Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions client/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ packages:
path: "../packages/flet"
relative: true
source: path
version: "0.83.0"
version: "0.83.1"
flet_ads:
dependency: "direct main"
description:
Expand Down Expand Up @@ -911,10 +911,10 @@ packages:
dependency: transitive
description:
name: matcher
sha256: "12956d0ad8390bbcc63ca2e1469c0619946ccb52809807067a7020d57e647aa6"
sha256: dc0b7dc7651697ea4ff3e69ef44b0407ea32c487a39fff6a4004fa585e901861
url: "https://pub.dev"
source: hosted
version: "0.12.18"
version: "0.12.19"
material_color_utilities:
dependency: transitive
description:
Expand Down Expand Up @@ -1628,10 +1628,10 @@ packages:
dependency: transitive
description:
name: test_api
sha256: "93167629bfc610f71560ab9312acdda4959de4df6fac7492c89ff0d3886f6636"
sha256: "8161c84903fd860b26bfdefb7963b3f0b68fee7adea0f59ef805ecca346f0c7a"
url: "https://pub.dev"
source: hosted
version: "0.7.9"
version: "0.7.10"
torch_light:
dependency: transitive
description:
Expand Down
4 changes: 4 additions & 0 deletions packages/flet/lib/src/controls/navigation_rail.dart
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,11 @@ class _NavigationRailControlState extends State<NavigationRailControl>
backgroundColor: widget.control.getColor("bgcolor", context),
indicatorColor: widget.control.getColor("indicator_color", context),
leading: widget.control.buildWidget("leading"),
leadingAtTop: widget.control.getBool("pin_leading_to_top", true)!,
trailing: widget.control.buildWidget("trailing"),
trailingAtBottom:
widget.control.getBool("pin_trailing_to_bottom", false)!,
scrollable: widget.control.getBool("scrollable", false)!,
selectedIndex: _selectedIndex,
useIndicator: widget.control.getBool("use_indicator"),
onDestinationSelected: _destinationChanged,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
import pytest
import pytest_asyncio

import flet as ft
import flet.testing as ftt


@pytest.mark.asyncio(loop_scope="module")
# Create a new flet_app instance for each test method
@pytest_asyncio.fixture(scope="function", autouse=True)
def flet_app(flet_app_function):
return flet_app_function


@pytest.mark.asyncio(loop_scope="function")
async def test_visible(flet_app: ftt.FletTestApp, request):
flet_app.page.theme_mode = ft.ThemeMode.LIGHT
await flet_app.assert_control_screenshot(
Expand Down Expand Up @@ -34,7 +41,7 @@ async def test_visible(flet_app: ftt.FletTestApp, request):
)


@pytest.mark.asyncio(loop_scope="module")
@pytest.mark.asyncio(loop_scope="function")
async def test_parent_not_visible_child_visible(flet_app: ftt.FletTestApp, request):
flet_app.page.theme_mode = ft.ThemeMode.LIGHT
await flet_app.assert_control_screenshot(
Expand Down Expand Up @@ -67,7 +74,7 @@ async def test_parent_not_visible_child_visible(flet_app: ftt.FletTestApp, reque
)


@pytest.mark.asyncio(loop_scope="module")
@pytest.mark.asyncio(loop_scope="function")
async def test_disabled_propagates_to_children(flet_app: ftt.FletTestApp, request):
flet_app.page.theme_mode = ft.ThemeMode.LIGHT
await flet_app.assert_control_screenshot(
Expand Down Expand Up @@ -97,7 +104,7 @@ async def test_disabled_propagates_to_children(flet_app: ftt.FletTestApp, reques
)


@pytest.mark.asyncio(loop_scope="module")
@pytest.mark.asyncio(loop_scope="function")
async def test_badge(flet_app: ftt.FletTestApp, request):
flet_app.page.theme_mode = ft.ThemeMode.LIGHT
await flet_app.assert_control_screenshot(
Expand Down Expand Up @@ -133,7 +140,7 @@ async def test_badge(flet_app: ftt.FletTestApp, request):
)


@pytest.mark.asyncio(loop_scope="module")
@pytest.mark.asyncio(loop_scope="function")
async def test_opacity(flet_app: ftt.FletTestApp, request):
flet_app.page.theme_mode = ft.ThemeMode.LIGHT
await flet_app.assert_control_screenshot(
Expand Down Expand Up @@ -173,7 +180,7 @@ async def test_opacity(flet_app: ftt.FletTestApp, request):
)


@pytest.mark.asyncio(loop_scope="module")
@pytest.mark.asyncio(loop_scope="function")
async def test_rtl(flet_app: ftt.FletTestApp, request):
flet_app.page.theme_mode = ft.ThemeMode.LIGHT
await flet_app.assert_control_screenshot(
Expand Down Expand Up @@ -225,7 +232,7 @@ async def test_rtl(flet_app: ftt.FletTestApp, request):
)


@pytest.mark.asyncio(loop_scope="module")
@pytest.mark.asyncio(loop_scope="function")
async def test_col(flet_app: ftt.FletTestApp, request):
flet_app.page.theme_mode = ft.ThemeMode.LIGHT
await flet_app.assert_control_screenshot(
Expand Down Expand Up @@ -275,3 +282,97 @@ async def test_col(flet_app: ftt.FletTestApp, request):
),
),
)


@pytest.mark.asyncio(loop_scope="function")
async def test_tooltip_string_is_findable(flet_app: ftt.FletTestApp):
flet_app.page.add(
ft.IconButton(
icon=ft.Icons.INFO_OUTLINED,
tooltip="Info tooltip",
)
)
await flet_app.tester.pump_and_settle()

finder = await flet_app.tester.find_by_tooltip("Info tooltip")
assert finder.count == 1


@pytest.mark.asyncio(loop_scope="function")
async def test_tooltip_shows_on_hover(flet_app: ftt.FletTestApp, request):
flet_app.page.theme_mode = ft.ThemeMode.LIGHT
flet_app.page.enable_screenshots = True
flet_app.resize_page(420, 300)
flet_app.page.update()

flet_app.page.add(
ft.Container(
padding=100,
content=ft.IconButton(
key="info_btn",
icon=ft.Icons.INFO_OUTLINED,
tooltip=ft.Tooltip(message="Tooltip message"),
),
)
)
flet_app.page.update()
await flet_app.tester.pump_and_settle()

button = await flet_app.tester.find_by_key("info_btn")
await flet_app.tester.mouse_hover(button)
await flet_app.tester.pump_and_settle()

flet_app.assert_screenshot(
request.node.name,
await flet_app.page.take_screenshot(
pixel_ratio=flet_app.screenshots_pixel_ratio
),
)


@pytest.mark.asyncio(loop_scope="function")
async def test_tooltip_custom_properties_on_hover(flet_app: ftt.FletTestApp, request):
flet_app.page.theme_mode = ft.ThemeMode.LIGHT
flet_app.page.enable_screenshots = True
flet_app.resize_page(460, 320)
flet_app.page.update()

flet_app.page.add(
ft.Container(
padding=100,
content=ft.IconButton(
key="info_btn_custom",
icon=ft.Icons.HELP_OUTLINE,
tooltip=ft.Tooltip(
message="Customized tooltip for Control.tooltip",
wait_duration=0,
show_duration=5000,
prefer_below=True,
vertical_offset=20,
bgcolor=ft.Colors.BLUE_GREY_900,
text_style=ft.TextStyle(
color=ft.Colors.WHITE, weight=ft.FontWeight.W_600, size=14
),
padding=ft.Padding.symmetric(horizontal=14, vertical=10),
margin=ft.Margin.only(top=8, left=8, right=8),
text_align=ft.TextAlign.CENTER,
decoration=ft.BoxDecoration(
border_radius=ft.BorderRadius.all(10),
),
),
),
)
)
flet_app.page.update()
await flet_app.tester.pump_and_settle()

button = await flet_app.tester.find_by_key("info_btn_custom")
await flet_app.tester.mouse_hover(button)
await flet_app.tester.pump_and_settle()

flet_app.assert_screenshot(
request.node.name,
await flet_app.page.take_screenshot(
pixel_ratio=flet_app.screenshots_pixel_ratio
),
)

This file was deleted.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,53 @@ async def test_no_selected_icon(flet_app: ftt.FletTestApp, request):
),
),
)


@pytest.mark.asyncio(loop_scope="function")
async def test_scrollable_with_pinned_leading_and_trailing(
flet_app: ftt.FletTestApp, request
):
flet_app.page.theme_mode = ft.ThemeMode.LIGHT

await flet_app.assert_control_screenshot(
request.node.name,
ft.NavigationRail(
height=280,
width=140,
selected_index=0,
label_type=ft.NavigationRailLabelType.ALL,
min_width=100,
min_extended_width=180,
scrollable=True,
pin_leading_to_top=True,
pin_trailing_to_bottom=True,
leading=ft.IconButton(icon=ft.Icons.MENU, tooltip="Menu"),
trailing=ft.IconButton(icon=ft.Icons.SETTINGS, tooltip="Settings"),
destinations=[
ft.NavigationRailDestination(
icon=ft.Icons.LOOKS_ONE,
label="One",
),
ft.NavigationRailDestination(
icon=ft.Icons.LOOKS_TWO,
label="Two",
),
ft.NavigationRailDestination(
icon=ft.Icons.LOOKS_3,
label="Three",
),
ft.NavigationRailDestination(
icon=ft.Icons.LOOKS_4,
label="Four",
),
ft.NavigationRailDestination(
icon=ft.Icons.LOOKS_5,
label="Five",
),
ft.NavigationRailDestination(
icon=ft.Icons.LOOKS_6,
label="Six",
),
],
),
)
Loading
Loading