Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 21 additions & 18 deletions lib/lifeCounter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -106,20 +106,23 @@ class _LifeCounterState extends State<LifeCounter> {
});
}

Widget getSetHealthButton(String text, int healthMultiplier) =>
RawMaterialButton(
onPressed: () => setHealth(healthMultiplier, widget.player),
padding: EdgeInsets.all(40),
shape: CircleBorder(),
child: Text(
text,
style: TextStyle(
shadows: [textShadow],
fontSize: 50,
color: widget.player.life > 0 ? usedColor.textColor : Colors.red,
),
),
);
Widget getSetHealthButton(int healthMultiplier) {
bool isPlus = healthMultiplier > 0;
String text = isPlus ? '+' : '-';
return Expanded(
child: RawMaterialButton(
onPressed: () => setHealth(healthMultiplier, widget.player),
child: Text(
text,
style: TextStyle(
shadows: [textShadow],
// - is smaller than + for some reason by default
fontSize: isPlus ? 48 : 60,
color: widget.player.life > 0 ? usedColor.textColor : Colors.red,
),
)),
);
}

@override
Widget build(BuildContext context) {
Expand All @@ -136,12 +139,12 @@ class _LifeCounterState extends State<LifeCounter> {
child: Container(
decoration: getLifeCounterContainerDecoration(),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
getSetHealthButton('-', -1),
getSetHealthButton(-1),
Container(
padding: EdgeInsets.symmetric(horizontal: 10, vertical: 10),
width: 130,
alignment: Alignment.center,
child: Stack(
alignment: Alignment.center,
Expand All @@ -167,7 +170,7 @@ class _LifeCounterState extends State<LifeCounter> {
),
],
)),
getSetHealthButton('+', 1),
getSetHealthButton(1),
],
),
),
Expand Down
2 changes: 1 addition & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class MyHomePage extends StatefulWidget {
class _MyHomePageState extends State<MyHomePage> {
int startingLife = 20;
int playerCount = 4;
bool useCardLayout = false;
bool useCardLayout = true;

List<PlayerStats> players = [
PlayerStats(life: 20, playerNumber: 1),
Expand Down