Skip to content

Commit 3dee2c5

Browse files
committed
Add DatePicker theme integration test and doc updates
Introduces an integration test for DatePicker theme customization with a golden screenshot for macOS. Updates docstrings for Theme class to clarify DataTableTheme and DatePickerTheme usage. Also refines ListTile hover_color docstring to specify when it takes effect.
1 parent cbdae3a commit 3dee2c5

4 files changed

Lines changed: 51 additions & 1 deletion

File tree

55.6 KB
Loading
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import datetime
2+
3+
import pytest
4+
import pytest_asyncio
5+
6+
import flet as ft
7+
import flet.testing as ftt
8+
9+
10+
# Create a new flet_app instance for each test method
11+
@pytest_asyncio.fixture(scope="function", autouse=True)
12+
def flet_app(flet_app_function):
13+
return flet_app_function
14+
15+
16+
@pytest.mark.asyncio(loop_scope="function")
17+
async def test_date_picker_theme(flet_app: ftt.FletTestApp, request):
18+
flet_app.page.theme = ft.Theme(
19+
date_picker_theme=ft.DatePickerTheme(
20+
bgcolor=ft.Colors.GREEN_200,
21+
)
22+
)
23+
24+
dp = ft.DatePicker(
25+
current_date=datetime.datetime(year=2025, month=8, day=15),
26+
first_date=datetime.datetime(year=2000, month=10, day=1),
27+
last_date=datetime.datetime(year=2025, month=10, day=1),
28+
)
29+
flet_app.page.enable_screenshots = True
30+
flet_app.page.window.width = 400
31+
flet_app.page.window.height = 600
32+
flet_app.page.show_dialog(dp)
33+
flet_app.page.update()
34+
await flet_app.tester.pump_and_settle()
35+
36+
flet_app.assert_screenshot(
37+
"theme1",
38+
await flet_app.page.take_screenshot(
39+
pixel_ratio=flet_app.screenshots_pixel_ratio
40+
),
41+
)

sdk/python/packages/flet/src/flet/controls/material/list_tile.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,8 @@ class ListTile(LayoutControl, AdaptiveControl):
115115

116116
hover_color: Optional[ColorValue] = None
117117
"""
118-
The tile's color when hovered. Only shows if `toggle_inputs` is True.
118+
The tile's color when hovered. Only takes effect if `toggle_inputs` is True or if
119+
`on_click` is provided.
119120
"""
120121

121122
selected: bool = False

sdk/python/packages/flet/src/flet/controls/theme.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3348,7 +3348,15 @@ class Theme:
33483348
"""
33493349

33503350
data_table_theme: Optional[DataTableTheme] = None
3351+
"""
3352+
Customizes the appearance of [`DataTable`][flet.DataTable] across the app.
3353+
"""
3354+
33513355
date_picker_theme: Optional[DatePickerTheme] = None
3356+
"""
3357+
Customizes the appearance of [`DatePicker`][flet.DatePicker] across the app.
3358+
"""
3359+
33523360
dialog_theme: Optional[DialogTheme] = None
33533361
"""
33543362
Customizes the appearance of [`AlertDialog`][flet.AlertDialog] across the app.

0 commit comments

Comments
 (0)