import 'package:flutter/material.dart'; import '../../game/enums.dart'; import '../../game/config.dart'; class BattleControls extends StatelessWidget { final bool isAttackEnabled; final bool isDefendEnabled; final VoidCallback onAttackPressed; final VoidCallback onDefendPressed; const BattleControls({ super.key, required this.isAttackEnabled, required this.isDefendEnabled, required this.onAttackPressed, required this.onDefendPressed, }); Widget _buildFloatingActionButton({ required String label, required Color color, required ActionType actionType, required bool isEnabled, required VoidCallback onPressed, }) { String iconPath; if (actionType == ActionType.attack) { iconPath = 'assets/data/icon/icon_weapon.png'; } else { iconPath = 'assets/data/icon/icon_shield.png'; } return FloatingActionButton( heroTag: label, onPressed: isEnabled ? onPressed : null, backgroundColor: isEnabled ? color : ThemeConfig.btnDisabled, child: Image.asset( iconPath, width: 32, height: 32, color: ThemeConfig.textColorWhite, // Tint icon white fit: BoxFit.contain, filterQuality: FilterQuality.high, ), ); } @override Widget build(BuildContext context) { return Column( mainAxisSize: MainAxisSize.min, children: [ _buildFloatingActionButton( label: "ATK", color: ThemeConfig.btnActionActive, actionType: ActionType.attack, isEnabled: isAttackEnabled, onPressed: onAttackPressed, ), const SizedBox(height: 16), _buildFloatingActionButton( label: "DEF", color: ThemeConfig.btnDefendActive, actionType: ActionType.defend, isEnabled: isDefendEnabled, onPressed: onDefendPressed, ), ], ); } }