Compare commits
12 Commits
80290efa0b
...
d341634885
| Author | SHA1 | Date | |
|---|---|---|---|
| d341634885 | |||
| d3a63bd299 | |||
| e0c8398873 | |||
| d65dd3d983 | |||
| 51a8c4ea58 | |||
| c67f688a77 | |||
| 1d9945c525 | |||
| 0202d09812 | |||
| 73d8e7522c | |||
| f4ed122220 | |||
| c0ff2bf677 | |||
| 282841ecf1 |
@@ -1,5 +1,6 @@
|
|||||||
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:uuid/uuid.dart';
|
||||||
|
|
||||||
class Game {
|
class Game {
|
||||||
final String id;
|
final String id;
|
||||||
@@ -9,12 +10,12 @@ class Game {
|
|||||||
final String winner;
|
final String winner;
|
||||||
|
|
||||||
Game({
|
Game({
|
||||||
|
String? id,
|
||||||
|
required this.name,
|
||||||
this.players,
|
this.players,
|
||||||
this.group,
|
this.group,
|
||||||
this.winner = '',
|
this.winner = '',
|
||||||
required this.id,
|
}) : id = id ?? const Uuid().v4();
|
||||||
required this.name,
|
|
||||||
});
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
|
|||||||
@@ -1,11 +1,13 @@
|
|||||||
import 'package:game_tracker/data/dto/player.dart';
|
import 'package:game_tracker/data/dto/player.dart';
|
||||||
|
import 'package:uuid/uuid.dart';
|
||||||
|
|
||||||
class Group {
|
class Group {
|
||||||
final String id;
|
final String id;
|
||||||
final String name;
|
final String name;
|
||||||
final List<Player> members;
|
final List<Player> members;
|
||||||
|
|
||||||
Group({required this.id, required this.name, required this.members});
|
Group({String? id, required this.name, required this.members})
|
||||||
|
: id = id ?? const Uuid().v4();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
|
import 'package:uuid/uuid.dart';
|
||||||
|
|
||||||
class Player {
|
class Player {
|
||||||
final String id;
|
final String id;
|
||||||
final String name;
|
final String name;
|
||||||
|
|
||||||
Player({required this.id, required this.name});
|
Player({String? id, required this.name}) : id = id ?? const Uuid().v4();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import 'package:game_tracker/presentation/widgets/tiles/text_icon_tile.dart';
|
|||||||
import 'package:game_tracker/presentation/widgets/top_centered_message.dart';
|
import 'package:game_tracker/presentation/widgets/top_centered_message.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:skeletonizer/skeletonizer.dart';
|
import 'package:skeletonizer/skeletonizer.dart';
|
||||||
import 'package:uuid/uuid.dart';
|
|
||||||
|
|
||||||
class CreateGroupView extends StatefulWidget {
|
class CreateGroupView extends StatefulWidget {
|
||||||
const CreateGroupView({super.key});
|
const CreateGroupView({super.key});
|
||||||
@@ -28,7 +27,7 @@ class _CreateGroupViewState extends State<CreateGroupView> {
|
|||||||
late Future<List<Player>> _allPlayersFuture;
|
late Future<List<Player>> _allPlayersFuture;
|
||||||
late final List<Player> skeletonData = List.filled(
|
late final List<Player> skeletonData = List.filled(
|
||||||
7,
|
7,
|
||||||
Player(id: '0', name: 'Player 0'),
|
Player(name: 'Player 0'),
|
||||||
);
|
);
|
||||||
final _groupNameController = TextEditingController();
|
final _groupNameController = TextEditingController();
|
||||||
final _searchBarController = TextEditingController();
|
final _searchBarController = TextEditingController();
|
||||||
@@ -56,8 +55,8 @@ class _CreateGroupViewState extends State<CreateGroupView> {
|
|||||||
backgroundColor: CustomTheme.backgroundColor,
|
backgroundColor: CustomTheme.backgroundColor,
|
||||||
scrolledUnderElevation: 0,
|
scrolledUnderElevation: 0,
|
||||||
title: const Text(
|
title: const Text(
|
||||||
"Create new group",
|
'Create new group',
|
||||||
style: const TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
|
style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
|
||||||
),
|
),
|
||||||
centerTitle: true,
|
centerTitle: true,
|
||||||
),
|
),
|
||||||
@@ -94,8 +93,11 @@ class _CreateGroupViewState extends State<CreateGroupView> {
|
|||||||
children: [
|
children: [
|
||||||
CustomSearchBar(
|
CustomSearchBar(
|
||||||
controller: _searchBarController,
|
controller: _searchBarController,
|
||||||
constraints: BoxConstraints(maxHeight: 45, minHeight: 45),
|
constraints: const BoxConstraints(
|
||||||
hintText: "Search for players",
|
maxHeight: 45,
|
||||||
|
minHeight: 45,
|
||||||
|
),
|
||||||
|
hintText: 'Search for players',
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
setState(() {
|
setState(() {
|
||||||
if (value.isEmpty) {
|
if (value.isEmpty) {
|
||||||
@@ -115,35 +117,34 @@ class _CreateGroupViewState extends State<CreateGroupView> {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
Text(
|
Text(
|
||||||
"Ausgewählte Spieler: (${selectedPlayers.length})",
|
'Ausgewählte Spieler: (${selectedPlayers.length})',
|
||||||
style: TextStyle(
|
style: const TextStyle(
|
||||||
fontSize: 16,
|
fontSize: 16,
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
Wrap(
|
Wrap(
|
||||||
alignment: WrapAlignment.start,
|
alignment: WrapAlignment.start,
|
||||||
crossAxisAlignment: WrapCrossAlignment.start,
|
crossAxisAlignment: WrapCrossAlignment.start,
|
||||||
spacing: 8.0,
|
spacing: 8.0,
|
||||||
runSpacing: 8.0,
|
runSpacing: 8.0,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
for (var selectedPlayer in selectedPlayers)
|
for (var player in selectedPlayers)
|
||||||
TextIconTile(
|
TextIconTile(
|
||||||
text: selectedPlayer.name,
|
text: player.name,
|
||||||
icon: Icons.close,
|
|
||||||
onIconTap: () {
|
onIconTap: () {
|
||||||
setState(() {
|
setState(() {
|
||||||
final currentSearch = _searchBarController.text
|
final currentSearch = _searchBarController.text
|
||||||
.toLowerCase();
|
.toLowerCase();
|
||||||
selectedPlayers.remove(selectedPlayer);
|
selectedPlayers.remove(player);
|
||||||
if (currentSearch.isEmpty ||
|
if (currentSearch.isEmpty ||
|
||||||
selectedPlayer.name.toLowerCase().contains(
|
player.name.toLowerCase().contains(
|
||||||
currentSearch,
|
currentSearch,
|
||||||
)) {
|
)) {
|
||||||
suggestedPlayers.add(selectedPlayer);
|
suggestedPlayers.add(player);
|
||||||
suggestedPlayers.sort(
|
suggestedPlayers.sort(
|
||||||
(a, b) => a.name.compareTo(b.name),
|
(a, b) => a.name.compareTo(b.name),
|
||||||
);
|
);
|
||||||
@@ -153,15 +154,15 @@ class _CreateGroupViewState extends State<CreateGroupView> {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
Text(
|
const Text(
|
||||||
"Alle Spieler:",
|
'Alle Spieler:',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 16,
|
fontSize: 16,
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
FutureBuilder(
|
FutureBuilder(
|
||||||
future: _allPlayersFuture,
|
future: _allPlayersFuture,
|
||||||
builder:
|
builder:
|
||||||
@@ -216,7 +217,7 @@ class _CreateGroupViewState extends State<CreateGroupView> {
|
|||||||
),
|
),
|
||||||
child:
|
child:
|
||||||
(suggestedPlayers.isEmpty &&
|
(suggestedPlayers.isEmpty &&
|
||||||
!allPlayers.isEmpty)
|
allPlayers.isNotEmpty)
|
||||||
? TopCenteredMessage(
|
? TopCenteredMessage(
|
||||||
icon: Icons.info,
|
icon: Icons.info,
|
||||||
title: 'Info',
|
title: 'Info',
|
||||||
@@ -230,10 +231,9 @@ class _CreateGroupViewState extends State<CreateGroupView> {
|
|||||||
itemCount: suggestedPlayers.length,
|
itemCount: suggestedPlayers.length,
|
||||||
itemBuilder:
|
itemBuilder:
|
||||||
(BuildContext context, int index) {
|
(BuildContext context, int index) {
|
||||||
return IconListTile(
|
return TextIconListTile(
|
||||||
text: suggestedPlayers[index]
|
text: suggestedPlayers[index]
|
||||||
.name,
|
.name,
|
||||||
icon: Icons.add,
|
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
setState(() {
|
setState(() {
|
||||||
if (!selectedPlayers.contains(
|
if (!selectedPlayers.contains(
|
||||||
@@ -264,9 +264,7 @@ class _CreateGroupViewState extends State<CreateGroupView> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
CustomWidthButton(
|
CustomWidthButton(
|
||||||
text: "Create group",
|
text: 'Create group',
|
||||||
infillColor: CustomTheme.primaryColor,
|
|
||||||
borderColor: CustomTheme.primaryColor,
|
|
||||||
disabledInfillColor: CustomTheme.boxColor,
|
disabledInfillColor: CustomTheme.boxColor,
|
||||||
sizeRelativeToWidth: 0.95,
|
sizeRelativeToWidth: 0.95,
|
||||||
onPressed:
|
onPressed:
|
||||||
@@ -275,7 +273,6 @@ class _CreateGroupViewState extends State<CreateGroupView> {
|
|||||||
: () async {
|
: () async {
|
||||||
bool success = await db.groupDao.addGroup(
|
bool success = await db.groupDao.addGroup(
|
||||||
group: Group(
|
group: Group(
|
||||||
id: Uuid().v4(),
|
|
||||||
name: _groupNameController.text,
|
name: _groupNameController.text,
|
||||||
members: selectedPlayers,
|
members: selectedPlayers,
|
||||||
),
|
),
|
||||||
@@ -284,14 +281,16 @@ class _CreateGroupViewState extends State<CreateGroupView> {
|
|||||||
_groupNameController.clear();
|
_groupNameController.clear();
|
||||||
_searchBarController.clear();
|
_searchBarController.clear();
|
||||||
selectedPlayers.clear();
|
selectedPlayers.clear();
|
||||||
|
if (!mounted) return;
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
} else {
|
} else {
|
||||||
|
if (!mounted) return;
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
SnackBar(
|
SnackBar(
|
||||||
backgroundColor: CustomTheme.boxColor,
|
backgroundColor: CustomTheme.boxColor,
|
||||||
content: Center(
|
content: const Center(
|
||||||
child: Text(
|
child: Text(
|
||||||
"Error while creating group, please try again",
|
'Error while creating group, please try again',
|
||||||
style: TextStyle(color: Colors.white),
|
style: TextStyle(color: Colors.white),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -301,7 +300,7 @@ class _CreateGroupViewState extends State<CreateGroupView> {
|
|||||||
setState(() {});
|
setState(() {});
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -21,12 +21,11 @@ class _GroupsViewState extends State<GroupsView> {
|
|||||||
late Future<List<Group>> _allGroupsFuture;
|
late Future<List<Group>> _allGroupsFuture;
|
||||||
late final AppDatabase db;
|
late final AppDatabase db;
|
||||||
|
|
||||||
final player = Player(id: 'p1', name: 'Sample');
|
final player = Player(name: 'Skeleton Player');
|
||||||
late final List<Group> skeletonData = List.filled(
|
late final List<Group> skeletonData = List.filled(
|
||||||
7,
|
7,
|
||||||
Group(
|
Group(
|
||||||
id: '0',
|
name: 'Skeleton Game',
|
||||||
name: 'Sample Game',
|
|
||||||
members: [player, player, player, player, player, player],
|
members: [player, player, player, player, player, player],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -107,8 +106,6 @@ class _GroupsViewState extends State<GroupsView> {
|
|||||||
bottom: 80,
|
bottom: 80,
|
||||||
child: CustomWidthButton(
|
child: CustomWidthButton(
|
||||||
text: 'Create Group',
|
text: 'Create Group',
|
||||||
infillColor: CustomTheme.primaryColor,
|
|
||||||
borderColor: CustomTheme.primaryColor,
|
|
||||||
sizeRelativeToWidth: 0.90,
|
sizeRelativeToWidth: 0.90,
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
await Navigator.push(
|
await Navigator.push(
|
||||||
|
|||||||
@@ -23,14 +23,14 @@ class CustomSearchBar extends StatelessWidget {
|
|||||||
constraints ?? const BoxConstraints(maxHeight: 45, minHeight: 45),
|
constraints ?? const BoxConstraints(maxHeight: 45, minHeight: 45),
|
||||||
hintText: hintText,
|
hintText: hintText,
|
||||||
onChanged: onChanged,
|
onChanged: onChanged,
|
||||||
hintStyle: MaterialStateProperty.all(const TextStyle(fontSize: 16)),
|
hintStyle: WidgetStateProperty.all(const TextStyle(fontSize: 16)),
|
||||||
leading: const Icon(Icons.search),
|
leading: const Icon(Icons.search),
|
||||||
backgroundColor: MaterialStateProperty.all(CustomTheme.boxColor),
|
backgroundColor: WidgetStateProperty.all(CustomTheme.boxColor),
|
||||||
side: MaterialStateProperty.all(BorderSide(color: CustomTheme.boxBorder)),
|
side: WidgetStateProperty.all(BorderSide(color: CustomTheme.boxBorder)),
|
||||||
shape: MaterialStateProperty.all(
|
shape: WidgetStateProperty.all(
|
||||||
RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
|
RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
|
||||||
),
|
),
|
||||||
elevation: MaterialStateProperty.all(0),
|
elevation: WidgetStateProperty.all(0),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,22 +1,23 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:game_tracker/core/custom_theme.dart';
|
||||||
|
|
||||||
|
enum ButtonStyle { primary, secondary }
|
||||||
|
|
||||||
class CustomWidthButton extends StatelessWidget {
|
class CustomWidthButton extends StatelessWidget {
|
||||||
const CustomWidthButton({
|
const CustomWidthButton({
|
||||||
super.key,
|
super.key,
|
||||||
required this.text,
|
required this.text,
|
||||||
required this.borderColor,
|
|
||||||
required this.infillColor,
|
|
||||||
this.disabledInfillColor,
|
this.disabledInfillColor,
|
||||||
|
this.buttonStyle = ButtonStyle.primary,
|
||||||
required this.sizeRelativeToWidth,
|
required this.sizeRelativeToWidth,
|
||||||
required this.onPressed,
|
required this.onPressed,
|
||||||
});
|
});
|
||||||
|
|
||||||
final String text;
|
final String text;
|
||||||
final Color borderColor;
|
|
||||||
final Color infillColor;
|
|
||||||
final Color? disabledInfillColor;
|
final Color? disabledInfillColor;
|
||||||
final double sizeRelativeToWidth;
|
final double sizeRelativeToWidth;
|
||||||
final VoidCallback? onPressed;
|
final VoidCallback? onPressed;
|
||||||
|
final ButtonStyle buttonStyle;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@@ -28,8 +29,15 @@ class CustomWidthButton extends StatelessWidget {
|
|||||||
MediaQuery.sizeOf(context).width * sizeRelativeToWidth,
|
MediaQuery.sizeOf(context).width * sizeRelativeToWidth,
|
||||||
60,
|
60,
|
||||||
),
|
),
|
||||||
backgroundColor: infillColor,
|
backgroundColor: buttonStyle == ButtonStyle.primary
|
||||||
side: BorderSide(color: borderColor, width: 2),
|
? CustomTheme.primaryColor
|
||||||
|
: CustomTheme.secondaryColor,
|
||||||
|
side: BorderSide(
|
||||||
|
color: buttonStyle == ButtonStyle.primary
|
||||||
|
? CustomTheme.primaryColor
|
||||||
|
: CustomTheme.secondaryColor,
|
||||||
|
width: 2,
|
||||||
|
),
|
||||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
|
||||||
),
|
),
|
||||||
child: Text(
|
child: Text(
|
||||||
|
|||||||
@@ -56,7 +56,8 @@ class GroupTile extends StatelessWidget {
|
|||||||
spacing: 12.0,
|
spacing: 12.0,
|
||||||
runSpacing: 8.0,
|
runSpacing: 8.0,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
for (var member in group.members) TextIconTile(text: member.name),
|
for (var member in group.members)
|
||||||
|
TextIconTile(text: member.name, iconEnabled: false),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(height: 2.5),
|
const SizedBox(height: 2.5),
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:game_tracker/core/custom_theme.dart';
|
import 'package:game_tracker/core/custom_theme.dart';
|
||||||
|
|
||||||
class IconListTile extends StatelessWidget {
|
class TextIconListTile extends StatelessWidget {
|
||||||
final String text;
|
final String text;
|
||||||
final IconData icon;
|
|
||||||
final VoidCallback onPressed;
|
final VoidCallback onPressed;
|
||||||
|
final bool iconEnabled;
|
||||||
|
|
||||||
const IconListTile({
|
const TextIconListTile({
|
||||||
super.key,
|
super.key,
|
||||||
required this.text,
|
required this.text,
|
||||||
required this.icon,
|
|
||||||
required this.onPressed,
|
required this.onPressed,
|
||||||
|
this.iconEnabled = true,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -28,13 +28,23 @@ class IconListTile extends StatelessWidget {
|
|||||||
mainAxisSize: MainAxisSize.max,
|
mainAxisSize: MainAxisSize.max,
|
||||||
children: [
|
children: [
|
||||||
Flexible(
|
Flexible(
|
||||||
child: Text(
|
child: Container(
|
||||||
text,
|
padding: const EdgeInsets.symmetric(vertical: 12.5),
|
||||||
overflow: TextOverflow.ellipsis,
|
child: Text(
|
||||||
style: const TextStyle(fontSize: 16, fontWeight: FontWeight.w500),
|
text,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 16,
|
||||||
|
fontWeight: FontWeight.w500,
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
IconButton(icon: Icon(icon, size: 20), onPressed: onPressed),
|
if (iconEnabled)
|
||||||
|
IconButton(
|
||||||
|
icon: const Icon(Icons.add, size: 20),
|
||||||
|
onPressed: onPressed,
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -3,14 +3,14 @@ import 'package:game_tracker/core/custom_theme.dart';
|
|||||||
|
|
||||||
class TextIconTile extends StatelessWidget {
|
class TextIconTile extends StatelessWidget {
|
||||||
final String text;
|
final String text;
|
||||||
final IconData? icon;
|
final bool iconEnabled;
|
||||||
final VoidCallback? onIconTap;
|
final VoidCallback? onIconTap;
|
||||||
|
|
||||||
const TextIconTile({
|
const TextIconTile({
|
||||||
super.key,
|
super.key,
|
||||||
required this.text,
|
required this.text,
|
||||||
this.icon,
|
|
||||||
this.onIconTap,
|
this.onIconTap,
|
||||||
|
this.iconEnabled = true,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -25,7 +25,7 @@ class TextIconTile extends StatelessWidget {
|
|||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
if (icon != null) const SizedBox(width: 3),
|
if (iconEnabled) const SizedBox(width: 3),
|
||||||
Flexible(
|
Flexible(
|
||||||
child: Text(
|
child: Text(
|
||||||
text,
|
text,
|
||||||
@@ -33,9 +33,12 @@ class TextIconTile extends StatelessWidget {
|
|||||||
style: const TextStyle(fontSize: 14, fontWeight: FontWeight.w500),
|
style: const TextStyle(fontSize: 14, fontWeight: FontWeight.w500),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (icon != null) ...<Widget>[
|
if (iconEnabled) ...<Widget>[
|
||||||
const SizedBox(width: 3),
|
const SizedBox(width: 3),
|
||||||
GestureDetector(onTap: onIconTap, child: Icon(icon, size: 20)),
|
GestureDetector(
|
||||||
|
onTap: onIconTap,
|
||||||
|
child: const Icon(Icons.close, size: 20),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ void main() {
|
|||||||
late Player player2;
|
late Player player2;
|
||||||
late Player player3;
|
late Player player3;
|
||||||
late Player player4;
|
late Player player4;
|
||||||
|
late Player player5;
|
||||||
late Group testgroup;
|
late Group testgroup;
|
||||||
late Game testgame;
|
late Game testgame;
|
||||||
|
|
||||||
@@ -24,20 +25,16 @@ void main() {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
player1 = Player(id: 'p1', name: 'Alice');
|
player1 = Player(name: 'Alice');
|
||||||
player2 = Player(id: 'p2', name: 'Bob');
|
player2 = Player(name: 'Bob');
|
||||||
player3 = Player(id: 'p3', name: 'Charlie');
|
player3 = Player(name: 'Charlie');
|
||||||
player4 = Player(id: 'p4', name: 'Diana');
|
player4 = Player(name: 'Diana');
|
||||||
testgroup = Group(
|
player5 = Player(name: 'Eve');
|
||||||
id: 'gr1',
|
testgroup = Group(name: 'Test Group', members: [player1, player2, player3]);
|
||||||
name: 'Test Group',
|
|
||||||
members: [player1, player2, player3],
|
|
||||||
);
|
|
||||||
testgame = Game(
|
testgame = Game(
|
||||||
id: 'ga1',
|
|
||||||
name: 'Test Game',
|
name: 'Test Game',
|
||||||
group: testgroup,
|
group: testgroup,
|
||||||
players: [player4],
|
players: [player4, player5],
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
tearDown(() async {
|
tearDown(() async {
|
||||||
|
|||||||
@@ -22,15 +22,11 @@ void main() {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
player1 = Player(id: 'p1', name: 'Alice');
|
player1 = Player(name: 'Alice');
|
||||||
player2 = Player(id: 'p2', name: 'Bob');
|
player2 = Player(name: 'Bob');
|
||||||
player3 = Player(id: 'p3', name: 'Charlie');
|
player3 = Player(name: 'Charlie');
|
||||||
player4 = Player(id: 'p4', name: 'Diana');
|
player4 = Player(name: 'Diana');
|
||||||
testgroup = Group(
|
testgroup = Group(name: 'Test Group', members: [player1, player2, player3]);
|
||||||
id: 'gr1',
|
|
||||||
name: 'Test Group',
|
|
||||||
members: [player1, player2, player3],
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
tearDown(() async {
|
tearDown(() async {
|
||||||
await database.close();
|
await database.close();
|
||||||
@@ -121,12 +117,12 @@ void main() {
|
|||||||
|
|
||||||
expect(playerAdded, true);
|
expect(playerAdded, true);
|
||||||
|
|
||||||
final playerAdded2 = await database.playerGroupDao.isPlayerInGroup(
|
final playerNotAdded = !await database.playerGroupDao.isPlayerInGroup(
|
||||||
playerId: 'a',
|
playerId: '',
|
||||||
groupId: testgroup.id,
|
groupId: testgroup.id,
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(playerAdded2, false);
|
expect(playerNotAdded, true);
|
||||||
|
|
||||||
expect(playerAdded, true);
|
expect(playerAdded, true);
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ void main() {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
testPlayer = Player(id: 'test_id', name: 'Test Player');
|
testPlayer = Player(name: 'Test Player');
|
||||||
});
|
});
|
||||||
tearDown(() async {
|
tearDown(() async {
|
||||||
await database.close();
|
await database.close();
|
||||||
@@ -25,7 +25,7 @@ void main() {
|
|||||||
|
|
||||||
group('player tests', () {
|
group('player tests', () {
|
||||||
test('all players get fetched correctly', () async {
|
test('all players get fetched correctly', () async {
|
||||||
final testPlayer2 = Player(id: 'gr2', name: 'Second Group');
|
final testPlayer2 = Player(name: 'Second Group');
|
||||||
await database.playerDao.addPlayer(player: testPlayer);
|
await database.playerDao.addPlayer(player: testPlayer);
|
||||||
await database.playerDao.addPlayer(player: testPlayer2);
|
await database.playerDao.addPlayer(player: testPlayer2);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user