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,
selectedGroups: widget.statistic.selectedGroups,
selectedGames: widget.statistic.selectedGames,
displayCount: displayCount,
showAllValues: true,
),
const SizedBox(height: 12),

View File

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

View File

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