Merge branch 'code_smells' into Arthur_Tests
continuous-integration/drone/push Build is passing Details

# Conflicts:
#	Sources/bowlin_project/test/manager_test.dart
pull/26/head
Lucas Delanier 2 years ago
commit 3a5d487041

@ -3,10 +3,4 @@
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="?android:colorBackground" /> <item android:drawable="?android:colorBackground" />
<!-- You can insert your own image assets here -->
<!-- <item>
<bitmap
android:gravity="center"
android:src="@mipmap/launch_image" />
</item> -->
</layer-list> </layer-list>

@ -3,10 +3,4 @@
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@android:color/white" /> <item android:drawable="@android:color/white" />
<!-- You can insert your own image assets here -->
<!-- <item>
<bitmap
android:gravity="center"
android:src="@mipmap/launch_image" />
</item> -->
</layer-list> </layer-list>

@ -1,17 +1,10 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<!-- Theme applied to the Android Window while the process is starting when the OS's Dark Mode setting is off -->
<style name="LaunchTheme" parent="@android:style/Theme.Light.NoTitleBar"> <style name="LaunchTheme" parent="@android:style/Theme.Light.NoTitleBar">
<!-- Show a splash screen on the activity. Automatically removed when
the Flutter engine draws its first frame -->
<item name="android:windowBackground">@drawable/launch_background</item> <item name="android:windowBackground">@drawable/launch_background</item>
</style> </style>
<!-- Theme applied to the Android Window as soon as the process has started.
This theme determines the color of the Android Window while your
Flutter UI initializes, as well as behind your Flutter UI while its
running.
This Theme is only used starting with V2 of Flutter's Android embedding. -->
<style name="NormalTheme" parent="@android:style/Theme.Light.NoTitleBar"> <style name="NormalTheme" parent="@android:style/Theme.Light.NoTitleBar">
<item name="android:windowBackground">?android:colorBackground</item> <item name="android:windowBackground">?android:colorBackground</item>
</style> </style>

@ -1,8 +1,6 @@
import 'package:bowl_in/model/AbstractRound.dart'; import 'package:bowl_in/model/AbstractRound.dart';
import 'package:bowl_in/model/GameDetail.dart'; import 'package:bowl_in/model/GameDetail.dart';
import 'package:bowl_in/model/Round.dart';
import 'package:bowl_in/views/ingame_screen2.dart'; import 'package:bowl_in/views/ingame_screen2.dart';
import 'package:bowl_in/widgets/button_new_party.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:go_router/go_router.dart'; import 'package:go_router/go_router.dart';

@ -1,11 +1,5 @@
import 'package:bowl_in/views/game_screen.dart';
import 'package:bowl_in/views/ingame_screen.dart';
import 'package:bowl_in/views/main_screen.dart';
import 'package:bowl_in/views/rank_screen.dart';
import 'package:bowl_in/views/welcome_screen.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:go_router/go_router.dart';
import 'package:bowl_in/config/app_router.dart'; import 'package:bowl_in/config/app_router.dart';
import 'model/IManager.dart'; import 'model/IManager.dart';

@ -1,8 +1,6 @@
import 'package:bowl_in/model/AbstractRound.dart'; import 'package:bowl_in/model/AbstractRound.dart';
import 'package:bowl_in/model/Game.dart'; import 'package:bowl_in/model/Game.dart';
import 'package:bowl_in/model/GamePlayer.dart';
import 'package:bowl_in/model/LastRound.dart'; import 'package:bowl_in/model/LastRound.dart';
import 'Player.dart'; import 'Player.dart';
import 'Round.dart'; import 'Round.dart';
import 'User.dart'; import 'User.dart';
@ -29,7 +27,6 @@ class GameDetail {
players.forEach((element) { players.forEach((element) {
this.rounds.add(LastRound(null, null, 0, element, 10, null)); this.rounds.add(LastRound(null, null, 0, element, 10, null));
}); });
} }
// Getters and setters // Getters and setters
@ -81,7 +78,6 @@ class GameDetail {
_players = value; _players = value;
} }
Map<Player, int> get points => _points; Map<Player, int> get points => _points;
void addGameToUsers() { void addGameToUsers() {
@ -101,7 +97,8 @@ class GameDetail {
void computeScores() { void computeScores() {
print("====COMPUTE POINTS===="); print("====COMPUTE POINTS====");
for (var element in rounds) { for (var element in rounds) {
points[element.player] = (points[element.player] ?? 0) + (element.points ?? 0); points[element.player] =
(points[element.player] ?? 0) + (element.points ?? 0);
print(element.points); print(element.points);
} }
computeWinner(); computeWinner();
@ -109,8 +106,8 @@ class GameDetail {
} }
Map<Player, int> getRank() { Map<Player, int> getRank() {
var sortedByValueMap = Map.fromEntries( var sortedByValueMap = Map.fromEntries(points.entries.toList()
points.entries.toList()..sort((e1, e2) => e2.value.compareTo(e1.value))); ..sort((e1, e2) => e2.value.compareTo(e1.value)));
return sortedByValueMap; return sortedByValueMap;
} }
} }

@ -1,9 +1,7 @@
import 'GameDetail.dart'; import 'GameDetail.dart';
import 'Player.dart'; import 'Player.dart';
import 'User.dart';
abstract class IGameManager { abstract class IGameManager {
// Methods
GameDetail getGameById(int id); GameDetail getGameById(int id);
List<GameDetail> getGamesByPlayerId(int id); List<GameDetail> getGamesByPlayerId(int id);
List<GameDetail> getGamesByPlayer(Player user); List<GameDetail> getGamesByPlayer(Player user);

@ -1,11 +1,8 @@
import 'package:bowl_in/model/GameDetail.dart'; import 'package:bowl_in/model/GameDetail.dart';
import 'package:bowl_in/model/GamePlayer.dart'; import 'package:bowl_in/model/GamePlayer.dart';
import 'User.dart'; import 'User.dart';
import 'Game.dart';
import 'IUserManager.dart'; import 'IUserManager.dart';
import 'IGameManager.dart'; import 'IGameManager.dart';
import 'Game.dart';
abstract class IManager { abstract class IManager {
late User _userCurrent; late User _userCurrent;

@ -1,11 +1,10 @@
import 'package:bowl_in/model/AbstractRound.dart'; import 'package:bowl_in/model/AbstractRound.dart';
import 'Player.dart';
class LastRound extends AbstractRound { class LastRound extends AbstractRound {
int? _thirdThrow; int? _thirdThrow;
LastRound(super.firstThrow, super.secondThrow, super.points, super.player, super.number, this._thirdThrow); LastRound(super.firstThrow, super.secondThrow, super.points, super.player,
super.number, this._thirdThrow);
int? get thirdThrow => _thirdThrow; int? get thirdThrow => _thirdThrow;
@ -96,7 +95,6 @@ class LastRound extends AbstractRound{
return (firstThrow ?? 0) + (secondThrow ?? 0) + (thirdThrow ?? 0); return (firstThrow ?? 0) + (secondThrow ?? 0) + (thirdThrow ?? 0);
} }
@override @override
int getMaxPinsThisShot() { int getMaxPinsThisShot() {
if (firstThrow == null) { if (firstThrow == null) {
@ -111,5 +109,4 @@ class LastRound extends AbstractRound{
return 10 - (secondThrow ?? 0); return 10 - (secondThrow ?? 0);
} }
} }
} }

@ -1,9 +1,8 @@
import 'package:bowl_in/model/AbstractRound.dart'; import 'package:bowl_in/model/AbstractRound.dart';
import 'GamePlayer.dart';
class Round extends AbstractRound { class Round extends AbstractRound {
Round(super.firstThrow, super.secondThrow, super.points, super.player,
Round(super.firstThrow, super.secondThrow, super.points, super.player, super.number); super.number);
@override @override
bool computeNext(int val) { bool computeNext(int val) {

@ -1,8 +1,6 @@
import 'package:bowl_in/model/GameDetail.dart'; import 'package:bowl_in/model/GameDetail.dart';
import 'package:bowl_in/model/Player.dart'; import 'package:bowl_in/model/Player.dart';
import 'User.dart';
class Stat { class Stat {
int _nbVictory; int _nbVictory;
int _nbGames; int _nbGames;
@ -86,14 +84,13 @@ class Stat {
double totalpins = 0; double totalpins = 0;
for (var r in gd.rounds) { for (var r in gd.rounds) {
if (p == r.player) { if (p == r.player) {
nbStrikes += r.getNbStrike(); nbStrikes += r.getNbStrike();
nbSpares += r.getNbSpares(); nbSpares += r.getNbSpares();
totalpins = totalpins + r.getPinsKnockedDown(); totalpins = totalpins + r.getPinsKnockedDown();
} }
} }
avgPinsPerRound = ((avgPinsPerRound * (nbGames-1)) + (totalpins/10))/nbGames; avgPinsPerRound =
((avgPinsPerRound * (nbGames - 1)) + (totalpins / 10)) / nbGames;
} }
} }

@ -1,4 +1,5 @@
library StubLib; library StubLib;
import '../IAuthManager.dart'; import '../IAuthManager.dart';
import '../User.dart'; import '../User.dart';
import 'StubData.dart'; import 'StubData.dart';
@ -12,7 +13,7 @@ class AuthManager extends IAuthManager {
bool verifiedUser(String mail, String password) { bool verifiedUser(String mail, String password) {
for (var user in parent.players) { for (var user in parent.players) {
if (user is User && user.mail == mail) { if (user is User && user.mail == mail) {
parent.userCurrent = user as User; parent.userCurrent = user;
return true; return true;
} }
} }

@ -1,11 +1,9 @@
library StubLib; library StubLib;
import '../Game.dart';
import '../IGameManager.dart'; import '../IGameManager.dart';
import '../GameDetail.dart'; import '../GameDetail.dart';
import '../Player.dart'; import '../Player.dart';
import '../User.dart'; import '../User.dart';
import '../Guest.dart';
import 'StubData.dart'; import 'StubData.dart';
class GameManager extends IGameManager { class GameManager extends IGameManager {

@ -2,7 +2,6 @@ library StubLib;
import '../Guest.dart'; import '../Guest.dart';
import '../IManager.dart'; import '../IManager.dart';
import '../Game.dart';
import '../IUserManager.dart'; import '../IUserManager.dart';
import '../IGameManager.dart'; import '../IGameManager.dart';
import '../Player.dart'; import '../Player.dart';
@ -51,15 +50,7 @@ class StubData extends IManager {
Achievement("Win a game") Achievement("Win a game")
], ],
[], [],
Stat( Stat(0, 0, 0, 0, 0, 0, 0, 0)),
0,
0,
0,
0,
0,
0,
0,
0)),
User( User(
9, 9,
"Dave", "Dave",
@ -82,15 +73,7 @@ class StubData extends IManager {
Achievement("Win a game") Achievement("Win a game")
], ],
[], [],
Stat( Stat(0, 0, 0, 0, 0, 0, 0, 0)),
0,
0,
0,
0,
0,
0,
0,
0)),
User( User(
22, 22,
"Louison", "Louison",
@ -102,15 +85,7 @@ class StubData extends IManager {
Achievement("Win a game") Achievement("Win a game")
], ],
[], [],
Stat( Stat(10, 12, 150, 7, 6, 700, 58.33, 30.2)),
10,
12,
150,
7,
6,
700,
58.33,
30.2)),
User( User(
23, 23,
"Owen", "Owen",
@ -122,15 +97,7 @@ class StubData extends IManager {
Achievement("Win a game") Achievement("Win a game")
], ],
[], [],
Stat( Stat(10, 12, 10, 7, 6, 700, 58.33, 30.2)),
10,
12,
10,
7,
6,
700,
58.33,
30.2)),
User( User(
24, 24,
"LULU", "LULU",
@ -142,15 +109,7 @@ class StubData extends IManager {
Achievement("Win a game") Achievement("Win a game")
], ],
[], [],
Stat( Stat(10, 12, 40, 7, 6, 700, 58.33, 30.2)),
10,
12,
40,
7,
6,
700,
58.33,
30.2)),
User( User(
25, 25,
"Raphael", "Raphael",
@ -162,25 +121,9 @@ class StubData extends IManager {
Achievement("Win a game") Achievement("Win a game")
], ],
[], [],
Stat( Stat(10, 12, 76, 7, 6, 700, 58.33, 30.2)),
10,
12,
76,
7,
6,
700,
58.33,
30.2)),
], ],
Stat( Stat(0, 0, 0, 0, 0, 0, 0, 0))
0,
0,
0,
0,
0,
0,
0,
0))
]; ];
List<GameDetail> _gameDetails = []; List<GameDetail> _gameDetails = [];
@ -229,8 +172,6 @@ class StubData extends IManager {
List<Round> get rounds => _rounds; List<Round> get rounds => _rounds;
List<Game> _games = [];
void _initGame() { void _initGame() {
// games.add(Game( // games.add(Game(
// gameDetails[0].id, // gameDetails[0].id,

@ -1,13 +1,10 @@
library StubLib; library StubLib;
import '../IUserManager.dart'; import '../IUserManager.dart';
import '../IAuthManager.dart';
import '../Player.dart'; import '../Player.dart';
import '../User.dart'; import '../User.dart';
import 'AuthManager.dart'; import 'AuthManager.dart';
import 'StubData.dart'; import 'StubData.dart';
import '../Player.dart';
import '../Stat.dart';
class UserManager extends IUserManager { class UserManager extends IUserManager {
final StubData parent; final StubData parent;

@ -1,17 +1,10 @@
import 'package:bowl_in/main.dart'; import 'package:bowl_in/main.dart';
import 'package:bowl_in/model/GameDetail.dart'; import 'package:bowl_in/model/GameDetail.dart';
import 'package:bowl_in/model/GamePlayer.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:google_fonts/google_fonts.dart'; import 'package:google_fonts/google_fonts.dart';
import '../model/Game.dart';
import '../model/Guest.dart';
import '../model/Player.dart'; import '../model/Player.dart';
import '../widgets/button_new_party.dart';
import '../widgets/ingame_widgets.dart'; import '../widgets/ingame_widgets.dart';
import '../widgets/scores_list_widget.dart';
class InGameScreen extends StatefulWidget { class InGameScreen extends StatefulWidget {
const InGameScreen({Key? key}) : super(key: key); const InGameScreen({Key? key}) : super(key: key);
@ -57,12 +50,7 @@ class _InGameScreenState extends State<InGameScreen> {
Spacer(), Spacer(),
ElevatedButton( ElevatedButton(
onPressed: () { onPressed: () {
GameDetail gd = GameDetail( GameDetail gd = GameDetail(-1, DateTime.now(), null, 0, false,
-1,
DateTime.now(),
null,
0,
false,
MyApp.controller.userCurrent.id, listPlayers); MyApp.controller.userCurrent.id, listPlayers);
MyApp.controller.gamePlayer.game = gd; MyApp.controller.gamePlayer.game = gd;
@ -81,8 +69,8 @@ class _InGameScreenState extends State<InGameScreen> {
width: 7, width: 7,
color: Color(0xff1ABAE0), color: Color(0xff1ABAE0),
), ),
onPrimary: Colors.transparent, foregroundColor: Colors.transparent,
primary: Colors.transparent, backgroundColor: Colors.transparent,
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(55), borderRadius: BorderRadius.circular(55),
), ),

@ -3,11 +3,7 @@ import 'package:bowl_in/model/AbstractRound.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart'; import 'package:google_fonts/google_fonts.dart';
import '../model/Round.dart';
import '../widgets/button_new_party.dart';
import '../widgets/ingame_widgets.dart'; import '../widgets/ingame_widgets.dart';
import '../widgets/scores_list_widget.dart';
class InGameScreen2 extends StatefulWidget { class InGameScreen2 extends StatefulWidget {
final AbstractRound currentRound; final AbstractRound currentRound;
@ -93,8 +89,8 @@ class _InGameScreen2State extends State<InGameScreen2> {
width: 7, width: 7,
color: Color(0xff1ABAE0), color: Color(0xff1ABAE0),
), ),
onPrimary: Colors.transparent, foregroundColor: Colors.transparent,
primary: Colors.transparent, backgroundColor: Colors.transparent,
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(55), borderRadius: BorderRadius.circular(55),
), ),

@ -66,8 +66,8 @@ class ButtonConnexion extends StatelessWidget {
width: 7, width: 7,
color: Color(0xffFF419B), color: Color(0xffFF419B),
), ),
onPrimary: Colors.white, backgroundColor: Colors.white,
primary: Color(0xffF40375), foregroundColor: Color(0xffF40375),
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(35), borderRadius: BorderRadius.circular(35),
), ),

@ -3,11 +3,7 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; 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/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 {
@ -21,8 +17,8 @@ class ButtonNewParty extends StatelessWidget {
width: 4, width: 4,
color: Color(0xffFF419B), color: Color(0xffFF419B),
), ),
onPrimary: Colors.white, backgroundColor: Colors.white,
primary: Color(0xffF40375), foregroundColor: Color(0xffF40375),
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(35), borderRadius: BorderRadius.circular(35),
), ),
@ -127,8 +123,8 @@ class NewGameModal extends StatelessWidget {
fontWeight: FontWeight.bold, fontSize: 18), fontWeight: FontWeight.bold, fontSize: 18),
), ),
style: ElevatedButton.styleFrom( style: ElevatedButton.styleFrom(
onPrimary: Colors.white, backgroundColor: Colors.white,
primary: Color(0xffF40375), foregroundColor: Color(0xffF40375),
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10), borderRadius: BorderRadius.circular(10),
), ),
@ -229,8 +225,8 @@ class ButtonJoinParty extends StatelessWidget {
width: 4, width: 4,
color: Color(0xff6B6588), color: Color(0xff6B6588),
), ),
onPrimary: Colors.white, backgroundColor: Colors.white,
primary: Color(0xff45405D), foregroundColor: Color(0xff45405D),
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(35), borderRadius: BorderRadius.circular(35),
), ),

@ -1,13 +1,9 @@
import 'dart:ui'; import 'dart:ui';
import 'package:bowl_in/main.dart'; 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'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.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 '../model/AbstractRound.dart'; import '../model/AbstractRound.dart';
import '../model/GameDetail.dart'; import '../model/GameDetail.dart';
import '../model/Guest.dart'; import '../model/Guest.dart';
@ -170,8 +166,8 @@ class _FinalScoreBoardState extends State<FinalScoreBoard> {
width: 7, width: 7,
color: Color(0xff1ABAE0), color: Color(0xff1ABAE0),
), ),
onPrimary: Colors.transparent, backgroundColor: Colors.transparent,
primary: Colors.transparent, foregroundColor: Colors.transparent,
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(55), borderRadius: BorderRadius.circular(55),
), ),
@ -252,7 +248,8 @@ class PodiumGameOverWidget extends StatelessWidget {
class InGameCardConfig extends StatefulWidget { class InGameCardConfig extends StatefulWidget {
final List<Player> listPlayer; final List<Player> listPlayer;
const InGameCardConfig({Key? key, required this.listPlayer}) : super(key: key); const InGameCardConfig({Key? key, required this.listPlayer})
: super(key: key);
@override @override
State<InGameCardConfig> createState() => _InGameCardConfigState(); State<InGameCardConfig> createState() => _InGameCardConfigState();
@ -266,14 +263,12 @@ class _InGameCardConfigState extends State<InGameCardConfig> {
void onDelete(Player p) { void onDelete(Player p) {
setState(() { setState(() {
widget.listPlayer.remove(p); widget.listPlayer.remove(p);
}); });
} }
void onReorder(int oldIndex, int newIndex) { void onReorder(int oldIndex, int newIndex) {
setState(() { setState(() {
if (oldIndex < newIndex) { if (oldIndex < newIndex) {
newIndex -= 1; newIndex -= 1;
} }
@ -325,7 +320,11 @@ class _InGameCardConfigState extends State<InGameCardConfig> {
], ],
), ),
)), )),
ListUserInGame(listPlayer: widget.listPlayer, onDelete: onDelete, onReorder: onReorder,), ListUserInGame(
listPlayer: widget.listPlayer,
onDelete: onDelete,
onReorder: onReorder,
),
Spacer(), Spacer(),
Image( Image(
image: AssetImage("assets/images/start_sentence.png"), image: AssetImage("assets/images/start_sentence.png"),
@ -350,7 +349,7 @@ class _InGameCardConfigState extends State<InGameCardConfig> {
style: ElevatedButton.styleFrom( style: ElevatedButton.styleFrom(
elevation: 5, elevation: 5,
shadowColor: Color(0xffB70056), shadowColor: Color(0xffB70056),
primary: Color(0xffF40375), foregroundColor: Color(0xffF40375),
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10), borderRadius: BorderRadius.circular(10),
), ),
@ -367,14 +366,18 @@ class ListUserInGame extends StatefulWidget {
final List<Player> listPlayer; final List<Player> listPlayer;
final Function(Player) onDelete; final Function(Player) onDelete;
final Function(int, int) onReorder; final Function(int, int) onReorder;
const ListUserInGame({Key? key, required this.listPlayer, required this.onDelete, required this.onReorder}) : super(key: key); const ListUserInGame(
{Key? key,
required this.listPlayer,
required this.onDelete,
required this.onReorder})
: 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(
@ -389,7 +392,11 @@ class _ListUserInGameState extends State<ListUserInGame> {
child: ReorderableListView.builder( child: ReorderableListView.builder(
itemCount: widget.listPlayer.length, itemCount: widget.listPlayer.length,
itemBuilder: (context, index) { itemBuilder: (context, index) {
return UserInGame(key:ValueKey(widget.listPlayer[index]) ,player: widget.listPlayer[index], onDelete: widget.onDelete, index: index); return UserInGame(
key: ValueKey(widget.listPlayer[index]),
player: widget.listPlayer[index],
onDelete: widget.onDelete,
index: index);
}, },
onReorder: widget.onReorder, onReorder: widget.onReorder,
), ),
@ -418,7 +425,12 @@ class UserInGame extends StatefulWidget {
final Player player; final Player player;
final Function(Player) onDelete; final Function(Player) onDelete;
final int index; final int index;
const UserInGame({Key? key, required this.player, required this.onDelete, required this.index}) : super(key: key); const UserInGame(
{Key? key,
required this.player,
required this.onDelete,
required this.index})
: super(key: key);
@override @override
State<UserInGame> createState() => _UserInGameState(); State<UserInGame> createState() => _UserInGameState();
@ -472,29 +484,26 @@ class _UserInGameState extends State<UserInGame> {
), ),
cursorColor: Colors.purple, cursorColor: Colors.purple,
textAlign: TextAlign.left, textAlign: TextAlign.left,
onChanged: (str)=> widget.player.name=str onChanged: (str) => widget.player.name = str,
,
), ),
), ),
) )
: SizedBox( : SizedBox(
width: 220, width: 220,
child: Text( 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))),
),
), ),
(widget.player is User && (widget.player as User).id == MyApp.controller.userCurrent.id) ? (widget.player is User &&
Icon(Icons.lock, color: Colors.amber) : (widget.player as User).id == MyApp.controller.userCurrent.id)
GestureDetector( ? Icon(Icons.lock, color: Colors.amber)
: GestureDetector(
onTap: () { onTap: () {
widget.onDelete(widget.player); widget.onDelete(widget.player);
}, },
child: Icon(Icons.close) child: Icon(Icons.close)),
),
Spacer() Spacer()
], ],
), ),
@ -518,8 +527,6 @@ class InGameCardThrow extends StatefulWidget {
} }
class _InGameCardThrowState extends State<InGameCardThrow> { class _InGameCardThrowState extends State<InGameCardThrow> {
GlobalKey<_NumberPadState> _numberPadKey = GlobalKey();
void initState() { void initState() {
super.initState(); super.initState();
} }

@ -2,9 +2,7 @@ import 'package:bowl_in/widgets/scores_list_widget.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart'; import 'package:google_fonts/google_fonts.dart';
import '../main.dart'; import '../main.dart';
import '../model/Player.dart';
import '../model/User.dart'; import '../model/User.dart';
class ProfilPodiumWidget extends StatelessWidget { class ProfilPodiumWidget extends StatelessWidget {

@ -2,7 +2,6 @@ import 'package:bowl_in/main.dart';
import 'package:bowl_in/widgets/button_new_party.dart'; import 'package:bowl_in/widgets/button_new_party.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:google_fonts/google_fonts.dart'; import 'package:google_fonts/google_fonts.dart';
import 'package:intl/date_symbol_data_local.dart'; import 'package:intl/date_symbol_data_local.dart';
import 'package:intl/intl.dart'; import 'package:intl/intl.dart';

@ -6,14 +6,14 @@ import 'package:bowl_in/model/Player.dart';
import 'package:bowl_in/model/StubManager/StubData.dart'; import 'package:bowl_in/model/StubManager/StubData.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
void testManager(IManager mgr) { void testManager(IManager mgr) {
test("Test manager " + mgr.runtimeType.toString(), () { test("Test manager " + mgr.runtimeType.toString(), () {
expect(mgr.userCurrent, mgr.userMgr.getUsersByName("Dave").first); expect(mgr.userCurrent, mgr.userMgr.getUsersByName("Dave").first);
expect(mgr.userCurrent, mgr.userMgr.getUserById(mgr.userCurrent.id)); expect(mgr.userCurrent, mgr.userMgr.getUserById(mgr.userCurrent.id));
List<Player> players = [mgr.userCurrent, Guest("Emre")]; List<Player> players = [mgr.userCurrent, Guest("Emre")];
GameDetail gd = GameDetail(mgr.gameMgr.getNextId(), DateTime.now(), null, 135, true, 5, players); GameDetail gd = GameDetail(
mgr.gameMgr.getNextId(), DateTime.now(), null, 135, true, 5, players);
mgr.gameMgr.addGame(gd); mgr.gameMgr.addGame(gd);
@ -26,8 +26,6 @@ void testManager(IManager mgr){
expect(players, mgr.gameMgr.getPlayersByIdGame(gd.id)); expect(players, mgr.gameMgr.getPlayersByIdGame(gd.id));
expect(gd, mgr.gameMgr.getGamesByPlayers(players).first); expect(gd, mgr.gameMgr.getGamesByPlayers(players).first);
}); });
} }

Loading…
Cancel
Save