feat(ui): presentational booster bar
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
// lib/ui/widgets/booster_bar.dart
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../game/models/booster.dart';
|
||||
|
||||
class BoosterBar extends StatelessWidget {
|
||||
const BoosterBar({super.key, required this.counts, required this.onTap});
|
||||
|
||||
final Map<BoosterType, int> counts;
|
||||
final void Function(BoosterType) onTap;
|
||||
|
||||
static const _icons = {
|
||||
BoosterType.hammer: Icons.gavel,
|
||||
BoosterType.shuffle: Icons.shuffle,
|
||||
BoosterType.lineBomb: Icons.clear_all,
|
||||
};
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
for (final t in BoosterType.values)
|
||||
_BoosterButton(
|
||||
key: ValueKey('booster_${t.name}'),
|
||||
icon: _icons[t]!,
|
||||
count: counts[t] ?? 0,
|
||||
onTap: () => onTap(t),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _BoosterButton extends StatelessWidget {
|
||||
const _BoosterButton(
|
||||
{super.key, required this.icon, required this.count, required this.onTap});
|
||||
final IconData icon;
|
||||
final int count;
|
||||
final VoidCallback onTap;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return InkWell(
|
||||
onTap: onTap,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8),
|
||||
child: Column(mainAxisSize: MainAxisSize.min, children: [
|
||||
Icon(icon, size: 28),
|
||||
const SizedBox(height: 2),
|
||||
Text('$count'),
|
||||
]),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user