add effect of button add player and textfield on guest player to rename them
continuous-integration/drone/push Build is passing Details

pull/25/head
Lucas Delanier 2 years ago
parent bf4da7a38a
commit e19e44f4e0

@ -10,4 +10,5 @@ abstract class IGameManager {
List<GameDetail> getGamesByPlayers(List<Player> users);
List<Player> getPlayersByIdGame(int id);
Map<Player, int> getRankByIdGame(int id);
addGame(GameDetail gd);
}

@ -81,4 +81,9 @@ class GameManager extends IGameManager {
}
throw Exception("Game not found.");
}
@override
addGame(GameDetail gd) {
parent.gameDetails.add(gd);
}
}

@ -54,12 +54,19 @@ class _InGameScreenState extends State<InGameScreen> {
Spacer(),
ElevatedButton(
onPressed: () {
GameDetail gd = GameDetail(1, DateTime.now(), null, 123, false,
MyApp.controller.userCurrent.id, [MyApp.controller.userCurrent, new Guest("Louison")]);
GameDetail gd = GameDetail(
1,
DateTime.now(),
null,
123,
false,
MyApp.controller.userCurrent.id,
[MyApp.controller.userCurrent, new Guest("Louison")]);
MyApp.controller.gamePlayer.game = gd;
MyApp.controller.gameCurrent = gd;
MyApp.controller.gamePlayer.onNext(false, context);
MyApp.controller.gameMgr.addGame(gd);
},
child: Text(
"PLAY",

@ -4,6 +4,10 @@ import 'package:flutter/services.dart';
import 'package:go_router/go_router.dart';
import 'package:google_fonts/google_fonts.dart';
import '../main.dart';
import '../model/GameDetail.dart';
import '../model/Player.dart';
import '../model/User.dart';
import 'ingame_widgets.dart';
class ButtonNewParty extends StatelessWidget {
@ -143,10 +147,14 @@ class NewGameModal extends StatelessWidget {
}
class ScoreBoardModal extends StatelessWidget {
const ScoreBoardModal({Key? key}) : super(key: key);
final GameDetail gamedetail;
const ScoreBoardModal({Key? key, required this.gamedetail}) : super(key: key);
@override
Widget build(BuildContext context) {
var rank = gamedetail.getRank();
var pseudoList = rank.keys.toList();
var scoreList = rank.values.toList();
return Dialog(
child: Stack(
alignment: Alignment.topCenter,
@ -159,39 +167,42 @@ class ScoreBoardModal extends StatelessWidget {
child:
Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
Expanded(
child: Padding(
padding: EdgeInsets.fromLTRB(0, 40, 0, 0),
child: Stack(
alignment: Alignment.topCenter,
children: [
/*Positioned(
child: PodiumGameOverWidget(
isfirst: 2,
pseudo: 'Lucas',
score: 123,
),
top: 70,
left: 30,
),
Positioned(
child: PodiumGameOverWidget(
isfirst: 1,
pseudo: 'Momo',
score: 160,
),
top: 10,
),
Positioned(
child: PodiumGameOverWidget(
isfirst: 3,
pseudo: 'popo',
score: 110,
),
top: 70,
right: 30,
)*/
],
),
child: Stack(
alignment: Alignment.topCenter,
children: [
rank.length > 1
? Positioned(
child: PodiumGameOverWidget(
isfirst: 2,
player: pseudoList[1],
score: scoreList[1],
),
top: 70,
left: 30,
)
: Container(),
rank.length > 0
? Positioned(
child: PodiumGameOverWidget(
isfirst: 1,
player: pseudoList[0],
score: scoreList[0],
),
top: 10,
)
: Container(),
rank.length > 2
? Positioned(
child: PodiumGameOverWidget(
isfirst: 3,
player: pseudoList[2],
score: scoreList[2],
),
top: 70,
right: 30,
)
: Container()
],
)),
]),
)

@ -1,5 +1,6 @@
import 'dart:ui';
import 'package:bowl_in/main.dart';
import 'package:bowl_in/widgets/profil_listpodium_widget.dart';
import 'package:bowl_in/widgets/scores_list_widget.dart';
import 'package:flutter/cupertino.dart';
@ -9,6 +10,7 @@ import 'package:google_fonts/google_fonts.dart';
import '../model/AbstractRound.dart';
import '../model/GameDetail.dart';
import '../model/Guest.dart';
import '../model/Player.dart';
class FinalScoreBoard extends StatefulWidget {
@ -255,6 +257,13 @@ class InGameCardConfig extends StatefulWidget {
}
class _InGameCardConfigState extends State<InGameCardConfig> {
late List<Player> listPlayer;
@override
void initState() {
listPlayer = [MyApp.controller.userCurrent];
super.initState();
}
@override
Widget build(BuildContext context) {
return Container(
@ -298,7 +307,7 @@ class _InGameCardConfigState extends State<InGameCardConfig> {
],
),
)),
ListUserInGame(),
ListUserInGame(listPlayer: listPlayer),
Spacer(),
Image(
image: AssetImage("assets/images/start_sentence.png"),
@ -307,7 +316,12 @@ class _InGameCardConfigState extends State<InGameCardConfig> {
Padding(
padding: EdgeInsets.fromLTRB(15, 0, 15, 15),
child: ElevatedButton(
onPressed: () {},
onPressed: () {
setState(() {
if (listPlayer.length < 10)
listPlayer.add(new Guest("guest"));
});
},
child: Text(
"+ Add a player",
style: GoogleFonts.roboto(
@ -332,7 +346,8 @@ class _InGameCardConfigState extends State<InGameCardConfig> {
}
class ListUserInGame extends StatefulWidget {
const ListUserInGame({Key? key}) : super(key: key);
final List<Player> listPlayer;
const ListUserInGame({Key? key, required this.listPlayer}) : super(key: key);
@override
State<ListUserInGame> createState() => _ListUserInGameState();
@ -347,23 +362,29 @@ class _ListUserInGameState extends State<ListUserInGame> {
crossAxisAlignment: CrossAxisAlignment.end,
children: [
ConstrainedBox(
constraints: new BoxConstraints(
maxHeight: 170,
),
child: ListView(children: [
UserInGame(),
UserInGame(),
UserInGame(),
UserInGame(),
UserInGame(),
])),
Text(
"3 player(s)",
style: GoogleFonts.roboto(
fontWeight: FontWeight.w500,
fontSize: 15,
color: CupertinoColors.black,
decoration: TextDecoration.none),
constraints: new BoxConstraints(
maxHeight: 170,
),
child: ListView.builder(
itemCount: widget.listPlayer.length,
itemBuilder: (context, index) {
return UserInGame(player: widget.listPlayer[index]);
}),
),
RichText(
text: TextSpan(
text: widget.listPlayer.length.toString(),
style: GoogleFonts.roboto(
fontWeight: FontWeight.w500,
fontSize: 15,
color: CupertinoColors.black,
decoration: TextDecoration.none),
children: const <TextSpan>[
TextSpan(
text: ' player(s)',
style: TextStyle(fontWeight: FontWeight.bold)),
],
),
)
],
));
@ -371,13 +392,15 @@ class _ListUserInGameState extends State<ListUserInGame> {
}
class UserInGame extends StatefulWidget {
const UserInGame({Key? key}) : super(key: key);
final Player player;
const UserInGame({Key? key, required this.player}) : super(key: key);
@override
State<UserInGame> createState() => _UserInGameState();
}
class _UserInGameState extends State<UserInGame> {
final userNameTextField = TextEditingController();
@override
Widget build(BuildContext context) {
return Container(
@ -399,20 +422,36 @@ class _UserInGameState extends State<UserInGame> {
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(70)),
image: DecorationImage(
image: AssetImage("assets/images/image_user_cyan.png"),
fit: BoxFit.cover),
image: AssetImage(widget.player.image), fit: BoxFit.cover),
),
),
SizedBox(
width: 10,
),
Text(
"Emre",
style: GoogleFonts.roboto(
fontSize: 18,
decoration: TextDecoration.none,
color: Color(0xff241E40)),
),
widget.player is Guest
? Material(
surfaceTintColor: Colors.transparent,
child: SizedBox(
width: 230,
child: TextField(
controller: userNameTextField,
style: const TextStyle(color: Colors.black),
decoration: InputDecoration(
border: InputBorder.none,
hintText: 'Pseudonyme',
),
cursorColor: Colors.purple,
textAlign: TextAlign.left,
),
),
)
: Text(
widget.player.name,
style: GoogleFonts.roboto(
fontSize: 18,
decoration: TextDecoration.none,
color: Color(0xff241E40)),
),
Spacer(),
],
),
@ -593,7 +632,10 @@ class SpareButton extends StatelessWidget {
final IntCallback onSonChanged;
final int valueToReturn;
const SpareButton(
{Key? key, required this.onSonChanged, required this.currentSelected, required this.valueToReturn})
{Key? key,
required this.onSonChanged,
required this.currentSelected,
required this.valueToReturn})
: super(key: key);
@override
@ -613,8 +655,9 @@ class SpareButton extends StatelessWidget {
child: Text(
"SPARE !",
style: GoogleFonts.roboto(
color:
currentSelected == valueToReturn ? Colors.pink : CupertinoColors.black,
color: currentSelected == valueToReturn
? Colors.pink
: CupertinoColors.black,
decoration: TextDecoration.none,
fontWeight: FontWeight.w900,
fontStyle: FontStyle.italic,

@ -113,8 +113,7 @@ class CardGame extends StatelessWidget {
runSpacing: 5,
children: game.players
.map((e) => ProfilPicture(
path: e.image
.toString(),
path: e.image.toString(),
))
.toList()))),
const Spacer(),
@ -147,7 +146,9 @@ class CardGame extends StatelessWidget {
showDialog(
context: context,
builder: (BuildContext context) {
return ScoreBoardModal();
return ScoreBoardModal(
gamedetail:
MyApp.controller.gameMgr.getGameById(game.id));
});
},
));

Loading…
Cancel
Save