77 lines
2.2 KiB
Dart
77 lines
2.2 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import '../../game/config.dart';
|
|
|
|
class BattleControls extends StatelessWidget {
|
|
final bool isAttackEnabled;
|
|
final bool isDefendEnabled;
|
|
final VoidCallback onAttackPressed;
|
|
final VoidCallback onDefendPressed;
|
|
final VoidCallback onItemPressed; // New
|
|
|
|
const BattleControls({
|
|
super.key,
|
|
required this.isAttackEnabled,
|
|
required this.isDefendEnabled,
|
|
required this.onAttackPressed,
|
|
required this.onDefendPressed,
|
|
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',
|
|
isEnabled: isAttackEnabled,
|
|
onPressed: onAttackPressed,
|
|
),
|
|
const SizedBox(height: 16),
|
|
_buildFloatingActionButton(
|
|
label: "DEF",
|
|
color: ThemeConfig.btnDefendActive,
|
|
iconPath: 'assets/data/icon/icon_shield.png',
|
|
isEnabled: isDefendEnabled,
|
|
onPressed: onDefendPressed,
|
|
),
|
|
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,
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|