2023-06-17 21:50:52 +00:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:intl/intl.dart';
|
|
|
|
|
|
|
|
class StatCellNum extends StatelessWidget {
|
2023-06-27 20:55:59 +00:00
|
|
|
const StatCellNum(
|
|
|
|
{super.key,
|
|
|
|
required this.playerStat,
|
|
|
|
required this.playerStatLabel,
|
|
|
|
required this.isScreenBig,
|
|
|
|
this.alertWidgets,
|
2023-07-12 15:14:25 +00:00
|
|
|
this.fractionDigits,
|
|
|
|
this.oldPlayerStat,
|
|
|
|
required this.higherIsBetter,
|
|
|
|
this.okText});
|
2023-06-17 21:50:52 +00:00
|
|
|
|
|
|
|
final num playerStat;
|
2023-06-28 16:50:40 +00:00
|
|
|
final num? oldPlayerStat;
|
|
|
|
final bool higherIsBetter;
|
2023-06-17 21:50:52 +00:00
|
|
|
final String playerStatLabel;
|
2023-07-12 15:14:25 +00:00
|
|
|
final String? okText;
|
2023-06-17 21:50:52 +00:00
|
|
|
final bool isScreenBig;
|
2023-06-27 20:55:59 +00:00
|
|
|
final List<Widget>? alertWidgets;
|
2023-06-17 21:50:52 +00:00
|
|
|
final int? fractionDigits;
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2023-06-27 20:55:59 +00:00
|
|
|
NumberFormat f =
|
|
|
|
NumberFormat.decimalPatternDigits(decimalDigits: fractionDigits ?? 0);
|
2023-06-17 21:50:52 +00:00
|
|
|
return Column(
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
f.format(playerStat),
|
|
|
|
style: TextStyle(
|
|
|
|
fontFamily: "Eurostile Round Extended",
|
|
|
|
fontSize: isScreenBig ? 32 : 24,
|
|
|
|
),
|
|
|
|
),
|
2023-06-28 16:50:40 +00:00
|
|
|
if (oldPlayerStat != null) Text(NumberFormat("+#,###.###;-#,###.###").format(playerStat - oldPlayerStat!), style: TextStyle(
|
|
|
|
color: higherIsBetter ?
|
|
|
|
oldPlayerStat! > playerStat ? Colors.red : Colors.green :
|
|
|
|
oldPlayerStat! < playerStat ? Colors.red : Colors.green
|
|
|
|
),),
|
2023-06-27 20:55:59 +00:00
|
|
|
alertWidgets == null
|
2023-06-17 21:50:52 +00:00
|
|
|
? Text(
|
|
|
|
playerStatLabel,
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
style: const TextStyle(
|
|
|
|
fontFamily: "Eurostile Round",
|
|
|
|
fontSize: 16,
|
|
|
|
),
|
|
|
|
)
|
|
|
|
: TextButton(
|
|
|
|
onPressed: () {
|
2023-06-27 20:55:59 +00:00
|
|
|
showDialog(
|
|
|
|
context: context,
|
|
|
|
builder: (BuildContext context) => AlertDialog(
|
|
|
|
title: Text(playerStatLabel,
|
|
|
|
style: const TextStyle(
|
|
|
|
fontFamily: "Eurostile Round Extended")),
|
|
|
|
content: SingleChildScrollView(
|
|
|
|
child: ListBody(children: alertWidgets!),
|
|
|
|
),
|
|
|
|
actions: <Widget>[
|
|
|
|
TextButton(
|
2023-07-12 15:14:25 +00:00
|
|
|
child: Text(okText??"OK"),
|
|
|
|
onPressed: () {Navigator.of(context).pop();}
|
2023-06-27 20:55:59 +00:00
|
|
|
)
|
|
|
|
],
|
|
|
|
));
|
2023-06-17 21:50:52 +00:00
|
|
|
},
|
2023-06-27 20:55:59 +00:00
|
|
|
style: ButtonStyle(
|
|
|
|
padding: MaterialStateProperty.all(EdgeInsets.zero)),
|
2023-06-17 21:50:52 +00:00
|
|
|
child: Text(
|
|
|
|
playerStatLabel,
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
style: const TextStyle(
|
|
|
|
fontFamily: "Eurostile Round",
|
|
|
|
fontSize: 16,
|
|
|
|
),
|
|
|
|
)),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|