feat: add subweapon support, weapon type logic, and compact item card UI options

This commit is contained in:
2026-04-28 01:39:39 +09:00
parent 0420e23939
commit 0e0748540e
46 changed files with 1795 additions and 577 deletions
+63 -13
View File
@@ -9,6 +9,7 @@ class ItemCardWidget extends StatelessWidget {
final VoidCallback? onTap;
final bool showPrice;
final bool canBuy;
final bool compact;
const ItemCardWidget({
super.key,
@@ -16,6 +17,7 @@ class ItemCardWidget extends StatelessWidget {
this.onTap,
this.showPrice = false,
this.canBuy = true,
this.compact = false,
});
@override
@@ -38,12 +40,12 @@ class ItemCardWidget extends StatelessWidget {
children: [
// Background Watermark/Silhouette Icon (Top-Left)
Positioned(
left: 8,
top: 8,
left: compact ? 4 : 8,
top: compact ? 4 : 8,
child: Image.asset(
ItemUtils.getIconPath(item.slot),
width: 32,
height: 32,
width: compact ? 24 : 32,
height: compact ? 24 : 32,
fit: BoxFit.contain,
color: Colors.black12, // Shadow silhouette
),
@@ -51,12 +53,12 @@ class ItemCardWidget extends StatelessWidget {
// Main Content (Centered)
Center(
child: Padding(
padding: const EdgeInsets.all(4.0),
padding: EdgeInsets.all(compact ? 2.0 : 4.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const SizedBox(height: 12),
if (!compact) const SizedBox(height: 12),
Text(
item.name,
maxLines: 1,
@@ -65,15 +67,23 @@ class ItemCardWidget extends StatelessWidget {
style: TextStyle(
fontWeight: FontWeight.bold,
color: ItemUtils.getRarityColor(item.rarity),
fontSize: 12,
fontSize: compact ? 10 : 12,
),
),
const SizedBox(height: 4),
if (item.weaponType != null)
Text(
item.weaponType == WeaponType.oneHanded ? "1-Handed" : "2-Handed",
style: const TextStyle(fontSize: 9, color: ThemeConfig.textColorGrey),
),
SizedBox(height: compact ? 1 : 4),
// Show Item Stats
FittedBox(
fit: BoxFit.scaleDown,
child: _buildItemStatText(item),
),
if (compact)
_buildCompactItemStatText(item)
else
FittedBox(
fit: BoxFit.scaleDown,
child: _buildItemStatText(item),
),
if (showPrice) ...[
const SizedBox(height: 4),
Text(
@@ -98,12 +108,52 @@ class ItemCardWidget extends StatelessWidget {
);
}
Widget _buildCompactItemStatText(Item item) {
final stats = <String>[];
if (item.atkBonus != 0) {
stats.add("${_sign(item.atkBonus)}${item.atkBonus}A");
}
if (item.hpBonus != 0) {
stats.add("${_sign(item.hpBonus)}${item.hpBonus}H");
}
if (item.armorBonus != 0) {
stats.add("${_sign(item.armorBonus)}${item.armorBonus}D");
}
if (item.luck != 0) {
stats.add("${_sign(item.luck)}${item.luck}L");
}
final effect = item.effects.isNotEmpty
? item.effects.first.type.name.toUpperCase()
: null;
final text = [
if (stats.isNotEmpty) stats.join(" "),
if (effect != null) effect,
].join(" ");
if (text.isEmpty) return const SizedBox.shrink();
return Text(
text,
maxLines: 1,
overflow: TextOverflow.ellipsis,
textAlign: TextAlign.center,
style: const TextStyle(
fontSize: ThemeConfig.fontSizeTiny,
color: ThemeConfig.statAtkColor,
),
);
}
String _sign(int value) => value > 0 ? "+" : "";
Widget _buildItemStatText(Item item) {
List<String> stats = [];
// Helper to format stat string
String formatStat(int value, String label) {
String sign = value > 0 ? "+" : ""; // Negative values already have '-'
String sign = _sign(value); // Negative values already have '-'
return "$sign$value $label";
}