1use waft_embedder::{Color, lerp_double};
4use waft_foundation::{App, DiagnosticsProperty, DoubleProperty, EnumProperty};
5use waft_painting::{AnyColor, ColorProperty, EdgeInsetsGeometry, ShapeBorderRef, TextStyle};
6use waft_services::MouseCursorRef;
7use waft_widgets::{
8 BuildContext, Builder, InheritedTheme, InheritedWidget, IntoWidget, KeyRef, WidgetRef,
9 WidgetStatePropertyRef,
10};
11
12use crate::list_tile::{ListTileControlAffinity, ListTileStyle, ListTileTitleAlignment};
13use crate::theme::Theme;
14use crate::theme_data::VisualDensity;
15
16#[derive(Clone, Debug, Default)]
41pub struct ListTileThemeData {
42 pub dense: Option<bool>,
44
45 pub shape: Option<ShapeBorderRef>,
47
48 pub style: Option<ListTileStyle>,
50
51 pub selected_color: Option<Color>,
53
54 pub icon_color: Option<AnyColor>,
56
57 pub text_color: Option<AnyColor>,
59
60 pub title_text_style: Option<TextStyle>,
62
63 pub subtitle_text_style: Option<TextStyle>,
65
66 pub leading_and_trailing_text_style: Option<TextStyle>,
68
69 pub content_padding: Option<EdgeInsetsGeometry>,
71
72 pub tile_color: Option<Color>,
74
75 pub selected_tile_color: Option<Color>,
77
78 pub horizontal_title_gap: Option<f64>,
80
81 pub min_vertical_padding: Option<f64>,
83
84 pub min_leading_width: Option<f64>,
86
87 pub min_tile_height: Option<f64>,
89
90 pub enable_feedback: Option<bool>,
92
93 pub mouse_cursor: Option<WidgetStatePropertyRef<Option<MouseCursorRef>>>,
95
96 pub visual_density: Option<VisualDensity>,
98
99 pub title_alignment: Option<ListTileTitleAlignment>,
101
102 pub control_affinity: Option<ListTileControlAffinity>,
106
107 pub is_three_line: Option<bool>,
111}
112
113crate::theme_data_getters::theme_data_getters! {
114 pub trait ListTileThemeDataGetters for ListTileThemeData, fields: list_tile_theme_data {
118 dense: Option<bool>,
119 shape: Option<ShapeBorderRef>,
120 style: Option<ListTileStyle>,
121 selected_color: Option<Color>,
122 icon_color: Option<AnyColor>,
123 text_color: Option<AnyColor>,
124 title_text_style: Option<TextStyle>,
125 subtitle_text_style: Option<TextStyle>,
126 leading_and_trailing_text_style: Option<TextStyle>,
127 content_padding: Option<EdgeInsetsGeometry>,
128 tile_color: Option<Color>,
129 selected_tile_color: Option<Color>,
130 horizontal_title_gap: Option<f64>,
131 min_vertical_padding: Option<f64>,
132 min_leading_width: Option<f64>,
133 min_tile_height: Option<f64>,
134 enable_feedback: Option<bool>,
135 mouse_cursor: Option<WidgetStatePropertyRef<Option<MouseCursorRef>>>,
136 visual_density: Option<VisualDensity>,
137 title_alignment: Option<ListTileTitleAlignment>,
138 control_affinity: Option<ListTileControlAffinity>,
139 is_three_line: Option<bool>,
140 }
141}
142
143macro_rules! list_tile_theme_data_setters {
146 ($owner:ident, $dart:literal, |$this:ident| $data:expr, $($field:ident: $ty:ty => $name:literal),* $(,)?) => {
147 $(
148 #[doc = concat!("Dart `", $dart, "(", $name, ":)`.")]
149 pub fn $field(mut self, $field: impl Into<$ty>) -> $owner {
150 let $this = &mut self;
151 $data.$field = Some($field.into());
152 self
153 }
154 )*
155 };
156}
157
158macro_rules! every_list_tile_theme_data_setter {
160 ($owner:ident, $dart:literal, |$this:ident| $data:expr) => {
161 list_tile_theme_data_setters!(
162 $owner,
163 $dart,
164 |$this| $data,
165 dense: bool => "dense",
166 shape: ShapeBorderRef => "shape",
167 style: ListTileStyle => "style",
168 selected_color: Color => "selectedColor",
169 icon_color: AnyColor => "iconColor",
170 text_color: AnyColor => "textColor",
171 title_text_style: TextStyle => "titleTextStyle",
172 subtitle_text_style: TextStyle => "subtitleTextStyle",
173 leading_and_trailing_text_style: TextStyle => "leadingAndTrailingTextStyle",
174 content_padding: EdgeInsetsGeometry => "contentPadding",
175 tile_color: Color => "tileColor",
176 selected_tile_color: Color => "selectedTileColor",
177 horizontal_title_gap: f64 => "horizontalTitleGap",
178 min_vertical_padding: f64 => "minVerticalPadding",
179 min_leading_width: f64 => "minLeadingWidth",
180 min_tile_height: f64 => "minTileHeight",
181 enable_feedback: bool => "enableFeedback",
182 mouse_cursor: WidgetStatePropertyRef<Option<MouseCursorRef>> => "mouseCursor",
183 visual_density: VisualDensity => "visualDensity",
184 title_alignment: ListTileTitleAlignment => "titleAlignment",
185 control_affinity: ListTileControlAffinity => "controlAffinity",
186 is_three_line: bool => "isThreeLine",
187 );
188 };
189}
190
191impl ListTileThemeData {
192 pub fn new() -> ListTileThemeData {
195 ListTileThemeData::default()
196 }
197
198 every_list_tile_theme_data_setter!(ListTileThemeData, "ListTileThemeData", |this| this);
199
200 pub fn copy_with(&self) -> ListTileThemeData {
206 self.clone()
207 }
208
209 pub fn lerp(
211 a: Option<&ListTileThemeData>,
212 b: Option<&ListTileThemeData>,
213 t: f64,
214 ) -> Option<ListTileThemeData> {
215 match (a, b) {
216 (None, None) => return None,
217 (Some(a), Some(b)) if std::ptr::eq(a, b) => return Some(a.clone()),
218 _ => {}
219 }
220 Some(ListTileThemeData {
221 dense: pick(a, b, t, |theme| theme.dense),
222 shape: ShapeBorderRef::lerp(
223 a.and_then(|a| a.shape.as_ref()),
224 b.and_then(|b| b.shape.as_ref()),
225 t,
226 ),
227 style: pick(a, b, t, |theme| theme.style),
228 selected_color: Color::lerp(
229 a.and_then(|a| a.selected_color),
230 b.and_then(|b| b.selected_color),
231 t,
232 ),
233 icon_color: AnyColor::lerp(
234 a.and_then(|a| a.icon_color.as_ref()),
235 b.and_then(|b| b.icon_color.as_ref()),
236 t,
237 )
238 .map(AnyColor::new),
239 text_color: AnyColor::lerp(
240 a.and_then(|a| a.text_color.as_ref()),
241 b.and_then(|b| b.text_color.as_ref()),
242 t,
243 )
244 .map(AnyColor::new),
245 title_text_style: TextStyle::lerp(
246 a.and_then(|a| a.title_text_style.as_ref()),
247 b.and_then(|b| b.title_text_style.as_ref()),
248 t,
249 ),
250 subtitle_text_style: TextStyle::lerp(
251 a.and_then(|a| a.subtitle_text_style.as_ref()),
252 b.and_then(|b| b.subtitle_text_style.as_ref()),
253 t,
254 ),
255 leading_and_trailing_text_style: TextStyle::lerp(
256 a.and_then(|a| a.leading_and_trailing_text_style.as_ref()),
257 b.and_then(|b| b.leading_and_trailing_text_style.as_ref()),
258 t,
259 ),
260 content_padding: EdgeInsetsGeometry::lerp(
261 a.and_then(|a| a.content_padding),
262 b.and_then(|b| b.content_padding),
263 t,
264 ),
265 tile_color: Color::lerp(
266 a.and_then(|a| a.tile_color),
267 b.and_then(|b| b.tile_color),
268 t,
269 ),
270 selected_tile_color: Color::lerp(
271 a.and_then(|a| a.selected_tile_color),
272 b.and_then(|b| b.selected_tile_color),
273 t,
274 ),
275 horizontal_title_gap: lerp_double(
276 a.and_then(|a| a.horizontal_title_gap),
277 b.and_then(|b| b.horizontal_title_gap),
278 t,
279 ),
280 min_vertical_padding: lerp_double(
281 a.and_then(|a| a.min_vertical_padding),
282 b.and_then(|b| b.min_vertical_padding),
283 t,
284 ),
285 min_leading_width: lerp_double(
286 a.and_then(|a| a.min_leading_width),
287 b.and_then(|b| b.min_leading_width),
288 t,
289 ),
290 min_tile_height: lerp_double(
291 a.and_then(|a| a.min_tile_height),
292 b.and_then(|b| b.min_tile_height),
293 t,
294 ),
295 enable_feedback: pick(a, b, t, |theme| theme.enable_feedback),
296 mouse_cursor: pick(a, b, t, |theme| theme.mouse_cursor.clone()),
297 visual_density: pick(a, b, t, |theme| theme.visual_density),
298 title_alignment: pick(a, b, t, |theme| theme.title_alignment),
299 control_affinity: pick(a, b, t, |theme| theme.control_affinity),
300 is_three_line: pick(a, b, t, |theme| theme.is_three_line),
301 })
302 }
303}
304
305fn pick<T>(
307 a: Option<&ListTileThemeData>,
308 b: Option<&ListTileThemeData>,
309 t: f64,
310 field: impl Fn(&ListTileThemeData) -> Option<T>,
311) -> Option<T> {
312 if t < 0.5 {
313 a.and_then(&field)
314 } else {
315 b.and_then(&field)
316 }
317}
318
319impl PartialEq for ListTileThemeData {
320 fn eq(&self, other: &ListTileThemeData) -> bool {
321 if std::ptr::eq(self, other) {
322 return true;
323 }
324 other.dense == self.dense
325 && other.shape == self.shape
326 && other.style == self.style
327 && other.selected_color == self.selected_color
328 && other.icon_color == self.icon_color
329 && other.title_text_style == self.title_text_style
330 && other.subtitle_text_style == self.subtitle_text_style
331 && other.leading_and_trailing_text_style == self.leading_and_trailing_text_style
332 && other.text_color == self.text_color
333 && other.content_padding == self.content_padding
334 && other.tile_color == self.tile_color
335 && other.selected_tile_color == self.selected_tile_color
336 && other.horizontal_title_gap == self.horizontal_title_gap
337 && other.min_vertical_padding == self.min_vertical_padding
338 && other.min_leading_width == self.min_leading_width
339 && other.min_tile_height == self.min_tile_height
340 && other.enable_feedback == self.enable_feedback
341 && other.mouse_cursor == self.mouse_cursor
342 && other.visual_density == self.visual_density
343 && other.title_alignment == self.title_alignment
344 && other.control_affinity == self.control_affinity
345 && other.is_three_line == self.is_three_line
346 }
347}
348
349#[derive(Debug)]
361pub struct ListTileTheme {
362 pub key: Option<KeyRef>,
363 pub data: Option<ListTileThemeData>,
365 pub dense: Option<bool>,
366 pub shape: Option<ShapeBorderRef>,
367 pub style: Option<ListTileStyle>,
368 pub selected_color: Option<Color>,
369 pub icon_color: Option<AnyColor>,
370 pub text_color: Option<AnyColor>,
371 pub content_padding: Option<EdgeInsetsGeometry>,
372 pub tile_color: Option<Color>,
373 pub selected_tile_color: Option<Color>,
374 pub enable_feedback: Option<bool>,
375 pub mouse_cursor: Option<WidgetStatePropertyRef<Option<MouseCursorRef>>>,
376 pub horizontal_title_gap: Option<f64>,
377 pub min_vertical_padding: Option<f64>,
378 pub min_leading_width: Option<f64>,
379 pub control_affinity: Option<ListTileControlAffinity>,
380 pub child: WidgetRef,
381}
382
383macro_rules! obsolete_list_tile_theme_setters {
386 ($($field:ident: $ty:ty => $name:literal),* $(,)?) => {
387 $(
388 #[doc = concat!("Dart `ListTileTheme(", $name, ":)`.")]
389 pub fn $field(mut self, $field: impl Into<$ty>) -> ListTileTheme {
390 debug_assert!(self.data.is_none());
391 self.$field = Some($field.into());
392 self
393 }
394 )*
395 };
396}
397
398impl ListTileTheme {
399 #[cfg_attr(debug_assertions, track_caller)]
405 pub fn new<K>(child: impl IntoWidget<K>) -> ListTileTheme {
406 ListTileTheme {
407 key: None,
408 data: None,
409 dense: None,
410 shape: None,
411 style: None,
412 selected_color: None,
413 icon_color: None,
414 text_color: None,
415 content_padding: None,
416 tile_color: None,
417 selected_tile_color: None,
418 enable_feedback: None,
419 mouse_cursor: None,
420 horizontal_title_gap: None,
421 min_vertical_padding: None,
422 min_leading_width: None,
423 control_affinity: None,
424 child: child.into_widget(),
425 }
426 }
427
428 pub fn key(mut self, key: KeyRef) -> ListTileTheme {
430 self.key = Some(key);
431 self
432 }
433
434 pub fn data(mut self, data: ListTileThemeData) -> ListTileTheme {
436 debug_assert!(
437 self.shape.is_none()
438 && self.selected_color.is_none()
439 && self.icon_color.is_none()
440 && self.text_color.is_none()
441 && self.content_padding.is_none()
442 && self.tile_color.is_none()
443 && self.selected_tile_color.is_none()
444 && self.enable_feedback.is_none()
445 && self.mouse_cursor.is_none()
446 && self.horizontal_title_gap.is_none()
447 && self.min_vertical_padding.is_none()
448 && self.min_leading_width.is_none()
449 && self.control_affinity.is_none()
450 );
451 self.data = Some(data);
452 self
453 }
454
455 pub fn dense(mut self, dense: bool) -> ListTileTheme {
457 self.dense = Some(dense);
458 self
459 }
460
461 pub fn style(mut self, style: ListTileStyle) -> ListTileTheme {
463 self.style = Some(style);
464 self
465 }
466
467 obsolete_list_tile_theme_setters!(
468 shape: ShapeBorderRef => "shape",
469 selected_color: Color => "selectedColor",
470 icon_color: AnyColor => "iconColor",
471 text_color: AnyColor => "textColor",
472 content_padding: EdgeInsetsGeometry => "contentPadding",
473 tile_color: Color => "tileColor",
474 selected_tile_color: Color => "selectedTileColor",
475 enable_feedback: bool => "enableFeedback",
476 mouse_cursor: WidgetStatePropertyRef<Option<MouseCursorRef>> => "mouseCursor",
477 horizontal_title_gap: f64 => "horizontalTitleGap",
478 min_vertical_padding: f64 => "minVerticalPadding",
479 min_leading_width: f64 => "minLeadingWidth",
480 control_affinity: ListTileControlAffinity => "controlAffinity",
481 );
482
483 pub fn effective_data(&self) -> ListTileThemeData {
485 match &self.data {
486 Some(data) => data.clone(),
487 None => ListTileThemeData {
488 dense: self.dense,
489 shape: self.shape.clone(),
490 style: self.style,
491 selected_color: self.selected_color,
492 icon_color: self.icon_color.clone(),
493 text_color: self.text_color.clone(),
494 content_padding: self.content_padding,
495 tile_color: self.tile_color,
496 selected_tile_color: self.selected_tile_color,
497 enable_feedback: self.enable_feedback,
498 mouse_cursor: self.mouse_cursor.clone(),
499 horizontal_title_gap: self.horizontal_title_gap,
500 min_vertical_padding: self.min_vertical_padding,
501 min_leading_width: self.min_leading_width,
502 control_affinity: self.control_affinity,
503 ..ListTileThemeData::default()
504 },
505 }
506 }
507
508 pub fn effective_dense(&self) -> Option<bool> {
513 match &self.data {
514 Some(data) => data.dense,
515 None => self.dense,
516 }
517 }
518
519 pub fn effective_shape(&self) -> Option<ShapeBorderRef> {
524 match &self.data {
525 Some(data) => data.shape.clone(),
526 None => self.shape.clone(),
527 }
528 }
529
530 pub fn effective_style(&self) -> Option<ListTileStyle> {
535 match &self.data {
536 Some(data) => data.style,
537 None => self.style,
538 }
539 }
540
541 pub fn effective_selected_color(&self) -> Option<Color> {
546 match &self.data {
547 Some(data) => data.selected_color,
548 None => self.selected_color,
549 }
550 }
551
552 pub fn effective_icon_color(&self) -> Option<AnyColor> {
557 match &self.data {
558 Some(data) => data.icon_color.clone(),
559 None => self.icon_color.clone(),
560 }
561 }
562
563 pub fn effective_text_color(&self) -> Option<AnyColor> {
568 match &self.data {
569 Some(data) => data.text_color.clone(),
570 None => self.text_color.clone(),
571 }
572 }
573
574 pub fn effective_content_padding(&self) -> Option<EdgeInsetsGeometry> {
579 match &self.data {
580 Some(data) => data.content_padding,
581 None => self.content_padding,
582 }
583 }
584
585 pub fn effective_tile_color(&self) -> Option<Color> {
590 match &self.data {
591 Some(data) => data.tile_color,
592 None => self.tile_color,
593 }
594 }
595
596 pub fn effective_selected_tile_color(&self) -> Option<Color> {
601 match &self.data {
602 Some(data) => data.selected_tile_color,
603 None => self.selected_tile_color,
604 }
605 }
606
607 pub fn effective_horizontal_title_gap(&self) -> Option<f64> {
612 match &self.data {
613 Some(data) => data.horizontal_title_gap,
614 None => self.horizontal_title_gap,
615 }
616 }
617
618 pub fn effective_min_vertical_padding(&self) -> Option<f64> {
623 match &self.data {
624 Some(data) => data.min_vertical_padding,
625 None => self.min_vertical_padding,
626 }
627 }
628
629 pub fn effective_min_leading_width(&self) -> Option<f64> {
634 match &self.data {
635 Some(data) => data.min_leading_width,
636 None => self.min_leading_width,
637 }
638 }
639
640 pub fn effective_enable_feedback(&self) -> Option<bool> {
645 match &self.data {
646 Some(data) => data.enable_feedback,
647 None => self.enable_feedback,
648 }
649 }
650
651 pub fn effective_control_affinity(&self) -> Option<ListTileControlAffinity> {
658 match &self.data {
659 Some(data) => data.control_affinity,
660 None => self.control_affinity,
661 }
662 }
663
664 pub fn of(app: &mut App, context: BuildContext) -> ListTileThemeData {
676 match context.depend_on_inherited_widget_of_exact_type::<ListTileTheme>(app) {
677 Some(result) => result.effective_data(),
678 None => Theme::of(app, context).list_tile_theme.clone(),
679 }
680 }
681
682 #[cfg_attr(debug_assertions, track_caller)]
688 pub fn merge<K>(child: impl IntoWidget<K>) -> ListTileThemeMerge {
689 ListTileThemeMerge {
690 key: None,
691 given: ListTileThemeData::new(),
692 child: child.into_widget(),
693 }
694 }
695}
696
697pub struct ListTileThemeMerge {
699 key: Option<KeyRef>,
700 given: ListTileThemeData,
702 child: WidgetRef,
703}
704
705impl ListTileThemeMerge {
706 pub fn key(mut self, key: KeyRef) -> ListTileThemeMerge {
708 self.key = Some(key);
709 self
710 }
711
712 every_list_tile_theme_data_setter!(ListTileThemeMerge, "ListTileTheme.merge", |this| this
713 .given);
714}
715
716pub struct ListTileThemeMergeKind;
718
719impl IntoWidget<ListTileThemeMergeKind> for ListTileThemeMerge {
720 #[cfg_attr(debug_assertions, track_caller)]
721 fn into_widget(self) -> WidgetRef {
722 Builder::new(move |app, context| {
723 let parent = ListTileTheme::of(app, context);
724 let given = &self.given;
725 let theme = ListTileTheme::new(self.child.clone()).data(ListTileThemeData {
726 dense: given.dense.or(parent.dense),
727 shape: given.shape.clone().or(parent.shape),
728 style: given.style.or(parent.style),
729 selected_color: given.selected_color.or(parent.selected_color),
730 icon_color: given.icon_color.clone().or(parent.icon_color),
731 text_color: given.text_color.clone().or(parent.text_color),
732 title_text_style: given.title_text_style.clone().or(parent.title_text_style),
733 subtitle_text_style: given
734 .subtitle_text_style
735 .clone()
736 .or(parent.subtitle_text_style),
737 leading_and_trailing_text_style: given
738 .leading_and_trailing_text_style
739 .clone()
740 .or(parent.leading_and_trailing_text_style),
741 content_padding: given.content_padding.or(parent.content_padding),
742 tile_color: given.tile_color.or(parent.tile_color),
743 selected_tile_color: given.selected_tile_color.or(parent.selected_tile_color),
744 enable_feedback: given.enable_feedback.or(parent.enable_feedback),
745 horizontal_title_gap: given.horizontal_title_gap.or(parent.horizontal_title_gap),
746 min_vertical_padding: given.min_vertical_padding.or(parent.min_vertical_padding),
747 min_leading_width: given.min_leading_width.or(parent.min_leading_width),
748 min_tile_height: given.min_tile_height.or(parent.min_tile_height),
749 title_alignment: given.title_alignment.or(parent.title_alignment),
750 mouse_cursor: given.mouse_cursor.clone().or(parent.mouse_cursor),
751 visual_density: given.visual_density.or(parent.visual_density),
752 control_affinity: given.control_affinity.or(parent.control_affinity),
753 is_three_line: given.is_three_line.or(parent.is_three_line),
754 });
755 match &self.key {
756 Some(key) => theme.key(key.clone()),
757 None => theme,
758 }
759 .into_widget()
760 })
761 .into_widget()
762 }
763}
764
765impl InheritedTheme for ListTileTheme {
766 fn wrap(&self, _app: &mut App, _context: BuildContext, child: WidgetRef) -> WidgetRef {
767 ListTileTheme::new(child)
768 .data(ListTileThemeData {
769 dense: self.effective_dense(),
770 shape: self.effective_shape(),
771 style: self.effective_style(),
772 selected_color: self.effective_selected_color(),
773 icon_color: self.effective_icon_color(),
774 text_color: self.effective_text_color(),
775 content_padding: self.effective_content_padding(),
776 tile_color: self.effective_tile_color(),
777 selected_tile_color: self.effective_selected_tile_color(),
778 enable_feedback: self.effective_enable_feedback(),
779 horizontal_title_gap: self.effective_horizontal_title_gap(),
780 min_vertical_padding: self.effective_min_vertical_padding(),
781 min_leading_width: self.effective_min_leading_width(),
782 is_three_line: self.data.as_ref().and_then(|data| data.is_three_line),
783 ..ListTileThemeData::default()
784 })
785 .into_widget()
786 }
787}
788
789impl InheritedWidget for ListTileTheme {
790 fn key(&self) -> Option<&KeyRef> {
791 self.key.as_ref()
792 }
793
794 fn child(&self) -> &WidgetRef {
795 &self.child
796 }
797
798 fn update_should_notify(&self, old_widget: &ListTileTheme) -> bool {
799 self.effective_data() != old_widget.effective_data()
800 }
801
802 fn as_inherited_theme(&self) -> Option<&dyn InheritedTheme> {
803 Some(self)
804 }
805}
806
807impl waft_foundation::Diagnosticable for ListTileThemeData {
808 fn debug_fill_properties(&self, properties: &mut waft_foundation::DiagnosticPropertiesBuilder) {
809 properties.add(DiagnosticsProperty::<bool>::new("dense", self.dense).default_value(None));
810 properties.add(
811 DiagnosticsProperty::<ShapeBorderRef>::new("shape", self.shape.clone())
812 .default_value(None),
813 );
814 properties.add(EnumProperty::<ListTileStyle>::new("style", self.style).default_value(None));
815 properties
816 .add(ColorProperty::new("selectedColor", self.selected_color).default_value(None));
817 properties.add(
818 DiagnosticsProperty::<AnyColor>::new("iconColor", self.icon_color.clone())
819 .default_value(None),
820 );
821 properties.add(
822 DiagnosticsProperty::<AnyColor>::new("textColor", self.text_color.clone())
823 .default_value(None),
824 );
825 properties.add(
826 DiagnosticsProperty::<TextStyle>::new("titleTextStyle", self.title_text_style.clone())
827 .default_value(None),
828 );
829 properties.add(
830 DiagnosticsProperty::<TextStyle>::new(
831 "subtitleTextStyle",
832 self.subtitle_text_style.clone(),
833 )
834 .default_value(None),
835 );
836 properties.add(
837 DiagnosticsProperty::<TextStyle>::new(
838 "leadingAndTrailingTextStyle",
839 self.leading_and_trailing_text_style.clone(),
840 )
841 .default_value(None),
842 );
843 properties.add(
844 DiagnosticsProperty::<EdgeInsetsGeometry>::new("contentPadding", self.content_padding)
845 .default_value(None),
846 );
847 properties.add(ColorProperty::new("tileColor", self.tile_color).default_value(None));
848 properties.add(
849 ColorProperty::new("selectedTileColor", self.selected_tile_color).default_value(None),
850 );
851 properties.add(
852 DoubleProperty::new("horizontalTitleGap", self.horizontal_title_gap)
853 .default_value(None),
854 );
855 properties.add(
856 DoubleProperty::new("minVerticalPadding", self.min_vertical_padding)
857 .default_value(None),
858 );
859 properties.add(
860 DoubleProperty::new("minLeadingWidth", self.min_leading_width).default_value(None),
861 );
862 properties
863 .add(DoubleProperty::new("minTileHeight", self.min_tile_height).default_value(None));
864 properties.add(
865 DiagnosticsProperty::<bool>::new("enableFeedback", self.enable_feedback)
866 .default_value(None),
867 );
868 properties.add(
869 DiagnosticsProperty::<String>::new(
870 "mouseCursor",
871 self.mouse_cursor
872 .as_deref()
873 .map(|property| property.to_string()),
874 )
875 .default_value(None),
876 );
877 properties.add(
878 DiagnosticsProperty::<VisualDensity>::new("visualDensity", self.visual_density)
879 .default_value(None),
880 );
881 properties.add(
882 DiagnosticsProperty::<waft_foundation::DartEnum<ListTileTitleAlignment>>::new(
883 "titleAlignment",
884 self.title_alignment.map(waft_foundation::DartEnum),
885 )
886 .default_value(None),
887 );
888 properties.add(
889 DiagnosticsProperty::<waft_foundation::DartEnum<ListTileControlAffinity>>::new(
890 "controlAffinity",
891 self.control_affinity.map(waft_foundation::DartEnum),
892 )
893 .default_value(None),
894 );
895 properties.add(
896 DiagnosticsProperty::<bool>::new("isThreeLine", self.is_three_line).default_value(None),
897 );
898 }
899}
900
901impl std::fmt::Display for ListTileThemeData {
902 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
903 f.write_str(&waft_foundation::Diagnosticable::to_string(self))
904 }
905}
906
907#[cfg(test)]
908mod tests {
909 use std::cell::{Cell, RefCell};
910 use std::rc::Rc;
911 use std::time::Duration;
912
913 use waft_embedder::{FontStyle, Offset, Radius, Rect, Size};
914 use waft_foundation::Listener;
915 use waft_painting::{BorderRadius, EdgeInsets, RoundedRectangleBorder, StadiumBorder};
916 use waft_services::SystemMouseCursors;
917 use waft_widgets::{
918 Center, Container, GlobalKey, ListView, SizedBox, StatefulBuilder, Text, WidgetState,
919 WidgetStateColor, WidgetStateMouseCursor, WidgetStateProperty,
920 };
921
922 use waft_widgets::testing::{TestPointer, WidgetTester, find, test_widgets};
923
924 use super::*;
925 use crate::colors::Colors;
926 use crate::drawer::Drawer;
927 use crate::ink_well::InkWell;
928 use crate::list_tile::ListTile;
929 use crate::list_tile::tests::{
930 THIRTEEN_LINES, avatar, ink_tile_color, key_rect, m2, m3, placeholder, pump_app, sized,
931 style_color, test_icon, test_text, tile_rect,
932 };
933 use crate::material::Material;
934 use crate::scaffold::{Scaffold, ScaffoldState};
935 use crate::test_support::material_app;
936 use crate::theme_data::ThemeData;
937 use waft_widgets::WidgetStatePropertyAll;
938
939 fn clickable() -> WidgetStatePropertyRef<Option<MouseCursorRef>> {
941 <dyn WidgetStateProperty<Option<MouseCursorRef>>>::resolve_with(|states| {
942 Some(WidgetStateMouseCursor::clickable().resolve(states))
943 })
944 }
945
946 fn textable() -> WidgetStatePropertyRef<Option<MouseCursorRef>> {
948 <dyn WidgetStateProperty<Option<MouseCursorRef>>>::resolve_with(|states| {
949 Some(WidgetStateMouseCursor::textable().resolve(states))
950 })
951 }
952
953 #[test]
954 fn list_tile_theme_data_copy_with_equality_basics() {
955 assert_eq!(
956 ListTileThemeData::new(),
957 ListTileThemeData::new().copy_with()
958 );
959 }
960
961 #[test]
962 fn list_tile_theme_data_lerp_special_cases() {
963 assert_eq!(ListTileThemeData::lerp(None, None, 0.0), None);
964 let data = ListTileThemeData::new();
965 assert_eq!(
967 ListTileThemeData::lerp(Some(&data), Some(&data), 0.5),
968 Some(data.clone())
969 );
970 }
971
972 #[test]
973 fn list_tile_theme_data_defaults() {
974 let theme_data = ListTileThemeData::new();
975 assert_eq!(theme_data.dense, None);
976 assert!(theme_data.shape.is_none());
977 assert_eq!(theme_data.style, None);
978 assert_eq!(theme_data.selected_color, None);
979 assert_eq!(theme_data.icon_color, None);
980 assert_eq!(theme_data.text_color, None);
981 assert_eq!(theme_data.title_text_style, None);
982 assert_eq!(theme_data.subtitle_text_style, None);
983 assert_eq!(theme_data.leading_and_trailing_text_style, None);
984 assert_eq!(theme_data.content_padding, None);
985 assert_eq!(theme_data.tile_color, None);
986 assert_eq!(theme_data.selected_tile_color, None);
987 assert_eq!(theme_data.horizontal_title_gap, None);
988 assert_eq!(theme_data.min_vertical_padding, None);
989 assert_eq!(theme_data.min_leading_width, None);
990 assert_eq!(theme_data.min_tile_height, None);
991 assert_eq!(theme_data.enable_feedback, None);
992 assert!(theme_data.mouse_cursor.is_none());
993 assert_eq!(theme_data.visual_density, None);
994 assert_eq!(theme_data.title_alignment, None);
995 assert_eq!(theme_data.is_three_line, None);
996 }
997
998 fn theme_under(
1000 tester: &mut WidgetTester,
1001 theme: impl FnOnce(WidgetRef) -> ListTileTheme,
1002 ) -> ListTileThemeData {
1003 let seen = Rc::new(RefCell::new(None));
1004 pump_app(tester, m3, |_app| {
1005 let seen = Rc::clone(&seen);
1006 let probe = Builder::new(move |app, context| {
1007 *seen.borrow_mut() = Some(ListTileTheme::of(app, context));
1008 SizedBox::new().into_widget()
1009 });
1010 Material::new()
1011 .child(theme(Center::new().child(probe).into_widget()))
1012 .into_widget()
1013 });
1014 seen.borrow_mut().take().expect("built")
1015 }
1016
1017 #[test]
1018 fn list_tile_theme_backwards_compatibility_constructor() {
1019 test_widgets(|tester| {
1020 let mouse_cursor = clickable();
1021 let theme = theme_under(tester, |child| {
1022 ListTileTheme::new(child)
1023 .dense(true)
1024 .shape(StadiumBorder::default())
1025 .style(ListTileStyle::Drawer)
1026 .selected_color(Color::new(0x00000001))
1027 .icon_color(Color::new(0x00000002))
1028 .text_color(Color::new(0x00000003))
1029 .content_padding(EdgeInsets::all(100.0))
1030 .tile_color(Color::new(0x00000004))
1031 .selected_tile_color(Color::new(0x00000005))
1032 .horizontal_title_gap(200.0)
1033 .min_vertical_padding(300.0)
1034 .min_leading_width(400.0)
1035 .enable_feedback(true)
1036 .mouse_cursor(Rc::clone(&mouse_cursor))
1037 });
1038
1039 assert_eq!(theme.dense, Some(true));
1040 assert_eq!(
1041 theme.shape,
1042 Some(ShapeBorderRef::new(StadiumBorder::default()))
1043 );
1044 assert_eq!(theme.style, Some(ListTileStyle::Drawer));
1045 assert_eq!(theme.selected_color, Some(Color::new(0x00000001)));
1046 assert_eq!(
1047 theme.icon_color,
1048 Some(AnyColor::new(Color::new(0x00000002)))
1049 );
1050 assert_eq!(
1051 theme.text_color,
1052 Some(AnyColor::new(Color::new(0x00000003)))
1053 );
1054 assert_eq!(theme.content_padding, Some(EdgeInsets::all(100.0).into()));
1055 assert_eq!(theme.tile_color, Some(Color::new(0x00000004)));
1056 assert_eq!(theme.selected_tile_color, Some(Color::new(0x00000005)));
1057 assert_eq!(theme.horizontal_title_gap, Some(200.0));
1058 assert_eq!(theme.min_vertical_padding, Some(300.0));
1059 assert_eq!(theme.min_leading_width, Some(400.0));
1060 assert_eq!(theme.enable_feedback, Some(true));
1061 assert!(Rc::ptr_eq(
1062 theme.mouse_cursor.as_ref().expect("a mouse cursor"),
1063 &mouse_cursor
1064 ));
1065 });
1066 }
1067
1068 struct ThemedCase<'a> {
1071 tester: &'a mut WidgetTester,
1072 leading: Rc<Cell<Option<Color>>>,
1073 trailing: Rc<Cell<Option<Color>>>,
1074 title: Rc<RefCell<Option<TextStyle>>>,
1075 subtitle: Rc<RefCell<Option<TextStyle>>>,
1076 theme: Rc<RefCell<Option<Rc<ThemeData>>>>,
1077 leading_key: GlobalKey,
1078 trailing_key: GlobalKey,
1079 list_tile_key: GlobalKey,
1080 }
1081
1082 #[derive(Default)]
1083 struct ThemedArgs {
1084 enabled: Option<bool>,
1085 dense: bool,
1086 selected: bool,
1087 shape: Option<ShapeBorderRef>,
1088 selected_color: Option<Color>,
1089 icon_color: Option<Color>,
1090 text_color: Option<Color>,
1091 }
1092
1093 impl<'a> ThemedCase<'a> {
1094 fn new(tester: &'a mut WidgetTester) -> ThemedCase<'a> {
1095 ThemedCase {
1096 tester,
1097 leading: Rc::new(Cell::new(None)),
1098 trailing: Rc::new(Cell::new(None)),
1099 title: Rc::new(RefCell::new(None)),
1100 subtitle: Rc::new(RefCell::new(None)),
1101 theme: Rc::new(RefCell::new(None)),
1102 leading_key: GlobalKey::new(),
1103 trailing_key: GlobalKey::new(),
1104 list_tile_key: GlobalKey::new(),
1105 }
1106 }
1107
1108 fn pump_frame(&mut self, args: ThemedArgs) {
1110 let mut data = ListTileThemeData::new()
1111 .dense(args.dense)
1112 .min_vertical_padding(25.0)
1113 .mouse_cursor(
1114 <dyn WidgetStateProperty<Option<MouseCursorRef>>>::resolve_with(|states| {
1115 if states.contains(&WidgetState::Disabled) {
1116 return Some(SystemMouseCursors::FORBIDDEN.into());
1117 }
1118
1119 Some(SystemMouseCursors::CLICK.into())
1120 }),
1121 )
1122 .visual_density(VisualDensity::COMPACT)
1123 .title_alignment(ListTileTitleAlignment::Bottom);
1124 data.shape = args.shape;
1125 data.selected_color = args.selected_color;
1126 data.icon_color = args.icon_color.map(AnyColor::new);
1127 data.text_color = args.text_color.map(AnyColor::new);
1128 let (leading, trailing, title, subtitle, theme) = (
1129 Rc::clone(&self.leading),
1130 Rc::clone(&self.trailing),
1131 Rc::clone(&self.title),
1132 Rc::clone(&self.subtitle),
1133 Rc::clone(&self.theme),
1134 );
1135 let (leading_key, trailing_key, list_tile_key) = (
1136 self.leading_key.clone(),
1137 self.trailing_key.clone(),
1138 self.list_tile_key.clone(),
1139 );
1140 let home = Material::new()
1141 .child(
1142 Center::new().child(
1143 ListTileTheme::new(Builder::new(move |app, context| {
1144 *theme.borrow_mut() = Some(Theme::of(app, context));
1145 ListTile::new()
1146 .key(list_tile_key.clone().into())
1147 .enabled(args.enabled.unwrap_or(true))
1148 .selected(args.selected)
1149 .leading(
1150 SizedBox::new()
1151 .key(leading_key.clone().into())
1152 .child(test_icon(&leading)),
1153 )
1154 .trailing(
1155 SizedBox::new()
1156 .key(trailing_key.clone().into())
1157 .child(test_icon(&trailing)),
1158 )
1159 .title(test_text("title", &title))
1160 .subtitle(test_text("subtitle", &subtitle))
1161 .into_widget()
1162 }))
1163 .data(data),
1164 ),
1165 )
1166 .into_widget();
1167 let theme = m2(&self.tester.cell.borrow());
1168 self.tester.pump_widget(material_app(theme, home));
1169 }
1170
1171 fn colors(&self) -> [Option<Color>; 4] {
1172 [
1173 self.leading.get(),
1174 self.trailing.get(),
1175 style_color(&self.title),
1176 style_color(&self.subtitle),
1177 ]
1178 }
1179
1180 fn theme(&self) -> Rc<ThemeData> {
1181 self.theme.borrow().clone().expect("built")
1182 }
1183 }
1184
1185 #[test]
1187 fn list_tile_theme() {
1188 test_widgets(|tester| {
1189 const GREEN: Color = Color::new(0xFF00FF00);
1190 const RED: Color = Color::new(0xFFFF0000);
1191 let rounded_shape = RoundedRectangleBorder {
1192 border_radius: BorderRadius::all(Radius::circular(4.0)).into(),
1193 ..RoundedRectangleBorder::default()
1194 };
1195 let mut case = ThemedCase::new(tester);
1196
1197 case.pump_frame(ThemedArgs {
1199 selected: true,
1200 ..ThemedArgs::default()
1201 });
1202 case.tester.pump_by(Duration::from_millis(300)); assert_eq!(case.colors(), [Some(case.theme().primary_color); 4]);
1204
1205 case.pump_frame(ThemedArgs {
1207 selected: true,
1208 selected_color: Some(GREEN),
1209 ..ThemedArgs::default()
1210 });
1211 case.tester.pump_by(Duration::from_millis(300)); assert_eq!(case.colors(), [Some(GREEN); 4]);
1213
1214 case.pump_frame(ThemedArgs {
1217 icon_color: Some(RED),
1218 text_color: Some(GREEN),
1219 ..ThemedArgs::default()
1220 });
1221 case.tester.pump_by(Duration::from_millis(300)); assert_eq!(
1223 case.colors(),
1224 [Some(RED), Some(RED), Some(GREEN), Some(GREEN)]
1225 );
1226
1227 case.pump_frame(ThemedArgs {
1229 enabled: Some(false),
1230 ..ThemedArgs::default()
1231 });
1232 case.tester.pump_by(Duration::from_millis(300)); assert_eq!(case.colors(), [Some(case.theme().disabled_color); 4]);
1234
1235 case.pump_frame(ThemedArgs {
1238 enabled: Some(false),
1239 selected: true,
1240 ..ThemedArgs::default()
1241 });
1242 case.tester.pump_by(Duration::from_millis(300)); assert_eq!(case.colors(), [Some(case.theme().disabled_color); 4]);
1244
1245 case.pump_frame(ThemedArgs {
1247 selected: true,
1248 shape: Some(ShapeBorderRef::new(rounded_shape)),
1249 ..ThemedArgs::default()
1250 });
1251 let ink_well = case.tester.element(find::by_type::<InkWell>().at(0));
1252 let custom_border = case.tester.widget(ink_well, |ink_well: &InkWell| {
1253 ink_well.ink_response.custom_border.clone()
1254 });
1255 assert_eq!(custom_border, Some(ShapeBorderRef::new(rounded_shape)));
1256
1257 case.pump_frame(ThemedArgs {
1259 enabled: Some(false),
1260 ..ThemedArgs::default()
1261 });
1262 let list_tile = case.tester.get_rect(find::text("title")).center();
1263 let mut gesture = TestPointer::mouse(1, 0);
1264 case.tester.add_pointer(&mut gesture, Offset::ZERO);
1265 case.tester.move_to(&mut gesture, list_tile, false);
1266 case.tester.pump_and_settle();
1267 let forbidden: MouseCursorRef = SystemMouseCursors::FORBIDDEN.into();
1268 assert!(*case.tester.active_cursor(1) == *forbidden);
1269
1270 assert_eq!(
1272 key_rect(case.tester, &case.list_tile_key).size(),
1273 Size::new(800.0, 80.0)
1274 );
1275
1276 let title_offset = case.tester.get_rect(find::text("title")).top_left();
1278 let leading_offset = key_rect(case.tester, &case.leading_key).top_left();
1279 let trailing_offset = key_rect(case.tester, &case.trailing_key).top_right();
1280 assert_eq!(leading_offset.dy() - title_offset.dy(), 6.0);
1281 assert_eq!(trailing_offset.dy() - title_offset.dy(), 6.0);
1282 });
1283 }
1284
1285 #[test]
1286 fn list_tile_theme_colors_are_applied_to_leading_and_trailing_text_widgets() {
1287 test_widgets(|tester| {
1288 let selected_color = Colors::ORANGE.primary();
1289 let default_color = Colors::BLACK;
1290 let mut colors = |enabled: bool, selected: bool| {
1291 let leading = Rc::new(RefCell::new(None));
1292 let trailing = Rc::new(RefCell::new(None));
1293 let title = Rc::new(RefCell::new(None));
1294 let theme = Rc::new(RefCell::new(None));
1295 pump_app(tester, m3, |_app| {
1296 let (leading, trailing, title, theme) = (
1297 Rc::clone(&leading),
1298 Rc::clone(&trailing),
1299 Rc::clone(&title),
1300 Rc::clone(&theme),
1301 );
1302 Material::new()
1303 .child(
1304 Center::new().child(
1305 ListTileTheme::new(Builder::new(move |app, context| {
1306 *theme.borrow_mut() = Some(Theme::of(app, context));
1307 ListTile::new()
1308 .enabled(enabled)
1309 .selected(selected)
1310 .leading(test_text("leading", &leading))
1311 .title(test_text("title", &title))
1312 .trailing(test_text("trailing", &trailing))
1313 .into_widget()
1314 }))
1315 .data(
1316 ListTileThemeData::new()
1317 .selected_color(selected_color)
1318 .text_color(default_color),
1319 ),
1320 ),
1321 )
1322 .into_widget()
1323 });
1324 tester.pump_and_settle();
1326 let theme: Rc<ThemeData> = theme.borrow_mut().take().expect("built");
1327 (style_color(&leading), style_color(&trailing), theme)
1328 };
1329
1330 let (leading, trailing, _) = colors(true, false);
1331 assert_eq!(leading, Some(default_color));
1333 assert_eq!(trailing, Some(default_color));
1334
1335 let (leading, trailing, _) = colors(true, true);
1336 assert_eq!(leading, Some(selected_color));
1338 assert_eq!(trailing, Some(selected_color));
1339
1340 let (leading, trailing, theme) = colors(false, false);
1341 assert_eq!(leading, Some(theme.disabled_color));
1343 assert_eq!(trailing, Some(theme.disabled_color));
1344 });
1345 }
1346
1347 fn italic(font_size: f64, color: u32) -> TextStyle {
1348 TextStyle::new()
1349 .font_size(font_size)
1350 .color(Color::new(color))
1351 .font_style(FontStyle::Italic)
1352 }
1353
1354 fn slot_styles(
1356 tester: &mut WidgetTester,
1357 theme: impl FnOnce(&App) -> ThemeData,
1358 tile: ListTile,
1359 ) -> [TextStyle; 4] {
1360 let seen: [Rc<RefCell<Option<TextStyle>>>; 4] =
1361 std::array::from_fn(|_| Rc::new(RefCell::new(None)));
1362 pump_app(tester, theme, |_app| {
1363 Material::new()
1364 .child(
1365 Center::new().child(
1366 tile.leading(test_text("leading", &seen[0]))
1367 .title(test_text("title", &seen[1]))
1368 .subtitle(test_text("subtitle", &seen[2]))
1369 .trailing(test_text("trailing", &seen[3])),
1370 ),
1371 )
1372 .into_widget()
1373 });
1374 seen.map(|seen| seen.borrow_mut().take().expect("built"))
1375 }
1376
1377 fn assert_slot_styles(styles: &[TextStyle; 4], expected: [&TextStyle; 4]) {
1378 for (style, expected) in styles.iter().zip(expected) {
1379 assert_eq!(style.font_size, expected.font_size);
1380 assert_eq!(style.color, expected.color);
1381 assert_eq!(style.font_style, expected.font_style);
1382 }
1383 }
1384
1385 fn case_styles() -> (TextStyle, TextStyle, TextStyle) {
1388 (
1389 italic(23.0, 0xffff0000),
1390 italic(20.0, 0xff00ff00),
1391 italic(18.0, 0xff0000ff),
1392 )
1393 }
1394
1395 fn respects_theme_text_styles(tester: &mut WidgetTester, use_material3: bool) {
1396 let (title, subtitle, leading_and_trailing) = case_styles();
1397 let theme_data = ListTileThemeData::new()
1398 .title_text_style(title.clone())
1399 .subtitle_text_style(subtitle.clone())
1400 .leading_and_trailing_text_style(leading_and_trailing.clone());
1401 let styles = slot_styles(
1402 tester,
1403 move |app| {
1404 ThemeData::builder()
1405 .use_material3(use_material3)
1406 .list_tile_theme(theme_data)
1407 .build(app)
1408 },
1409 ListTile::new(),
1410 );
1411 assert_slot_styles(
1412 &styles,
1413 [
1414 &leading_and_trailing,
1415 &title,
1416 &subtitle,
1417 &leading_and_trailing,
1418 ],
1419 );
1420 }
1421
1422 #[test]
1423 fn material3_list_tile_respects_list_tile_theme_text_styles() {
1424 test_widgets(|tester| respects_theme_text_styles(tester, true));
1425 }
1426
1427 #[test]
1428 fn material2_list_tile_respects_list_tile_theme_text_styles() {
1429 test_widgets(|tester| respects_theme_text_styles(tester, false));
1430 }
1431
1432 fn theme_text_styles_are_overridden(tester: &mut WidgetTester, use_material3: bool) {
1433 let (title, subtitle, leading_and_trailing) = case_styles();
1434 let styles = slot_styles(
1435 tester,
1436 move |app| {
1437 ThemeData::builder()
1438 .use_material3(use_material3)
1439 .list_tile_theme(
1440 ListTileThemeData::new()
1441 .title_text_style(TextStyle::new().font_size(20.0))
1442 .subtitle_text_style(TextStyle::new().font_size(17.5))
1443 .leading_and_trailing_text_style(TextStyle::new().font_size(15.0)),
1444 )
1445 .build(app)
1446 },
1447 ListTile::new()
1448 .title_text_style(title.clone())
1449 .subtitle_text_style(subtitle.clone())
1450 .leading_and_trailing_text_style(leading_and_trailing.clone()),
1451 );
1452 assert_slot_styles(
1453 &styles,
1454 [
1455 &leading_and_trailing,
1456 &title,
1457 &subtitle,
1458 &leading_and_trailing,
1459 ],
1460 );
1461 }
1462
1463 #[test]
1464 fn material3_list_tile_text_styles_are_overridden_by_list_tile_properties() {
1465 test_widgets(|tester| theme_text_styles_are_overridden(tester, true));
1466 }
1467
1468 #[test]
1469 fn material2_list_tile_text_styles_are_overridden_by_list_tile_properties() {
1470 test_widgets(|tester| theme_text_styles_are_overridden(tester, false));
1471 }
1472
1473 fn tile_colors_before_and_after_tap(
1475 tester: &mut WidgetTester,
1476 theme_data: ListTileThemeData,
1477 tile: impl Fn() -> ListTile + 'static,
1478 ) -> (Option<Color>, Option<Color>) {
1479 let is_selected = Rc::new(Cell::new(false));
1480 pump_app(tester, m3, move |_app| {
1481 Material::new()
1482 .child(
1483 ListTileTheme::new(Center::new().child(StatefulBuilder::new(
1484 move |_app, _context, set_state| {
1485 let toggled = Rc::clone(&is_selected);
1486 tile()
1487 .selected(is_selected.get())
1488 .on_tap(Listener::new(move |app| {
1489 let toggled = Rc::clone(&toggled);
1490 set_state(app, &mut |_app| toggled.set(!toggled.get()));
1491 }))
1492 .title(Text::new("Title"))
1493 .into_widget()
1494 },
1495 )))
1496 .data(theme_data),
1497 )
1498 .into_widget()
1499 });
1500 let before = ink_tile_color(tester);
1501 let center = tile_rect(tester, 0).center();
1503 tester.tap_at(center, 1);
1504 tester.pump_and_settle();
1505 (before, ink_tile_color(tester))
1506 }
1507
1508 #[test]
1511 fn list_tile_respects_list_tile_theme_tile_color_and_selected_tile_color() {
1512 test_widgets(|tester| {
1513 let theme = ListTileThemeData::new()
1514 .tile_color(Colors::GREEN.shade500())
1515 .selected_tile_color(Colors::RED.shade500());
1516 assert_eq!(
1517 tile_colors_before_and_after_tap(tester, theme, ListTile::new),
1518 (Some(Colors::GREEN.shade500()), Some(Colors::RED.shade500()))
1519 );
1520 });
1521 }
1522
1523 #[test]
1525 fn list_tile_theme_tile_colors_are_overridden_by_list_tile_properties() {
1526 test_widgets(|tester| {
1527 let tile_color = Colors::GREEN.shade500();
1528 let selected_tile_color = Colors::RED.shade500();
1529 let theme = ListTileThemeData::new()
1530 .selected_tile_color(Colors::GREEN.primary())
1531 .tile_color(Colors::RED.primary());
1532 assert_eq!(
1533 tile_colors_before_and_after_tap(tester, theme, move || {
1534 ListTile::new()
1535 .tile_color(tile_color)
1536 .selected_tile_color(selected_tile_color)
1537 }),
1538 (Some(tile_color), Some(selected_tile_color))
1539 );
1540 });
1541 }
1542
1543 fn state_color() -> WidgetStateColor {
1544 WidgetStateColor::resolve_with(|states| {
1545 if states.contains(&WidgetState::Disabled) {
1546 return Colors::RED.primary();
1547 }
1548 if states.contains(&WidgetState::Selected) {
1549 return Colors::GREEN.primary();
1550 }
1551 Colors::BLUE.primary()
1552 })
1553 }
1554
1555 #[test]
1557 fn list_tile_uses_list_tile_theme_shape_in_a_drawer() {
1558 test_widgets(|tester| {
1559 let scaffold_key = GlobalKey::new();
1562 let shape_border = RoundedRectangleBorder {
1563 border_radius: BorderRadius::all(Radius::circular(20.0)).into(),
1564 ..RoundedRectangleBorder::default()
1565 };
1566
1567 pump_app(
1568 tester,
1569 |app| {
1570 ThemeData::builder()
1571 .list_tile_theme(ListTileThemeData::new().shape(shape_border))
1572 .build(app)
1573 },
1574 |_app| {
1575 Scaffold::new()
1576 .key(scaffold_key.clone().into())
1577 .drawer(Drawer::new().child(ListTile::new()))
1578 .body(Container::new())
1579 .into_widget()
1580 },
1581 );
1582 tester.pump_and_settle();
1583
1584 let scaffold_state = scaffold_key
1585 .current_state::<ScaffoldState>(&tester.cell.borrow_mut())
1586 .expect("a mounted scaffold");
1587 scaffold_state.open_drawer(&mut tester.cell.borrow_mut());
1588 tester.pump();
1590
1591 let list_tile = tester.element(find::by_type::<ListTile>().at(0));
1592 let ink_well = find::by_type::<InkWell>()
1593 .evaluate(tester)
1594 .into_iter()
1595 .find(|ink_well| tester.ancestors(*ink_well).contains(&list_tile))
1596 .expect("the tile's InkWell");
1597 let ink_well_border = tester.widget(ink_well, |ink_well: &InkWell| {
1598 ink_well.ink_response.custom_border.clone()
1599 });
1600 assert_eq!(ink_well_border, Some(ShapeBorderRef::new(shape_border)));
1602 });
1603 }
1604
1605 #[test]
1606 fn list_tile_respects_widget_state_color_list_tile_theme_text_color() {
1607 test_widgets(|tester| {
1608 let mut title_color = |enabled: bool, selected: bool| {
1609 pump_app(
1610 tester,
1611 |app| {
1612 ThemeData::builder()
1613 .list_tile_theme(ListTileThemeData::new().text_color(state_color()))
1614 .build(app)
1615 },
1616 |_app| {
1617 Material::new()
1618 .child(
1619 Center::new().child(
1620 ListTile::new()
1621 .enabled(enabled)
1622 .selected(selected)
1623 .title(Text::new("title"))
1624 .subtitle(Text::new("subtitle")),
1625 ),
1626 )
1627 .into_widget()
1628 },
1629 );
1630 tester.pump_and_settle();
1631 tester.text_color("title")
1632 };
1633 assert_eq!(title_color(false, false), Colors::RED.primary());
1635 assert_eq!(title_color(true, false), Colors::BLUE.primary());
1637 assert_eq!(title_color(true, true), Colors::GREEN.primary());
1639 });
1640 }
1641
1642 #[test]
1643 fn list_tile_respects_widget_state_color_list_tile_theme_icon_color() {
1644 test_widgets(|tester| {
1645 let mut icon_color = |enabled: bool, selected: bool| {
1646 let seen = Rc::new(Cell::new(None));
1647 pump_app(
1648 tester,
1649 |app| {
1650 ThemeData::builder()
1651 .list_tile_theme(ListTileThemeData::new().icon_color(state_color()))
1652 .build(app)
1653 },
1654 |_app| {
1655 Material::new()
1656 .child(
1657 Center::new().child(
1658 ListTile::new()
1659 .enabled(enabled)
1660 .selected(selected)
1661 .leading(test_icon(&seen)),
1662 ),
1663 )
1664 .into_widget()
1665 },
1666 );
1667 tester.pump_and_settle();
1668 seen.get()
1669 };
1670 assert_eq!(icon_color(false, false), Some(Colors::RED.primary()));
1672 assert_eq!(icon_color(true, false), Some(Colors::BLUE.primary()));
1674 assert_eq!(icon_color(true, true), Some(Colors::GREEN.primary()));
1676 });
1677 }
1678
1679 #[test]
1680 fn list_tile_theme_data_copy_with_overrides_all_properties() {
1681 let original = ListTileThemeData::new()
1683 .dense(true)
1684 .shape(StadiumBorder::default())
1685 .style(ListTileStyle::Drawer)
1686 .selected_color(Color::new(0x00000001))
1687 .icon_color(Color::new(0x00000002))
1688 .text_color(Color::new(0x00000003))
1689 .title_text_style(TextStyle::new().color(Color::new(0x00000004)))
1690 .subtitle_text_style(TextStyle::new().color(Color::new(0x00000005)))
1691 .leading_and_trailing_text_style(TextStyle::new().color(Color::new(0x00000006)))
1692 .content_padding(EdgeInsets::all(100.0))
1693 .tile_color(Color::new(0x00000007))
1694 .selected_tile_color(Color::new(0x00000008))
1695 .horizontal_title_gap(200.0)
1696 .min_vertical_padding(300.0)
1697 .min_leading_width(400.0)
1698 .min_tile_height(30.0)
1699 .enable_feedback(true)
1700 .title_alignment(ListTileTitleAlignment::Bottom)
1701 .is_three_line(true);
1702
1703 let copy = original
1704 .copy_with()
1705 .dense(false)
1706 .shape(RoundedRectangleBorder::default())
1707 .style(ListTileStyle::List)
1708 .selected_color(Color::new(0x00000009))
1709 .icon_color(Color::new(0x0000000A))
1710 .text_color(Color::new(0x0000000B))
1711 .title_text_style(TextStyle::new().color(Color::new(0x0000000C)))
1712 .subtitle_text_style(TextStyle::new().color(Color::new(0x0000000D)))
1713 .leading_and_trailing_text_style(TextStyle::new().color(Color::new(0x0000000E)))
1714 .content_padding(EdgeInsets::all(500.0))
1715 .tile_color(Color::new(0x0000000F))
1716 .selected_tile_color(Color::new(0x00000010))
1717 .horizontal_title_gap(600.0)
1718 .min_vertical_padding(700.0)
1719 .min_leading_width(800.0)
1720 .min_tile_height(80.0)
1721 .enable_feedback(false)
1722 .title_alignment(ListTileTitleAlignment::Top)
1723 .is_three_line(false);
1724
1725 assert_eq!(copy.dense, Some(false));
1726 assert_eq!(
1727 copy.shape,
1728 Some(ShapeBorderRef::new(RoundedRectangleBorder::default()))
1729 );
1730 assert_eq!(copy.style, Some(ListTileStyle::List));
1731 assert_eq!(copy.selected_color, Some(Color::new(0x00000009)));
1732 assert_eq!(copy.icon_color, Some(AnyColor::new(Color::new(0x0000000A))));
1733 assert_eq!(copy.text_color, Some(AnyColor::new(Color::new(0x0000000B))));
1734 assert_eq!(
1735 copy.title_text_style,
1736 Some(TextStyle::new().color(Color::new(0x0000000C)))
1737 );
1738 assert_eq!(
1739 copy.subtitle_text_style,
1740 Some(TextStyle::new().color(Color::new(0x0000000D)))
1741 );
1742 assert_eq!(
1743 copy.leading_and_trailing_text_style,
1744 Some(TextStyle::new().color(Color::new(0x0000000E)))
1745 );
1746 assert_eq!(copy.content_padding, Some(EdgeInsets::all(500.0).into()));
1747 assert_eq!(copy.tile_color, Some(Color::new(0x0000000F)));
1748 assert_eq!(copy.selected_tile_color, Some(Color::new(0x00000010)));
1749 assert_eq!(copy.horizontal_title_gap, Some(600.0));
1750 assert_eq!(copy.min_vertical_padding, Some(700.0));
1751 assert_eq!(copy.min_leading_width, Some(800.0));
1752 assert_eq!(copy.min_tile_height, Some(80.0));
1753 assert_eq!(copy.enable_feedback, Some(false));
1754 assert_eq!(copy.title_alignment, Some(ListTileTitleAlignment::Top));
1755 assert_eq!(copy.is_three_line, Some(false));
1756 }
1757
1758 #[test]
1759 fn list_tile_theme_title_alignment_is_overridden_by_list_tile_title_alignment() {
1760 test_widgets(|tester| {
1761 let leading_key = GlobalKey::new();
1762 let trailing_key = GlobalKey::new();
1763 pump_app(
1764 tester,
1765 |app| {
1766 ThemeData::builder()
1767 .list_tile_theme(
1768 ListTileThemeData::new()
1769 .title_alignment(ListTileTitleAlignment::Center),
1770 )
1771 .build(app)
1772 },
1773 |_app| {
1774 Material::new()
1775 .child(
1776 Center::new().child(
1777 ListTile::new()
1778 .title_alignment(ListTileTitleAlignment::Top)
1779 .leading(sized(&leading_key, 24.0, 24.0))
1780 .title(Text::new("\nHeadline Text\n"))
1781 .subtitle(Text::new("\nSupporting Text\n"))
1782 .trailing(sized(&trailing_key, 24.0, 24.0)),
1783 ),
1784 )
1785 .into_widget()
1786 },
1787 );
1788 let tile_offset = tile_rect(tester, 0).top_left();
1789 let leading_offset = key_rect(tester, &leading_key).top_left();
1790 let trailing_offset = key_rect(tester, &trailing_key).top_right();
1791 assert_eq!(leading_offset.dy() - tile_offset.dy(), 8.0);
1792 assert_eq!(trailing_offset.dy() - tile_offset.dy(), 8.0);
1793 });
1794 }
1795
1796 #[test]
1797 fn list_tile_theme_merge_supports_all_properties() {
1798 test_widgets(|tester| {
1799 let parent_mouse_cursor = textable();
1800 let mouse_cursor = clickable();
1801 let seen = Rc::new(RefCell::new(None));
1802 pump_app(
1803 tester,
1804 {
1805 let parent_mouse_cursor = Rc::clone(&parent_mouse_cursor);
1806 move |app| {
1807 ThemeData::builder()
1808 .list_tile_theme(
1809 ListTileThemeData::new()
1810 .dense(true)
1811 .shape(StadiumBorder::default())
1812 .style(ListTileStyle::Drawer)
1813 .selected_color(Color::new(0x00000001))
1814 .icon_color(Color::new(0x00000002))
1815 .text_color(Color::new(0x00000003))
1816 .title_text_style(
1817 TextStyle::new().color(Color::new(0x00000004)),
1818 )
1819 .subtitle_text_style(
1820 TextStyle::new().color(Color::new(0x00000005)),
1821 )
1822 .leading_and_trailing_text_style(
1823 TextStyle::new().color(Color::new(0x00000006)),
1824 )
1825 .content_padding(EdgeInsets::all(100.0))
1826 .tile_color(Color::new(0x00000007))
1827 .selected_tile_color(Color::new(0x00000008))
1828 .horizontal_title_gap(200.0)
1829 .min_vertical_padding(300.0)
1830 .min_leading_width(400.0)
1831 .min_tile_height(30.0)
1832 .enable_feedback(true)
1833 .title_alignment(ListTileTitleAlignment::Bottom)
1834 .mouse_cursor(parent_mouse_cursor)
1835 .visual_density(VisualDensity::COMFORTABLE)
1836 .is_three_line(true),
1837 )
1838 .build(app)
1839 }
1840 },
1841 {
1842 let mouse_cursor = Rc::clone(&mouse_cursor);
1843 let seen = Rc::clone(&seen);
1844 move |_app| {
1845 let probe = Builder::new(move |app, context| {
1846 *seen.borrow_mut() = Some(ListTileTheme::of(app, context));
1847 ListTile::new().into_widget()
1848 });
1849 Material::new()
1850 .child(
1851 Center::new().child(
1852 ListTileTheme::merge(probe)
1853 .dense(false)
1854 .shape(RoundedRectangleBorder::default())
1855 .style(ListTileStyle::List)
1856 .selected_color(Color::new(0x00000009))
1857 .icon_color(Color::new(0x0000000A))
1858 .text_color(Color::new(0x0000000B))
1859 .title_text_style(
1860 TextStyle::new().color(Color::new(0x0000000C)),
1861 )
1862 .subtitle_text_style(
1863 TextStyle::new().color(Color::new(0x0000000D)),
1864 )
1865 .leading_and_trailing_text_style(
1866 TextStyle::new().color(Color::new(0x0000000E)),
1867 )
1868 .content_padding(EdgeInsets::all(500.0))
1869 .tile_color(Color::new(0x0000000F))
1870 .selected_tile_color(Color::new(0x00000010))
1871 .horizontal_title_gap(600.0)
1872 .min_vertical_padding(700.0)
1873 .min_leading_width(800.0)
1874 .min_tile_height(80.0)
1875 .enable_feedback(false)
1876 .title_alignment(ListTileTitleAlignment::Top)
1877 .mouse_cursor(mouse_cursor)
1878 .visual_density(VisualDensity::COMPACT)
1879 .is_three_line(false),
1880 ),
1881 )
1882 .into_widget()
1883 }
1884 },
1885 );
1886 let _ = tester;
1887 let theme: ListTileThemeData = seen.borrow_mut().take().expect("built");
1888 assert_eq!(theme.dense, Some(false));
1889 assert_eq!(
1890 theme.shape,
1891 Some(ShapeBorderRef::new(RoundedRectangleBorder::default()))
1892 );
1893 assert_eq!(theme.style, Some(ListTileStyle::List));
1894 assert_eq!(theme.selected_color, Some(Color::new(0x00000009)));
1895 assert_eq!(
1896 theme.icon_color,
1897 Some(AnyColor::new(Color::new(0x0000000A)))
1898 );
1899 assert_eq!(
1900 theme.text_color,
1901 Some(AnyColor::new(Color::new(0x0000000B)))
1902 );
1903 assert_eq!(
1904 theme.title_text_style,
1905 Some(TextStyle::new().color(Color::new(0x0000000C)))
1906 );
1907 assert_eq!(
1908 theme.subtitle_text_style,
1909 Some(TextStyle::new().color(Color::new(0x0000000D)))
1910 );
1911 assert_eq!(
1912 theme.leading_and_trailing_text_style,
1913 Some(TextStyle::new().color(Color::new(0x0000000E)))
1914 );
1915 assert_eq!(theme.content_padding, Some(EdgeInsets::all(500.0).into()));
1916 assert_eq!(theme.tile_color, Some(Color::new(0x0000000F)));
1917 assert_eq!(theme.selected_tile_color, Some(Color::new(0x00000010)));
1918 assert_eq!(theme.horizontal_title_gap, Some(600.0));
1919 assert_eq!(theme.min_vertical_padding, Some(700.0));
1920 assert_eq!(theme.min_leading_width, Some(800.0));
1921 assert_eq!(theme.min_tile_height, Some(80.0));
1922 assert_eq!(theme.enable_feedback, Some(false));
1923 assert_eq!(theme.title_alignment, Some(ListTileTitleAlignment::Top));
1924 assert!(Rc::ptr_eq(
1925 theme.mouse_cursor.as_ref().expect("a mouse cursor"),
1926 &mouse_cursor
1927 ));
1928 assert_eq!(theme.visual_density, Some(VisualDensity::COMPACT));
1929 assert_eq!(theme.is_three_line, Some(false));
1930 });
1931 }
1932
1933 const HEIGHT: f64 = 300.0;
1934 const AVATAR_TOP: f64 = 130.0;
1935 const PLACEHOLDER_TOP: f64 = 138.0;
1936
1937 fn two_line() -> [Rect; 6] {
1938 [
1939 Rect::from_ltwh(0.0, 0.0, 800.0, HEIGHT),
1940 Rect::from_ltwh(16.0, AVATAR_TOP, 40.0, 40.0),
1941 Rect::from_ltwh(800.0 - 24.0 - 24.0, PLACEHOLDER_TOP, 24.0, 24.0),
1942 Rect::from_ltwh(0.0, HEIGHT, 800.0, 72.0),
1943 Rect::from_ltwh(16.0, HEIGHT + 16.0, 40.0, 40.0),
1944 Rect::from_ltwh(800.0 - 24.0 - 24.0, HEIGHT + 24.0, 24.0, 24.0),
1945 ]
1946 }
1947
1948 fn three_line() -> [Rect; 6] {
1949 [
1950 Rect::from_ltwh(0.0, 0.0, 800.0, HEIGHT),
1951 Rect::from_ltwh(16.0, 8.0, 40.0, 40.0),
1952 Rect::from_ltwh(800.0 - 24.0 - 24.0, 8.0, 24.0, 24.0),
1953 Rect::from_ltwh(0.0, HEIGHT, 800.0, 88.0),
1954 Rect::from_ltwh(16.0, HEIGHT + 8.0, 40.0, 40.0),
1955 Rect::from_ltwh(800.0 - 24.0 - 24.0, HEIGHT + 8.0, 24.0, 24.0),
1956 ]
1957 }
1958
1959 fn rects(
1962 tester: &mut WidgetTester,
1963 theme_data_is_three_line: Option<bool>,
1964 theme_is_three_line: Option<bool>,
1965 ) -> [Rect; 6] {
1966 let keys: [GlobalKey; 4] = std::array::from_fn(|_| GlobalKey::new());
1967 crate::list_tile::tests::pump_unique_app(
1968 tester,
1969 |app| {
1970 let mut theme = ThemeData::builder();
1971 if let Some(is_three_line) = theme_data_is_three_line {
1972 theme = theme
1973 .list_tile_theme(ListTileThemeData::new().is_three_line(is_three_line));
1974 }
1975 theme.build(app)
1976 },
1977 |_app| {
1978 let tile = |avatar_key: &GlobalKey, placeholder_key: &GlobalKey, subtitle: &str| {
1979 ListTile::new()
1980 .leading(avatar(avatar_key))
1981 .trailing(placeholder(placeholder_key, 24.0, 24.0))
1982 .title(Text::new("A"))
1983 .subtitle(Text::new(subtitle))
1984 .into_widget()
1985 };
1986 let list = ListView::new().children([
1987 tile(&keys[0], &keys[1], THIRTEEN_LINES),
1988 tile(&keys[2], &keys[3], "A"),
1989 ]);
1990 let child = match theme_is_three_line {
1991 Some(is_three_line) => ListTileTheme::new(list)
1992 .data(ListTileThemeData::new().is_three_line(is_three_line))
1993 .into_widget(),
1994 None => list.into_widget(),
1995 };
1996 Material::new().child(child).into_widget()
1997 },
1998 );
1999 [
2000 tile_rect(tester, 0),
2001 key_rect(tester, &keys[0]),
2002 key_rect(tester, &keys[1]),
2003 tile_rect(tester, 1),
2004 key_rect(tester, &keys[2]),
2005 key_rect(tester, &keys[3]),
2006 ]
2007 }
2008
2009 #[test]
2011 fn list_tile_theme_data_is_three_line() {
2012 test_widgets(|tester| {
2013 assert_eq!(rects(tester, None, None), two_line());
2014 assert_eq!(rects(tester, Some(false), None), two_line());
2015 assert_eq!(rects(tester, Some(true), None), three_line());
2016 });
2017 }
2018
2019 #[test]
2021 fn list_tile_theme_is_three_line() {
2022 test_widgets(|tester| {
2023 assert_eq!(rects(tester, Some(true), Some(false)), two_line());
2024 assert_eq!(rects(tester, None, Some(true)), three_line());
2026 });
2027 }
2028 #[test]
2030 fn a_list_tile_theme_data_describes_nothing_by_default() {
2031 assert_eq!(
2032 waft_widgets::testing::describe_properties(|properties| {
2033 waft_foundation::Diagnosticable::debug_fill_properties(
2034 &ListTileThemeData::new(),
2035 properties,
2036 )
2037 }),
2038 Vec::<String>::new()
2039 );
2040 }
2041
2042 #[test]
2044 fn an_assigned_list_tile_theme_describes_every_property() {
2045 let mouse_cursor: WidgetStatePropertyRef<Option<MouseCursorRef>> = Rc::new(
2046 WidgetStatePropertyAll::new(Some(SystemMouseCursors::CLICK.into())),
2047 );
2048 let theme = ListTileThemeData::new()
2049 .dense(true)
2050 .shape(StadiumBorder::default())
2051 .style(ListTileStyle::Drawer)
2052 .selected_color(Color::new(0x00000001))
2053 .icon_color(AnyColor::new(Color::new(0x00000002)))
2054 .text_color(AnyColor::new(Color::new(0x00000003)))
2055 .title_text_style(TextStyle::new().color(Color::new(0x00000004)))
2056 .subtitle_text_style(TextStyle::new().color(Color::new(0x00000005)))
2057 .leading_and_trailing_text_style(TextStyle::new().color(Color::new(0x00000006)))
2058 .content_padding(EdgeInsetsGeometry::all(100.0))
2059 .tile_color(Color::new(0x00000007))
2060 .selected_tile_color(Color::new(0x00000008))
2061 .horizontal_title_gap(200.0)
2062 .min_vertical_padding(300.0)
2063 .min_leading_width(400.0)
2064 .min_tile_height(30.0)
2065 .enable_feedback(true)
2066 .mouse_cursor(mouse_cursor)
2067 .visual_density(VisualDensity::COMFORTABLE)
2068 .title_alignment(ListTileTitleAlignment::Top)
2069 .is_three_line(true);
2070 let description = waft_widgets::testing::describe_properties(|properties| {
2071 waft_foundation::Diagnosticable::debug_fill_properties(&theme, properties)
2072 });
2073 let description: Vec<String> = description
2074 .iter()
2075 .map(|line| waft_rendering::testing::ignoring_hash_codes(line))
2076 .collect();
2077 assert_eq!(
2078 description,
2079 [
2080 "dense: true".to_string(),
2081 format!("shape: {}", ShapeBorderRef::from(StadiumBorder::default())),
2082 "style: drawer".to_string(),
2083 format!("selectedColor: {}", Color::new(0x00000001)),
2084 format!("iconColor: {}", Color::new(0x00000002)),
2085 format!("textColor: {}", Color::new(0x00000003)),
2086 format!(
2087 "titleTextStyle: {}",
2088 TextStyle::new().color(Color::new(0x00000004))
2089 ),
2090 format!(
2091 "subtitleTextStyle: {}",
2092 TextStyle::new().color(Color::new(0x00000005))
2093 ),
2094 format!(
2095 "leadingAndTrailingTextStyle: {}",
2096 TextStyle::new().color(Color::new(0x00000006))
2097 ),
2098 "contentPadding: EdgeInsets.all(100.0)".to_string(),
2099 format!("tileColor: {}", Color::new(0x00000007)),
2100 format!("selectedTileColor: {}", Color::new(0x00000008)),
2101 "horizontalTitleGap: 200.0".to_string(),
2102 "minVerticalPadding: 300.0".to_string(),
2103 "minLeadingWidth: 400.0".to_string(),
2104 "minTileHeight: 30.0".to_string(),
2105 "enableFeedback: true".to_string(),
2106 "mouseCursor: WidgetStatePropertyAll(SystemMouseCursor(click))".to_string(),
2107 "visualDensity: VisualDensity#00000(h: -1.0, v: -1.0)(horizontal: -1.0, vertical: -1.0)"
2108 .to_string(),
2109 "titleAlignment: ListTileTitleAlignment.top".to_string(),
2110 "isThreeLine: true".to_string(),
2111 ]
2112 );
2113 }
2114}