From 5b418817b20c9078fc95c501bded0c38f9d66f25 Mon Sep 17 00:00:00 2001 From: Felix Kirchner Date: Fri, 18 Jul 2025 23:41:09 +0200 Subject: [PATCH] Visual improvements on table --- .../views/point_overview_view.dart | 78 ++++++++++++------- 1 file changed, 51 insertions(+), 27 deletions(-) diff --git a/lib/presentation/views/point_overview_view.dart b/lib/presentation/views/point_overview_view.dart index f8e15ea..38d74c6 100644 --- a/lib/presentation/views/point_overview_view.dart +++ b/lib/presentation/views/point_overview_view.dart @@ -1,3 +1,4 @@ +import 'package:cabo_counter/core/custom_theme.dart'; import 'package:cabo_counter/data/game_session.dart'; import 'package:cabo_counter/l10n/generated/app_localizations.dart'; import 'package:flutter/cupertino.dart'; @@ -24,16 +25,32 @@ class _PointOverviewViewState extends State { child: SingleChildScrollView( padding: const EdgeInsets.fromLTRB(0, 100, 0, 0), child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 5.0), + padding: const EdgeInsets.symmetric(horizontal: 8.0), child: DataTable( dataRowMinHeight: 60, dataRowMaxHeight: 60, dividerThickness: 0.5, columnSpacing: 20, columns: [ - const DataColumn(label: Text('#')), + const DataColumn( + numeric: true, + headingRowAlignment: MainAxisAlignment.center, + label: Text( + '#', + style: TextStyle(fontWeight: FontWeight.bold), + ), + columnWidth: IntrinsicColumnWidth(flex: 0.5)), ...widget.gameSession.players.map( - (player) => DataColumn(label: Text(player)), + (player) => DataColumn( + label: FittedBox( + fit: BoxFit.fill, + child: Text( + player, + style: + const TextStyle(fontWeight: FontWeight.bold), + )), + headingRowAlignment: MainAxisAlignment.center, + columnWidth: const IntrinsicColumnWidth(flex: 1)), ), ], rows: List.generate( @@ -46,40 +63,47 @@ class _PointOverviewViewState extends State { alignment: Alignment.center, child: Text( '$roundIndex', - style: const TextStyle( - fontWeight: FontWeight.bold, fontSize: 20), + style: const TextStyle(fontSize: 20), ), )), ...List.generate(widget.gameSession.players.length, (playerIndex) { final score = round.scores[playerIndex]; final update = round.scoreUpdates[playerIndex]; + final saidCabo = round.caboPlayerIndex == playerIndex + ? true + : false; return DataCell( - Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Container( - padding: const EdgeInsets.symmetric( - horizontal: 6, vertical: 2), - decoration: BoxDecoration( - color: update <= 0 - ? Colors.green[200] - : Colors.red[200], - borderRadius: BorderRadius.circular(8), - ), - child: Text( - '${update >= 0 ? '+' : '-'}$update', - style: TextStyle( + Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Container( + padding: const EdgeInsets.symmetric( + horizontal: 6, vertical: 2), + decoration: BoxDecoration( color: update <= 0 - ? Colors.green[900] - : Colors.red[900], - fontWeight: FontWeight.bold, + ? CustomTheme.primaryColor + : CupertinoColors.destructiveRed, + borderRadius: BorderRadius.circular(8), + ), + child: Text( + '${update >= 0 ? '+' : '-'}$update', + style: const TextStyle( + color: CupertinoColors.white, + fontWeight: FontWeight.bold, + ), ), ), - ), - const SizedBox(height: 4), - Text('$score'), - ], + const SizedBox(height: 4), + Text('$score', + style: TextStyle( + fontWeight: saidCabo + ? FontWeight.bold + : FontWeight.normal, + )), + ], + ), ), ); }),