Compare commits
7 Commits
feature/11
...
feature/11
| Author | SHA1 | Date | |
|---|---|---|---|
| 58d8d07b63 | |||
| c983ca22dd | |||
| 45b11359b3 | |||
| 57fb8dbcc8 | |||
| 7024699a61 | |||
| 94c3bad02b | |||
| ed2d672dee |
@@ -19,4 +19,7 @@ class Constants {
|
|||||||
|
|
||||||
/// Maximum length for team names
|
/// Maximum length for team names
|
||||||
static const int MAX_TEAM_NAME_LENGTH = 32;
|
static const int MAX_TEAM_NAME_LENGTH = 32;
|
||||||
|
|
||||||
|
/// Maximum length for game descriptions
|
||||||
|
static const int MAX_GAME_DESCRIPTION_LENGTH = 256;
|
||||||
}
|
}
|
||||||
|
|||||||
23
lib/data/dto/game.dart
Normal file
23
lib/data/dto/game.dart
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
import 'package:clock/clock.dart';
|
||||||
|
import 'package:uuid/uuid.dart';
|
||||||
|
|
||||||
|
class Game {
|
||||||
|
final String id;
|
||||||
|
final DateTime createdAt;
|
||||||
|
final String name;
|
||||||
|
final String? ruleset;
|
||||||
|
final String? description;
|
||||||
|
final int? color;
|
||||||
|
final String? icon;
|
||||||
|
|
||||||
|
Game({
|
||||||
|
String? id,
|
||||||
|
DateTime? createdAt,
|
||||||
|
required this.name,
|
||||||
|
this.ruleset,
|
||||||
|
this.description,
|
||||||
|
this.color,
|
||||||
|
this.icon,
|
||||||
|
}) : id = id ?? const Uuid().v4(),
|
||||||
|
createdAt = createdAt ?? clock.now();
|
||||||
|
}
|
||||||
@@ -10,6 +10,7 @@
|
|||||||
"choose_group": "Gruppe wählen",
|
"choose_group": "Gruppe wählen",
|
||||||
"choose_ruleset": "Regelwerk wählen",
|
"choose_ruleset": "Regelwerk wählen",
|
||||||
"could_not_add_player": "Spieler:in {playerName} konnte nicht hinzugefügt werden",
|
"could_not_add_player": "Spieler:in {playerName} konnte nicht hinzugefügt werden",
|
||||||
|
"create_game": "Spielvorlage erstellen",
|
||||||
"create_group": "Gruppe erstellen",
|
"create_group": "Gruppe erstellen",
|
||||||
"create_match": "Spiel erstellen",
|
"create_match": "Spiel erstellen",
|
||||||
"create_new_group": "Neue Gruppe erstellen",
|
"create_new_group": "Neue Gruppe erstellen",
|
||||||
@@ -22,13 +23,12 @@
|
|||||||
"days_ago": "vor {count} Tagen",
|
"days_ago": "vor {count} Tagen",
|
||||||
"delete": "Löschen",
|
"delete": "Löschen",
|
||||||
"delete_all_data": "Alle Daten löschen",
|
"delete_all_data": "Alle Daten löschen",
|
||||||
"delete_group": "Diese Gruppe löschen",
|
"delete_game": "Spielvorlage löschen",
|
||||||
"edit_group": "Gruppe bearbeiten",
|
|
||||||
"delete_group": "Gruppe löschen",
|
"delete_group": "Gruppe löschen",
|
||||||
|
"description": "Beschreibung",
|
||||||
|
"edit_game": "Spielvorlage bearbeiten",
|
||||||
"edit_group": "Gruppe bearbeiten",
|
"edit_group": "Gruppe bearbeiten",
|
||||||
"error_creating_group": "Fehler beim Erstellen der Gruppe, bitte erneut versuchen",
|
"error_creating_group": "Fehler beim Erstellen der Gruppe, bitte erneut versuchen",
|
||||||
"error_deleting_group": "Fehler beim Löschen der Gruppe, bitte erneut versuchen",
|
|
||||||
"error_editing_group": "Fehler beim Bearbeiten der Gruppe, bitte erneut versuchen",
|
|
||||||
"error_reading_file": "Fehler beim Lesen der Datei",
|
"error_reading_file": "Fehler beim Lesen der Datei",
|
||||||
"export_canceled": "Export abgebrochen",
|
"export_canceled": "Export abgebrochen",
|
||||||
"export_data": "Daten exportieren",
|
"export_data": "Daten exportieren",
|
||||||
|
|||||||
@@ -30,6 +30,9 @@
|
|||||||
"@could_not_add_player": {
|
"@could_not_add_player": {
|
||||||
"description": "Error message when adding a player fails"
|
"description": "Error message when adding a player fails"
|
||||||
},
|
},
|
||||||
|
"@create_game": {
|
||||||
|
"description": "Button text to create a game"
|
||||||
|
},
|
||||||
"@create_group": {
|
"@create_group": {
|
||||||
"description": "Button text to create a group"
|
"description": "Button text to create a group"
|
||||||
},
|
},
|
||||||
@@ -37,10 +40,10 @@
|
|||||||
"description": "Button text to create a match"
|
"description": "Button text to create a match"
|
||||||
},
|
},
|
||||||
"@create_new_group": {
|
"@create_new_group": {
|
||||||
"description": "Appbar text to create a new group"
|
"description": "Button text to create a new group"
|
||||||
},
|
},
|
||||||
"@create_new_match": {
|
"@create_new_match": {
|
||||||
"description": "Appbar text to create a new match"
|
"description": "Button text to create a new match"
|
||||||
},
|
},
|
||||||
"@created_on": {
|
"@created_on": {
|
||||||
"description": "Label for creation date"
|
"description": "Label for creation date"
|
||||||
@@ -71,21 +74,24 @@
|
|||||||
"@delete_all_data": {
|
"@delete_all_data": {
|
||||||
"description": "Confirmation dialog for deleting all data"
|
"description": "Confirmation dialog for deleting all data"
|
||||||
},
|
},
|
||||||
"@delete_group": {
|
"@delete_game": {
|
||||||
"description": "Confirmation dialog for deleting a group"
|
"description": "Button text to delete a game"
|
||||||
},
|
},
|
||||||
|
"@delete_group": {
|
||||||
|
"description": "Button text to delete a group"
|
||||||
|
},
|
||||||
|
"description": {
|
||||||
|
"description": "Description label"
|
||||||
|
},
|
||||||
|
"edit_game": {
|
||||||
|
"description": "Button text to edit a game"
|
||||||
|
},
|
||||||
"@edit_group": {
|
"@edit_group": {
|
||||||
"description": "Button & Appbar label for editing a group"
|
"description": "Button text to edit a group"
|
||||||
},
|
},
|
||||||
"@error_creating_group": {
|
"@error_creating_group": {
|
||||||
"description": "Error message when group creation fails"
|
"description": "Error message when group creation fails"
|
||||||
},
|
},
|
||||||
"@error_deleting_group": {
|
|
||||||
"description": "Error message when group deletion fails"
|
|
||||||
},
|
|
||||||
"@error_editing_group": {
|
|
||||||
"description": "Error message when group editing fails"
|
|
||||||
},
|
|
||||||
"@error_reading_file": {
|
"@error_reading_file": {
|
||||||
"description": "Error message when file cannot be read"
|
"description": "Error message when file cannot be read"
|
||||||
},
|
},
|
||||||
@@ -314,6 +320,7 @@
|
|||||||
"choose_group": "Choose Group",
|
"choose_group": "Choose Group",
|
||||||
"choose_ruleset": "Choose Ruleset",
|
"choose_ruleset": "Choose Ruleset",
|
||||||
"could_not_add_player": "Could not add player",
|
"could_not_add_player": "Could not add player",
|
||||||
|
"create_game": "Create Game",
|
||||||
"create_group": "Create Group",
|
"create_group": "Create Group",
|
||||||
"create_match": "Create match",
|
"create_match": "Create match",
|
||||||
"create_new_group": "Create new group",
|
"create_new_group": "Create new group",
|
||||||
@@ -326,11 +333,12 @@
|
|||||||
"days_ago": "{count} days ago",
|
"days_ago": "{count} days ago",
|
||||||
"delete": "Delete",
|
"delete": "Delete",
|
||||||
"delete_all_data": "Delete all data",
|
"delete_all_data": "Delete all data",
|
||||||
|
"delete_game": "Delete Game",
|
||||||
"delete_group": "Delete Group",
|
"delete_group": "Delete Group",
|
||||||
|
"description": "Description",
|
||||||
|
"edit_game": "Edit Game",
|
||||||
"edit_group": "Edit Group",
|
"edit_group": "Edit Group",
|
||||||
"error_creating_group": "Error while creating group, please try again",
|
"error_creating_group": "Error while creating group, please try again",
|
||||||
"error_deleting_group": "Error while deleting group, please try again",
|
|
||||||
"error_editing_group": "Error while editing group, please try again",
|
|
||||||
"error_reading_file": "Error reading file",
|
"error_reading_file": "Error reading file",
|
||||||
"export_canceled": "Export canceled",
|
"export_canceled": "Export canceled",
|
||||||
"export_data": "Export data",
|
"export_data": "Export data",
|
||||||
|
|||||||
@@ -98,6 +98,18 @@ abstract class AppLocalizations {
|
|||||||
Locale('en'),
|
Locale('en'),
|
||||||
];
|
];
|
||||||
|
|
||||||
|
/// No description provided for @description.
|
||||||
|
///
|
||||||
|
/// In en, this message translates to:
|
||||||
|
/// **'Description'**
|
||||||
|
String get description;
|
||||||
|
|
||||||
|
/// No description provided for @edit_game.
|
||||||
|
///
|
||||||
|
/// In en, this message translates to:
|
||||||
|
/// **'Edit Game'**
|
||||||
|
String get edit_game;
|
||||||
|
|
||||||
/// Label for all players list
|
/// Label for all players list
|
||||||
///
|
///
|
||||||
/// In en, this message translates to:
|
/// In en, this message translates to:
|
||||||
@@ -158,6 +170,12 @@ abstract class AppLocalizations {
|
|||||||
/// **'Could not add player'**
|
/// **'Could not add player'**
|
||||||
String could_not_add_player(Object playerName);
|
String could_not_add_player(Object playerName);
|
||||||
|
|
||||||
|
/// Button text to create a game
|
||||||
|
///
|
||||||
|
/// In en, this message translates to:
|
||||||
|
/// **'Create Game'**
|
||||||
|
String get create_game;
|
||||||
|
|
||||||
/// Button text to create a group
|
/// Button text to create a group
|
||||||
///
|
///
|
||||||
/// In en, this message translates to:
|
/// In en, this message translates to:
|
||||||
@@ -170,7 +188,7 @@ abstract class AppLocalizations {
|
|||||||
/// **'Create match'**
|
/// **'Create match'**
|
||||||
String get create_match;
|
String get create_match;
|
||||||
|
|
||||||
/// Appbar text to create a new group
|
/// Button text to create a new group
|
||||||
///
|
///
|
||||||
/// In en, this message translates to:
|
/// In en, this message translates to:
|
||||||
/// **'Create new group'**
|
/// **'Create new group'**
|
||||||
@@ -182,7 +200,7 @@ abstract class AppLocalizations {
|
|||||||
/// **'Created on'**
|
/// **'Created on'**
|
||||||
String get created_on;
|
String get created_on;
|
||||||
|
|
||||||
/// Appbar text to create a new match
|
/// Button text to create a new match
|
||||||
///
|
///
|
||||||
/// In en, this message translates to:
|
/// In en, this message translates to:
|
||||||
/// **'Create new match'**
|
/// **'Create new match'**
|
||||||
@@ -230,13 +248,19 @@ abstract class AppLocalizations {
|
|||||||
/// **'Delete all data'**
|
/// **'Delete all data'**
|
||||||
String get delete_all_data;
|
String get delete_all_data;
|
||||||
|
|
||||||
/// Confirmation dialog for deleting a group
|
/// Button text to delete a game
|
||||||
|
///
|
||||||
|
/// In en, this message translates to:
|
||||||
|
/// **'Delete Game'**
|
||||||
|
String get delete_game;
|
||||||
|
|
||||||
|
/// Button text to delete a group
|
||||||
///
|
///
|
||||||
/// In en, this message translates to:
|
/// In en, this message translates to:
|
||||||
/// **'Delete Group'**
|
/// **'Delete Group'**
|
||||||
String get delete_group;
|
String get delete_group;
|
||||||
|
|
||||||
/// Button & Appbar label for editing a group
|
/// Button text to edit a group
|
||||||
///
|
///
|
||||||
/// In en, this message translates to:
|
/// In en, this message translates to:
|
||||||
/// **'Edit Group'**
|
/// **'Edit Group'**
|
||||||
@@ -248,18 +272,6 @@ abstract class AppLocalizations {
|
|||||||
/// **'Error while creating group, please try again'**
|
/// **'Error while creating group, please try again'**
|
||||||
String get error_creating_group;
|
String get error_creating_group;
|
||||||
|
|
||||||
/// Error message when group deletion fails
|
|
||||||
///
|
|
||||||
/// In en, this message translates to:
|
|
||||||
/// **'Error while deleting group, please try again'**
|
|
||||||
String get error_deleting_group;
|
|
||||||
|
|
||||||
/// Error message when group editing fails
|
|
||||||
///
|
|
||||||
/// In en, this message translates to:
|
|
||||||
/// **'Error while editing group, please try again'**
|
|
||||||
String get error_editing_group;
|
|
||||||
|
|
||||||
/// Error message when file cannot be read
|
/// Error message when file cannot be read
|
||||||
///
|
///
|
||||||
/// In en, this message translates to:
|
/// In en, this message translates to:
|
||||||
|
|||||||
@@ -8,6 +8,12 @@ import 'app_localizations.dart';
|
|||||||
class AppLocalizationsDe extends AppLocalizations {
|
class AppLocalizationsDe extends AppLocalizations {
|
||||||
AppLocalizationsDe([String locale = 'de']) : super(locale);
|
AppLocalizationsDe([String locale = 'de']) : super(locale);
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get description => 'Beschreibung';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get edit_game => 'Spielvorlage bearbeiten';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get all_players => 'Alle Spieler:innen';
|
String get all_players => 'Alle Spieler:innen';
|
||||||
|
|
||||||
@@ -40,6 +46,9 @@ class AppLocalizationsDe extends AppLocalizations {
|
|||||||
return 'Spieler:in $playerName konnte nicht hinzugefügt werden';
|
return 'Spieler:in $playerName konnte nicht hinzugefügt werden';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get create_game => 'Spielvorlage erstellen';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get create_group => 'Gruppe erstellen';
|
String get create_group => 'Gruppe erstellen';
|
||||||
|
|
||||||
@@ -78,6 +87,9 @@ class AppLocalizationsDe extends AppLocalizations {
|
|||||||
@override
|
@override
|
||||||
String get delete_all_data => 'Alle Daten löschen';
|
String get delete_all_data => 'Alle Daten löschen';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get delete_game => 'Spielvorlage löschen';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get delete_group => 'Gruppe löschen';
|
String get delete_group => 'Gruppe löschen';
|
||||||
|
|
||||||
@@ -88,14 +100,6 @@ class AppLocalizationsDe extends AppLocalizations {
|
|||||||
String get error_creating_group =>
|
String get error_creating_group =>
|
||||||
'Fehler beim Erstellen der Gruppe, bitte erneut versuchen';
|
'Fehler beim Erstellen der Gruppe, bitte erneut versuchen';
|
||||||
|
|
||||||
@override
|
|
||||||
String get error_deleting_group =>
|
|
||||||
'Fehler beim Löschen der Gruppe, bitte erneut versuchen';
|
|
||||||
|
|
||||||
@override
|
|
||||||
String get error_editing_group =>
|
|
||||||
'Fehler beim Bearbeiten der Gruppe, bitte erneut versuchen';
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get error_reading_file => 'Fehler beim Lesen der Datei';
|
String get error_reading_file => 'Fehler beim Lesen der Datei';
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,12 @@ import 'app_localizations.dart';
|
|||||||
class AppLocalizationsEn extends AppLocalizations {
|
class AppLocalizationsEn extends AppLocalizations {
|
||||||
AppLocalizationsEn([String locale = 'en']) : super(locale);
|
AppLocalizationsEn([String locale = 'en']) : super(locale);
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get description => 'Description';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get edit_game => 'Edit Game';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get all_players => 'All players';
|
String get all_players => 'All players';
|
||||||
|
|
||||||
@@ -40,6 +46,9 @@ class AppLocalizationsEn extends AppLocalizations {
|
|||||||
return 'Could not add player';
|
return 'Could not add player';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get create_game => 'Create Game';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get create_group => 'Create Group';
|
String get create_group => 'Create Group';
|
||||||
|
|
||||||
@@ -78,6 +87,9 @@ class AppLocalizationsEn extends AppLocalizations {
|
|||||||
@override
|
@override
|
||||||
String get delete_all_data => 'Delete all data';
|
String get delete_all_data => 'Delete all data';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get delete_game => 'Delete Game';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get delete_group => 'Delete Group';
|
String get delete_group => 'Delete Group';
|
||||||
|
|
||||||
@@ -88,14 +100,6 @@ class AppLocalizationsEn extends AppLocalizations {
|
|||||||
String get error_creating_group =>
|
String get error_creating_group =>
|
||||||
'Error while creating group, please try again';
|
'Error while creating group, please try again';
|
||||||
|
|
||||||
@override
|
|
||||||
String get error_deleting_group =>
|
|
||||||
'Error while deleting group, please try again';
|
|
||||||
|
|
||||||
@override
|
|
||||||
String get error_editing_group =>
|
|
||||||
'Error while editing group, please try again';
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get error_reading_file => 'Error reading file';
|
String get error_reading_file => 'Error reading file';
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:game_tracker/core/adaptive_page_route.dart';
|
import 'package:game_tracker/core/adaptive_page_route.dart';
|
||||||
import 'package:game_tracker/core/custom_theme.dart';
|
import 'package:game_tracker/core/custom_theme.dart';
|
||||||
import 'package:game_tracker/l10n/generated/app_localizations.dart';
|
import 'package:game_tracker/l10n/generated/app_localizations.dart';
|
||||||
import 'package:game_tracker/presentation/views/main_menu/group_view/group_view.dart';
|
import 'package:game_tracker/presentation/views/main_menu/group_view/groups_view.dart';
|
||||||
import 'package:game_tracker/presentation/views/main_menu/home_view.dart';
|
import 'package:game_tracker/presentation/views/main_menu/home_view.dart';
|
||||||
import 'package:game_tracker/presentation/views/main_menu/match_view/match_view.dart';
|
import 'package:game_tracker/presentation/views/main_menu/match_view/match_view.dart';
|
||||||
import 'package:game_tracker/presentation/views/main_menu/settings_view/settings_view.dart';
|
import 'package:game_tracker/presentation/views/main_menu/settings_view/settings_view.dart';
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:game_tracker/core/constants.dart';
|
||||||
import 'package:game_tracker/core/custom_theme.dart';
|
import 'package:game_tracker/core/custom_theme.dart';
|
||||||
import 'package:game_tracker/core/enums.dart';
|
import 'package:game_tracker/core/enums.dart';
|
||||||
import 'package:game_tracker/data/db/database.dart';
|
import 'package:game_tracker/data/db/database.dart';
|
||||||
@@ -11,10 +12,8 @@ import 'package:game_tracker/presentation/widgets/text_input/text_input_field.da
|
|||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
class CreateGroupView extends StatefulWidget {
|
class CreateGroupView extends StatefulWidget {
|
||||||
const CreateGroupView({super.key, this.groupToEdit});
|
/// A view that allows the user to create a new group
|
||||||
|
const CreateGroupView({super.key});
|
||||||
/// The group to edit, if any
|
|
||||||
final Group? groupToEdit;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<CreateGroupView> createState() => _CreateGroupViewState();
|
State<CreateGroupView> createState() => _CreateGroupViewState();
|
||||||
@@ -23,29 +22,16 @@ class CreateGroupView extends StatefulWidget {
|
|||||||
class _CreateGroupViewState extends State<CreateGroupView> {
|
class _CreateGroupViewState extends State<CreateGroupView> {
|
||||||
late final AppDatabase db;
|
late final AppDatabase db;
|
||||||
|
|
||||||
/// GlobalKey for ScaffoldMessenger to show snackbars
|
|
||||||
final _scaffoldMessengerKey = GlobalKey<ScaffoldMessengerState>();
|
|
||||||
|
|
||||||
/// Controller for the group name input field
|
/// Controller for the group name input field
|
||||||
final _groupNameController = TextEditingController();
|
final _groupNameController = TextEditingController();
|
||||||
|
|
||||||
/// List of currently selected players
|
/// List of currently selected players
|
||||||
List<Player> selectedPlayers = [];
|
List<Player> selectedPlayers = [];
|
||||||
|
|
||||||
/// List of initially selected players (when editing a group)
|
|
||||||
List<Player> initialSelectedPlayers = [];
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
db = Provider.of<AppDatabase>(context, listen: false);
|
db = Provider.of<AppDatabase>(context, listen: false);
|
||||||
if(widget.groupToEdit != null) {
|
|
||||||
_groupNameController.text = widget.groupToEdit!.name;
|
|
||||||
setState(() {
|
|
||||||
initialSelectedPlayers = widget.groupToEdit!.members;
|
|
||||||
selectedPlayers = widget.groupToEdit!.members;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
_groupNameController.addListener(() {
|
_groupNameController.addListener(() {
|
||||||
setState(() {});
|
setState(() {});
|
||||||
});
|
});
|
||||||
@@ -61,42 +47,10 @@ class _CreateGroupViewState extends State<CreateGroupView> {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final loc = AppLocalizations.of(context);
|
final loc = AppLocalizations.of(context);
|
||||||
return ScaffoldMessenger(
|
return ScaffoldMessenger(
|
||||||
key: _scaffoldMessengerKey,
|
|
||||||
child: Scaffold(
|
child: Scaffold(
|
||||||
resizeToAvoidBottomInset: false,
|
resizeToAvoidBottomInset: false,
|
||||||
backgroundColor: CustomTheme.backgroundColor,
|
backgroundColor: CustomTheme.backgroundColor,
|
||||||
appBar: AppBar(title: Text(widget.groupToEdit == null ? loc.create_new_group : loc.edit_group), actions: widget.groupToEdit == null ? [] : [IconButton(icon: const Icon(Icons.delete), onPressed: () async {
|
appBar: AppBar(title: Text(loc.create_new_group)),
|
||||||
if(widget.groupToEdit != null) {
|
|
||||||
showDialog<bool>(
|
|
||||||
context: context,
|
|
||||||
builder: (context) => AlertDialog(
|
|
||||||
title: Text(loc.delete_group),
|
|
||||||
content: Text(loc.this_cannot_be_undone),
|
|
||||||
actions: [
|
|
||||||
TextButton(
|
|
||||||
onPressed: () => Navigator.of(context).pop(false),
|
|
||||||
child: Text(loc.cancel),
|
|
||||||
),
|
|
||||||
TextButton(
|
|
||||||
onPressed: () => Navigator.of(context).pop(true),
|
|
||||||
child: Text(loc.delete),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
).then((confirmed) async {
|
|
||||||
if (confirmed == true && context.mounted) {
|
|
||||||
bool success = await db.groupDao.deleteGroup(groupId: widget.groupToEdit!.id);
|
|
||||||
if (!context.mounted) return;
|
|
||||||
if (success) {
|
|
||||||
Navigator.pop(context);
|
|
||||||
} else {
|
|
||||||
if (!mounted) return;
|
|
||||||
showSnackbar(message: loc.error_deleting_group);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},)],),
|
|
||||||
body: SafeArea(
|
body: SafeArea(
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
@@ -106,11 +60,11 @@ class _CreateGroupViewState extends State<CreateGroupView> {
|
|||||||
child: TextInputField(
|
child: TextInputField(
|
||||||
controller: _groupNameController,
|
controller: _groupNameController,
|
||||||
hintText: loc.group_name,
|
hintText: loc.group_name,
|
||||||
|
maxLength: Constants.MAX_GROUP_NAME_LENGTH,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: PlayerSelection(
|
child: PlayerSelection(
|
||||||
initialSelectedPlayers: initialSelectedPlayers,
|
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
setState(() {
|
setState(() {
|
||||||
selectedPlayers = [...value];
|
selectedPlayers = [...value];
|
||||||
@@ -119,7 +73,7 @@ class _CreateGroupViewState extends State<CreateGroupView> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
CustomWidthButton(
|
CustomWidthButton(
|
||||||
text: widget.groupToEdit == null ? loc.create_group : loc.edit_group,
|
text: loc.create_group,
|
||||||
sizeRelativeToWidth: 0.95,
|
sizeRelativeToWidth: 0.95,
|
||||||
buttonType: ButtonType.primary,
|
buttonType: ButtonType.primary,
|
||||||
onPressed:
|
onPressed:
|
||||||
@@ -127,34 +81,29 @@ class _CreateGroupViewState extends State<CreateGroupView> {
|
|||||||
(selectedPlayers.length < 2))
|
(selectedPlayers.length < 2))
|
||||||
? null
|
? null
|
||||||
: () async {
|
: () async {
|
||||||
late Group? updatedGroup;
|
bool success = await db.groupDao.addGroup(
|
||||||
late bool success;
|
group: Group(
|
||||||
if (widget.groupToEdit == null) {
|
|
||||||
success = await db.groupDao.addGroup(
|
|
||||||
group: Group(
|
|
||||||
name: _groupNameController.text.trim(),
|
|
||||||
members: selectedPlayers,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
updatedGroup = Group(
|
|
||||||
id: widget.groupToEdit!.id,
|
|
||||||
name: _groupNameController.text.trim(),
|
name: _groupNameController.text.trim(),
|
||||||
members: selectedPlayers,
|
members: selectedPlayers,
|
||||||
);
|
),
|
||||||
//TODO: Implement group editing in database
|
);
|
||||||
/*
|
|
||||||
success = await db.groupDao.updateGroup(
|
|
||||||
group: updatedGroup,
|
|
||||||
);
|
|
||||||
*/
|
|
||||||
success = true;
|
|
||||||
}
|
|
||||||
if (!context.mounted) return;
|
if (!context.mounted) return;
|
||||||
if (success) {
|
if (success) {
|
||||||
Navigator.pop(context, updatedGroup);
|
Navigator.pop(context);
|
||||||
} else {
|
} else {
|
||||||
showSnackbar(message: widget.groupToEdit == null ? loc.error_creating_group : loc.error_editing_group);
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
SnackBar(
|
||||||
|
backgroundColor: CustomTheme.boxColor,
|
||||||
|
content: Center(
|
||||||
|
child: Text(
|
||||||
|
AppLocalizations.of(
|
||||||
|
context,
|
||||||
|
).error_creating_group,
|
||||||
|
style: const TextStyle(color: Colors.white),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
@@ -165,21 +114,4 @@ class _CreateGroupViewState extends State<CreateGroupView> {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
/// Displays a snackbar with the given message and optional action.
|
|
||||||
///
|
|
||||||
/// [message] The message to display in the snackbar.
|
|
||||||
void showSnackbar({
|
|
||||||
required String message,
|
|
||||||
}) {
|
|
||||||
final messenger = _scaffoldMessengerKey.currentState;
|
|
||||||
if (messenger != null) {
|
|
||||||
messenger.hideCurrentSnackBar();
|
|
||||||
messenger.showSnackBar(
|
|
||||||
SnackBar(
|
|
||||||
content: Text(message, style: const TextStyle(color: Colors.white)),
|
|
||||||
backgroundColor: CustomTheme.boxColor,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,10 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:game_tracker/core/adaptive_page_route.dart';
|
|
||||||
import 'package:game_tracker/core/custom_theme.dart';
|
import 'package:game_tracker/core/custom_theme.dart';
|
||||||
import 'package:game_tracker/data/db/database.dart';
|
import 'package:game_tracker/data/db/database.dart';
|
||||||
import 'package:game_tracker/data/dto/group.dart';
|
import 'package:game_tracker/data/dto/group.dart';
|
||||||
import 'package:game_tracker/data/dto/match.dart';
|
import 'package:game_tracker/data/dto/match.dart';
|
||||||
import 'package:game_tracker/data/dto/player.dart';
|
import 'package:game_tracker/data/dto/player.dart';
|
||||||
import 'package:game_tracker/l10n/generated/app_localizations.dart';
|
import 'package:game_tracker/l10n/generated/app_localizations.dart';
|
||||||
import 'package:game_tracker/presentation/views/main_menu/group_view/create_group_view.dart';
|
|
||||||
import 'package:game_tracker/presentation/widgets/app_skeleton.dart';
|
import 'package:game_tracker/presentation/widgets/app_skeleton.dart';
|
||||||
import 'package:game_tracker/presentation/widgets/buttons/animated_dialog_button.dart';
|
import 'package:game_tracker/presentation/widgets/buttons/animated_dialog_button.dart';
|
||||||
import 'package:game_tracker/presentation/widgets/buttons/main_menu_button.dart';
|
import 'package:game_tracker/presentation/widgets/buttons/main_menu_button.dart';
|
||||||
@@ -17,10 +15,10 @@ import 'package:game_tracker/presentation/widgets/tiles/text_icon_tile.dart';
|
|||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
class GroupDetailView extends StatefulWidget {
|
class GroupProfileView extends StatefulWidget {
|
||||||
/// A view that displays the profile of a group
|
/// A view that displays the profile of a group
|
||||||
/// - [group]: The group to display
|
/// - [group]: The group to display
|
||||||
const GroupDetailView({
|
const GroupProfileView({
|
||||||
super.key,
|
super.key,
|
||||||
required this.group,
|
required this.group,
|
||||||
required this.callback,
|
required this.callback,
|
||||||
@@ -32,13 +30,12 @@ class GroupDetailView extends StatefulWidget {
|
|||||||
final VoidCallback callback;
|
final VoidCallback callback;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<GroupDetailView> createState() => _GroupDetailViewState();
|
State<GroupProfileView> createState() => _GroupProfileViewState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _GroupDetailViewState extends State<GroupDetailView> {
|
class _GroupProfileViewState extends State<GroupProfileView> {
|
||||||
late final AppDatabase db;
|
late final AppDatabase db;
|
||||||
bool isLoading = true;
|
bool isLoading = true;
|
||||||
late Group _group;
|
|
||||||
|
|
||||||
/// Total matches played in this group
|
/// Total matches played in this group
|
||||||
int totalMatches = 0;
|
int totalMatches = 0;
|
||||||
@@ -48,7 +45,6 @@ class _GroupDetailViewState extends State<GroupDetailView> {
|
|||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
_group = widget.group;
|
|
||||||
db = Provider.of<AppDatabase>(context, listen: false);
|
db = Provider.of<AppDatabase>(context, listen: false);
|
||||||
_loadStatistics();
|
_loadStatistics();
|
||||||
}
|
}
|
||||||
@@ -89,7 +85,7 @@ class _GroupDetailViewState extends State<GroupDetailView> {
|
|||||||
),
|
),
|
||||||
).then((confirmed) async {
|
).then((confirmed) async {
|
||||||
if (confirmed! && context.mounted) {
|
if (confirmed! && context.mounted) {
|
||||||
await db.groupDao.deleteGroup(groupId: _group.id);
|
await db.groupDao.deleteGroup(groupId: widget.group.id);
|
||||||
if (!context.mounted) return;
|
if (!context.mounted) return;
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
widget.callback.call();
|
widget.callback.call();
|
||||||
@@ -120,7 +116,7 @@ class _GroupDetailViewState extends State<GroupDetailView> {
|
|||||||
),
|
),
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
Text(
|
Text(
|
||||||
_group.name,
|
widget.group.name,
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
fontSize: 28,
|
fontSize: 28,
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
@@ -130,7 +126,7 @@ class _GroupDetailViewState extends State<GroupDetailView> {
|
|||||||
),
|
),
|
||||||
const SizedBox(height: 5),
|
const SizedBox(height: 5),
|
||||||
Text(
|
Text(
|
||||||
'${loc.created_on} ${DateFormat.yMMMd(Localizations.localeOf(context).toString()).format(_group.createdAt)}',
|
'${loc.created_on} ${DateFormat.yMMMd(Localizations.localeOf(context).toString()).format(widget.group.createdAt)}',
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
fontSize: 12,
|
fontSize: 12,
|
||||||
color: CustomTheme.textColor,
|
color: CustomTheme.textColor,
|
||||||
@@ -147,7 +143,7 @@ class _GroupDetailViewState extends State<GroupDetailView> {
|
|||||||
crossAxisAlignment: WrapCrossAlignment.start,
|
crossAxisAlignment: WrapCrossAlignment.start,
|
||||||
spacing: 12,
|
spacing: 12,
|
||||||
runSpacing: 8,
|
runSpacing: 8,
|
||||||
children: _group.members.map((member) {
|
children: widget.group.members.map((member) {
|
||||||
return TextIconTile(
|
return TextIconTile(
|
||||||
text: member.name,
|
text: member.name,
|
||||||
iconEnabled: false,
|
iconEnabled: false,
|
||||||
@@ -165,7 +161,7 @@ class _GroupDetailViewState extends State<GroupDetailView> {
|
|||||||
children: [
|
children: [
|
||||||
_buildStatRow(
|
_buildStatRow(
|
||||||
loc.members,
|
loc.members,
|
||||||
_group.members.length.toString(),
|
widget.group.members.length.toString(),
|
||||||
),
|
),
|
||||||
_buildStatRow(
|
_buildStatRow(
|
||||||
loc.played_matches,
|
loc.played_matches,
|
||||||
@@ -183,24 +179,19 @@ class _GroupDetailViewState extends State<GroupDetailView> {
|
|||||||
child: MainMenuButton(
|
child: MainMenuButton(
|
||||||
text: loc.edit_group,
|
text: loc.edit_group,
|
||||||
icon: Icons.edit,
|
icon: Icons.edit,
|
||||||
onPressed: () async {
|
onPressed: () {
|
||||||
final updatedGroup = await Navigator.push<Group?>(
|
// TODO: Uncomment when GroupDetailView is implemented
|
||||||
|
/*
|
||||||
|
await Navigator.push(
|
||||||
context,
|
context,
|
||||||
adaptivePageRoute(
|
adaptivePageRoute(
|
||||||
builder: (context) {
|
builder: (context) {
|
||||||
return CreateGroupView(
|
|
||||||
groupToEdit: _group,
|
return const GroupDetailView();
|
||||||
);
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
);
|
);*/
|
||||||
if (updatedGroup != null && mounted) {
|
print('Edit Group pressed');
|
||||||
setState(() {
|
|
||||||
_group = updatedGroup;
|
|
||||||
});
|
|
||||||
_loadStatistics();
|
|
||||||
widget.callback();
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -242,8 +233,9 @@ class _GroupDetailViewState extends State<GroupDetailView> {
|
|||||||
/// Loads statistics for this group
|
/// Loads statistics for this group
|
||||||
Future<void> _loadStatistics() async {
|
Future<void> _loadStatistics() async {
|
||||||
final matches = await db.matchDao.getAllMatches();
|
final matches = await db.matchDao.getAllMatches();
|
||||||
final groupMatches =
|
final groupMatches = matches
|
||||||
matches.where((match) => match.group?.id == _group.id).toList();
|
.where((match) => match.group?.id == widget.group.id)
|
||||||
|
.toList();
|
||||||
|
|
||||||
setState(() {
|
setState(() {
|
||||||
totalMatches = groupMatches.length;
|
totalMatches = groupMatches.length;
|
||||||
@@ -261,7 +253,7 @@ class _GroupDetailViewState extends State<GroupDetailView> {
|
|||||||
if (match.winner != null) {
|
if (match.winner != null) {
|
||||||
bestPlayerCounts.update(
|
bestPlayerCounts.update(
|
||||||
match.winner!,
|
match.winner!,
|
||||||
(value) => value + 1,
|
(value) => value + 1,
|
||||||
ifAbsent: () => 1,
|
ifAbsent: () => 1,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -6,8 +6,8 @@ import 'package:game_tracker/data/db/database.dart';
|
|||||||
import 'package:game_tracker/data/dto/group.dart';
|
import 'package:game_tracker/data/dto/group.dart';
|
||||||
import 'package:game_tracker/data/dto/player.dart';
|
import 'package:game_tracker/data/dto/player.dart';
|
||||||
import 'package:game_tracker/l10n/generated/app_localizations.dart';
|
import 'package:game_tracker/l10n/generated/app_localizations.dart';
|
||||||
import 'package:game_tracker/presentation/views/main_menu/group_view/group_detail_view.dart';
|
|
||||||
import 'package:game_tracker/presentation/views/main_menu/group_view/create_group_view.dart';
|
import 'package:game_tracker/presentation/views/main_menu/group_view/create_group_view.dart';
|
||||||
|
import 'package:game_tracker/presentation/views/main_menu/group_view/group_profile_view.dart';
|
||||||
import 'package:game_tracker/presentation/widgets/app_skeleton.dart';
|
import 'package:game_tracker/presentation/widgets/app_skeleton.dart';
|
||||||
import 'package:game_tracker/presentation/widgets/buttons/main_menu_button.dart';
|
import 'package:game_tracker/presentation/widgets/buttons/main_menu_button.dart';
|
||||||
import 'package:game_tracker/presentation/widgets/tiles/group_tile.dart';
|
import 'package:game_tracker/presentation/widgets/tiles/group_tile.dart';
|
||||||
@@ -82,7 +82,7 @@ class _GroupsViewState extends State<GroupsView> {
|
|||||||
context,
|
context,
|
||||||
adaptivePageRoute(
|
adaptivePageRoute(
|
||||||
builder: (context) {
|
builder: (context) {
|
||||||
return GroupDetailView(
|
return GroupProfileView(
|
||||||
group: groups[index],
|
group: groups[index],
|
||||||
callback: loadGroups,
|
callback: loadGroups,
|
||||||
);
|
);
|
||||||
@@ -1,7 +1,10 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:game_tracker/core/adaptive_page_route.dart';
|
||||||
import 'package:game_tracker/core/custom_theme.dart';
|
import 'package:game_tracker/core/custom_theme.dart';
|
||||||
import 'package:game_tracker/core/enums.dart';
|
import 'package:game_tracker/core/enums.dart';
|
||||||
|
import 'package:game_tracker/data/dto/game.dart';
|
||||||
import 'package:game_tracker/l10n/generated/app_localizations.dart';
|
import 'package:game_tracker/l10n/generated/app_localizations.dart';
|
||||||
|
import 'package:game_tracker/presentation/views/main_menu/match_view/create_match/game_view/create_game_view.dart';
|
||||||
import 'package:game_tracker/presentation/widgets/text_input/custom_search_bar.dart';
|
import 'package:game_tracker/presentation/widgets/text_input/custom_search_bar.dart';
|
||||||
import 'package:game_tracker/presentation/widgets/tiles/title_description_list_tile.dart';
|
import 'package:game_tracker/presentation/widgets/tiles/title_description_list_tile.dart';
|
||||||
|
|
||||||
@@ -51,6 +54,17 @@ class _ChooseGameViewState extends State<ChooseGameView> {
|
|||||||
Navigator.of(context).pop(selectedGameIndex);
|
Navigator.of(context).pop(selectedGameIndex);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
actions: [IconButton(
|
||||||
|
icon: const Icon(Icons.add),
|
||||||
|
onPressed: () async {
|
||||||
|
await Navigator.push(context, adaptivePageRoute(
|
||||||
|
builder: (context) => CreateGameView(
|
||||||
|
callback: () {}, //TODO: implement callback
|
||||||
|
),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
},
|
||||||
|
)],
|
||||||
title: Text(loc.choose_game),
|
title: Text(loc.choose_game),
|
||||||
),
|
),
|
||||||
body: PopScope(
|
body: PopScope(
|
||||||
@@ -85,7 +99,7 @@ class _ChooseGameViewState extends State<ChooseGameView> {
|
|||||||
context,
|
context,
|
||||||
),
|
),
|
||||||
isHighlighted: selectedGameIndex == index,
|
isHighlighted: selectedGameIndex == index,
|
||||||
onPressed: () async {
|
onTap: () async {
|
||||||
setState(() {
|
setState(() {
|
||||||
if (selectedGameIndex == index) {
|
if (selectedGameIndex == index) {
|
||||||
selectedGameIndex = -1;
|
selectedGameIndex = -1;
|
||||||
@@ -94,6 +108,16 @@ class _ChooseGameViewState extends State<ChooseGameView> {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
onLongPress: () async {
|
||||||
|
await Navigator.push(context, adaptivePageRoute(
|
||||||
|
builder: (context) => CreateGameView(
|
||||||
|
//TODO: implement callback & giving real game to create game view
|
||||||
|
gameToEdit: Game(name: 'Cabo', description: '', ruleset: 'Highest Points'),
|
||||||
|
callback: () {},
|
||||||
|
),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
},
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -64,9 +64,6 @@ class _CreateMatchViewState extends State<CreateMatchView> {
|
|||||||
/// The currently selected players
|
/// The currently selected players
|
||||||
List<Player>? selectedPlayers;
|
List<Player>? selectedPlayers;
|
||||||
|
|
||||||
/// GlobalKey for ScaffoldMessenger to show snackbars
|
|
||||||
final _scaffoldMessengerKey = GlobalKey<ScaffoldMessengerState>();
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
@@ -110,7 +107,6 @@ class _CreateMatchViewState extends State<CreateMatchView> {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final loc = AppLocalizations.of(context);
|
final loc = AppLocalizations.of(context);
|
||||||
return ScaffoldMessenger(
|
return ScaffoldMessenger(
|
||||||
key: _scaffoldMessengerKey,
|
|
||||||
child: Scaffold(
|
child: Scaffold(
|
||||||
resizeToAvoidBottomInset: false,
|
resizeToAvoidBottomInset: false,
|
||||||
backgroundColor: CustomTheme.backgroundColor,
|
backgroundColor: CustomTheme.backgroundColor,
|
||||||
|
|||||||
@@ -0,0 +1,93 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:game_tracker/core/custom_theme.dart';
|
||||||
|
import 'package:game_tracker/core/enums.dart';
|
||||||
|
import 'package:game_tracker/l10n/generated/app_localizations.dart';
|
||||||
|
import 'package:game_tracker/presentation/widgets/tiles/title_description_list_tile.dart';
|
||||||
|
class ChooseRulesetView extends StatefulWidget {
|
||||||
|
/// A view that allows the user to choose a ruleset from a list of available rulesets
|
||||||
|
/// - [rulesets]: A list of tuples containing the ruleset and its description
|
||||||
|
/// - [initialRulesetIndex]: The index of the initially selected ruleset
|
||||||
|
const ChooseRulesetView({
|
||||||
|
super.key,
|
||||||
|
required this.rulesets,
|
||||||
|
required this.initialRulesetIndex,
|
||||||
|
});
|
||||||
|
/// A list of tuples containing the ruleset and its description
|
||||||
|
final List<(Ruleset, String)> rulesets;
|
||||||
|
/// The index of the initially selected ruleset
|
||||||
|
final int initialRulesetIndex;
|
||||||
|
@override
|
||||||
|
State<ChooseRulesetView> createState() => _ChooseRulesetViewState();
|
||||||
|
}
|
||||||
|
class _ChooseRulesetViewState extends State<ChooseRulesetView> {
|
||||||
|
/// Currently selected ruleset index
|
||||||
|
late int selectedRulesetIndex;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
selectedRulesetIndex = widget.initialRulesetIndex;
|
||||||
|
super.initState();
|
||||||
|
}
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final loc = AppLocalizations.of(context);
|
||||||
|
return DefaultTabController(
|
||||||
|
length: 2,
|
||||||
|
initialIndex: 0,
|
||||||
|
child: Scaffold(
|
||||||
|
backgroundColor: CustomTheme.backgroundColor,
|
||||||
|
appBar: AppBar(
|
||||||
|
leading: IconButton(
|
||||||
|
icon: const Icon(Icons.arrow_back_ios),
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.of(context).pop(
|
||||||
|
selectedRulesetIndex == -1
|
||||||
|
? null
|
||||||
|
: widget.rulesets[selectedRulesetIndex].$1,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
title: Text(loc.choose_ruleset),
|
||||||
|
),
|
||||||
|
body: PopScope(
|
||||||
|
// This fixes that the Android Back Gesture didn't return the
|
||||||
|
// selectedRulesetIndex and therefore the selected Ruleset wasn't saved
|
||||||
|
canPop: false,
|
||||||
|
onPopInvokedWithResult: (bool didPop, Object? result) {
|
||||||
|
if (didPop) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Navigator.of(context).pop(
|
||||||
|
selectedRulesetIndex == -1
|
||||||
|
? null
|
||||||
|
: widget.rulesets[selectedRulesetIndex].$1,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
child: ListView.builder(
|
||||||
|
padding: const EdgeInsets.only(bottom: 85),
|
||||||
|
itemCount: widget.rulesets.length,
|
||||||
|
itemBuilder: (BuildContext context, int index) {
|
||||||
|
return TitleDescriptionListTile(
|
||||||
|
onTap: () async {
|
||||||
|
setState(() {
|
||||||
|
if (selectedRulesetIndex == index) {
|
||||||
|
selectedRulesetIndex = -1;
|
||||||
|
} else {
|
||||||
|
selectedRulesetIndex = index;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
title: translateRulesetToString(
|
||||||
|
widget.rulesets[index].$1,
|
||||||
|
context,
|
||||||
|
),
|
||||||
|
description: widget.rulesets[index].$2,
|
||||||
|
isHighlighted: selectedRulesetIndex == index,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,140 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:game_tracker/core/adaptive_page_route.dart';
|
||||||
|
import 'package:game_tracker/core/constants.dart';
|
||||||
|
import 'package:game_tracker/core/custom_theme.dart';
|
||||||
|
import 'package:game_tracker/core/enums.dart';
|
||||||
|
import 'package:game_tracker/data/dto/game.dart';
|
||||||
|
import 'package:game_tracker/l10n/generated/app_localizations.dart';
|
||||||
|
import 'package:game_tracker/presentation/views/main_menu/match_view/create_match/game_view/choose_ruleset_view.dart';
|
||||||
|
import 'package:game_tracker/presentation/widgets/buttons/custom_width_button.dart';
|
||||||
|
import 'package:game_tracker/presentation/widgets/text_input/text_input_field.dart';
|
||||||
|
import 'package:game_tracker/presentation/widgets/tiles/choose_tile.dart';
|
||||||
|
|
||||||
|
class CreateGameView extends StatefulWidget {
|
||||||
|
const CreateGameView({super.key, this.gameToEdit, required this.callback});
|
||||||
|
|
||||||
|
final Game? gameToEdit;
|
||||||
|
|
||||||
|
final VoidCallback callback;
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<CreateGameView> createState() => _CreateGameViewState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _CreateGameViewState extends State<CreateGameView> {
|
||||||
|
Ruleset? selectedRuleset;
|
||||||
|
int selectedRulesetIndex = -1;
|
||||||
|
late List<(Ruleset, String)> _rulesets;
|
||||||
|
|
||||||
|
final _gameNameController = TextEditingController();
|
||||||
|
final _descriptionController = TextEditingController();
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_gameNameController.addListener(() => setState(() {}));
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void didChangeDependencies() {
|
||||||
|
super.didChangeDependencies();
|
||||||
|
final loc = AppLocalizations.of(context);
|
||||||
|
_rulesets = [
|
||||||
|
(Ruleset.singleWinner, loc.ruleset_single_winner),
|
||||||
|
(Ruleset.singleLoser, loc.ruleset_single_loser),
|
||||||
|
(Ruleset.mostPoints, loc.ruleset_most_points),
|
||||||
|
(Ruleset.leastPoints, loc.ruleset_least_points),
|
||||||
|
];
|
||||||
|
|
||||||
|
if (widget.gameToEdit != null) {
|
||||||
|
_gameNameController.text = widget.gameToEdit!.name;
|
||||||
|
_descriptionController.text = widget.gameToEdit!.description ?? '';
|
||||||
|
// TODO: Handle ruleset initialization from gameToEdit
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_gameNameController.dispose();
|
||||||
|
_descriptionController.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
var loc = AppLocalizations.of(context);
|
||||||
|
final isEditing = widget.gameToEdit != null;
|
||||||
|
|
||||||
|
return ScaffoldMessenger(
|
||||||
|
child: Scaffold(
|
||||||
|
backgroundColor: CustomTheme.backgroundColor,
|
||||||
|
appBar: AppBar(
|
||||||
|
title: Text(isEditing ? loc.edit_game : loc.create_game),
|
||||||
|
),
|
||||||
|
body: SafeArea(
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
margin: CustomTheme.tileMargin,
|
||||||
|
child: TextInputField(
|
||||||
|
controller: _gameNameController,
|
||||||
|
maxLength: Constants.MAX_MATCH_NAME_LENGTH,
|
||||||
|
hintText: loc.game_name,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
ChooseTile(
|
||||||
|
title: loc.ruleset,
|
||||||
|
trailingText: selectedRuleset == null
|
||||||
|
? loc.none
|
||||||
|
: translateRulesetToString(selectedRuleset!, context),
|
||||||
|
onPressed: () async {
|
||||||
|
final result = await Navigator.of(context).push<Ruleset?>(
|
||||||
|
adaptivePageRoute(
|
||||||
|
builder: (context) => ChooseRulesetView(
|
||||||
|
rulesets: _rulesets,
|
||||||
|
initialRulesetIndex: selectedRulesetIndex,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
if (mounted) {
|
||||||
|
setState(() {
|
||||||
|
selectedRuleset = result;
|
||||||
|
selectedRulesetIndex =
|
||||||
|
result == null ? -1 : _rulesets.indexWhere((r) => r.$1 == result);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
Container(
|
||||||
|
margin: CustomTheme.tileMargin,
|
||||||
|
child: TextInputField(
|
||||||
|
controller: _descriptionController,
|
||||||
|
hintText: loc.description,
|
||||||
|
minLines: 6,
|
||||||
|
maxLines: 6,
|
||||||
|
maxLength: Constants.MAX_GAME_DESCRIPTION_LENGTH,
|
||||||
|
showCounterText: true,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const Spacer(),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.all(12.0),
|
||||||
|
child: CustomWidthButton(
|
||||||
|
text: isEditing ? loc.edit_group : loc.create_game,
|
||||||
|
sizeRelativeToWidth: 1,
|
||||||
|
buttonType: ButtonType.primary,
|
||||||
|
onPressed: _gameNameController.text.trim().isNotEmpty && selectedRulesetIndex != -1
|
||||||
|
? () {
|
||||||
|
//TODO: Handle saving to db & updating game selection view
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
}
|
||||||
|
: null,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -31,7 +31,6 @@ class _SettingsViewState extends State<SettingsView> {
|
|||||||
version: 'n.A.',
|
version: 'n.A.',
|
||||||
buildNumber: 'n.A.',
|
buildNumber: 'n.A.',
|
||||||
);
|
);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
|
|||||||
@@ -70,7 +70,6 @@ class _PlayerSelectionState extends State<PlayerSelection> {
|
|||||||
super.initState();
|
super.initState();
|
||||||
db = Provider.of<AppDatabase>(context, listen: false);
|
db = Provider.of<AppDatabase>(context, listen: false);
|
||||||
suggestedPlayers = skeletonData;
|
suggestedPlayers = skeletonData;
|
||||||
selectedPlayers = widget.initialSelectedPlayers ?? [];
|
|
||||||
loadPlayerList();
|
loadPlayerList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -85,6 +84,7 @@ class _PlayerSelectionState extends State<PlayerSelection> {
|
|||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
CustomSearchBar(
|
CustomSearchBar(
|
||||||
|
maxLength: Constants.MAX_PLAYER_NAME_LENGTH,
|
||||||
controller: _searchBarController,
|
controller: _searchBarController,
|
||||||
constraints: const BoxConstraints(maxHeight: 45, minHeight: 45),
|
constraints: const BoxConstraints(maxHeight: 45, minHeight: 45),
|
||||||
hintText: loc.search_for_players,
|
hintText: loc.search_for_players,
|
||||||
@@ -100,7 +100,7 @@ class _PlayerSelectionState extends State<PlayerSelection> {
|
|||||||
if (value.isEmpty) {
|
if (value.isEmpty) {
|
||||||
// If the search is empty, it shows all unselected players.
|
// If the search is empty, it shows all unselected players.
|
||||||
suggestedPlayers = allPlayers.where((player) {
|
suggestedPlayers = allPlayers.where((player) {
|
||||||
return !selectedPlayers.any((p) => p.id == player.id);
|
return !selectedPlayers.contains(player);
|
||||||
}).toList();
|
}).toList();
|
||||||
} else {
|
} else {
|
||||||
// If there is input, it filters by name match (case-insensitive) and ensures
|
// If there is input, it filters by name match (case-insensitive) and ensures
|
||||||
@@ -109,7 +109,9 @@ class _PlayerSelectionState extends State<PlayerSelection> {
|
|||||||
final bool nameMatches = player.name.toLowerCase().contains(
|
final bool nameMatches = player.name.toLowerCase().contains(
|
||||||
value.toLowerCase(),
|
value.toLowerCase(),
|
||||||
);
|
);
|
||||||
final bool isNotSelected = !selectedPlayers.any((p) => p.id == player.id);
|
final bool isNotSelected = !selectedPlayers.contains(
|
||||||
|
player,
|
||||||
|
);
|
||||||
return nameMatches && isNotSelected;
|
return nameMatches && isNotSelected;
|
||||||
}).toList();
|
}).toList();
|
||||||
}
|
}
|
||||||
@@ -124,49 +126,46 @@ class _PlayerSelectionState extends State<PlayerSelection> {
|
|||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
height: 50,
|
height: 50,
|
||||||
child: AppSkeleton(
|
child: selectedPlayers.isEmpty
|
||||||
enabled: isLoading,
|
? Center(child: Text(loc.no_players_selected))
|
||||||
child: selectedPlayers.isEmpty
|
: SingleChildScrollView(
|
||||||
? Center(child: Text(loc.no_players_selected))
|
scrollDirection: Axis.horizontal,
|
||||||
: SingleChildScrollView(
|
child: Row(
|
||||||
scrollDirection: Axis.horizontal,
|
children: [
|
||||||
child: Row(
|
for (var player in selectedPlayers)
|
||||||
children: [
|
Padding(
|
||||||
for (var player in selectedPlayers)
|
padding: const EdgeInsets.only(right: 8.0),
|
||||||
Padding(
|
child: TextIconTile(
|
||||||
padding: const EdgeInsets.only(right: 8.0),
|
text: player.name,
|
||||||
child: TextIconTile(
|
onIconTap: () {
|
||||||
text: player.name,
|
setState(() {
|
||||||
onIconTap: () {
|
// Removes the player from the selection and notifies the parent.
|
||||||
setState(() {
|
selectedPlayers.remove(player);
|
||||||
// Removes the player from the selection and notifies the parent.
|
widget.onChanged([...selectedPlayers]);
|
||||||
selectedPlayers.remove(player);
|
|
||||||
widget.onChanged([...selectedPlayers]);
|
|
||||||
|
|
||||||
// Get the current search query
|
// Get the current search query
|
||||||
final currentSearch = _searchBarController
|
final currentSearch = _searchBarController
|
||||||
.text
|
.text
|
||||||
.toLowerCase();
|
.toLowerCase();
|
||||||
|
|
||||||
// If the player matches the current search query (or search is empty),
|
// If the player matches the current search query (or search is empty),
|
||||||
// they are added back to the `suggestedPlayers` and the list is re-sorted.
|
// they are added back to the `suggestedPlayers` and the list is re-sorted.
|
||||||
if (currentSearch.isEmpty ||
|
if (currentSearch.isEmpty ||
|
||||||
player.name.toLowerCase().contains(
|
player.name.toLowerCase().contains(
|
||||||
currentSearch,
|
currentSearch,
|
||||||
)) {
|
)) {
|
||||||
suggestedPlayers.add(player);
|
suggestedPlayers.add(player);
|
||||||
suggestedPlayers.sort(
|
suggestedPlayers.sort(
|
||||||
(a, b) => a.name.compareTo(b.name),
|
(a, b) => a.name.compareTo(b.name),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
),
|
|
||||||
),
|
),
|
||||||
],
|
),
|
||||||
),
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
Text(
|
Text(
|
||||||
@@ -246,21 +245,7 @@ class _PlayerSelectionState extends State<PlayerSelection> {
|
|||||||
// Otherwise, use the loaded players from the database.
|
// Otherwise, use the loaded players from the database.
|
||||||
loadedPlayers.sort((a, b) => a.name.compareTo(b.name));
|
loadedPlayers.sort((a, b) => a.name.compareTo(b.name));
|
||||||
allPlayers = [...loadedPlayers];
|
allPlayers = [...loadedPlayers];
|
||||||
if (widget.initialSelectedPlayers != null) {
|
suggestedPlayers = [...loadedPlayers];
|
||||||
// Excludes already selected players from the suggested players list.
|
|
||||||
suggestedPlayers = loadedPlayers.where((p) => !widget.initialSelectedPlayers!.any((ip) => ip.id == p.id)).toList();
|
|
||||||
// Ensures that only players available for selection are pre-selected.
|
|
||||||
selectedPlayers = widget.initialSelectedPlayers!
|
|
||||||
.where(
|
|
||||||
(p) => allPlayers.any(
|
|
||||||
(available) => available.id == p.id,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
.toList();
|
|
||||||
} else {
|
|
||||||
// If no initial selection, all loaded players are suggested.
|
|
||||||
suggestedPlayers = [...loadedPlayers];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
isLoading = false;
|
isLoading = false;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:game_tracker/core/constants.dart';
|
|
||||||
import 'package:game_tracker/core/custom_theme.dart';
|
import 'package:game_tracker/core/custom_theme.dart';
|
||||||
|
|
||||||
class CustomSearchBar extends StatelessWidget {
|
class CustomSearchBar extends StatelessWidget {
|
||||||
@@ -22,6 +21,7 @@ class CustomSearchBar extends StatelessWidget {
|
|||||||
this.onTrailingButtonPressed,
|
this.onTrailingButtonPressed,
|
||||||
this.onChanged,
|
this.onChanged,
|
||||||
this.constraints,
|
this.constraints,
|
||||||
|
this.maxLength,
|
||||||
});
|
});
|
||||||
|
|
||||||
/// The controller for the search bar's text input.
|
/// The controller for the search bar's text input.
|
||||||
@@ -48,15 +48,19 @@ class CustomSearchBar extends StatelessWidget {
|
|||||||
/// The constraints for the search bar.
|
/// The constraints for the search bar.
|
||||||
final BoxConstraints? constraints;
|
final BoxConstraints? constraints;
|
||||||
|
|
||||||
|
/// Optional parameter for maximum length of the input text.
|
||||||
|
final int? maxLength;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
/// Enforce maximum length on the input text
|
/// Enforce maximum length on the input text
|
||||||
const maxLength = Constants.MAX_PLAYER_NAME_LENGTH;
|
if (maxLength != null) {
|
||||||
if (controller.text.length > maxLength) {
|
if (controller.text.length > maxLength!) {
|
||||||
controller.text = controller.text.substring(0, maxLength);
|
controller.text = controller.text.substring(0, maxLength);
|
||||||
controller.selection = TextSelection.fromPosition(
|
controller.selection = TextSelection.fromPosition(
|
||||||
TextPosition(offset: controller.text.length),
|
TextPosition(offset: controller.text.length),
|
||||||
);
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return SearchBar(
|
return SearchBar(
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
import 'package:game_tracker/core/custom_theme.dart';
|
import 'package:game_tracker/core/custom_theme.dart';
|
||||||
|
|
||||||
class TextInputField extends StatelessWidget {
|
class TextInputField extends StatelessWidget {
|
||||||
@@ -7,12 +8,18 @@ class TextInputField extends StatelessWidget {
|
|||||||
/// - [onChanged]: Optional callback invoked when the text in the field changes.
|
/// - [onChanged]: Optional callback invoked when the text in the field changes.
|
||||||
/// - [hintText]: The hint text displayed in the text input field when it is empty
|
/// - [hintText]: The hint text displayed in the text input field when it is empty
|
||||||
/// - [maxLength]: Optional parameter for maximum length of the input text.
|
/// - [maxLength]: Optional parameter for maximum length of the input text.
|
||||||
|
/// - [maxLines]: The maximum number of lines for the text input field. Defaults to 1.
|
||||||
|
/// - [minLines]: The minimum number of lines for the text input field. Defaults to 1.
|
||||||
|
/// - [showCounterText]: Whether to show the counter text in the text input field. Defaults to false.
|
||||||
const TextInputField({
|
const TextInputField({
|
||||||
super.key,
|
super.key,
|
||||||
required this.controller,
|
required this.controller,
|
||||||
required this.hintText,
|
required this.hintText,
|
||||||
this.onChanged,
|
this.onChanged,
|
||||||
this.maxLength,
|
this.maxLength,
|
||||||
|
this.maxLines = 1,
|
||||||
|
this.minLines = 1,
|
||||||
|
this.showCounterText = false
|
||||||
});
|
});
|
||||||
|
|
||||||
/// The controller for the text input field.
|
/// The controller for the text input field.
|
||||||
@@ -27,17 +34,30 @@ class TextInputField extends StatelessWidget {
|
|||||||
/// Optional parameter for maximum length of the input text.
|
/// Optional parameter for maximum length of the input text.
|
||||||
final int? maxLength;
|
final int? maxLength;
|
||||||
|
|
||||||
|
/// The maximum number of lines for the text input field.
|
||||||
|
final int? maxLines;
|
||||||
|
|
||||||
|
/// The minimum number of lines for the text input field.
|
||||||
|
final int? minLines;
|
||||||
|
|
||||||
|
/// Whether to show the counter text in the text input field.
|
||||||
|
final bool showCounterText;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return TextField(
|
return TextField(
|
||||||
controller: controller,
|
controller: controller,
|
||||||
onChanged: onChanged,
|
onChanged: onChanged,
|
||||||
maxLength: maxLength,
|
maxLength: maxLength,
|
||||||
|
maxLengthEnforcement: MaxLengthEnforcement.truncateAfterCompositionEnds,
|
||||||
|
maxLines: maxLines,
|
||||||
|
minLines: minLines,
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
filled: true,
|
filled: true,
|
||||||
fillColor: CustomTheme.boxColor,
|
fillColor: CustomTheme.boxColor,
|
||||||
hintText: hintText,
|
hintText: hintText,
|
||||||
hintStyle: const TextStyle(fontSize: 18),
|
hintStyle: const TextStyle(fontSize: 18),
|
||||||
|
counterText: showCounterText ? null : '',
|
||||||
enabledBorder: OutlineInputBorder(
|
enabledBorder: OutlineInputBorder(
|
||||||
borderRadius: const BorderRadius.all(Radius.circular(12)),
|
borderRadius: const BorderRadius.all(Radius.circular(12)),
|
||||||
borderSide: BorderSide(color: CustomTheme.boxBorder),
|
borderSide: BorderSide(color: CustomTheme.boxBorder),
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ class TitleDescriptionListTile extends StatelessWidget {
|
|||||||
/// - [title]: The title text displayed on the tile.
|
/// - [title]: The title text displayed on the tile.
|
||||||
/// - [description]: The description text displayed below the title.
|
/// - [description]: The description text displayed below the title.
|
||||||
/// - [onPressed]: The callback invoked when the tile is tapped.
|
/// - [onPressed]: The callback invoked when the tile is tapped.
|
||||||
|
/// - [onLongPress]: The callback invoked when the tile is tapped.
|
||||||
/// - [isHighlighted]: A boolean to determine if the tile should be highlighted.
|
/// - [isHighlighted]: A boolean to determine if the tile should be highlighted.
|
||||||
/// - [badgeText]: Optional text to display in a badge on the right side of the title.
|
/// - [badgeText]: Optional text to display in a badge on the right side of the title.
|
||||||
/// - [badgeColor]: Optional color for the badge background.
|
/// - [badgeColor]: Optional color for the badge background.
|
||||||
@@ -13,7 +14,8 @@ class TitleDescriptionListTile extends StatelessWidget {
|
|||||||
super.key,
|
super.key,
|
||||||
required this.title,
|
required this.title,
|
||||||
required this.description,
|
required this.description,
|
||||||
this.onPressed,
|
this.onTap,
|
||||||
|
this.onLongPress,
|
||||||
this.isHighlighted = false,
|
this.isHighlighted = false,
|
||||||
this.badgeText,
|
this.badgeText,
|
||||||
this.badgeColor,
|
this.badgeColor,
|
||||||
@@ -26,7 +28,10 @@ class TitleDescriptionListTile extends StatelessWidget {
|
|||||||
final String description;
|
final String description;
|
||||||
|
|
||||||
/// The callback invoked when the tile is tapped.
|
/// The callback invoked when the tile is tapped.
|
||||||
final VoidCallback? onPressed;
|
final VoidCallback? onTap;
|
||||||
|
|
||||||
|
/// The callback invoked when the tile is long-pressed.
|
||||||
|
final VoidCallback? onLongPress;
|
||||||
|
|
||||||
/// A boolean to determine if the tile should be highlighted.
|
/// A boolean to determine if the tile should be highlighted.
|
||||||
final bool isHighlighted;
|
final bool isHighlighted;
|
||||||
@@ -40,7 +45,8 @@ class TitleDescriptionListTile extends StatelessWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
onTap: onPressed,
|
onTap: onTap,
|
||||||
|
onLongPress: onLongPress,
|
||||||
child: AnimatedContainer(
|
child: AnimatedContainer(
|
||||||
margin: const EdgeInsets.symmetric(vertical: 10, horizontal: 10),
|
margin: const EdgeInsets.symmetric(vertical: 10, horizontal: 10),
|
||||||
padding: const EdgeInsets.symmetric(vertical: 6, horizontal: 12),
|
padding: const EdgeInsets.symmetric(vertical: 6, horizontal: 12),
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
name: game_tracker
|
name: game_tracker
|
||||||
description: "Game Tracking App for Card Games"
|
description: "Game Tracking App for Card Games"
|
||||||
publish_to: 'none'
|
publish_to: 'none'
|
||||||
version: 0.0.9+242
|
version: 0.0.10+248
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ^3.8.1
|
sdk: ^3.8.1
|
||||||
|
|||||||
Reference in New Issue
Block a user