CreateGroupView erstellt #28
@@ -36,8 +36,8 @@ class _CreateGroupViewState extends State<CreateGroupView> {
|
|||||||
_allPlayersFuture.then((loadedPlayers) {
|
_allPlayersFuture.then((loadedPlayers) {
|
||||||
setState(() {
|
setState(() {
|
||||||
loadedPlayers.sort((a, b) => a.name.compareTo(b.name));
|
loadedPlayers.sort((a, b) => a.name.compareTo(b.name));
|
||||||
allPlayers = loadedPlayers;
|
allPlayers = [...loadedPlayers];
|
||||||
suggestedPlayers = loadedPlayers;
|
suggestedPlayers = [...loadedPlayers];
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -123,7 +123,7 @@ class _CreateGroupViewState extends State<CreateGroupView> {
|
|||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
setState(() {
|
setState(() {
|
||||||
if (value.isEmpty) {
|
if (value.isEmpty) {
|
||||||
suggestedPlayers = allPlayers;
|
suggestedPlayers = [...allPlayers];
|
||||||
} else {
|
} else {
|
||||||
suggestedPlayers = allPlayers.where((player) {
|
suggestedPlayers = allPlayers.where((player) {
|
||||||
return player.name.toLowerCase().contains(
|
return player.name.toLowerCase().contains(
|
||||||
@@ -197,131 +197,122 @@ class _CreateGroupViewState extends State<CreateGroupView> {
|
|||||||
SizedBox(height: 10),
|
SizedBox(height: 10),
|
||||||
FutureBuilder(
|
FutureBuilder(
|
||||||
future: _allPlayersFuture,
|
future: _allPlayersFuture,
|
||||||
builder:
|
builder: (BuildContext context, AsyncSnapshot<List<Player>> snapshot) {
|
||||||
(
|
if (snapshot.hasError) {
|
||||||
BuildContext context,
|
return const Center(
|
||||||
AsyncSnapshot<List<Player>> snapshot,
|
child: TopCenteredMessage(
|
||||||
) {
|
icon: Icons.report,
|
||||||
if (snapshot.hasError) {
|
title: 'Error',
|
||||||
return const Center(
|
message: 'Player data couldn\'t\nbe loaded.',
|
||||||
child: TopCenteredMessage(
|
),
|
||||||
icon: Icons.report,
|
);
|
||||||
title: 'Error',
|
}
|
||||||
message: 'Player data couldn\'t\nbe loaded.',
|
if (snapshot.connectionState == ConnectionState.done &&
|
||||||
),
|
(!snapshot.hasData ||
|
||||||
);
|
snapshot.data!.isEmpty ||
|
||||||
}
|
(selectedPlayers.isEmpty &&
|
||||||
if (snapshot.connectionState ==
|
allPlayers.isEmpty))) {
|
||||||
ConnectionState.done &&
|
return const Center(
|
||||||
(!snapshot.hasData ||
|
child: TopCenteredMessage(
|
||||||
snapshot.data!.isEmpty ||
|
icon: Icons.info,
|
||||||
(suggestedPlayers.isEmpty &&
|
title: 'Info',
|
||||||
allPlayers.isEmpty))) {
|
message: 'No players created yet.',
|
||||||
return const Center(
|
),
|
||||||
child: TopCenteredMessage(
|
);
|
||||||
icon: Icons.info,
|
}
|
||||||
title: 'Info',
|
final bool isLoading =
|
||||||
message: 'No players created yet.',
|
snapshot.connectionState == ConnectionState.waiting;
|
||||||
),
|
return Expanded(
|
||||||
);
|
child: Skeletonizer(
|
||||||
}
|
effect: PulseEffect(
|
||||||
final bool isLoading =
|
from: Colors.grey[800]!,
|
||||||
snapshot.connectionState ==
|
to: Colors.grey[600]!,
|
||||||
ConnectionState.waiting;
|
duration: const Duration(milliseconds: 800),
|
||||||
return Expanded(
|
),
|
||||||
child: Skeletonizer(
|
enabled: isLoading,
|
||||||
effect: PulseEffect(
|
enableSwitchAnimation: true,
|
||||||
from: Colors.grey[800]!,
|
switchAnimationConfig: const SwitchAnimationConfig(
|
||||||
to: Colors.grey[600]!,
|
duration: Duration(milliseconds: 200),
|
||||||
duration: const Duration(milliseconds: 800),
|
switchInCurve: Curves.linear,
|
||||||
),
|
switchOutCurve: Curves.linear,
|
||||||
enabled: isLoading,
|
transitionBuilder:
|
||||||
enableSwitchAnimation: true,
|
AnimatedSwitcher.defaultTransitionBuilder,
|
||||||
switchAnimationConfig:
|
layoutBuilder:
|
||||||
const SwitchAnimationConfig(
|
AnimatedSwitcher.defaultLayoutBuilder,
|
||||||
duration: Duration(milliseconds: 200),
|
),
|
||||||
switchInCurve: Curves.linear,
|
child:
|
||||||
switchOutCurve: Curves.linear,
|
(suggestedPlayers.isEmpty &&
|
||||||
transitionBuilder: AnimatedSwitcher
|
!allPlayers.isEmpty)
|
||||||
.defaultTransitionBuilder,
|
? TopCenteredMessage(
|
||||||
layoutBuilder:
|
icon: Icons.info,
|
||||||
AnimatedSwitcher.defaultLayoutBuilder,
|
title: 'Info',
|
||||||
),
|
message:
|
||||||
child:
|
(selectedPlayers.length ==
|
||||||
(suggestedPlayers.isEmpty &&
|
allPlayers.length)
|
||||||
!allPlayers.isEmpty)
|
? 'No more players to add.'
|
||||||
? TopCenteredMessage(
|
: 'No players found with that name.',
|
||||||
icon: Icons.info,
|
)
|
||||||
title: 'Info',
|
: ListView.builder(
|
||||||
message:
|
itemCount: suggestedPlayers.length,
|
||||||
'No players found with that name.',
|
itemBuilder: (BuildContext context, int index) {
|
||||||
)
|
return Container(
|
||||||
: ListView.builder(
|
margin: const EdgeInsets.symmetric(
|
||||||
itemCount: suggestedPlayers.length,
|
horizontal: 5,
|
||||||
itemBuilder: (BuildContext context, int index) {
|
vertical: 5,
|
||||||
return Container(
|
),
|
||||||
margin: const EdgeInsets.symmetric(
|
padding: const EdgeInsets.symmetric(
|
||||||
horizontal: 5,
|
horizontal: 10,
|
||||||
vertical: 5,
|
),
|
||||||
),
|
decoration: BoxDecoration(
|
||||||
padding: const EdgeInsets.symmetric(
|
color: CustomTheme.boxColor,
|
||||||
horizontal: 10,
|
border: Border.all(
|
||||||
),
|
color: CustomTheme.boxBorder,
|
||||||
decoration: BoxDecoration(
|
),
|
||||||
color: CustomTheme.boxColor,
|
borderRadius: BorderRadius.circular(
|
||||||
border: Border.all(
|
12,
|
||||||
color: CustomTheme.boxBorder,
|
),
|
||||||
|
),
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment:
|
||||||
|
MainAxisAlignment.spaceBetween,
|
||||||
|
mainAxisSize: MainAxisSize.max,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
suggestedPlayers[index].name,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 16,
|
||||||
|
fontWeight: FontWeight.w500,
|
||||||
),
|
),
|
||||||
borderRadius:
|
|
||||||
BorderRadius.circular(12),
|
|
||||||
),
|
),
|
||||||
child: Row(
|
IconButton(
|
||||||
mainAxisAlignment:
|
icon: Icon(Icons.add, size: 20),
|
||||||
MainAxisAlignment
|
onPressed: () {
|
||||||
.spaceBetween,
|
setState(() {
|
||||||
mainAxisSize: MainAxisSize.max,
|
if (!selectedPlayers.contains(
|
||||||
children: [
|
suggestedPlayers[index],
|
||||||
Text(
|
)) {
|
||||||
suggestedPlayers[index].name,
|
selectedPlayers.add(
|
||||||
style: TextStyle(
|
suggestedPlayers[index],
|
||||||
fontSize: 16,
|
);
|
||||||
fontWeight: FontWeight.w500,
|
selectedPlayers.sort(
|
||||||
),
|
(a, b) => a.name
|
||||||
),
|
.compareTo(b.name),
|
||||||
IconButton(
|
);
|
||||||
icon: Icon(
|
suggestedPlayers.remove(
|
||||||
Icons.add,
|
suggestedPlayers[index],
|
||||||
size: 20,
|
);
|
||||||
),
|
}
|
||||||
onPressed: () {
|
});
|
||||||
setState(() {
|
},
|
||||||
if (!selectedPlayers.contains(
|
|
||||||
suggestedPlayers[index],
|
|
||||||
)) {
|
|
||||||
selectedPlayers.add(
|
|
||||||
suggestedPlayers[index],
|
|
||||||
);
|
|
||||||
selectedPlayers.sort(
|
|
||||||
(a, b) =>
|
|
||||||
a.name.compareTo(
|
|
||||||
b.name,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
suggestedPlayers.remove(
|
|
||||||
suggestedPlayers[index],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
);
|
],
|
||||||
},
|
),
|
||||||
),
|
);
|
||||||
),
|
},
|
||||||
);
|
),
|
||||||
},
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|||||||
Reference in New Issue
Block a user