85 lines
2.4 KiB
Dart
85 lines
2.4 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
import '../../../core/theme/app_colors.dart';
|
|
import '../../../core/theme/app_typography.dart';
|
|
import '../../rides/ride_state_machine.dart';
|
|
|
|
/// Authoritative ride status badge/chip.
|
|
///
|
|
/// Subscribes strictly to [rideStateMachineProvider.select((s) => s.state)]
|
|
/// to prevent rebuilding on 20 Hz telemetry ticks.
|
|
class RideStatusChip extends ConsumerWidget {
|
|
const RideStatusChip({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
|
final state = ref.watch(
|
|
rideStateMachineProvider.select((s) => s.state),
|
|
);
|
|
|
|
final isRecording = state == RideState.riding;
|
|
final isPaused = state == RideState.paused;
|
|
|
|
final Color badgeColor;
|
|
final String label;
|
|
|
|
if (isRecording) {
|
|
badgeColor = AppColors.raceRed;
|
|
label = 'RECORDING';
|
|
} else if (isPaused) {
|
|
badgeColor = AppColors.warningAmber;
|
|
label = 'PAUSED';
|
|
} else if (state == RideState.ready) {
|
|
badgeColor = AppColors.cyberCyan;
|
|
label = 'READY';
|
|
} else {
|
|
badgeColor = Colors.white54;
|
|
label = 'STANDBY';
|
|
}
|
|
|
|
return Container(
|
|
padding: const EdgeInsets.symmetric(horizontal: 9, vertical: 4),
|
|
decoration: BoxDecoration(
|
|
color: badgeColor.withValues(alpha: isRecording ? 0.18 : 0.10),
|
|
borderRadius: BorderRadius.circular(6),
|
|
border: Border.all(
|
|
color: badgeColor.withValues(alpha: isRecording ? 0.8 : 0.35),
|
|
width: 1.0,
|
|
),
|
|
),
|
|
child: Row(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Container(
|
|
width: 7,
|
|
height: 7,
|
|
decoration: BoxDecoration(
|
|
shape: BoxShape.circle,
|
|
color: badgeColor,
|
|
boxShadow: isRecording
|
|
? [
|
|
BoxShadow(
|
|
color: badgeColor.withValues(alpha: 0.6),
|
|
blurRadius: 6,
|
|
),
|
|
]
|
|
: null,
|
|
),
|
|
),
|
|
const SizedBox(width: 6),
|
|
Text(
|
|
label,
|
|
style: TextStyle(
|
|
fontFamily: AppTypography.fontTelemetry,
|
|
fontSize: 10,
|
|
fontWeight: FontWeight.w800,
|
|
color: badgeColor,
|
|
letterSpacing: 0.6,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|