import 'package:flutter/material.dart'; /// Widget de liste personnalisé avec support du thème et animations. /// /// Ce widget fournit un élément de liste cohérent avec le design system, /// utilisant automatiquement les couleurs du thème actif. /// /// **Usage:** /// ```dart /// CustomListTile( /// icon: Icons.settings, /// label: 'Paramètres', /// onTap: () { /// // Action /// }, /// ) /// ``` class CustomListTile extends StatelessWidget { /// Crée un nouveau [CustomListTile]. /// /// [icon] L'icône à afficher à gauche /// [label] Le texte à afficher /// [onTap] La fonction à exécuter lors du clic /// [trailing] Un widget optionnel à afficher à droite /// [subtitle] Un sous-titre optionnel /// [iconColor] Couleur personnalisée pour l'icône (optionnel) const CustomListTile({ required this.icon, required this.label, required this.onTap, super.key, this.trailing, this.subtitle, this.iconColor, }); /// L'icône à afficher à gauche final IconData icon; /// Le texte à afficher final String label; /// La fonction à exécuter lors du clic final VoidCallback? onTap; /// Un widget optionnel à afficher à droite final Widget? trailing; /// Un sous-titre optionnel final String? subtitle; /// Couleur personnalisée pour l'icône (optionnel) final Color? iconColor; @override Widget build(BuildContext context) { final theme = Theme.of(context); final isEnabled = onTap != null; return InkWell( onTap: onTap, borderRadius: BorderRadius.circular(12), child: ListTile( leading: CircleAvatar( backgroundColor: (iconColor ?? theme.colorScheme.primary) .withOpacity(0.1), child: Icon( icon, color: iconColor ?? theme.colorScheme.primary, size: 20, ), ), title: Text( label, style: theme.textTheme.titleMedium?.copyWith( fontWeight: FontWeight.w600, color: isEnabled ? theme.colorScheme.onSurface : theme.colorScheme.onSurface.withOpacity(0.38), ), ), subtitle: subtitle != null ? Text( subtitle!, style: theme.textTheme.bodySmall?.copyWith( color: theme.colorScheme.onSurface.withOpacity(0.6), ), ) : null, trailing: trailing ?? (isEnabled ? Icon( Icons.chevron_right, color: theme.colorScheme.onSurface.withOpacity(0.5), ) : null), contentPadding: const EdgeInsets.symmetric( horizontal: 16, vertical: 8, ), ), ); } }