import 'package:flutter/material.dart'; import '../../../../core/theme/app_theme.dart'; import '../../../../core/constants/asset_paths.dart'; class PlateCounter extends StatelessWidget { final double weight; final int count; final ValueChanged onChanged; const PlateCounter({ super.key, required this.weight, required this.count, required this.onChanged, }); Color _getPlateColor() { final colorValue = PlateColors.colors[weight]; return colorValue != null ? Color(colorValue) : Colors.grey; } Color _getTextColor(double weight) { if (weight == 5.0) { return Colors.black; } if (weight <= 2.5) { return Colors.white70; } return Colors.white; } @override Widget build(BuildContext context) { return Card( margin: const EdgeInsets.only(bottom: 8), child: Padding( padding: const EdgeInsets.all(12), child: Row( children: [ Container( width: 48, height: 48, decoration: BoxDecoration( color: _getPlateColor(), shape: BoxShape.circle, border: Border.all( color: Colors.white24, width: 2, ), ), child: Center( child: Text( weight == weight.toInt() ? '${weight.toInt()}' : weight.toStringAsFixed(2), style: TextStyle( color: _getTextColor(weight), fontWeight: FontWeight.bold, fontSize: 12, ), ), ), ), const SizedBox(width: 16), Expanded( child: Text( '${weight.toStringAsFixed(weight == weight.toInt() ? 0 : 2)} kg', style: Theme.of(context).textTheme.bodyLarge, ), ), IconButton( icon: const Icon(Icons.remove_circle_outline), onPressed: count > 0 ? () => onChanged(count - 1) : null, color: AppTheme.primaryColor, ), Container( width: 40, height: 40, alignment: Alignment.center, decoration: BoxDecoration( color: AppTheme.primaryColor.withValues(alpha: 0.1), borderRadius: BorderRadius.circular(8), border: Border.all( color: AppTheme.primaryColor.withValues(alpha: 0.3)), ), child: Text( count.toString(), style: Theme.of(context).textTheme.titleLarge?.copyWith( color: Colors.white, fontWeight: FontWeight.bold, ), textAlign: TextAlign.center, ), ), IconButton( icon: const Icon(Icons.add_circle_outline), onPressed: count < 20 ? () => onChanged(count + 1) : null, color: AppTheme.primaryColor, ), ], ), ), ); } }