code smells clean
continuous-integration/drone/push Build is passing Details

code_smells
Lucas Delanier 2 years ago
parent bc0a33d54a
commit 9ce2225ca6

@ -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,27 +78,27 @@ class GameDetail {
_players = value; _players = value;
} }
Map<Player, int> get points => _points; Map<Player, int> get points => _points;
void addGameToUsers(){ void addGameToUsers() {
for(var p in players){ for (var p in players) {
if(p is User){ if (p is User) {
p.games.add(Game(this.id, this.time, points[p] ?? 0, true, players)); p.games.add(Game(this.id, this.time, points[p] ?? 0, true, players));
p.stat.updateStats(this, p); p.stat.updateStats(this, p);
} }
} }
} }
void computeWinner(){ void computeWinner() {
print(getRank().entries.first.key.name); print(getRank().entries.first.key.name);
this.winner = getRank().entries.first.key; this.winner = getRank().entries.first.key;
} }
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;
@ -15,21 +14,21 @@ class LastRound extends AbstractRound{
@override @override
bool computeNext(int val) { bool computeNext(int val) {
if(firstThrow==null){ if (firstThrow == null) {
firstThrow=val; firstThrow = val;
if(previousRound?.isSpare() ?? false){ if (previousRound?.isSpare() ?? false) {
previousRound?.update(val); previousRound?.update(val);
} }
return false; return false;
}else if(secondThrow==null){ } else if (secondThrow == null) {
secondThrow=val; secondThrow = val;
if ((firstThrow??0)+(secondThrow??0)<10){ if ((firstThrow ?? 0) + (secondThrow ?? 0) < 10) {
computePoints(); computePoints();
return true ; return true;
} }
return false; return false;
}else if((firstThrow??0)+(secondThrow??0)>=10){ } else if ((firstThrow ?? 0) + (secondThrow ?? 0) >= 10) {
thirdThrow=val; thirdThrow = val;
} }
computePoints(); computePoints();
return true; return true;
@ -37,36 +36,36 @@ class LastRound extends AbstractRound{
@override @override
void computePoints() { void computePoints() {
points = (firstThrow??0)+(secondThrow??0)+(thirdThrow??0); points = (firstThrow ?? 0) + (secondThrow ?? 0) + (thirdThrow ?? 0);
print("Compute points : " + points.toString()); print("Compute points : " + points.toString());
if(previousRound?.isStrike()??false){ if (previousRound?.isStrike() ?? false) {
update(points??0); update(points ?? 0);
} }
unsubscribePreviousRound(); unsubscribePreviousRound();
} }
@override @override
bool shotIsStrike(){ bool shotIsStrike() {
if(firstThrow==null){ if (firstThrow == null) {
return true; return true;
}else if(secondThrow==null){ } else if (secondThrow == null) {
return firstThrow==10; return firstThrow == 10;
}else{ } else {
return secondThrow==10; return secondThrow == 10;
} }
} }
@override @override
int getNbSpares() { int getNbSpares() {
int nb = 0; int nb = 0;
if(firstThrow!=10){ if (firstThrow != 10) {
if((firstThrow??0)+(secondThrow??0)==10){ if ((firstThrow ?? 0) + (secondThrow ?? 0) == 10) {
nb+=1; nb += 1;
} }
}else{ } else {
if((thirdThrow??0)+(secondThrow??0)==10) { if ((thirdThrow ?? 0) + (secondThrow ?? 0) == 10) {
nb+=1; nb += 1;
} }
} }
return nb; return nb;
@ -75,17 +74,17 @@ class LastRound extends AbstractRound{
@override @override
int getNbStrike() { int getNbStrike() {
int nb = 0; int nb = 0;
if(firstThrow==10){ if (firstThrow == 10) {
nb+=1; nb += 1;
if(secondThrow==10){ if (secondThrow == 10) {
nb+=1; nb += 1;
if(thirdThrow==10) { if (thirdThrow == 10) {
nb+=1; nb += 1;
} }
} }
}else{ } else {
if(thirdThrow==10) { if (thirdThrow == 10) {
nb+=1; nb += 1;
} }
} }
return nb; return nb;
@ -93,23 +92,21 @@ class LastRound extends AbstractRound{
@override @override
int getPinsKnockedDown() { int getPinsKnockedDown() {
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) {
return 10; return 10;
}else if(firstThrow==10 && secondThrow==null){ } else if (firstThrow == 10 && secondThrow == null) {
return 10; return 10;
}else if(secondThrow==null){ } else if (secondThrow == null) {
return 10 - (firstThrow??0); return 10 - (firstThrow ?? 0);
}else if(secondThrow==10){ } else if (secondThrow == 10) {
return 10; return 10;
}else{ } else {
return 10 - (secondThrow??0); return 10 - (secondThrow ?? 0);
} }
} }
} }

@ -1,25 +1,24 @@
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) {
if(firstThrow==null){ if (firstThrow == null) {
firstThrow=val; firstThrow = val;
if(previousRound?.isSpare() ?? false){ if (previousRound?.isSpare() ?? false) {
previousRound?.update(val); previousRound?.update(val);
unsubscribePreviousRound(); unsubscribePreviousRound();
} }
if(val==10){ if (val == 10) {
computePoints(); computePoints();
return true; return true;
} }
return false; return false;
}else if(firstThrow!=10 && secondThrow==null){ } else if (firstThrow != 10 && secondThrow == null) {
secondThrow=val; secondThrow = val;
} }
computePoints(); computePoints();
return true; return true;
@ -27,20 +26,20 @@ class Round extends AbstractRound{
@override @override
void computePoints() { void computePoints() {
points = (firstThrow ?? 0)+(secondThrow ?? 0); points = (firstThrow ?? 0) + (secondThrow ?? 0);
if(previousRound?.isStrike() ?? false){ if (previousRound?.isStrike() ?? false) {
previousRound?.update(points ?? 0); previousRound?.update(points ?? 0);
} }
} }
@override @override
bool shotIsStrike(){ bool shotIsStrike() {
return firstThrow==null; return firstThrow == null;
} }
@override @override
int getNbSpares() { int getNbSpares() {
if(isSpare()){ if (isSpare()) {
return 1; return 1;
} }
return 0; return 0;
@ -48,7 +47,7 @@ class Round extends AbstractRound{
@override @override
int getNbStrike() { int getNbStrike() {
if(isStrike()){ if (isStrike()) {
return 1; return 1;
} }
return 0; return 0;
@ -56,14 +55,14 @@ class Round extends AbstractRound{
@override @override
int getPinsKnockedDown() { int getPinsKnockedDown() {
return (firstThrow ?? 0)+(secondThrow ?? 0); return (firstThrow ?? 0) + (secondThrow ?? 0);
} }
@override @override
int getMaxPinsThisShot() { int getMaxPinsThisShot() {
if(firstThrow==null){ if (firstThrow == null) {
return 10; return 10;
}else{ } else {
return 10 - (firstThrow ?? 0); return 10 - (firstThrow ?? 0);
} }
} }

@ -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;
@ -74,26 +72,25 @@ class Stat {
_avgPinsPerRound = value; _avgPinsPerRound = value;
} }
void updateStats(GameDetail gd, Player p){ void updateStats(GameDetail gd, Player p) {
nbGames +=1; nbGames += 1;
if(gd.winner == p){ if (gd.winner == p) {
nbVictory +=1; nbVictory += 1;
} }
if((gd.points[p] ?? 0) > highscore){ if ((gd.points[p] ?? 0) > highscore) {
highscore = gd.points[p] ?? 0; highscore = gd.points[p] ?? 0;
} }
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 {

@ -51,15 +51,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 +74,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 +86,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 +98,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 +110,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 +122,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 +173,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();
@ -264,16 +261,14 @@ class _InGameCardConfigState extends State<InGameCardConfig> {
super.initState(); super.initState();
} }
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();
@ -443,7 +455,7 @@ class _UserInGameState extends State<UserInGame> {
children: [ children: [
ReorderableDragStartListener( ReorderableDragStartListener(
index: widget.index, index: widget.index,
child : Container( child: Container(
width: 30, width: 30,
height: 30, height: 30,
decoration: BoxDecoration( decoration: BoxDecoration(
@ -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();
} }

Loading…
Cancel
Save