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<GameDetail> getGamesByPlayers(List<Player> users);
List<Player> getPlayersByIdGame(int id); List<Player> getPlayersByIdGame(int id);
Map<Player, int> getRankByIdGame(int id); Map<Player, int> getRankByIdGame(int id);
addGame(GameDetail gd);
} }

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

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

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

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

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

Loading…
Cancel
Save