import 'package:flutter/material.dart'; import '../../../../core/protocol/sensor_state.dart'; class FlagPill extends StatelessWidget { final String label; final bool active; final Color color; const FlagPill({ super.key, required this.label, required this.active, required this.color, }); @override Widget build(BuildContext context) { return AnimatedContainer( duration: const Duration(milliseconds: 100), padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 5), decoration: BoxDecoration( color: active ? color.withAlpha(40) : const Color(0xFF1A1A1A), borderRadius: BorderRadius.circular(20), border: Border.all( color: active ? color : Colors.white12, width: 1.5, ), ), child: Text( label, style: TextStyle( color: active ? color : Colors.grey, fontSize: 11, fontWeight: active ? FontWeight.bold : FontWeight.normal, letterSpacing: 1, ), ), ); } } /// Row of all flag pills derived from a SensorState. class FlagRow extends StatelessWidget { final SensorState state; final Color accentColor; const FlagRow({super.key, required this.state, required this.accentColor}); @override Widget build(BuildContext context) { return Wrap( spacing: 6, runSpacing: 6, alignment: WrapAlignment.center, children: [ FlagPill(label: 'MIL', active: state.mil, color: Colors.amber), FlagPill(label: 'VTEC', active: state.vtec, color: Colors.blue), FlagPill(label: 'KNOCK', active: state.knock, color: Colors.red), FlagPill(label: 'FUEL CUT', active: state.fuelCut, color: Colors.red), FlagPill(label: 'REV LIM', active: state.revLimit, color: Colors.orange), FlagPill(label: 'FAN', active: state.fanOut, color: Colors.green), FlagPill(label: 'LAUNCH', active: state.launch, color: Colors.purple), ], ); } }