CreateGroupView erstellt #28
@@ -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'),
|
||||||
);
|
);
|
||||||
|
sneeex marked this conversation as resolved
Outdated
|
|||||||
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),
|
||||||
|
sneeex marked this conversation as resolved
Outdated
flixcoo
commented
Single Quotes Single Quotes
|
|||||||
),
|
),
|
||||||
|
sneeex marked this conversation as resolved
Outdated
flixcoo
commented
`const` unnötig
|
|||||||
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,
|
||||||
|
sneeex marked this conversation as resolved
Outdated
flixcoo
commented
`constraints: const BoxConstraints(...`
|
|||||||
|
minHeight: 45,
|
||||||
|
sneeex marked this conversation as resolved
Outdated
flixcoo
commented
single quotes single quotes
|
|||||||
|
),
|
||||||
|
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> {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
sneeex marked this conversation as resolved
Outdated
flixcoo
commented
`const SizedBox()`
|
|||||||
),
|
),
|
||||||
SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
|
sneeex marked this conversation as resolved
Outdated
flixcoo
commented
single quotes single quotes
|
|||||||
Text(
|
Text(
|
||||||
|
sneeex marked this conversation as resolved
Outdated
flixcoo
commented
`const TextStyle()`
|
|||||||
"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,
|
||||||
),
|
),
|
||||||
|
sneeex marked this conversation as resolved
Outdated
flixcoo
commented
`const SizedBox()`
|
|||||||
),
|
),
|
||||||
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,
|
||||||
|
sneeex marked this conversation as resolved
Outdated
flixcoo
commented
lieber lieber `var player in selectedPlayers`?
|
|||||||
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> {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
sneeex marked this conversation as resolved
Outdated
flixcoo
commented
`const SizedBox()`
|
|||||||
SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
Text(
|
const Text(
|
||||||
|
sneeex marked this conversation as resolved
Outdated
flixcoo
commented
single quotes single quotes
|
|||||||
"Alle Spieler:",
|
'Alle Spieler:',
|
||||||
|
sneeex marked this conversation as resolved
Outdated
flixcoo
commented
`const TextStyle`
|
|||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 16,
|
fontSize: 16,
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
sneeex marked this conversation as resolved
Outdated
flixcoo
commented
`const SizedBox()`
|
|||||||
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 &&
|
||||||
|
sneeex marked this conversation as resolved
Outdated
flixcoo
commented
Lieber Lieber `isNotEmpty`
|
|||||||
!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',
|
||||||
|
sneeex marked this conversation as resolved
Outdated
flixcoo
commented
single quotes single quotes
|
|||||||
infillColor: CustomTheme.primaryColor,
|
|
||||||
borderColor: CustomTheme.primaryColor,
|
|
||||||
disabledInfillColor: CustomTheme.boxColor,
|
disabledInfillColor: CustomTheme.boxColor,
|
||||||
sizeRelativeToWidth: 0.95,
|
sizeRelativeToWidth: 0.95,
|
||||||
onPressed:
|
onPressed:
|
||||||
|
sneeex marked this conversation as resolved
Outdated
flixcoo
commented
Button sieht deaktiviert aus wie ein SecondaryButton, styling anpassen. Ggf. Attribut festlegen, welches festlegt ob Button primary styling oder secondary styling hat Button sieht deaktiviert aus wie ein SecondaryButton, styling anpassen. Ggf. Attribut festlegen, welches festlegt ob Button primary styling oder secondary styling hat
|
|||||||
@@ -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,
|
||||||
),
|
),
|
||||||
|
sneeex marked this conversation as resolved
Outdated
flixcoo
commented
`const` bzw #35 reinmergen und weglassen
|
|||||||
@@ -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;
|
||||||
|
sneeex marked this conversation as resolved
Outdated
flixcoo
commented
Bei asynchronen aufgaben Bei asynchronen aufgaben `mounted` check
|
|||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
SnackBar(
|
SnackBar(
|
||||||
|
sneeex marked this conversation as resolved
Outdated
flixcoo
commented
`mounted` check
|
|||||||
backgroundColor: CustomTheme.boxColor,
|
backgroundColor: CustomTheme.boxColor,
|
||||||
content: Center(
|
content: const Center(
|
||||||
child: Text(
|
child: Text(
|
||||||
|
sneeex marked this conversation as resolved
Outdated
flixcoo
commented
`const`
|
|||||||
"Error while creating group, please try again",
|
'Error while creating group, please try again',
|
||||||
style: TextStyle(color: Colors.white),
|
style: TextStyle(color: Colors.white),
|
||||||
|
sneeex marked this conversation as resolved
Outdated
flixcoo
commented
single quotes single quotes
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -301,7 +300,7 @@ class _CreateGroupViewState extends State<CreateGroupView> {
|
|||||||
setState(() {});
|
setState(() {});
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
],
|
],
|
||||||
|
sneeex marked this conversation as resolved
Outdated
flixcoo
commented
`const`
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
Reference in New Issue
Block a user
id nach #35 nicht mehr notwendig