update
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../game/config.dart';
|
||||
import '../common/custom_icon_button.dart';
|
||||
|
||||
class BattleControls extends StatelessWidget {
|
||||
final bool isAttackEnabled;
|
||||
@@ -18,57 +18,30 @@ class BattleControls extends StatelessWidget {
|
||||
required this.onItemPressed, // New
|
||||
});
|
||||
|
||||
Widget _buildFloatingActionButton({
|
||||
required String label,
|
||||
required Color color,
|
||||
required String iconPath, // Changed from ActionType to String
|
||||
required bool isEnabled,
|
||||
required VoidCallback onPressed,
|
||||
}) {
|
||||
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,
|
||||
iconPath: 'assets/data/icon/icon_weapon.png',
|
||||
CustomIconButton(
|
||||
iconPath: 'assets/images/icons/weapons/sword_02.png',
|
||||
isEnabled: isAttackEnabled,
|
||||
onPressed: onAttackPressed,
|
||||
onTap: onAttackPressed,
|
||||
iconColor: Colors.white,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
_buildFloatingActionButton(
|
||||
label: "DEF",
|
||||
color: ThemeConfig.btnDefendActive,
|
||||
iconPath: 'assets/data/icon/icon_shield.png',
|
||||
CustomIconButton(
|
||||
iconPath: 'assets/images/icons/subweapons/shield_01.png',
|
||||
isEnabled: isDefendEnabled,
|
||||
onPressed: onDefendPressed,
|
||||
onTap: onDefendPressed,
|
||||
iconColor: Colors.white,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
_buildFloatingActionButton(
|
||||
label: "ITEM",
|
||||
color: Colors.indigoAccent, // Distinct color for Item
|
||||
iconPath:
|
||||
'assets/data/icon/icon_accessory.png', // Placeholder for Bag
|
||||
isEnabled:
|
||||
isAttackEnabled, // Enabled when it's player turn (same as attack)
|
||||
onPressed: onItemPressed,
|
||||
CustomIconButton(
|
||||
iconPath: 'assets/images/icons/potions/potion_blue.png',
|
||||
isEnabled: isAttackEnabled, // Enabled when it's player turn
|
||||
onTap: onItemPressed,
|
||||
iconColor: Colors.white,
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user