Compare commits
9 Commits
ee84c60ba6
...
enhancemen
| Author | SHA1 | Date | |
|---|---|---|---|
| ab20bd764b | |||
| 8ca4e3210e | |||
| a480530919 | |||
| 906c8d8450 | |||
| 000bdc8cbc | |||
| 497f30421d | |||
| 2a72332bcd | |||
| 7aa41abe61 | |||
| 799b7d8403 |
@@ -11,6 +11,8 @@ class CustomTheme {
|
|||||||
static Color onBoxColor = const Color(0xFF181818);
|
static Color onBoxColor = const Color(0xFF181818);
|
||||||
static Color boxBorder = const Color(0xFF272727);
|
static Color boxBorder = const Color(0xFF272727);
|
||||||
static const Color textColor = Colors.white;
|
static const Color textColor = Colors.white;
|
||||||
|
static Color navBarItemSelectedColor = primaryColor.withValues(green: 0.4);
|
||||||
|
static Color navBarItemUnselectedColor = Colors.white.withValues(alpha: 0.6);
|
||||||
|
|
||||||
// ==================== Border Radius ====================
|
// ==================== Border Radius ====================
|
||||||
static const double standardBorderRadius = 12.0;
|
static const double standardBorderRadius = 12.0;
|
||||||
|
|||||||
@@ -17,12 +17,8 @@
|
|||||||
"data_successfully_imported": "Daten erfolgreich importiert",
|
"data_successfully_imported": "Daten erfolgreich importiert",
|
||||||
"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_all_data": "Diese Gruppe löschen",
|
|
||||||
"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",
|
||||||
|
|||||||
@@ -34,10 +34,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 group"
|
"description": "Button text to create a new group"
|
||||||
},
|
},
|
||||||
"@create_new_match": {
|
"@create_new_match": {
|
||||||
"description": "Appbar text to create a match"
|
"description": "Button text to create a new match"
|
||||||
},
|
},
|
||||||
"@data_successfully_deleted": {
|
"@data_successfully_deleted": {
|
||||||
"description": "Success message after deleting data"
|
"description": "Success message after deleting data"
|
||||||
@@ -62,21 +62,9 @@
|
|||||||
"@delete_all_data": {
|
"@delete_all_data": {
|
||||||
"description": "Confirmation dialog for deleting all data"
|
"description": "Confirmation dialog for deleting all data"
|
||||||
},
|
},
|
||||||
"@delete_group": {
|
|
||||||
"description": "Confirmation dialog for deleting a group"
|
|
||||||
},
|
|
||||||
"@edit_group": {
|
|
||||||
"description": "Button & Appbar label for editing 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"
|
||||||
},
|
},
|
||||||
@@ -289,12 +277,8 @@
|
|||||||
"data_successfully_imported": "Data successfully imported",
|
"data_successfully_imported": "Data successfully imported",
|
||||||
"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_group": "Delete this 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",
|
||||||
|
|||||||
@@ -164,13 +164,13 @@ abstract class AppLocalizations {
|
|||||||
/// **'Create match'**
|
/// **'Create match'**
|
||||||
String get create_match;
|
String get create_match;
|
||||||
|
|
||||||
/// Appbar text to create a 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'**
|
||||||
String get create_new_group;
|
String get create_new_group;
|
||||||
|
|
||||||
/// Appbar text to create a 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'**
|
||||||
@@ -209,39 +209,15 @@ abstract class AppLocalizations {
|
|||||||
/// Confirmation dialog for deleting all data
|
/// Confirmation dialog for deleting all data
|
||||||
///
|
///
|
||||||
/// In en, this message translates to:
|
/// In en, this message translates to:
|
||||||
/// **'Delete all data?'**
|
/// **'Delete all data'**
|
||||||
String get delete_all_data;
|
String get delete_all_data;
|
||||||
|
|
||||||
/// Confirmation dialog for deleting a group
|
|
||||||
///
|
|
||||||
/// In en, this message translates to:
|
|
||||||
/// **'Delete this group?'**
|
|
||||||
String get delete_group;
|
|
||||||
|
|
||||||
/// Button & Appbar label for editing a group
|
|
||||||
///
|
|
||||||
/// In en, this message translates to:
|
|
||||||
/// **'Edit Group'**
|
|
||||||
String get edit_group;
|
|
||||||
|
|
||||||
/// Error message when group creation fails
|
/// Error message when group creation fails
|
||||||
///
|
///
|
||||||
/// In en, this message translates to:
|
/// In en, this message translates to:
|
||||||
/// **'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:
|
||||||
|
|||||||
@@ -67,26 +67,12 @@ class AppLocalizationsDe extends AppLocalizations {
|
|||||||
String get delete => 'Löschen';
|
String get delete => 'Löschen';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get delete_all_data => 'Diese Gruppe löschen?';
|
String get delete_all_data => 'Alle Daten löschen';
|
||||||
|
|
||||||
@override
|
|
||||||
String get delete_group => 'Delete this group?';
|
|
||||||
|
|
||||||
@override
|
|
||||||
String get edit_group => 'Gruppe bearbeiten';
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
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';
|
||||||
|
|
||||||
|
|||||||
@@ -67,26 +67,12 @@ class AppLocalizationsEn extends AppLocalizations {
|
|||||||
String get delete => 'Delete';
|
String get delete => 'Delete';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get delete_all_data => 'Delete all data?';
|
String get delete_all_data => 'Delete all data';
|
||||||
|
|
||||||
@override
|
|
||||||
String get delete_group => 'Delete this group?';
|
|
||||||
|
|
||||||
@override
|
|
||||||
String get edit_group => 'Edit Group';
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
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';
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import 'dart:ui';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
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';
|
||||||
@@ -71,53 +73,97 @@ class _CustomNavigationBarState extends State<CustomNavigationBar>
|
|||||||
backgroundColor: CustomTheme.backgroundColor,
|
backgroundColor: CustomTheme.backgroundColor,
|
||||||
body: tabs[currentIndex],
|
body: tabs[currentIndex],
|
||||||
extendBody: true,
|
extendBody: true,
|
||||||
bottomNavigationBar: SafeArea(
|
bottomNavigationBar: SizedBox(
|
||||||
minimum: const EdgeInsets.only(bottom: 30),
|
height: 70 + MediaQuery.of(context).padding.bottom,
|
||||||
child: Container(
|
child: Stack(
|
||||||
margin: const EdgeInsets.symmetric(horizontal: 12.0, vertical: 10),
|
children: [
|
||||||
decoration: BoxDecoration(
|
// Dynamisch generierte Blur-Layer für ultra-smooth Übergang
|
||||||
borderRadius: BorderRadius.circular(24),
|
...List.generate(35, (index) {
|
||||||
color: CustomTheme.primaryColor,
|
// Verwende kubische Kurve für noch natürlicheren, weicheren Übergang
|
||||||
),
|
final progress = index / 34.0; // 0.0 bis 1.0
|
||||||
child: ClipRRect(
|
final cubic = progress * progress * progress; // Kubische Kurve
|
||||||
borderRadius: BorderRadius.circular(24),
|
final blurStrength = 0.5 + (cubic * 50.0); // Sehr sanft von 0.5 bis 50.5
|
||||||
child: SizedBox(
|
|
||||||
height: 60,
|
// Höhe geht jetzt komplett von 100% bis 0% (ganz nach unten)
|
||||||
child: Row(
|
// Mit extra Dichte am unteren Ende für weicheren Übergang
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
final heightFactor = index < 25
|
||||||
children: <Widget>[
|
? 1.0 - (progress * 0.7) // Erste 25 Layer: 100% bis 30%
|
||||||
NavbarItem(
|
: 0.3 - ((index - 25) / 34.0); // Letzte 10 Layer: 30% bis 0% (dichter)
|
||||||
index: 0,
|
|
||||||
isSelected: currentIndex == 0,
|
return Positioned(
|
||||||
icon: Icons.home_rounded,
|
left: 0,
|
||||||
label: loc.home,
|
right: 0,
|
||||||
onTabTapped: onTabTapped,
|
bottom: 0,
|
||||||
|
height: (70 + MediaQuery.of(context).padding.bottom) * heightFactor.clamp(0.05, 1.0),
|
||||||
|
child: ClipRect(
|
||||||
|
child: BackdropFilter(
|
||||||
|
filter: ImageFilter.blur(
|
||||||
|
sigmaX: blurStrength,
|
||||||
|
sigmaY: blurStrength,
|
||||||
|
),
|
||||||
|
child: Container(
|
||||||
|
color: Colors.transparent,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
NavbarItem(
|
),
|
||||||
index: 1,
|
);
|
||||||
isSelected: currentIndex == 1,
|
}),
|
||||||
icon: Icons.gamepad_rounded,
|
// Gradient-Overlay
|
||||||
label: loc.matches,
|
Positioned.fill(
|
||||||
onTabTapped: onTabTapped,
|
child: Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
gradient: LinearGradient(
|
||||||
|
begin: Alignment.bottomCenter,
|
||||||
|
end: Alignment.topCenter,
|
||||||
|
colors: [
|
||||||
|
CustomTheme.boxColor.withValues(alpha: 1),
|
||||||
|
CustomTheme.boxColor.withValues(alpha: 0.0),
|
||||||
|
],
|
||||||
|
stops: const [0.4, 1],
|
||||||
),
|
),
|
||||||
NavbarItem(
|
),
|
||||||
index: 2,
|
|
||||||
isSelected: currentIndex == 2,
|
|
||||||
icon: Icons.group_rounded,
|
|
||||||
label: loc.groups,
|
|
||||||
onTabTapped: onTabTapped,
|
|
||||||
),
|
|
||||||
NavbarItem(
|
|
||||||
index: 3,
|
|
||||||
isSelected: currentIndex == 3,
|
|
||||||
icon: Icons.bar_chart_rounded,
|
|
||||||
label: loc.statistics,
|
|
||||||
onTabTapped: onTabTapped,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
// Navbar-Inhalt
|
||||||
|
SafeArea(
|
||||||
|
child: SizedBox(
|
||||||
|
height: 70,
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||||
|
children: <Widget>[
|
||||||
|
NavbarItem(
|
||||||
|
index: 0,
|
||||||
|
isSelected: currentIndex == 0,
|
||||||
|
icon: Icons.home_rounded,
|
||||||
|
label: loc.home,
|
||||||
|
onTabTapped: onTabTapped,
|
||||||
|
),
|
||||||
|
NavbarItem(
|
||||||
|
index: 1,
|
||||||
|
isSelected: currentIndex == 1,
|
||||||
|
icon: Icons.gamepad_rounded,
|
||||||
|
label: loc.matches,
|
||||||
|
onTabTapped: onTabTapped,
|
||||||
|
),
|
||||||
|
NavbarItem(
|
||||||
|
index: 2,
|
||||||
|
isSelected: currentIndex == 2,
|
||||||
|
icon: Icons.group_rounded,
|
||||||
|
label: loc.groups,
|
||||||
|
onTabTapped: onTabTapped,
|
||||||
|
),
|
||||||
|
NavbarItem(
|
||||||
|
index: 3,
|
||||||
|
isSelected: currentIndex == 3,
|
||||||
|
icon: Icons.bar_chart_rounded,
|
||||||
|
label: loc.statistics,
|
||||||
|
onTabTapped: onTabTapped,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -0,0 +1,113 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:game_tracker/core/custom_theme.dart';
|
||||||
|
import 'package:game_tracker/core/enums.dart';
|
||||||
|
import 'package:game_tracker/data/db/database.dart';
|
||||||
|
import 'package:game_tracker/data/dto/group.dart';
|
||||||
|
import 'package:game_tracker/data/dto/player.dart';
|
||||||
|
import 'package:game_tracker/l10n/generated/app_localizations.dart';
|
||||||
|
import 'package:game_tracker/presentation/widgets/buttons/custom_width_button.dart';
|
||||||
|
import 'package:game_tracker/presentation/widgets/player_selection.dart';
|
||||||
|
import 'package:game_tracker/presentation/widgets/text_input/text_input_field.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
|
class CreateGroupView extends StatefulWidget {
|
||||||
|
const CreateGroupView({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<CreateGroupView> createState() => _CreateGroupViewState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _CreateGroupViewState extends State<CreateGroupView> {
|
||||||
|
late final AppDatabase db;
|
||||||
|
|
||||||
|
/// Controller for the group name input field
|
||||||
|
final _groupNameController = TextEditingController();
|
||||||
|
|
||||||
|
/// List of currently selected players
|
||||||
|
List<Player> selectedPlayers = [];
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
db = Provider.of<AppDatabase>(context, listen: false);
|
||||||
|
_groupNameController.addListener(() {
|
||||||
|
setState(() {});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_groupNameController.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final loc = AppLocalizations.of(context);
|
||||||
|
return ScaffoldMessenger(
|
||||||
|
child: Scaffold(
|
||||||
|
backgroundColor: CustomTheme.backgroundColor,
|
||||||
|
appBar: AppBar(title: Text(loc.create_new_group)),
|
||||||
|
body: SafeArea(
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
margin: CustomTheme.standardMargin,
|
||||||
|
child: TextInputField(
|
||||||
|
controller: _groupNameController,
|
||||||
|
hintText: loc.group_name,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
child: PlayerSelection(
|
||||||
|
onChanged: (value) {
|
||||||
|
setState(() {
|
||||||
|
selectedPlayers = [...value];
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
CustomWidthButton(
|
||||||
|
text: loc.create_group,
|
||||||
|
sizeRelativeToWidth: 0.95,
|
||||||
|
buttonType: ButtonType.primary,
|
||||||
|
onPressed:
|
||||||
|
(_groupNameController.text.isEmpty ||
|
||||||
|
(selectedPlayers.length < 2))
|
||||||
|
? null
|
||||||
|
: () async {
|
||||||
|
bool success = await db.groupDao.addGroup(
|
||||||
|
group: Group(
|
||||||
|
name: _groupNameController.text.trim(),
|
||||||
|
members: selectedPlayers,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
if (!context.mounted) return;
|
||||||
|
if (success) {
|
||||||
|
Navigator.pop(context);
|
||||||
|
} else {
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
SnackBar(
|
||||||
|
backgroundColor: CustomTheme.boxColor,
|
||||||
|
content: Center(
|
||||||
|
child: Text(
|
||||||
|
AppLocalizations.of(
|
||||||
|
context,
|
||||||
|
).error_creating_group,
|
||||||
|
style: const TextStyle(color: Colors.white),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
const SizedBox(height: 20),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,181 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:game_tracker/core/custom_theme.dart';
|
|
||||||
import 'package:game_tracker/core/enums.dart';
|
|
||||||
import 'package:game_tracker/data/db/database.dart';
|
|
||||||
import 'package:game_tracker/data/dto/group.dart';
|
|
||||||
import 'package:game_tracker/data/dto/player.dart';
|
|
||||||
import 'package:game_tracker/l10n/generated/app_localizations.dart';
|
|
||||||
import 'package:game_tracker/presentation/widgets/buttons/custom_width_button.dart';
|
|
||||||
import 'package:game_tracker/presentation/widgets/player_selection.dart';
|
|
||||||
import 'package:game_tracker/presentation/widgets/text_input/text_input_field.dart';
|
|
||||||
import 'package:provider/provider.dart';
|
|
||||||
|
|
||||||
class GroupDetailView extends StatefulWidget {
|
|
||||||
const GroupDetailView({super.key, this.groupToEdit});
|
|
||||||
|
|
||||||
/// The group to edit, if any
|
|
||||||
final Group? groupToEdit;
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<GroupDetailView> createState() => _GroupDetailViewState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _GroupDetailViewState extends State<GroupDetailView> {
|
|
||||||
late final AppDatabase db;
|
|
||||||
|
|
||||||
/// GlobalKey for ScaffoldMessenger to show snackbars
|
|
||||||
final _scaffoldMessengerKey = GlobalKey<ScaffoldMessengerState>();
|
|
||||||
|
|
||||||
/// Controller for the group name input field
|
|
||||||
final _groupNameController = TextEditingController();
|
|
||||||
|
|
||||||
/// List of currently selected players
|
|
||||||
List<Player> selectedPlayers = [];
|
|
||||||
|
|
||||||
/// List of initially selected players (when editing a group)
|
|
||||||
List<Player> initialSelectedPlayers = [];
|
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
super.initState();
|
|
||||||
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(() {
|
|
||||||
setState(() {});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
void dispose() {
|
|
||||||
_groupNameController.dispose();
|
|
||||||
super.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
final loc = AppLocalizations.of(context);
|
|
||||||
return ScaffoldMessenger(
|
|
||||||
key: _scaffoldMessengerKey,
|
|
||||||
child: Scaffold(
|
|
||||||
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 {
|
|
||||||
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 {
|
|
||||||
showSnackbar(message: loc.error_deleting_group);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},)],),
|
|
||||||
body: SafeArea(
|
|
||||||
child: Column(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
Container(
|
|
||||||
margin: CustomTheme.standardMargin,
|
|
||||||
child: TextInputField(
|
|
||||||
controller: _groupNameController,
|
|
||||||
hintText: loc.group_name,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Expanded(
|
|
||||||
child: PlayerSelection(
|
|
||||||
initialSelectedPlayers: initialSelectedPlayers,
|
|
||||||
onChanged: (value) {
|
|
||||||
setState(() {
|
|
||||||
selectedPlayers = [...value];
|
|
||||||
});
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
CustomWidthButton(
|
|
||||||
text: widget.groupToEdit == null ? loc.create_group : loc.edit_group,
|
|
||||||
sizeRelativeToWidth: 0.95,
|
|
||||||
buttonType: ButtonType.primary,
|
|
||||||
onPressed:
|
|
||||||
(_groupNameController.text.isEmpty ||
|
|
||||||
(selectedPlayers.length < 2))
|
|
||||||
? null
|
|
||||||
: () async {
|
|
||||||
late bool success;
|
|
||||||
if (widget.groupToEdit == null) {
|
|
||||||
success = await db.groupDao.addGroup(
|
|
||||||
group: Group(
|
|
||||||
name: _groupNameController.text.trim(),
|
|
||||||
members: selectedPlayers,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
//TODO: Implement group editing in database
|
|
||||||
/*
|
|
||||||
success = await db.groupDao.updateGroup(
|
|
||||||
group: Group(
|
|
||||||
id: widget.groupToEdit!.id,
|
|
||||||
name: _groupNameController.text.trim(),
|
|
||||||
members: selectedPlayers,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
*/
|
|
||||||
success = false;
|
|
||||||
}
|
|
||||||
if (!context.mounted) return;
|
|
||||||
if (success) {
|
|
||||||
Navigator.pop(context);
|
|
||||||
} else {
|
|
||||||
showSnackbar(message: widget.groupToEdit == null ? loc.error_creating_group : loc.error_editing_group);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
),
|
|
||||||
const SizedBox(height: 20),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
/// 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,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -6,7 +6,7 @@ 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/widgets/app_skeleton.dart';
|
import 'package:game_tracker/presentation/widgets/app_skeleton.dart';
|
||||||
import 'package:game_tracker/presentation/widgets/buttons/custom_width_button.dart';
|
import 'package:game_tracker/presentation/widgets/buttons/custom_width_button.dart';
|
||||||
import 'package:game_tracker/presentation/widgets/tiles/group_tile.dart';
|
import 'package:game_tracker/presentation/widgets/tiles/group_tile.dart';
|
||||||
@@ -73,19 +73,7 @@ class _GroupsViewState extends State<GroupsView> {
|
|||||||
height: MediaQuery.paddingOf(context).bottom - 20,
|
height: MediaQuery.paddingOf(context).bottom - 20,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return GroupTile(group: groups[index], onTap: () async {
|
return GroupTile(group: groups[index]);
|
||||||
await Navigator.push(
|
|
||||||
context,
|
|
||||||
adaptivePageRoute(
|
|
||||||
builder: (context) {
|
|
||||||
return GroupDetailView(groupToEdit: groups[index]);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
|
||||||
setState(() {
|
|
||||||
loadGroups();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -100,7 +88,7 @@ class _GroupsViewState extends State<GroupsView> {
|
|||||||
context,
|
context,
|
||||||
adaptivePageRoute(
|
adaptivePageRoute(
|
||||||
builder: (context) {
|
builder: (context) {
|
||||||
return const GroupDetailView();
|
return const CreateGroupView();
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -70,9 +70,6 @@ class _CreateMatchViewState extends State<CreateMatchView> {
|
|||||||
/// List of available rulesets with their localized string representations
|
/// List of available rulesets with their localized string representations
|
||||||
late final List<(Ruleset, String)> _rulesets;
|
late final List<(Ruleset, String)> _rulesets;
|
||||||
|
|
||||||
/// GlobalKey for ScaffoldMessenger to show snackbars
|
|
||||||
final _scaffoldMessengerKey = GlobalKey<ScaffoldMessengerState>();
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
@@ -123,7 +120,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(
|
||||||
backgroundColor: CustomTheme.backgroundColor,
|
backgroundColor: CustomTheme.backgroundColor,
|
||||||
appBar: AppBar(title: Text(loc.create_new_match)),
|
appBar: AppBar(title: Text(loc.create_new_match)),
|
||||||
|
|||||||
@@ -105,7 +105,8 @@ class _MatchViewState extends State<MatchView> {
|
|||||||
),
|
),
|
||||||
Positioned(
|
Positioned(
|
||||||
bottom: MediaQuery.paddingOf(context).bottom,
|
bottom: MediaQuery.paddingOf(context).bottom,
|
||||||
child: CustomWidthButton(
|
child: SizedBox.shrink()
|
||||||
|
/* CustomWidthButton(
|
||||||
text: loc.create_match,
|
text: loc.create_match,
|
||||||
sizeRelativeToWidth: 0.90,
|
sizeRelativeToWidth: 0.90,
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
@@ -118,6 +119,7 @@ class _MatchViewState extends State<MatchView> {
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
*/
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import 'package:game_tracker/core/enums.dart';
|
|||||||
import 'package:game_tracker/l10n/generated/app_localizations.dart';
|
import 'package:game_tracker/l10n/generated/app_localizations.dart';
|
||||||
import 'package:game_tracker/presentation/widgets/tiles/settings_list_tile.dart';
|
import 'package:game_tracker/presentation/widgets/tiles/settings_list_tile.dart';
|
||||||
import 'package:game_tracker/services/data_transfer_service.dart';
|
import 'package:game_tracker/services/data_transfer_service.dart';
|
||||||
|
import 'package:package_info_plus/package_info_plus.dart';
|
||||||
|
|
||||||
class SettingsView extends StatefulWidget {
|
class SettingsView extends StatefulWidget {
|
||||||
const SettingsView({super.key});
|
const SettingsView({super.key});
|
||||||
@@ -13,119 +14,126 @@ class SettingsView extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _SettingsViewState extends State<SettingsView> {
|
class _SettingsViewState extends State<SettingsView> {
|
||||||
|
PackageInfo _packageInfo = PackageInfo(
|
||||||
/// GlobalKey for ScaffoldMessenger to show snackbars
|
appName: 'n.A.',
|
||||||
final _scaffoldMessengerKey = GlobalKey<ScaffoldMessengerState>();
|
packageName: 'n.A.',
|
||||||
|
version: 'n.A.',
|
||||||
|
buildNumber: 'n.A.',
|
||||||
|
);
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
|
_initPackageInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
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(
|
||||||
appBar: AppBar(backgroundColor: CustomTheme.backgroundColor),
|
appBar: AppBar(backgroundColor: CustomTheme.backgroundColor),
|
||||||
backgroundColor: CustomTheme.backgroundColor,
|
backgroundColor: CustomTheme.backgroundColor,
|
||||||
body: LayoutBuilder(
|
body: Column(
|
||||||
builder: (BuildContext context, BoxConstraints constraints) =>
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
SingleChildScrollView(
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
child: Column(
|
children: [
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
Padding(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
padding: const EdgeInsets.fromLTRB(24, 0, 24, 10),
|
||||||
children: [
|
child: Text(
|
||||||
Padding(
|
textAlign: TextAlign.start,
|
||||||
padding: const EdgeInsets.fromLTRB(24, 0, 24, 10),
|
loc.menu,
|
||||||
child: Text(
|
style: const TextStyle(
|
||||||
textAlign: TextAlign.start,
|
fontSize: 28,
|
||||||
loc.menu,
|
fontWeight: FontWeight.bold,
|
||||||
style: const TextStyle(
|
|
||||||
fontSize: 28,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.symmetric(
|
|
||||||
horizontal: 24,
|
|
||||||
vertical: 10,
|
|
||||||
),
|
|
||||||
child: Text(
|
|
||||||
textAlign: TextAlign.start,
|
|
||||||
loc.settings,
|
|
||||||
style: const TextStyle(
|
|
||||||
fontSize: 22,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
SettingsListTile(
|
|
||||||
title: loc.export_data,
|
|
||||||
icon: Icons.upload_rounded,
|
|
||||||
suffixWidget: const Icon(Icons.arrow_forward_ios, size: 16),
|
|
||||||
onPressed: () async {
|
|
||||||
final String json =
|
|
||||||
await DataTransferService.getAppDataAsJson(context);
|
|
||||||
final result = await DataTransferService.exportData(
|
|
||||||
json,
|
|
||||||
'game_tracker-data',
|
|
||||||
);
|
|
||||||
if (!context.mounted) return;
|
|
||||||
showExportSnackBar(context: context, result: result);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
SettingsListTile(
|
|
||||||
title: loc.import_data,
|
|
||||||
icon: Icons.download_rounded,
|
|
||||||
suffixWidget: const Icon(Icons.arrow_forward_ios, size: 16),
|
|
||||||
onPressed: () async {
|
|
||||||
final result = await DataTransferService.importData(
|
|
||||||
context,
|
|
||||||
);
|
|
||||||
if (!context.mounted) return;
|
|
||||||
showImportSnackBar(context: context, result: result);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
SettingsListTile(
|
|
||||||
title: loc.delete_all_data,
|
|
||||||
icon: Icons.delete_rounded,
|
|
||||||
suffixWidget: const Icon(Icons.arrow_forward_ios, size: 16),
|
|
||||||
onPressed: () {
|
|
||||||
showDialog<bool>(
|
|
||||||
context: context,
|
|
||||||
builder: (context) => AlertDialog(
|
|
||||||
title: Text(loc.delete_all_data),
|
|
||||||
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) {
|
|
||||||
if (confirmed == true && context.mounted) {
|
|
||||||
DataTransferService.deleteAllData(context);
|
|
||||||
showSnackbar(
|
|
||||||
context: context,
|
|
||||||
message: AppLocalizations.of(
|
|
||||||
context,
|
|
||||||
).data_successfully_deleted,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 10),
|
||||||
|
child: Text(
|
||||||
|
textAlign: TextAlign.start,
|
||||||
|
loc.settings,
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 22,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SettingsListTile(
|
||||||
|
title: loc.export_data,
|
||||||
|
icon: Icons.upload_rounded,
|
||||||
|
suffixWidget: const Icon(Icons.arrow_forward_ios, size: 16),
|
||||||
|
onPressed: () async {
|
||||||
|
final String json = await DataTransferService.getAppDataAsJson(
|
||||||
|
context,
|
||||||
|
);
|
||||||
|
final result = await DataTransferService.exportData(
|
||||||
|
json,
|
||||||
|
'game_tracker-data',
|
||||||
|
);
|
||||||
|
if (!context.mounted) return;
|
||||||
|
showExportSnackBar(context: context, result: result);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
SettingsListTile(
|
||||||
|
title: loc.import_data,
|
||||||
|
icon: Icons.download_rounded,
|
||||||
|
suffixWidget: const Icon(Icons.arrow_forward_ios, size: 16),
|
||||||
|
onPressed: () async {
|
||||||
|
final result = await DataTransferService.importData(context);
|
||||||
|
if (!context.mounted) return;
|
||||||
|
showImportSnackBar(context: context, result: result);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
SettingsListTile(
|
||||||
|
title: loc.delete_all_data,
|
||||||
|
icon: Icons.delete_rounded,
|
||||||
|
suffixWidget: const Icon(Icons.arrow_forward_ios, size: 16),
|
||||||
|
onPressed: () {
|
||||||
|
showDialog<bool>(
|
||||||
|
context: context,
|
||||||
|
builder: (context) => AlertDialog(
|
||||||
|
title: Text('${loc.delete_all_data}?'),
|
||||||
|
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) {
|
||||||
|
if (confirmed == true && context.mounted) {
|
||||||
|
DataTransferService.deleteAllData(context);
|
||||||
|
showSnackbar(
|
||||||
|
context: context,
|
||||||
|
message: AppLocalizations.of(
|
||||||
|
context,
|
||||||
|
).data_successfully_deleted,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
const Spacer(),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.all(20),
|
||||||
|
child: Center(
|
||||||
|
child: Text(
|
||||||
|
'Version ${_packageInfo.version} (${_packageInfo.buildNumber})',
|
||||||
|
style: TextStyle(
|
||||||
|
color: Colors.grey.shade600,
|
||||||
|
fontSize: 14,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -201,4 +209,11 @@ class _SettingsViewState extends State<SettingsView> {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> _initPackageInfo() async {
|
||||||
|
final info = await PackageInfo.fromPlatform();
|
||||||
|
setState(() {
|
||||||
|
_packageInfo = info;
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:game_tracker/core/custom_theme.dart';
|
||||||
|
|
||||||
/// A navigation bar item widget that represents a single tab in a navigation bar.
|
/// A navigation bar item widget that represents a single tab in a navigation bar.
|
||||||
/// - [index]: The index of the tab.
|
/// - [index]: The index of the tab.
|
||||||
@@ -35,7 +36,45 @@ class NavbarItem extends StatefulWidget {
|
|||||||
State<NavbarItem> createState() => _NavbarItemState();
|
State<NavbarItem> createState() => _NavbarItemState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _NavbarItemState extends State<NavbarItem> {
|
class _NavbarItemState extends State<NavbarItem>
|
||||||
|
with SingleTickerProviderStateMixin {
|
||||||
|
/// Animation controller for the scale animation
|
||||||
|
late AnimationController _animationController;
|
||||||
|
|
||||||
|
/// Scale animation for the icon when selected
|
||||||
|
late Animation<double> _scaleAnimation;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_animationController = AnimationController(
|
||||||
|
duration: const Duration(milliseconds: 300),
|
||||||
|
vsync: this,
|
||||||
|
);
|
||||||
|
|
||||||
|
_scaleAnimation = Tween<double>(begin: 1.0, end: 1.2).animate(
|
||||||
|
CurvedAnimation(
|
||||||
|
parent: _animationController,
|
||||||
|
curve: Curves.easeInOutBack,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
if (widget.isSelected) {
|
||||||
|
_animationController.forward();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Retrigger animation on selection change
|
||||||
|
@override
|
||||||
|
void didUpdateWidget(NavbarItem oldWidget) {
|
||||||
|
super.didUpdateWidget(oldWidget);
|
||||||
|
if (widget.isSelected && !oldWidget.isSelected) {
|
||||||
|
_animationController.forward();
|
||||||
|
} else if (!widget.isSelected && oldWidget.isSelected) {
|
||||||
|
_animationController.reverse();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Expanded(
|
return Expanded(
|
||||||
@@ -48,19 +87,29 @@ class _NavbarItemState extends State<NavbarItem> {
|
|||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
Icon(
|
ScaleTransition(
|
||||||
widget.icon,
|
scale: widget.isSelected
|
||||||
color: widget.isSelected ? Colors.white : Colors.black,
|
? _scaleAnimation
|
||||||
|
: const AlwaysStoppedAnimation(1.0),
|
||||||
|
child: Icon(
|
||||||
|
widget.icon,
|
||||||
|
color: widget.isSelected
|
||||||
|
? CustomTheme.navBarItemSelectedColor
|
||||||
|
: CustomTheme.navBarItemUnselectedColor,
|
||||||
|
size: 26,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 4),
|
const SizedBox(height: 4),
|
||||||
Text(
|
Text(
|
||||||
widget.label,
|
widget.label,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: widget.isSelected ? Colors.white : Colors.black,
|
color: widget.isSelected
|
||||||
fontSize: 12,
|
? CustomTheme.navBarItemSelectedColor
|
||||||
|
: CustomTheme.navBarItemUnselectedColor,
|
||||||
|
fontSize: widget.isSelected ? 12 : 11,
|
||||||
fontWeight: widget.isSelected
|
fontWeight: widget.isSelected
|
||||||
? FontWeight.bold
|
? FontWeight.bold
|
||||||
: FontWeight.normal,
|
: FontWeight.w500,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@@ -69,4 +118,10 @@ class _NavbarItemState extends State<NavbarItem> {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_animationController.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,7 +99,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 +108,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 +125,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(
|
||||||
@@ -245,21 +243,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;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -6,9 +6,8 @@ import 'package:game_tracker/presentation/widgets/tiles/text_icon_tile.dart';
|
|||||||
/// A tile widget that displays information about a group, including its name and members.
|
/// A tile widget that displays information about a group, including its name and members.
|
||||||
/// - [group]: The group data to be displayed.
|
/// - [group]: The group data to be displayed.
|
||||||
/// - [isHighlighted]: Whether the tile should be highlighted.
|
/// - [isHighlighted]: Whether the tile should be highlighted.
|
||||||
/// - [onTap]: An optional callback function to handle tap events.
|
|
||||||
class GroupTile extends StatelessWidget {
|
class GroupTile extends StatelessWidget {
|
||||||
const GroupTile({super.key, required this.group, this.isHighlighted = false, this.onTap});
|
const GroupTile({super.key, required this.group, this.isHighlighted = false});
|
||||||
|
|
||||||
/// The group data to be displayed.
|
/// The group data to be displayed.
|
||||||
final Group group;
|
final Group group;
|
||||||
@@ -16,67 +15,61 @@ class GroupTile extends StatelessWidget {
|
|||||||
/// Whether the tile should be highlighted.
|
/// Whether the tile should be highlighted.
|
||||||
final bool isHighlighted;
|
final bool isHighlighted;
|
||||||
|
|
||||||
/// Callback function to handle tap events.
|
|
||||||
final VoidCallback? onTap;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return GestureDetector(
|
return AnimatedContainer(
|
||||||
onTap: onTap,
|
margin: CustomTheme.standardMargin,
|
||||||
child: AnimatedContainer(
|
padding: const EdgeInsets.symmetric(vertical: 5, horizontal: 10),
|
||||||
margin: CustomTheme.standardMargin,
|
decoration: isHighlighted
|
||||||
padding: const EdgeInsets.symmetric(vertical: 5, horizontal: 10),
|
? CustomTheme.highlightedBoxDecoration
|
||||||
decoration: isHighlighted
|
: CustomTheme.standardBoxDecoration,
|
||||||
? CustomTheme.highlightedBoxDecoration
|
duration: const Duration(milliseconds: 150),
|
||||||
: CustomTheme.standardBoxDecoration,
|
child: Column(
|
||||||
duration: const Duration(milliseconds: 150),
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
child: Column(
|
children: [
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
Row(
|
||||||
children: [
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
Row(
|
children: [
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
Flexible(
|
||||||
children: [
|
child: Text(
|
||||||
Flexible(
|
group.name,
|
||||||
child: Text(
|
overflow: TextOverflow.ellipsis,
|
||||||
group.name,
|
style: const TextStyle(
|
||||||
overflow: TextOverflow.ellipsis,
|
fontWeight: FontWeight.bold,
|
||||||
|
fontSize: 18,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
'${group.members.length}',
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.w900,
|
||||||
fontSize: 18,
|
fontSize: 18,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
const SizedBox(width: 3),
|
||||||
Row(
|
const Icon(Icons.group, size: 22),
|
||||||
children: [
|
],
|
||||||
Text(
|
),
|
||||||
'${group.members.length}',
|
],
|
||||||
style: const TextStyle(
|
),
|
||||||
fontWeight: FontWeight.w900,
|
const SizedBox(height: 5),
|
||||||
fontSize: 18,
|
Wrap(
|
||||||
),
|
alignment: WrapAlignment.start,
|
||||||
),
|
crossAxisAlignment: WrapCrossAlignment.start,
|
||||||
const SizedBox(width: 3),
|
spacing: 12.0,
|
||||||
const Icon(Icons.group, size: 22),
|
runSpacing: 8.0,
|
||||||
],
|
children: <Widget>[
|
||||||
),
|
for (var member in [
|
||||||
],
|
...group.members,
|
||||||
),
|
]..sort((a, b) => a.name.compareTo(b.name)))
|
||||||
const SizedBox(height: 5),
|
TextIconTile(text: member.name, iconEnabled: false),
|
||||||
Wrap(
|
],
|
||||||
alignment: WrapAlignment.start,
|
),
|
||||||
crossAxisAlignment: WrapCrossAlignment.start,
|
const SizedBox(height: 2.5),
|
||||||
spacing: 12.0,
|
],
|
||||||
runSpacing: 8.0,
|
|
||||||
children: <Widget>[
|
|
||||||
for (var member in [
|
|
||||||
...group.members,
|
|
||||||
]..sort((a, b) => a.name.compareTo(b.name)))
|
|
||||||
TextIconTile(text: member.name, iconEnabled: false),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
const SizedBox(height: 2.5),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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.3+93
|
version: 0.0.1+149
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ^3.8.1
|
sdk: ^3.8.1
|
||||||
@@ -22,6 +22,7 @@ dependencies:
|
|||||||
intl: any
|
intl: any
|
||||||
flutter_localizations:
|
flutter_localizations:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
|
package_info_plus: ^9.0.0
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
|
|||||||
Reference in New Issue
Block a user