/// UnionFlow Switch Tile - Ligne de paramètre avec switch /// /// Tile avec titre, description et switch pour les paramètres library uf_switch_tile; import 'package:flutter/material.dart'; import '../../unionflow_design_system.dart'; /// Tile de paramètre avec switch /// /// Usage: /// ```dart /// UFSwitchTile( /// title: 'Notifications', /// subtitle: 'Activer les notifications push', /// value: true, /// onChanged: (value) => setState(() => _notifications = value), /// ) /// ``` class UFSwitchTile extends StatelessWidget { /// Titre du paramètre final String title; /// Description du paramètre final String subtitle; /// Valeur actuelle du switch final bool value; /// Callback appelé lors du changement final ValueChanged? onChanged; /// Couleur de fond (par défaut: surfaceVariant) final Color? backgroundColor; const UFSwitchTile({ super.key, required this.title, required this.subtitle, required this.value, this.onChanged, this.backgroundColor, }); @override Widget build(BuildContext context) { final isDark = Theme.of(context).brightness == Brightness.dark; final effectiveBgColor = backgroundColor ?? (isDark ? AppColors.surfaceDark : AppColors.surface); return Container( margin: const EdgeInsets.only(bottom: SpacingTokens.lg), padding: const EdgeInsets.all(SpacingTokens.lg), decoration: BoxDecoration( color: effectiveBgColor, borderRadius: BorderRadius.circular(SpacingTokens.radiusLg), ), child: Row( children: [ Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( title, style: AppTypography.bodyTextSmall.copyWith( fontWeight: FontWeight.w600, color: isDark ? AppColors.textPrimaryDark : AppColors.textPrimary, ), ), Text( subtitle, style: AppTypography.subtitleSmall.copyWith( color: isDark ? AppColors.textSecondaryDark : AppColors.textSecondary, ), ), ], ), ), Switch( value: value, onChanged: onChanged, activeColor: AppColors.primary, ), ], ), ); } }