Implemented game tile in choose game view
This commit is contained in:
@@ -58,7 +58,7 @@ Color getColorFromGameColor(GameColor color) {
|
|||||||
case GameColor.purple:
|
case GameColor.purple:
|
||||||
return Colors.purple;
|
return Colors.purple;
|
||||||
case GameColor.orange:
|
case GameColor.orange:
|
||||||
return Colors.orange;
|
return const Color(0xFFef681f);
|
||||||
case GameColor.pink:
|
case GameColor.pink:
|
||||||
return Colors.pink;
|
return Colors.pink;
|
||||||
case GameColor.teal:
|
case GameColor.teal:
|
||||||
@@ -66,8 +66,10 @@ Color getColorFromGameColor(GameColor color) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Counts how many players in the match are not part of the group
|
/// Counts how many players in the [match] are not part of the group
|
||||||
/// Returns the count as a string, or an empty string if there is no group
|
///
|
||||||
|
/// Returns the text you append after the group name, e.g. " + 5" or an empty
|
||||||
|
/// string if there are no extra players
|
||||||
String getExtraPlayerCount(Match match) {
|
String getExtraPlayerCount(Match match) {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import 'package:tallee/data/models/game.dart';
|
|||||||
import 'package:tallee/l10n/generated/app_localizations.dart';
|
import 'package:tallee/l10n/generated/app_localizations.dart';
|
||||||
import 'package:tallee/presentation/views/main_menu/match_view/create_match/create_game/create_game_view.dart';
|
import 'package:tallee/presentation/views/main_menu/match_view/create_match/create_game/create_game_view.dart';
|
||||||
import 'package:tallee/presentation/widgets/text_input/custom_search_bar.dart';
|
import 'package:tallee/presentation/widgets/text_input/custom_search_bar.dart';
|
||||||
import 'package:tallee/presentation/widgets/tiles/title_description_list_tile.dart';
|
import 'package:tallee/presentation/widgets/tiles/game_tile.dart';
|
||||||
|
|
||||||
class ChooseGameView extends StatefulWidget {
|
class ChooseGameView extends StatefulWidget {
|
||||||
/// A view that allows the user to choose a game from a list of available games
|
/// A view that allows the user to choose a game from a list of available games
|
||||||
@@ -110,6 +110,7 @@ class _ChooseGameViewState extends State<ChooseGameView> {
|
|||||||
},
|
},
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
|
// Search Bar
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 10),
|
padding: const EdgeInsets.symmetric(horizontal: 10),
|
||||||
child: CustomSearchBar(
|
child: CustomSearchBar(
|
||||||
@@ -121,15 +122,18 @@ class _ChooseGameViewState extends State<ChooseGameView> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 5),
|
const SizedBox(height: 5),
|
||||||
|
|
||||||
|
// Game list
|
||||||
Expanded(
|
Expanded(
|
||||||
child: ListView.builder(
|
child: ListView.builder(
|
||||||
itemCount: filteredGames.length,
|
itemCount: filteredGames.length,
|
||||||
itemBuilder: (BuildContext context, int index) {
|
itemBuilder: (BuildContext context, int index) {
|
||||||
final game = filteredGames[index];
|
final game = filteredGames[index];
|
||||||
return TitleDescriptionListTile(
|
return GameTile(
|
||||||
title: game.name,
|
title: game.name,
|
||||||
description: game.description,
|
description: game.description,
|
||||||
badgeText: translateRulesetToString(game.ruleset, context),
|
badgeText: translateRulesetToString(game.ruleset, context),
|
||||||
|
badgeColor: getColorFromGameColor(game.color),
|
||||||
isHighlighted: selectedGameId == game.id,
|
isHighlighted: selectedGameId == game.id,
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
setState(() {
|
setState(() {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import 'package:tallee/core/common.dart';
|
|||||||
import 'package:tallee/core/custom_theme.dart';
|
import 'package:tallee/core/custom_theme.dart';
|
||||||
import 'package:tallee/core/enums.dart';
|
import 'package:tallee/core/enums.dart';
|
||||||
import 'package:tallee/l10n/generated/app_localizations.dart';
|
import 'package:tallee/l10n/generated/app_localizations.dart';
|
||||||
import 'package:tallee/presentation/widgets/tiles/title_description_list_tile.dart';
|
import 'package:tallee/presentation/widgets/tiles/game_tile.dart';
|
||||||
|
|
||||||
class ChooseColorView extends StatefulWidget {
|
class ChooseColorView extends StatefulWidget {
|
||||||
/// A view that allows the user to choose a color from a list of available game colors
|
/// A view that allows the user to choose a color from a list of available game colors
|
||||||
@@ -54,7 +54,7 @@ class _ChooseColorViewState extends State<ChooseColorView> {
|
|||||||
itemCount: colors.length,
|
itemCount: colors.length,
|
||||||
itemBuilder: (BuildContext context, int index) {
|
itemBuilder: (BuildContext context, int index) {
|
||||||
final color = colors[index];
|
final color = colors[index];
|
||||||
return TitleDescriptionListTile(
|
return GameTile(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
setState(() {
|
setState(() {
|
||||||
if (selectedColor == color) {
|
if (selectedColor == color) {
|
||||||
|
|||||||
Reference in New Issue
Block a user