@@ -98,24 +98,114 @@ async def test_properties2(flet_app: ftt.FletTestApp, request):
9898
9999 lt = ft .ListTile (
100100 key = "lt" ,
101- title = "List Tile" ,
101+ title = "List Tile without three line" ,
102+ subtitle = "Long Long Long Long Long Long Long Long Long Long Long "
103+ "Long Long Long Long Long Long Long Long Long Long Long"
104+ "Long Subtitle with is_three_line = False" ,
105+ # is_three_line=True,
106+ leading = ft .Icon (ft .Icons .STAR ),
107+ trailing = ft .Icon (ft .Icons .ARROW_FORWARD ),
108+ bgcolor = ft .Colors .LIGHT_BLUE_ACCENT_100 ,
109+ splash_color = ft .Colors .GREEN_200 , # is not shown on screenshot
110+ hover_color = ft .Colors .YELLOW_200 ,
111+ )
112+
113+ lt1 = ft .ListTile (
114+ title = "List Tile with three line" ,
115+ subtitle = "Long Long Long Long Long Long Long Long Long Long Long "
116+ "Long Long Long Long Long Long Long Long Long Long Long"
117+ "Long Subtitle with is_three_line = True" ,
118+ is_three_line = True , # not sure if this behaviour is correct or not.
119+ # Tested it in flutter, it also shows more than 3 lines
120+ leading = ft .Icon (ft .Icons .STAR ),
121+ trailing = ft .Icon (ft .Icons .ARROW_FORWARD ),
122+ bgcolor = ft .Colors .LIGHT_BLUE_ACCENT_100 ,
123+ splash_color = ft .Colors .GREEN_200 , # is not shown on screenshot
124+ hover_color = ft .Colors .YELLOW_200 ,
125+ )
126+
127+ lt2 = ft .ListTile (
128+ title = "List Tile with Compact visual density" ,
129+ subtitle = "Long Long Long Long Long Long Long Long Long Long Long "
130+ "Long Long Long Long Long Long Long Long Long Long Long"
131+ "Long Subtitle with is_three_line = False" ,
132+ leading = ft .Icon (ft .Icons .STAR ),
133+ trailing = ft .Icon (ft .Icons .ARROW_FORWARD ),
134+ bgcolor = ft .Colors .LIGHT_BLUE_ACCENT_100 ,
135+ visual_density = ft .VisualDensity .COMPACT ,
136+ )
137+
138+ lt3 = ft .ListTile (
139+ title = "List Tile with horizontal spacing" ,
102140 subtitle = "Subtitle" ,
141+ leading = ft .Icon (ft .Icons .STAR ),
142+ trailing = ft .Icon (ft .Icons .ARROW_FORWARD ),
143+ bgcolor = ft .Colors .LIGHT_BLUE_ACCENT_100 ,
144+ splash_color = ft .Colors .GREEN_200 , # is not shown on screenshot
145+ hover_color = ft .Colors .YELLOW_200 ,
146+ horizontal_spacing = 50 ,
147+ title_alignment = ft .ListTileTitleAlignment .THREE_LINE , # default value
148+ )
149+
150+ lt4 = ft .ListTile (
151+ title = "List Tile with minimum leading width" ,
152+ subtitle = "Top Title Alignment" ,
103153 is_three_line = True ,
104154 leading = ft .Icon (ft .Icons .STAR ),
105155 trailing = ft .Icon (ft .Icons .ARROW_FORWARD ),
106- content_padding = ft .Padding .all (20 ),
107156 bgcolor = ft .Colors .LIGHT_BLUE_ACCENT_100 ,
108- bgcolor_activated = ft .Colors .GREEN_200 ,
157+ splash_color = ft .Colors .GREEN_200 , # is not shown on screenshot
109158 hover_color = ft .Colors .YELLOW_200 ,
110- selected_color = ft .Colors .PINK_200 ,
111- selected_tile_color = ft .Colors .PURPLE_200 ,
112- selected = False ,
113- toggle_inputs = True ,
114- style = ft .ListTileStyle .DRAWER ,
115- shape = ft .RoundedRectangleBorder (radius = 10 ),
159+ min_leading_width = 100 ,
160+ title_alignment = ft .ListTileTitleAlignment .TOP , # default value
116161 )
117162
118- flet_app .page .add (lt )
163+ lt5 = ft .ListTile (
164+ title = "List Tile with minimum vertical padding" ,
165+ subtitle = "Center Title Alignment" ,
166+ leading = ft .Icon (ft .Icons .STAR ),
167+ trailing = ft .Icon (ft .Icons .ARROW_FORWARD ),
168+ bgcolor = ft .Colors .LIGHT_BLUE_ACCENT_100 ,
169+ splash_color = ft .Colors .GREEN_200 , # is not shown on screenshot
170+ hover_color = ft .Colors .YELLOW_200 ,
171+ min_vertical_padding = 30 ,
172+ title_alignment = ft .ListTileTitleAlignment .CENTER ,
173+ )
174+
175+ lt6 = ft .ListTile (
176+ title = "List Tile with icon color and text color and styles" ,
177+ subtitle = "Bottom Title Alignment" ,
178+ icon_color = ft .Colors .RED ,
179+ text_color = ft .Colors .PURPLE ,
180+ title_text_style = ft .TextStyle (size = 20 , weight = ft .FontWeight .BOLD ),
181+ subtitle_text_style = ft .TextStyle (size = 10 , italic = True ),
182+ leading = ft .Icon (ft .Icons .STAR ),
183+ trailing = ft .Icon (ft .Icons .ARROW_FORWARD ),
184+ bgcolor = ft .Colors .LIGHT_BLUE_ACCENT_100 ,
185+ title_alignment = ft .ListTileTitleAlignment .BOTTOM ,
186+ )
187+
188+ lt7 = ft .ListTile (
189+ title = "List Tile with leading and trailing text style" ,
190+ subtitle = "Title Height Title Alignment" ,
191+ icon_color = ft .Colors .RED ,
192+ leading = ft .Text ("Leading" ),
193+ trailing = ft .Text ("Trailing" ),
194+ bgcolor = ft .Colors .LIGHT_BLUE_ACCENT_100 ,
195+ title_alignment = ft .ListTileTitleAlignment .TITLE_HEIGHT ,
196+ )
197+
198+ lt8 = ft .ListTile (
199+ title = "List Tile with minimum height" ,
200+ subtitle = "Title Height Title Alignment" ,
201+ icon_color = ft .Colors .RED ,
202+ leading = ft .Text ("Leading" ),
203+ trailing = ft .Text ("Trailing" ),
204+ bgcolor = ft .Colors .LIGHT_BLUE_ACCENT_100 ,
205+ min_height = 150 ,
206+ )
207+
208+ flet_app .page .add (lt , lt1 , lt2 , lt3 , lt4 , lt5 , lt6 , lt7 , lt8 )
119209 flet_app .page .update ()
120210 await flet_app .tester .pump_and_settle ()
121211
@@ -127,8 +217,6 @@ async def test_properties2(flet_app: ftt.FletTestApp, request):
127217 )
128218
129219 # test hover
130- flet_app .page .update ()
131- await flet_app .tester .pump_and_settle ()
132220 tile = await flet_app .tester .find_by_key ("lt" )
133221 assert tile .count == 1
134222 await flet_app .tester .mouse_hover (tile )
@@ -140,3 +228,56 @@ async def test_properties2(flet_app: ftt.FletTestApp, request):
140228 pixel_ratio = flet_app .screenshots_pixel_ratio
141229 ),
142230 )
231+
232+
233+ @pytest .mark .asyncio (loop_scope = "function" )
234+ async def test_toggle_inputs (flet_app : ftt .FletTestApp , request ):
235+ flet_app .page .enable_screenshots = True
236+ flet_app .page .window .width = 400
237+ flet_app .page .window .height = 600
238+
239+ lt = ft .ListTile (
240+ key = "lt" ,
241+ title = "ListTileStyle with toggle inputs" ,
242+ subtitle = "List" ,
243+ leading = ft .Icon (ft .Icons .STAR ),
244+ trailing = ft .Checkbox (),
245+ bgcolor = ft .Colors .LIGHT_BLUE_ACCENT_100 ,
246+ style = ft .ListTileStyle .LIST ,
247+ toggle_inputs = True ,
248+ )
249+
250+ flet_app .page .add (lt )
251+ flet_app .page .update ()
252+ await flet_app .tester .pump_and_settle ()
253+
254+ flet_app .assert_screenshot (
255+ "toggle_initial" ,
256+ await flet_app .page .take_screenshot (
257+ pixel_ratio = flet_app .screenshots_pixel_ratio
258+ ),
259+ )
260+
261+ # test click1
262+ tile = await flet_app .tester .find_by_key ("lt" )
263+ assert tile .count == 1
264+ await flet_app .tester .tap (tile )
265+ await flet_app .tester .pump_and_settle ()
266+
267+ flet_app .assert_screenshot (
268+ "toggle_click1" ,
269+ await flet_app .page .take_screenshot (
270+ pixel_ratio = flet_app .screenshots_pixel_ratio
271+ ),
272+ )
273+
274+ # test click2 - issue #5627
275+ # await flet_app.tester.tap(tile)
276+ # await flet_app.tester.pump_and_settle()
277+
278+ # flet_app.assert_screenshot(
279+ # "toggle_click2",
280+ # await flet_app.page.take_screenshot(
281+ # pixel_ratio=flet_app.screenshots_pixel_ratio
282+ # ),
283+ # )
0 commit comments