import 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart'; class AppCustomCheckbox extends StatelessWidget { final String label; final bool value; final ValueChanged onChanged; final double checkboxSize; final double checkmarkSizeFactor; final double fontSize; /// Survol (desktop) ou appui long (mobile) pour afficher un texte d’aide. final String? tooltip; const AppCustomCheckbox({ super.key, required this.label, required this.value, required this.onChanged, this.checkboxSize = 20.0, this.checkmarkSizeFactor = 1.4, this.fontSize = 16.0, this.tooltip, }); @override Widget build(BuildContext context) { return Row( mainAxisSize: MainAxisSize.min, children: [ GestureDetector( onTap: () => onChanged(!value), behavior: HitTestBehavior.opaque, child: Row( mainAxisSize: MainAxisSize.min, children: [ SizedBox( width: checkboxSize, height: checkboxSize, child: Stack( alignment: Alignment.center, clipBehavior: Clip.none, children: [ Image.asset( 'assets/images/square.png', height: checkboxSize, width: checkboxSize, ), if (value) Image.asset( 'assets/images/coche.png', height: checkboxSize * checkmarkSizeFactor, width: checkboxSize * checkmarkSizeFactor, ), ], ), ), const SizedBox(width: 10), Flexible( child: Text( label, style: GoogleFonts.merienda(fontSize: fontSize), overflow: TextOverflow.ellipsis, ), ), ], ), ), if (tooltip != null && tooltip!.trim().isNotEmpty) ...[ const SizedBox(width: 6), Tooltip( message: tooltip!.trim(), waitDuration: const Duration(milliseconds: 300), triggerMode: TooltipTriggerMode.tap, showDuration: const Duration(seconds: 6), child: Icon( Icons.info_outline, size: fontSize * 1.2, color: Colors.black54, ), ), ], ], ); } }