Visual improvements on table

This commit is contained in:
2025-07-18 23:41:09 +02:00
parent c8de78ee77
commit 5b418817b2

View File

@@ -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<PointOverviewView> {
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<DataRow>.generate(
@@ -46,16 +63,19 @@ class _PointOverviewViewState extends State<PointOverviewView> {
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(
Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
@@ -63,24 +83,28 @@ class _PointOverviewViewState extends State<PointOverviewView> {
horizontal: 6, vertical: 2),
decoration: BoxDecoration(
color: update <= 0
? Colors.green[200]
: Colors.red[200],
? CustomTheme.primaryColor
: CupertinoColors.destructiveRed,
borderRadius: BorderRadius.circular(8),
),
child: Text(
'${update >= 0 ? '+' : '-'}$update',
style: TextStyle(
color: update <= 0
? Colors.green[900]
: Colors.red[900],
style: const TextStyle(
color: CupertinoColors.white,
fontWeight: FontWeight.bold,
),
),
),
const SizedBox(height: 4),
Text('$score'),
Text('$score',
style: TextStyle(
fontWeight: saidCabo
? FontWeight.bold
: FontWeight.normal,
)),
],
),
),
);
}),
],