Replaced emojis with unicode and implemented winner string

This commit is contained in:
Felix Kirchner
2025-04-23 23:06:31 +02:00
parent 5a3c893fc8
commit 116cfe9a6a
3 changed files with 41 additions and 20 deletions

View File

@@ -74,10 +74,10 @@ class _ActiveGameViewState extends State<ActiveGameView> {
title: Text(
'Runde ${index + 1}',
),
trailing:
index + 1 == widget.gameSession.playerScores[0].length
? Text('', style: TextStyle(fontSize: 22))
: Text('', style: TextStyle(fontSize: 22)),
trailing: index + 1 != widget.gameSession.round ||
widget.gameSession.finished == true
? (Text('\u{2705}', style: TextStyle(fontSize: 22)))
: Text('\u{23F3}', style: TextStyle(fontSize: 22)),
onTap: () async {
// ignore: unused_local_variable
final val = await Navigator.push(
@@ -105,7 +105,6 @@ class _ActiveGameViewState extends State<ActiveGameView> {
List<int> _getSortedPlayerIndices() {
List<int> playerIndices =
List<int>.generate(widget.gameSession.players.length, (index) => index);
print('Player Indices: $playerIndices');
// Sort the indices based on the summed points
playerIndices.sort((a, b) {
int scoreA = widget.gameSession.playerScores[a][0];
@@ -122,17 +121,17 @@ class _ActiveGameViewState extends State<ActiveGameView> {
switch (index) {
case 0:
return Text(
'🥇',
'\u{1F947}',
style: TextStyle(fontSize: 22),
);
case 1:
return Text(
'🥈',
'\u{1F948}',
style: TextStyle(fontSize: 22),
);
case 2:
return Text(
'🥉',
'\u{1F949}',
style: TextStyle(fontSize: 22),
);
default:

View File

@@ -53,7 +53,6 @@ class _MainMenuViewState extends State<MainMenuView> {
@override
Widget build(BuildContext context) {
gameSessionArray.sort((b, a) => a.createdAt.compareTo(b.createdAt));
calculateRoundNumbers();
return CupertinoPageScaffold(
navigationBar: CupertinoNavigationBar(
@@ -89,8 +88,15 @@ class _MainMenuViewState extends State<MainMenuView> {
padding: EdgeInsets.symmetric(vertical: 10.0),
child: CupertinoListTile(
title: Text(session.gameTitle),
subtitle:
Text('Modus: ${_translateGameMode(session.gameMode)}'),
subtitle: session.finished == true
? Text(
'\u{1F947} ${session.winner}',
style: TextStyle(fontSize: 14),
)
: Text(
'Modus: ${_translateGameMode(session.gameMode)}',
style: TextStyle(fontSize: 14),
),
trailing: Row(
children: [
Text('${session.round}'),
@@ -102,14 +108,15 @@ class _MainMenuViewState extends State<MainMenuView> {
Icon(CupertinoIcons.person_2_fill),
],
),
onTap: () {
Navigator.push(
onTap: () async {
final val = await Navigator.push(
context,
CupertinoPageRoute(
builder: (context) => ActiveGameView(
gameSession: gameSessionArray[index]),
),
);
setState(() {});
},
));
},
@@ -129,10 +136,4 @@ class _MainMenuViewState extends State<MainMenuView> {
return '-';
}
}
void calculateRoundNumbers() {
for (var s in gameSessionArray) {
s.round = s.playerScores[0].length;
}
}
}