Implemented new point view

This commit is contained in:
2025-08-02 16:44:31 +02:00
parent 3346bfe6d9
commit 287294526a
2 changed files with 145 additions and 116 deletions

View File

@@ -21,41 +21,57 @@ class _PointsViewState extends State<PointsView> {
middle: Text(AppLocalizations.of(context).point_overview), middle: Text(AppLocalizations.of(context).point_overview),
previousPageTitle: AppLocalizations.of(context).back, previousPageTitle: AppLocalizations.of(context).back,
), ),
child: SafeArea(child: LayoutBuilder(builder: (context, constraints) {
final int columnCount = 1 + widget.gameSession.players.length;
final double columnWidth = constraints.maxWidth / columnCount;
return SingleChildScrollView(
scrollDirection: Axis.vertical,
child: SingleChildScrollView( child: SingleChildScrollView(
padding: const EdgeInsets.fromLTRB(0, 100, 0, 0), scrollDirection: Axis.horizontal,
child: ConstrainedBox(
constraints: BoxConstraints(minWidth: constraints.maxWidth),
child: Padding( child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 8.0), padding: const EdgeInsets.symmetric(horizontal: 8),
child: DataTable( child: DataTable(
dataRowMinHeight: 60,
dataRowMaxHeight: 60, dataRowMaxHeight: 60,
dividerThickness: 0.5, dataRowMinHeight: 60,
columnSpacing: 20, columnSpacing: 20,
columns: [ columns: [
const DataColumn( const DataColumn(
numeric: true, label: SizedBox(
headingRowAlignment: MainAxisAlignment.center, width: 18,
label: Text( child: Text(
'#', '#',
style: TextStyle(fontWeight: FontWeight.bold), style: TextStyle(fontWeight: FontWeight.bold),
textAlign: TextAlign.center,
),
),
numeric: true,
), ),
columnWidth: IntrinsicColumnWidth(flex: 0.5)),
...widget.gameSession.players.map( ...widget.gameSession.players.map(
(player) => DataColumn( (player) => DataColumn(
label: FittedBox( label: SizedBox(
fit: BoxFit.fill, width: columnWidth,
child: Text( child: Text(
player, player,
style: const TextStyle(fontWeight: FontWeight.bold), style: const TextStyle(
)), fontWeight: FontWeight.bold),
headingRowAlignment: MainAxisAlignment.center, overflow: TextOverflow.ellipsis,
columnWidth: const IntrinsicColumnWidth(flex: 1)), softWrap: true,
maxLines: 2,
textAlign: TextAlign.center,
),
),
),
), ),
], ],
rows: [ rows: [
...List<DataRow>.generate( ...List<DataRow>.generate(
widget.gameSession.roundList.length, widget.gameSession.roundList.length,
(roundIndex) { (roundIndex) {
final round = widget.gameSession.roundList[roundIndex]; final round =
widget.gameSession.roundList[roundIndex];
return DataRow( return DataRow(
cells: [ cells: [
DataCell(Align( DataCell(Align(
@@ -65,17 +81,23 @@ class _PointsViewState extends State<PointsView> {
style: const TextStyle(fontSize: 20), style: const TextStyle(fontSize: 20),
), ),
)), )),
...List.generate(widget.gameSession.players.length, ...List.generate(
widget.gameSession.players.length,
(playerIndex) { (playerIndex) {
final int score = round.scores[playerIndex]; final int score = round.scores[playerIndex];
final int update = round.scoreUpdates[playerIndex]; final int update =
round.scoreUpdates[playerIndex];
final bool saidCabo = final bool saidCabo =
round.caboPlayerIndex == playerIndex; round.caboPlayerIndex == playerIndex;
return DataCell( return DataCell(
Center( Center(
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment:
MainAxisAlignment.center,
children: [ children: [
const SizedBox(
height: 5,
),
Container( Container(
padding: const EdgeInsets.symmetric( padding: const EdgeInsets.symmetric(
horizontal: 6, vertical: 2), horizontal: 6, vertical: 2),
@@ -83,7 +105,8 @@ class _PointsViewState extends State<PointsView> {
color: update <= 0 color: update <= 0
? CustomTheme.pointLossColor ? CustomTheme.pointLossColor
: CustomTheme.pointGainColor, : CustomTheme.pointGainColor,
borderRadius: BorderRadius.circular(8), borderRadius:
BorderRadius.circular(8),
), ),
child: Text( child: Text(
'${update >= 0 ? '+' : ''}$update', '${update >= 0 ? '+' : ''}$update',
@@ -96,6 +119,10 @@ class _PointsViewState extends State<PointsView> {
const SizedBox(height: 4), const SizedBox(height: 4),
Text('$score', Text('$score',
style: TextStyle( style: TextStyle(
decorationThickness: 1,
decoration: saidCabo
? TextDecoration.underline
: TextDecoration.none,
fontWeight: saidCabo fontWeight: saidCabo
? FontWeight.bold ? FontWeight.bold
: FontWeight.normal, : FontWeight.normal,
@@ -115,8 +142,8 @@ class _PointsViewState extends State<PointsView> {
alignment: Alignment.center, alignment: Alignment.center,
child: Text( child: Text(
'Σ', 'Σ',
style: style: TextStyle(
TextStyle(fontSize: 25, fontWeight: FontWeight.bold), fontSize: 25, fontWeight: FontWeight.bold),
), ),
)), )),
...widget.gameSession.playerScores.map( ...widget.gameSession.playerScores.map(
@@ -125,7 +152,8 @@ class _PointsViewState extends State<PointsView> {
child: Text( child: Text(
'$score', '$score',
style: const TextStyle( style: const TextStyle(
fontSize: 20, fontWeight: FontWeight.bold), fontSize: 20,
fontWeight: FontWeight.bold),
), ),
), ),
), ),
@@ -136,6 +164,7 @@ class _PointsViewState extends State<PointsView> {
), ),
), ),
), ),
); ));
})));
} }
} }

View File

@@ -2,7 +2,7 @@ name: cabo_counter
description: "Mobile app for the card game Cabo" description: "Mobile app for the card game Cabo"
publish_to: 'none' publish_to: 'none'
version: 0.5.4+613 version: 0.5.4+616
environment: environment:
sdk: ^3.5.4 sdk: ^3.5.4