Merge pull request #153 from flixcoo/enhance/147-sticky-header-table

Sticky header table
This commit is contained in:
2025-08-04 19:39:29 +02:00
committed by GitHub
3 changed files with 245 additions and 132 deletions

View File

@@ -30,6 +30,7 @@ class _GraphViewState extends State<GraphView> {
middle: Text(AppLocalizations.of(context).scoring_history), middle: Text(AppLocalizations.of(context).scoring_history),
previousPageTitle: AppLocalizations.of(context).back, previousPageTitle: AppLocalizations.of(context).back,
), ),
child: SafeArea(
child: Visibility( child: Visibility(
visible: widget.gameSession.roundNumber > 1 || visible: widget.gameSession.roundNumber > 1 ||
widget.gameSession.isGameFinished, widget.gameSession.isGameFinished,
@@ -51,8 +52,6 @@ class _GraphViewState extends State<GraphView> {
), ),
], ],
), ),
child: Padding(
padding: const EdgeInsets.fromLTRB(0, 100, 0, 0),
child: SfCartesianChart( child: SfCartesianChart(
enableAxisAnimation: true, enableAxisAnimation: true,
legend: const Legend( legend: const Legend(

View File

@@ -21,41 +21,117 @@ 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: SingleChildScrollView( child: SafeArea(child: LayoutBuilder(builder: (context, constraints) {
padding: const EdgeInsets.fromLTRB(0, 100, 0, 0), const double caboFieldWidthFactor = 0.2;
const double roundColWidth = 35;
const double tablePadding = 8;
final int playerCount = widget.gameSession.players.length;
final double playerColWidth =
(constraints.maxWidth - roundColWidth - (tablePadding)) /
playerCount;
return Column(
children: [
ConstrainedBox(
constraints: BoxConstraints(maxWidth: constraints.maxWidth),
child: Padding( child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 8.0), padding: const EdgeInsets.symmetric(horizontal: tablePadding),
child: DataTable( child: DataTable(
dataRowMinHeight: 60, dataRowMaxHeight: 0,
dataRowMaxHeight: 60, dataRowMinHeight: 0,
dividerThickness: 0.5, columnSpacing: 0,
columnSpacing: 20, horizontalMargin: 0,
columns: [ columns: [
const DataColumn( const DataColumn(
numeric: true, label: SizedBox(
headingRowAlignment: MainAxisAlignment.center, width: roundColWidth,
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: playerColWidth,
child: Padding(
padding:
const EdgeInsets.symmetric(horizontal: 8),
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: const [],
),
),
),
Expanded(
child: SingleChildScrollView(
scrollDirection: Axis.vertical,
child: ConstrainedBox(
constraints:
BoxConstraints(maxWidth: constraints.maxWidth),
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: tablePadding),
child: DataTable(
dataRowMaxHeight: 75,
dataRowMinHeight: 75,
columnSpacing: 0,
horizontalMargin: 0,
headingRowHeight: 0,
columns: [
const DataColumn(
label: SizedBox(
width: roundColWidth,
child: Text(
'#',
style: TextStyle(fontWeight: FontWeight.bold),
textAlign: TextAlign.center,
),
),
numeric: true,
),
...widget.gameSession.players.map(
(player) => DataColumn(
label: SizedBox(
width: playerColWidth,
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: 8),
child: Text(
player,
style: const TextStyle(
fontWeight: FontWeight.bold),
overflow: TextOverflow.ellipsis,
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,45 +141,78 @@ 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 =
final int update = round.scoreUpdates[playerIndex]; round.scores[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: Padding(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
padding: const EdgeInsets.symmetric( padding: const EdgeInsets.symmetric(
horizontal: 6, vertical: 2), vertical: 6.0),
child: Container(
width: playerColWidth *
(playerCount *
caboFieldWidthFactor), // Adjust width based on amount of players
decoration: BoxDecoration(
color: saidCabo
? CustomTheme
.buttonBackgroundColor
: CupertinoColors.transparent,
borderRadius:
BorderRadius.circular(5),
),
child: Column(
mainAxisAlignment:
MainAxisAlignment.center,
children: [
const SizedBox(
height: 5,
),
Container(
padding: const EdgeInsets
.symmetric(
horizontal: 6,
vertical: 2),
decoration: BoxDecoration( decoration: BoxDecoration(
color: update <= 0 color: update <= 0
? CustomTheme.pointLossColor ? CustomTheme
: CustomTheme.pointGainColor, .pointLossColor
borderRadius: BorderRadius.circular(8), : CustomTheme
.pointGainColor,
borderRadius:
BorderRadius.circular(
6),
), ),
child: Text( child: Text(
'${update >= 0 ? '+' : ''}$update', '${update >= 0 ? '+' : ''}$update',
style: const TextStyle( style: const TextStyle(
color: CupertinoColors.white, color:
fontWeight: FontWeight.bold, CupertinoColors.white,
fontWeight:
FontWeight.bold,
), ),
), ),
), ),
const SizedBox(height: 4), const SizedBox(height: 4),
Text('$score', Text(
'$score',
style: TextStyle( style: TextStyle(
color: CustomTheme.white,
fontWeight: saidCabo fontWeight: saidCabo
? FontWeight.bold ? FontWeight.bold
: FontWeight.normal, : FontWeight.normal,
)), ),
),
], ],
), ),
), ),
); ),
));
}), }),
], ],
); );
@@ -115,8 +224,9 @@ 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 +235,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),
), ),
), ),
), ),
@@ -135,7 +246,10 @@ 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+609 version: 0.5.5+639
environment: environment:
sdk: ^3.5.4 sdk: ^3.5.4