diff --git a/example/lib/src/containers/containers_view.dart b/example/lib/src/containers/containers_view.dart index 0c10ecb..9024132 100644 --- a/example/lib/src/containers/containers_view.dart +++ b/example/lib/src/containers/containers_view.dart @@ -3,6 +3,13 @@ import 'package:flutter/material.dart'; import '../build_context_x.dart'; import '../constants.dart'; +final _icons = [ + Icons.add_reaction_sharp, + Icons.yard, + Icons.baby_changing_station, + Icons.cabin, +]; + class ContainersView extends StatefulWidget { const ContainersView({super.key}); @@ -13,12 +20,8 @@ class ContainersView extends StatefulWidget { class _ContainersViewState extends State { var _elevation = 2.0; var _inDialog = true; - final _icons = [ - Icons.add_reaction_sharp, - Icons.yard, - Icons.baby_changing_station, - Icons.cabin, - ]; + + final _selected = List.generate(_icons.length, (index) => false); @override Widget build(BuildContext context) { @@ -89,6 +92,8 @@ class _ContainersViewState extends State { containerWithBorder, for (var i = 0; i < _icons.length; i++) ListTile( + selected: _selected[i], + onTap: () => setState(() => _selected[i] = !_selected[i]), leading: Icon(_icons[i]), title: Text('ListTile title $i'), subtitle: i.isEven ? null : const Text('Subtitle'), diff --git a/example/pubspec.lock b/example/pubspec.lock index d835789..23d5010 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -209,4 +209,4 @@ packages: version: "14.2.5" sdks: dart: ">=3.3.0 <4.0.0" - flutter: ">=3.24.0" + flutter: ">=3.24.3" diff --git a/lib/src/theme.dart b/lib/src/theme.dart index 346930c..66d4d13 100644 --- a/lib/src/theme.dart +++ b/lib/src/theme.dart @@ -118,6 +118,7 @@ ThemeData _phoenixTheme({ cardTheme: _cardTheme(colorScheme), drawerTheme: _drawerTheme(colorScheme), inputDecorationTheme: _inputDecorationTheme(colorScheme), + listTileTheme: _createListTileTheme(colorScheme), ); } @@ -548,3 +549,25 @@ SnackBarThemeData _snackBarThemeData(ColorScheme colorScheme) { ), ); } + +ListTileThemeData _createListTileTheme(ColorScheme colorScheme) { + final isHighContrast = + [Colors.black, Colors.white].contains(colorScheme.primary); + + return ListTileThemeData( + selectedColor: + isHighContrast ? colorScheme.onInverseSurface : colorScheme.onSurface, + iconColor: colorScheme.onSurface.withOpacity(0.8), + selectedTileColor: isHighContrast + ? colorScheme.inverseSurface + : colorScheme.onSurface.withOpacity( + colorScheme.brightness == Brightness.dark ? 0.035 : 0.04, + ), + minVerticalPadding: 6, + visualDensity: const VisualDensity(horizontal: -4, vertical: -4), + shape: const RoundedRectangleBorder( + borderRadius: BorderRadius.all(Radius.circular(6)), + side: BorderSide.none, + ), + ); +}