feat: showing game color in choose tile

This commit is contained in:
2026-05-03 10:59:46 +02:00
parent 5d832c98a7
commit 6272794cc5
4 changed files with 38 additions and 23 deletions

View File

@@ -14,15 +14,13 @@ class Game {
Game({ Game({
required this.name, required this.name,
required this.ruleset, required this.ruleset,
required this.color, this.color = GameColor.orange,
this.description = '',
this.icon = '',
String? id, String? id,
DateTime? createdAt, DateTime? createdAt,
String? description,
String? icon,
}) : id = id ?? const Uuid().v4(), }) : id = id ?? const Uuid().v4(),
createdAt = createdAt ?? clock.now(), createdAt = createdAt ?? clock.now();
description = description ?? '',
icon = icon ?? '';
@override @override
String toString() { String toString() {

View File

@@ -56,7 +56,7 @@ class _CreateGameViewState extends State<CreateGameView> {
late List<(Ruleset, String)> _rulesets; late List<(Ruleset, String)> _rulesets;
/// The currently selected color for the game. /// The currently selected color for the game.
GameColor? selectedColor; GameColor? selectedColor = GameColor.orange;
/// Controller for the game name input field. /// Controller for the game name input field.
final _gameNameController = TextEditingController(); final _gameNameController = TextEditingController();
@@ -212,9 +212,11 @@ class _CreateGameViewState extends State<CreateGameView> {
if (!isEditMode()) if (!isEditMode())
ChooseTile( ChooseTile(
title: loc.ruleset, title: loc.ruleset,
trailingText: selectedRuleset == null trailing: selectedRuleset == null
? loc.none ? Text(loc.none)
: translateRulesetToString(selectedRuleset!, context), : Text(
translateRulesetToString(selectedRuleset!, context),
),
onPressed: () async { onPressed: () async {
final result = await Navigator.of(context).push<Ruleset?>( final result = await Navigator.of(context).push<Ruleset?>(
adaptivePageRoute( adaptivePageRoute(
@@ -238,9 +240,24 @@ class _CreateGameViewState extends State<CreateGameView> {
// Choose color tile // Choose color tile
ChooseTile( ChooseTile(
title: loc.color, title: loc.color,
trailingText: selectedColor == null trailing: selectedColor == null
? loc.none ? Text(loc.none)
: translateGameColorToString(selectedColor!, context), : Row(
children: [
Text(
translateGameColorToString(selectedColor!, context),
),
Container(
width: 16,
height: 16,
margin: const EdgeInsets.only(left: 12),
decoration: BoxDecoration(
color: getColorFromGameColor(selectedColor!),
shape: BoxShape.circle,
),
),
],
),
onPressed: () async { onPressed: () async {
final result = await Navigator.of(context).push<GameColor?>( final result = await Navigator.of(context).push<GameColor?>(
adaptivePageRoute( adaptivePageRoute(

View File

@@ -132,9 +132,9 @@ class _CreateMatchViewState extends State<CreateMatchView> {
if (!isEditMode()) if (!isEditMode())
ChooseTile( ChooseTile(
title: loc.game, title: loc.game,
trailingText: selectedGame == null trailing: selectedGame == null
? loc.none_group ? Text(loc.none_group)
: selectedGame!.name, : Text(selectedGame!.name),
onPressed: () async { onPressed: () async {
selectedGame = await Navigator.of(context).push( selectedGame = await Navigator.of(context).push(
adaptivePageRoute( adaptivePageRoute(
@@ -158,9 +158,9 @@ class _CreateMatchViewState extends State<CreateMatchView> {
// Group selection tile. // Group selection tile.
ChooseTile( ChooseTile(
title: loc.group, title: loc.group,
trailingText: selectedGroup == null trailing: selectedGroup == null
? loc.none_group ? Text(loc.none_group)
: selectedGroup!.name, : Text(selectedGroup!.name),
onPressed: () async { onPressed: () async {
// Remove all players from the previously selected group from // Remove all players from the previously selected group from
// the selected players list, in case the user deselects the // the selected players list, in case the user deselects the

View File

@@ -4,12 +4,12 @@ import 'package:tallee/core/custom_theme.dart';
class ChooseTile extends StatefulWidget { class ChooseTile extends StatefulWidget {
/// A tile widget that allows users to choose an option by tapping on it. /// A tile widget that allows users to choose an option by tapping on it.
/// - [title]: The title text displayed on the tile. /// - [title]: The title text displayed on the tile.
/// - [trailingText]: Optional trailing text displayed on the tile. /// - [trailing]: Optional trailing text displayed on the tile.
/// - [onPressed]: The callback invoked when the tile is tapped. /// - [onPressed]: The callback invoked when the tile is tapped.
const ChooseTile({ const ChooseTile({
super.key, super.key,
required this.title, required this.title,
this.trailingText, this.trailing,
this.onPressed, this.onPressed,
}); });
@@ -20,7 +20,7 @@ class ChooseTile extends StatefulWidget {
final VoidCallback? onPressed; final VoidCallback? onPressed;
/// Optional trailing text displayed on the tile. /// Optional trailing text displayed on the tile.
final String? trailingText; final Widget? trailing;
@override @override
State<ChooseTile> createState() => _ChooseTileState(); State<ChooseTile> createState() => _ChooseTileState();
@@ -42,7 +42,7 @@ class _ChooseTileState extends State<ChooseTile> {
style: const TextStyle(fontSize: 16, fontWeight: FontWeight.bold), style: const TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
), ),
const Spacer(), const Spacer(),
if (widget.trailingText != null) Text(widget.trailingText!), if (widget.trailing != null) widget.trailing!,
const SizedBox(width: 10), const SizedBox(width: 10),
const Icon(Icons.arrow_forward_ios, size: 16), const Icon(Icons.arrow_forward_ios, size: 16),
], ],