From 7a3d4f98fbd344e5f8c578ee50dfe3256689a716 Mon Sep 17 00:00:00 2001 From: ZTL-UwU Date: Thu, 11 Jan 2024 14:42:15 +0800 Subject: [PATCH] Improve analysis summary tablet layout --- lib/src/view/analysis/analysis_screen.dart | 163 +++++++++++---------- 1 file changed, 84 insertions(+), 79 deletions(-) diff --git a/lib/src/view/analysis/analysis_screen.dart b/lib/src/view/analysis/analysis_screen.dart index 12da2d7e66..de067af50b 100644 --- a/lib/src/view/analysis/analysis_screen.dart +++ b/lib/src/view/analysis/analysis_screen.dart @@ -841,89 +841,94 @@ class ServerAnalysisSummary extends ConsumerWidget { children: [ AcplChart(options), if (serverAnalysis != null) - Padding( - padding: const EdgeInsets.all(16.0), - child: Table( - defaultVerticalAlignment: TableCellVerticalAlignment.middle, - columnWidths: const { - 0: FlexColumnWidth(1), - 1: FlexColumnWidth(1), - 2: FlexColumnWidth(1), - }, - children: [ - TableRow( + Center( + child: SizedBox( + width: math.min(MediaQuery.of(context).size.width, 500), + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 16.0), + child: Table( + defaultVerticalAlignment: TableCellVerticalAlignment.middle, + columnWidths: const { + 0: FlexColumnWidth(1), + 1: FlexColumnWidth(1), + 2: FlexColumnWidth(1), + }, children: [ - _SummaryPlayerName(Side.white, pgnHeaders), - const SizedBox(width: 0), - _SummaryPlayerName(Side.black, pgnHeaders), - ], - ), - for (final item in [ - ( - serverAnalysis.white.inaccuracies.toString(), - 'Inaccuracies', - serverAnalysis.black.inaccuracies.toString() - ), - ( - serverAnalysis.white.inaccuracies.toString(), - 'Mistakes', - serverAnalysis.black.inaccuracies.toString() - ), - ( - serverAnalysis.white.inaccuracies.toString(), - 'Blunders', - serverAnalysis.black.inaccuracies.toString() - ), - if (serverAnalysis.white.acpl != null && - serverAnalysis.black.acpl != null) - ( - serverAnalysis.white.acpl.toString(), - context.l10n.averageCentipawnLoss, - serverAnalysis.black.acpl.toString(), + TableRow( + children: [ + _SummaryPlayerName(Side.white, pgnHeaders), + const SizedBox(width: 0), + _SummaryPlayerName(Side.black, pgnHeaders), + ], ), - ]) - TableRow( - children: [ - _SummaryNumber(item.$1), - Text( - item.$2, - softWrap: true, + for (final item in [ + ( + serverAnalysis.white.inaccuracies.toString(), + 'Inaccuracies', + serverAnalysis.black.inaccuracies.toString() ), - _SummaryNumber(item.$3), - ], - ), - if (serverAnalysis.white.accuracy != null && - serverAnalysis.black.accuracy != null) - TableRow( - children: [ - _SummaryNumber('${serverAnalysis.white.accuracy}%'), - Center( - child: Row( - children: [ - Text( - context.l10n.accuracy, - softWrap: true, - ), - const SizedBox(width: 8.0), - PlatformIconButton( - icon: Icons.info_outline_rounded, - semanticsLabel: 'More info', - padding: EdgeInsets.zero, - onTap: () async { - await launchUrl( - Uri.parse( - 'https://lichess.org/page/accuracy', - ), - ); - }, - ), - ], + ( + serverAnalysis.white.inaccuracies.toString(), + 'Mistakes', + serverAnalysis.black.inaccuracies.toString() + ), + ( + serverAnalysis.white.inaccuracies.toString(), + 'Blunders', + serverAnalysis.black.inaccuracies.toString() + ), + if (serverAnalysis.white.acpl != null && + serverAnalysis.black.acpl != null) + ( + serverAnalysis.white.acpl.toString(), + context.l10n.averageCentipawnLoss, + serverAnalysis.black.acpl.toString(), ), + ]) + TableRow( + children: [ + _SummaryNumber(item.$1), + Text( + item.$2, + softWrap: true, + ), + _SummaryNumber(item.$3), + ], ), - _SummaryNumber('${serverAnalysis.black.accuracy}%'), - ], - ), - ], + if (serverAnalysis.white.accuracy != null && + serverAnalysis.black.accuracy != null) + TableRow( + children: [ + _SummaryNumber('${serverAnalysis.white.accuracy}%'), + Center( + child: Row( + children: [ + Text( + context.l10n.accuracy, + softWrap: true, + ), + const SizedBox(width: 8.0), + PlatformIconButton( + icon: Icons.info_outline_rounded, + semanticsLabel: 'More info', + padding: EdgeInsets.zero, + onTap: () async { + await launchUrl( + Uri.parse( + 'https://lichess.org/page/accuracy', + ), + ); + }, + ), + ], + ), + ), + _SummaryNumber('${serverAnalysis.black.accuracy}%'), + ], + ), + ], + ), + ), ), ), ], @@ -967,7 +972,7 @@ class _SummaryPlayerName extends StatelessWidget { child: Center( heightFactor: 1.4, child: Padding( - padding: const EdgeInsets.only(right: 8, bottom: 8), + padding: const EdgeInsets.only(bottom: 4), child: Wrap( crossAxisAlignment: WrapCrossAlignment.center, spacing: 2.0,