您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

109 行
3.2KB

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