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({
required this.name,
required this.ruleset,
required this.color,
this.color = GameColor.orange,
this.description = '',
this.icon = '',
String? id,
DateTime? createdAt,
String? description,
String? icon,
}) : id = id ?? const Uuid().v4(),
createdAt = createdAt ?? clock.now(),
description = description ?? '',
icon = icon ?? '';
createdAt = createdAt ?? clock.now();
@override
String toString() {

View File

@@ -56,7 +56,7 @@ class _CreateGameViewState extends State<CreateGameView> {
late List<(Ruleset, String)> _rulesets;
/// The currently selected color for the game.
GameColor? selectedColor;
GameColor? selectedColor = GameColor.orange;
/// Controller for the game name input field.
final _gameNameController = TextEditingController();
@@ -212,9 +212,11 @@ class _CreateGameViewState extends State<CreateGameView> {
if (!isEditMode())
ChooseTile(
title: loc.ruleset,
trailingText: selectedRuleset == null
? loc.none
: translateRulesetToString(selectedRuleset!, context),
trailing: selectedRuleset == null
? Text(loc.none)
: Text(
translateRulesetToString(selectedRuleset!, context),
),
onPressed: () async {
final result = await Navigator.of(context).push<Ruleset?>(
adaptivePageRoute(
@@ -238,9 +240,24 @@ class _CreateGameViewState extends State<CreateGameView> {
// Choose color tile
ChooseTile(
title: loc.color,
trailingText: selectedColor == null
? loc.none
: translateGameColorToString(selectedColor!, context),
trailing: selectedColor == null
? Text(loc.none)
: 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 {
final result = await Navigator.of(context).push<GameColor?>(
adaptivePageRoute(

View File

@@ -132,9 +132,9 @@ class _CreateMatchViewState extends State<CreateMatchView> {
if (!isEditMode())
ChooseTile(
title: loc.game,
trailingText: selectedGame == null
? loc.none_group
: selectedGame!.name,
trailing: selectedGame == null
? Text(loc.none_group)
: Text(selectedGame!.name),
onPressed: () async {
selectedGame = await Navigator.of(context).push(
adaptivePageRoute(
@@ -158,9 +158,9 @@ class _CreateMatchViewState extends State<CreateMatchView> {
// Group selection tile.
ChooseTile(
title: loc.group,
trailingText: selectedGroup == null
? loc.none_group
: selectedGroup!.name,
trailing: selectedGroup == null
? Text(loc.none_group)
: Text(selectedGroup!.name),
onPressed: () async {
// Remove all players from the previously selected group from
// 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 {
/// A tile widget that allows users to choose an option by tapping on it.
/// - [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.
const ChooseTile({
super.key,
required this.title,
this.trailingText,
this.trailing,
this.onPressed,
});
@@ -20,7 +20,7 @@ class ChooseTile extends StatefulWidget {
final VoidCallback? onPressed;
/// Optional trailing text displayed on the tile.
final String? trailingText;
final Widget? trailing;
@override
State<ChooseTile> createState() => _ChooseTileState();
@@ -42,7 +42,7 @@ class _ChooseTileState extends State<ChooseTile> {
style: const TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
),
const Spacer(),
if (widget.trailingText != null) Text(widget.trailingText!),
if (widget.trailing != null) widget.trailing!,
const SizedBox(width: 10),
const Icon(Icons.arrow_forward_ios, size: 16),
],