update
This commit is contained in:
parent
cb48d0db48
commit
adb6c2d20b
|
|
@ -32,4 +32,19 @@ class ItemUtils {
|
||||||
return 'assets/images/icons/potions/potion_blue.png';
|
return 'assets/images/icons/potions/potion_blue.png';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static String getBorderPath(ItemRarity rarity) {
|
||||||
|
switch (rarity) {
|
||||||
|
case ItemRarity.normal:
|
||||||
|
return 'assets/images/icons/borders/border_000.png';
|
||||||
|
case ItemRarity.magic:
|
||||||
|
return 'assets/images/icons/borders/border_001.png';
|
||||||
|
case ItemRarity.rare:
|
||||||
|
return 'assets/images/icons/borders/border_004.png';
|
||||||
|
case ItemRarity.legendary:
|
||||||
|
return 'assets/images/icons/borders/border_005.png';
|
||||||
|
case ItemRarity.unique:
|
||||||
|
return 'assets/images/icons/borders/border_014.png';
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import '../common/custom_icon_button.dart';
|
import '../common/custom_button_widget.dart';
|
||||||
|
|
||||||
class BattleControls extends StatelessWidget {
|
class BattleControls extends StatelessWidget {
|
||||||
final bool isAttackEnabled;
|
final bool isAttackEnabled;
|
||||||
|
|
@ -23,25 +23,52 @@ class BattleControls extends StatelessWidget {
|
||||||
return Column(
|
return Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
CustomIconButton(
|
CustomButtonWidget(
|
||||||
iconPath: 'assets/images/icons/weapons/sword_02.png',
|
width: 64,
|
||||||
isEnabled: isAttackEnabled,
|
height: 64,
|
||||||
onTap: onAttackPressed,
|
padding: const EdgeInsets.all(12),
|
||||||
iconColor: Colors.white,
|
onTap: isAttackEnabled ? onAttackPressed : null,
|
||||||
|
child: Opacity(
|
||||||
|
opacity: isAttackEnabled ? 1.0 : 0.5,
|
||||||
|
child: Image.asset(
|
||||||
|
'assets/images/icons/weapons/sword_02.png',
|
||||||
|
color: Colors.white,
|
||||||
|
fit: BoxFit.contain,
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
CustomIconButton(
|
CustomButtonWidget(
|
||||||
iconPath: 'assets/images/icons/subweapons/shield_01.png',
|
width: 64,
|
||||||
isEnabled: isDefendEnabled,
|
height: 64,
|
||||||
onTap: onDefendPressed,
|
padding: const EdgeInsets.all(12),
|
||||||
iconColor: Colors.white,
|
onTap: isDefendEnabled ? onDefendPressed : null,
|
||||||
|
child: Opacity(
|
||||||
|
opacity: isDefendEnabled ? 1.0 : 0.5,
|
||||||
|
child: Image.asset(
|
||||||
|
'assets/images/icons/subweapons/shield_02.png',
|
||||||
|
color: Colors.white,
|
||||||
|
fit: BoxFit.contain,
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
CustomIconButton(
|
CustomButtonWidget(
|
||||||
iconPath: 'assets/images/icons/potions/potion_blue.png',
|
width: 64,
|
||||||
isEnabled: isAttackEnabled, // Enabled when it's player turn
|
height: 64,
|
||||||
onTap: onItemPressed,
|
padding: const EdgeInsets.all(12),
|
||||||
iconColor: Colors.white,
|
onTap:
|
||||||
|
onItemPressed, // Item usually always enabled or managed by parent? Sticking to logic
|
||||||
|
child: Opacity(
|
||||||
|
opacity: isAttackEnabled
|
||||||
|
? 1.0
|
||||||
|
: 0.5, // Using AttackEnabled as proxy for "Player Turn"? Text implies "Enabled when it's player turn"
|
||||||
|
child: Image.asset(
|
||||||
|
'assets/images/icons/potions/potion_blue.png',
|
||||||
|
color: Colors.white,
|
||||||
|
fit: BoxFit.contain,
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,54 @@
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class CustomButtonWidget extends StatelessWidget {
|
||||||
|
final Widget child;
|
||||||
|
final VoidCallback? onTap;
|
||||||
|
final String imagePath;
|
||||||
|
final double? width;
|
||||||
|
final double? height;
|
||||||
|
final EdgeInsetsGeometry padding;
|
||||||
|
final Color? backgroundColor;
|
||||||
|
|
||||||
|
const CustomButtonWidget({
|
||||||
|
super.key,
|
||||||
|
required this.child,
|
||||||
|
this.onTap,
|
||||||
|
this.imagePath = 'assets/images/icons/borders/border_000.png',
|
||||||
|
this.width,
|
||||||
|
this.height,
|
||||||
|
this.padding = EdgeInsets.zero,
|
||||||
|
this.backgroundColor,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return GestureDetector(
|
||||||
|
onTap: onTap,
|
||||||
|
behavior: HitTestBehavior.opaque,
|
||||||
|
child: SizedBox(
|
||||||
|
width: width,
|
||||||
|
height: height,
|
||||||
|
child: Stack(
|
||||||
|
children: [
|
||||||
|
// Background Color
|
||||||
|
if (backgroundColor != null)
|
||||||
|
Positioned.fill(child: Container(color: backgroundColor)),
|
||||||
|
// Background Image (Border)
|
||||||
|
Positioned.fill(
|
||||||
|
child: Image.asset(
|
||||||
|
imagePath,
|
||||||
|
fit: BoxFit.fill,
|
||||||
|
filterQuality: FilterQuality.high,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
// Content
|
||||||
|
Padding(
|
||||||
|
padding: padding,
|
||||||
|
child: Center(child: child),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,26 @@
|
||||||
|
# Custom Button Widget & Asset Implementation
|
||||||
|
|
||||||
|
> Restoration of Prompt 69
|
||||||
|
|
||||||
|
## Goal
|
||||||
|
|
||||||
|
Implement a unified `CustomButtonWidget` that utilizes game assets (borders/panels) for a consistent UI look, and apply it to both `ItemCardWidget` and `BattleControls`.
|
||||||
|
|
||||||
|
## Tasks
|
||||||
|
|
||||||
|
1. **Create `CustomButtonWidget`** (`lib/widgets/common/custom_button_widget.dart`)
|
||||||
|
- Should support an image background (`assets/images/icons/borders/...`).
|
||||||
|
- Should support `onTap`.
|
||||||
|
- Should support arbitrary `child` content.
|
||||||
|
- Should support `size` or adaptive sizing.
|
||||||
|
- Optional: Support "Icon Button" mode for convenience or just composability.
|
||||||
|
|
||||||
|
2. **Refactor `BattleControls`** (`lib/widgets/battle/battle_controls.dart`)
|
||||||
|
- Replace `CustomIconButton` with `CustomButtonWidget` (or wrap content in it).
|
||||||
|
- Use appropriate border assets (e.g., `border_000.png` or specialized ones).
|
||||||
|
|
||||||
|
3. **Refactor `ItemCardWidget`** (`lib/widgets/common/item_card_widget.dart`)
|
||||||
|
- (Cancelled) User decided to keep the current version of ItemCardWidget without CustomButtonWidget integration.
|
||||||
|
|
||||||
|
4. **Asset Verification**
|
||||||
|
- Ensure `assets/images/icons/borders/` and `panel-border-...` are used correctly.
|
||||||
Loading…
Reference in New Issue