Adding deletion of players during game creation
continuous-integration/drone/push Build is passing Details

pull/25/head
Arthur VALIN 2 years ago
parent c64d8926ab
commit 36031ebf07

@ -85,7 +85,7 @@ class _AnalysisScreenState extends State<AnalysisScreen> {
verticalDirection: VerticalDirection.up, verticalDirection: VerticalDirection.up,
children: [ children: [
StatsCard( StatsCard(
title: "Number of victory", title: "Number of victories",
val: MyApp.controller.userCurrent.stat.nbVictory.toDouble(), val: MyApp.controller.userCurrent.stat.nbVictory.toDouble(),
precision: 0, precision: 0,
), ),

@ -12,6 +12,7 @@ import '../model/AbstractRound.dart';
import '../model/GameDetail.dart'; import '../model/GameDetail.dart';
import '../model/Guest.dart'; import '../model/Guest.dart';
import '../model/Player.dart'; import '../model/Player.dart';
import '../model/User.dart';
class FinalScoreBoard extends StatefulWidget { class FinalScoreBoard extends StatefulWidget {
final GameDetail gameDeatil; final GameDetail gameDeatil;
@ -263,6 +264,12 @@ class _InGameCardConfigState extends State<InGameCardConfig> {
super.initState(); super.initState();
} }
void onDelete(Player p){
setState(() {
widget.listPlayer.remove(p);
});
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Container( return Container(
@ -306,7 +313,7 @@ class _InGameCardConfigState extends State<InGameCardConfig> {
], ],
), ),
)), )),
ListUserInGame(listPlayer: widget.listPlayer), ListUserInGame(listPlayer: widget.listPlayer, onDelete: onDelete),
Spacer(), Spacer(),
Image( Image(
image: AssetImage("assets/images/start_sentence.png"), image: AssetImage("assets/images/start_sentence.png"),
@ -346,13 +353,15 @@ class _InGameCardConfigState extends State<InGameCardConfig> {
class ListUserInGame extends StatefulWidget { class ListUserInGame extends StatefulWidget {
final List<Player> listPlayer; final List<Player> listPlayer;
const ListUserInGame({Key? key, required this.listPlayer}) : super(key: key); final Function(Player) onDelete;
const ListUserInGame({Key? key, required this.listPlayer, required this.onDelete}) : super(key: key);
@override @override
State<ListUserInGame> createState() => _ListUserInGameState(); State<ListUserInGame> createState() => _ListUserInGameState();
} }
class _ListUserInGameState extends State<ListUserInGame> { class _ListUserInGameState extends State<ListUserInGame> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Padding( return Padding(
@ -367,7 +376,7 @@ class _ListUserInGameState extends State<ListUserInGame> {
child: ListView.builder( child: ListView.builder(
itemCount: widget.listPlayer.length, itemCount: widget.listPlayer.length,
itemBuilder: (context, index) { itemBuilder: (context, index) {
return UserInGame(player: widget.listPlayer[index]); return UserInGame(player: widget.listPlayer[index], onDelete: widget.onDelete);
}), }),
), ),
RichText( RichText(
@ -392,7 +401,8 @@ class _ListUserInGameState extends State<ListUserInGame> {
class UserInGame extends StatefulWidget { class UserInGame extends StatefulWidget {
final Player player; final Player player;
const UserInGame({Key? key, required this.player}) : super(key: key); final Function(Player) onDelete;
const UserInGame({Key? key, required this.player, required this.onDelete}) : super(key: key);
@override @override
State<UserInGame> createState() => _UserInGameState(); State<UserInGame> createState() => _UserInGameState();
@ -431,7 +441,7 @@ class _UserInGameState extends State<UserInGame> {
? Material( ? Material(
surfaceTintColor: Colors.transparent, surfaceTintColor: Colors.transparent,
child: SizedBox( child: SizedBox(
width: 230, width: 220,
child: TextField( child: TextField(
controller: userNameTextField, controller: userNameTextField,
style: const TextStyle(color: Colors.black), style: const TextStyle(color: Colors.black),
@ -448,14 +458,25 @@ class _UserInGameState extends State<UserInGame> {
), ),
), ),
) )
: Text( : SizedBox(
width: 220,
child: Text(
widget.player.name, widget.player.name,
style: GoogleFonts.roboto( style: GoogleFonts.roboto(
fontSize: 18, fontSize: 18,
decoration: TextDecoration.none, decoration: TextDecoration.none,
color: Color(0xff241E40)), color: Color(0xff241E40))
),
), ),
Spacer(), (widget.player is User && (widget.player as User).id == MyApp.controller.userCurrent.id) ?
Icon(Icons.lock, color: Colors.amber) :
GestureDetector(
onTap: () {
widget.onDelete(widget.player);
},
child: Icon(Icons.close)
),
Spacer()
], ],
), ),
); );

Loading…
Cancel
Save