71 lines
2.0 KiB
Dart
71 lines
2.0 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
/// Barre de temps présentational — le décompte est piloté par le parent
|
|
/// (GuidedStepChallengeController), en miroir de `StepTimer` de visitapp-web.
|
|
class GuidedStepTimer extends StatelessWidget {
|
|
final int totalSeconds;
|
|
final int remainingSeconds;
|
|
final bool isGame;
|
|
|
|
const GuidedStepTimer({
|
|
Key? key,
|
|
required this.totalSeconds,
|
|
required this.remainingSeconds,
|
|
this.isGame = false,
|
|
}) : super(key: key);
|
|
|
|
static String _format(int s) {
|
|
final m = s ~/ 60;
|
|
final r = s % 60;
|
|
return '$m:${r.toString().padLeft(2, '0')}';
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final pct = totalSeconds > 0 ? remainingSeconds / totalSeconds : 0.0;
|
|
final color = pct > 0.5
|
|
? const Color(0xFF16A34A)
|
|
: pct > 0.25
|
|
? const Color(0xFFF59E0B)
|
|
: const Color(0xFFDC2626);
|
|
|
|
return Column(
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
children: [
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Text(
|
|
'Temps restant',
|
|
style: TextStyle(
|
|
fontSize: 12,
|
|
color: isGame ? const Color(0xFF8a8068) : const Color(0xFF6B7B86),
|
|
),
|
|
),
|
|
Text(
|
|
_format(remainingSeconds),
|
|
style: TextStyle(
|
|
fontSize: 13,
|
|
fontWeight: FontWeight.w700,
|
|
fontFeatures: const [FontFeature.tabularFigures()],
|
|
color: color,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
const SizedBox(height: 4),
|
|
ClipRRect(
|
|
borderRadius: BorderRadius.circular(4),
|
|
child: LinearProgressIndicator(
|
|
value: pct.clamp(0.0, 1.0),
|
|
minHeight: 8,
|
|
backgroundColor:
|
|
isGame ? Colors.white.withOpacity(0.1) : const Color(0xFFE2DCD2),
|
|
valueColor: AlwaysStoppedAnimation<Color>(color),
|
|
),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|