You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

101 line
3.2KB

  1. // lib/presentation/widgets/creation_flow_layout.dart
  2. import 'package:flutter/material.dart';
  3. class CreationProgressIndicator extends StatelessWidget {
  4. const CreationProgressIndicator({ required this.currentStep, super.key,
  5. this.totalSteps = 3,
  6. });
  7. final int currentStep;
  8. final int totalSteps;
  9. @override
  10. Widget build(BuildContext context) => Padding(
  11. padding: const EdgeInsets.symmetric(vertical: 16),
  12. // --- MODIFICATION 1 : On centre la Row principale ---
  13. child: Center(
  14. child: Row(
  15. // On s'assure que la Row ne prend que la place nécessaire
  16. mainAxisSize: MainAxisSize.min,
  17. children: List.generate(totalSteps, (index) {
  18. final isActive = index == currentStep;
  19. final isCompleted = index < currentStep;
  20. final isLast = index == totalSteps - 1;
  21. // --- MODIFICATION 2 : Chaque segment a maintenant une largeur fixe ---
  22. return Row(
  23. children: [
  24. // Le cercle de l'étape
  25. Container(
  26. height: 24,
  27. width: 24,
  28. decoration: BoxDecoration(
  29. shape: BoxShape.circle,
  30. color: isActive || isCompleted
  31. ? Theme.of(context).primaryColor
  32. : Theme.of(context).colorScheme.surfaceContainerHighest,
  33. ),
  34. child: Center(
  35. child: isCompleted
  36. ? const Icon(Icons.check, color: Colors.white, size: 16)
  37. : Text(
  38. '${index + 1}',
  39. style: TextStyle(
  40. color: isActive
  41. ? Colors.white
  42. : Theme.of(context).colorScheme.onSurfaceVariant,
  43. fontWeight: FontWeight.bold,
  44. ),
  45. ),
  46. ),
  47. ),
  48. // La ligne de connexion (sauf pour la dernière)
  49. if (!isLast)
  50. Container(
  51. // On donne une largeur fixe à la ligne de connexion
  52. width: 60,
  53. height: 2,
  54. margin: const EdgeInsets.symmetric(horizontal: 8),
  55. color: isCompleted
  56. ? Theme.of(context).primaryColor
  57. : Theme.of(context).colorScheme.surfaceContainerHighest,
  58. ),
  59. ],
  60. );
  61. }),
  62. ),
  63. ),
  64. );
  65. }
  66. // Le reste du fichier CreationFlowLayout reste inchangé
  67. class CreationFlowLayout extends StatelessWidget {
  68. const CreationFlowLayout({
  69. required this.currentStep, required this.title, required this.child, super.key,
  70. });
  71. final int currentStep;
  72. final String title;
  73. final Widget child;
  74. @override
  75. Widget build(BuildContext context) => Scaffold(
  76. appBar: AppBar(
  77. title: Text(title),
  78. elevation: 0,
  79. centerTitle: true,
  80. ),
  81. body: Column(
  82. children: [
  83. CreationProgressIndicator(currentStep: currentStep),
  84. const Divider(height: 1),
  85. Expanded(
  86. child: child,
  87. ),
  88. ],
  89. ),
  90. );
  91. }