feat: placement text color
This commit is contained in:
@@ -272,7 +272,7 @@ class _MatchDetailViewState extends State<MatchDetailView> {
|
|||||||
children: getSingleResultRow(loc),
|
children: getSingleResultRow(loc),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return getScoreResultWidget(loc);
|
return getMultiResultRows(loc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -323,7 +323,7 @@ class _MatchDetailViewState extends State<MatchDetailView> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the result widget for scores or placement
|
/// Returns the result widget for scores or placement
|
||||||
Widget getScoreResultWidget(AppLocalizations loc) {
|
Widget getMultiResultRows(AppLocalizations loc) {
|
||||||
List<(String, int)> playerScores = [];
|
List<(String, int)> playerScores = [];
|
||||||
for (var player in match.players) {
|
for (var player in match.players) {
|
||||||
int score = match.scores[player.id]?.score ?? 0;
|
int score = match.scores[player.id]?.score ?? 0;
|
||||||
@@ -351,33 +351,58 @@ class _MatchDetailViewState extends State<MatchDetailView> {
|
|||||||
color: CustomTheme.textColor,
|
color: CustomTheme.textColor,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Text(
|
getResultValueText(loc, i, playerScores[i].$2),
|
||||||
ruleset == Ruleset.placement
|
|
||||||
? getPlacementText(i + 1, context, loc)
|
|
||||||
: getPointLabel(loc, playerScores[i].$2),
|
|
||||||
style: const TextStyle(
|
|
||||||
fontSize: 16,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
color: CustomTheme.primaryColor,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Widget getResultValueText(AppLocalizations loc, int index, int score) {
|
||||||
|
final ruleset = match.game.ruleset;
|
||||||
|
|
||||||
|
if (ruleset == Ruleset.placement) {
|
||||||
|
return Text(
|
||||||
|
getPlacementText(context, index + 1),
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 16,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color: getPlacementTextcolor(index),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return Text(
|
||||||
|
getPointLabel(loc, score),
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 16,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color: CustomTheme.primaryColor,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Color getPlacementTextcolor(int placement) {
|
||||||
|
switch (placement) {
|
||||||
|
case 0:
|
||||||
|
return const Color(0xFFFFBF00);
|
||||||
|
case 1:
|
||||||
|
return const Color(0xBBFFFFFF);
|
||||||
|
case 2:
|
||||||
|
return const Color(0xFFCD7F32);
|
||||||
|
default:
|
||||||
|
return CustomTheme.textColor;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Returns if the result can be displayed in a single row
|
// Returns if the result can be displayed in a single row
|
||||||
bool isSingleRowResult() {
|
bool isSingleRowResult() {
|
||||||
return match.game.ruleset == Ruleset.singleWinner ||
|
return match.game.ruleset == Ruleset.singleWinner ||
|
||||||
match.game.ruleset == Ruleset.singleLoser;
|
match.game.ruleset == Ruleset.singleLoser;
|
||||||
}
|
}
|
||||||
|
|
||||||
String getPlacementText(
|
String getPlacementText(BuildContext context, int rank) {
|
||||||
int rank,
|
final loc = AppLocalizations.of(context);
|
||||||
BuildContext context,
|
|
||||||
AppLocalizations loc,
|
|
||||||
) {
|
|
||||||
final locale = Localizations.localeOf(context).languageCode;
|
final locale = Localizations.localeOf(context).languageCode;
|
||||||
|
|
||||||
if (locale == 'de') {
|
if (locale == 'de') {
|
||||||
|
|||||||
Reference in New Issue
Block a user