Fixed custom list tile disabled

This commit is contained in:
Juan Gilsanz Polo 2023-02-04 20:50:14 +01:00
parent eebcec329b
commit cffdd6244e
2 changed files with 13 additions and 10 deletions

View file

@ -304,6 +304,7 @@ class _LogsFiltersModalWidgetState extends State<LogsFiltersModalWidget> {
onTap: logsProvider.clientsLoadStatus == 1 onTap: logsProvider.clientsLoadStatus == 1
? openSelectClients ? openSelectClients
: null, : null,
disabled: logsProvider.clientsLoadStatus != 1 ,
icon: Icons.smartphone_rounded, icon: Icons.smartphone_rounded,
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 12), padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 12),
trailing: logsProvider.clientsLoadStatus == 0 trailing: logsProvider.clientsLoadStatus == 0

View file

@ -9,6 +9,7 @@ class CustomListTile extends StatelessWidget {
final Widget? trailing; final Widget? trailing;
final EdgeInsets? padding; final EdgeInsets? padding;
final void Function()? onLongPress; final void Function()? onLongPress;
final bool? disabled;
const CustomListTile({ const CustomListTile({
Key? key, Key? key,
@ -19,7 +20,8 @@ class CustomListTile extends StatelessWidget {
this.icon, this.icon,
this.trailing, this.trailing,
this.padding, this.padding,
this.onLongPress this.onLongPress,
this.disabled
}) : super(key: key); }) : super(key: key);
@override @override
@ -42,9 +44,9 @@ class CustomListTile extends StatelessWidget {
Icon( Icon(
icon, icon,
size: 24, size: 24,
color: onTap != null || onLongPress != null color: disabled == true
? Theme.of(context).listTileTheme.iconColor ? Theme.of(context).colorScheme.onSurface.withOpacity(0.38)
: Theme.of(context).colorScheme.onSurface.withOpacity(0.38), : Theme.of(context).listTileTheme.iconColor,
), ),
const SizedBox(width: 16), const SizedBox(width: 16),
], ],
@ -57,9 +59,9 @@ class CustomListTile extends StatelessWidget {
style: TextStyle( style: TextStyle(
fontSize: 16, fontSize: 16,
fontWeight: FontWeight.w400, fontWeight: FontWeight.w400,
color: onTap != null || onLongPress != null color: disabled == true
? Theme.of(context).colorScheme.onSurface ? Theme.of(context).colorScheme.onSurface.withOpacity(0.38)
: Theme.of(context).colorScheme.onSurface.withOpacity(0.38), : Theme.of(context).colorScheme.onSurface,
), ),
), ),
if (subtitle != null || subtitleWidget != null) ...[ if (subtitle != null || subtitleWidget != null) ...[
@ -68,9 +70,9 @@ class CustomListTile extends StatelessWidget {
if (subtitle != null && subtitleWidget == null) Text( if (subtitle != null && subtitleWidget == null) Text(
subtitle!, subtitle!,
style: TextStyle( style: TextStyle(
color: onTap != null || onLongPress != null color: disabled == true
? Theme.of(context).colorScheme.onSurfaceVariant ? Theme.of(context).colorScheme.onSurfaceVariant.withOpacity(0.38)
: Theme.of(context).colorScheme.onSurfaceVariant.withOpacity(0.38), : Theme.of(context).colorScheme.onSurfaceVariant,
fontSize: 14, fontSize: 14,
fontWeight: FontWeight.w400 fontWeight: FontWeight.w400
), ),