feat: dynamic display count shown in tile
Some checks failed
Pull Request Pipeline / lint (pull_request) Successful in 47s
Pull Request Pipeline / test (pull_request) Successful in 49s
Pull Request Pipeline / localizations (pull_request) Failing after 29s

This commit is contained in:
2026-05-25 13:06:11 +02:00
parent b9710ed851
commit fb2f6d3adc
3 changed files with 27 additions and 19 deletions

View File

@@ -65,6 +65,8 @@ class _StatisticDetailViewState extends State<StatisticDetailView> {
barColor: widget.barColor, barColor: widget.barColor,
selectedGroups: widget.statistic.selectedGroups, selectedGroups: widget.statistic.selectedGroups,
selectedGames: widget.statistic.selectedGames, selectedGames: widget.statistic.selectedGames,
displayCount: displayCount,
showAllValues: true,
), ),
const SizedBox(height: 12), const SizedBox(height: 12),

View File

@@ -26,9 +26,10 @@ class StatisticsTile extends StatelessWidget {
required this.width, required this.width,
required this.values, required this.values,
required this.barColor, required this.barColor,
this.displayCount, required this.displayCount,
this.selectedGroups, this.selectedGroups,
this.selectedGames, this.selectedGames,
this.showAllValues = false,
}); });
/// The icon displayed next to the title. /// The icon displayed next to the title.
@@ -46,11 +47,13 @@ class StatisticsTile extends StatelessWidget {
/// The color of the bars representing the values. /// The color of the bars representing the values.
final Color barColor; final Color barColor;
final int? displayCount; // statistic data
final int displayCount;
final List<Group>? selectedGroups; final List<Group>? selectedGroups;
final List<Game>? selectedGames; final List<Game>? selectedGames;
final bool showAllValues;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final loc = AppLocalizations.of(context); final loc = AppLocalizations.of(context);
@@ -76,9 +79,9 @@ class StatisticsTile extends StatelessWidget {
final maxBarWidth = constraints.maxWidth * 0.8; final maxBarWidth = constraints.maxWidth * 0.8;
// If displayCount wasnt provided, take all values // If displayCount wasnt provided, take all values
final valuesShown = displayCount == null final valuesShown = showAllValues
? values.length ? values.length
: min(values.length, displayCount!); : min(values.length, displayCount);
final displayValues = values.take(valuesShown).toList(); final displayValues = values.take(valuesShown).toList();
final maxVal = displayValues.isNotEmpty final maxVal = displayValues.isNotEmpty
? displayValues.fold<num>( ? displayValues.fold<num>(
@@ -103,6 +106,17 @@ class StatisticsTile extends StatelessWidget {
maxBarWidth, maxBarWidth,
); );
final barClr = index >= displayCount
? barColor.withAlpha(150)
: barColor;
var textClr = barColor.computeLuminance() > 0.5
? const Color(0xFF101010)
: CustomTheme.textColor;
textClr = textClr.withAlpha(
index >= displayCount ? 220 : 255,
);
return Padding( return Padding(
padding: const EdgeInsets.symmetric(vertical: 2.0), padding: const EdgeInsets.symmetric(vertical: 2.0),
child: Row( child: Row(
@@ -119,7 +133,7 @@ class StatisticsTile extends StatelessWidget {
width: barWidth, width: barWidth,
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.circular(4), borderRadius: BorderRadius.circular(4),
color: barColor, color: barClr,
), ),
), ),
@@ -138,13 +152,7 @@ class StatisticsTile extends StatelessWidget {
style: TextStyle( style: TextStyle(
fontSize: 16, fontSize: 16,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
color: color: textClr,
barColor ==
getColorFromAppColor(
AppColor.yellow,
)
? const Color(0xFF101010)
: CustomTheme.textColor,
), ),
), ),
TextSpan( TextSpan(

View File

@@ -8,9 +8,7 @@ import 'package:tallee/core/enums.dart';
import 'package:tallee/data/db/database.dart'; import 'package:tallee/data/db/database.dart';
import 'package:tallee/data/models/game.dart'; import 'package:tallee/data/models/game.dart';
import 'package:tallee/data/models/group.dart'; import 'package:tallee/data/models/group.dart';
import 'package:tallee/data/models/match.dart';
import 'package:tallee/data/models/player.dart'; import 'package:tallee/data/models/player.dart';
import 'package:tallee/data/models/score_entry.dart';
import 'package:tallee/data/models/statistic.dart'; import 'package:tallee/data/models/statistic.dart';
void main() { void main() {
@@ -23,10 +21,10 @@ void main() {
late Group testGroup1; late Group testGroup1;
late Group testGroup2; late Group testGroup2;
late Game testGame; late Game testGame;
late Match testMatch1; /*late Match testMatch1;
late Match testMatch2; late Match testMatch2;
late Match testMatchOnlyPlayers; late Match testMatchOnlyPlayers;
late Match testMatchOnlyGroup; late Match testMatchOnlyGroup;*/
final fixedDate = DateTime(2025, 19, 11, 00, 11, 23); final fixedDate = DateTime(2025, 19, 11, 00, 11, 23);
final fakeClock = Clock(() => fixedDate); final fakeClock = Clock(() => fixedDate);
@@ -62,7 +60,7 @@ void main() {
color: AppColor.blue, color: AppColor.blue,
icon: '', icon: '',
); );
testMatch1 = Match( /*testMatch1 = Match(
name: 'First Test Match', name: 'First Test Match',
game: testGame, game: testGame,
group: testGroup1, group: testGroup1,
@@ -85,7 +83,7 @@ void main() {
game: testGame, game: testGame,
group: testGroup2, group: testGroup2,
players: testGroup2.members, players: testGroup2.members,
); );*/
}); });
await database.playerDao.addPlayersAsList( await database.playerDao.addPlayersAsList(
players: [ players: [