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">
<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>

@ -3,10 +3,4 @@
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<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>

@ -1,17 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<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">
<!-- 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>
</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">
<item name="android:windowBackground">?android:colorBackground</item>
</style>

@ -1,8 +1,6 @@
import 'package:bowl_in/model/AbstractRound.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/widgets/button_new_party.dart';
import 'package:flutter/cupertino.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/services.dart';
import 'package:go_router/go_router.dart';
import 'package:bowl_in/config/app_router.dart';
import 'model/IManager.dart';

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

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

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

@ -1,11 +1,10 @@
import 'package:bowl_in/model/AbstractRound.dart';
import 'Player.dart';
class LastRound extends AbstractRound {
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;
@ -96,7 +95,6 @@ class LastRound extends AbstractRound{
return (firstThrow ?? 0) + (secondThrow ?? 0) + (thirdThrow ?? 0);
}
@override
int getMaxPinsThisShot() {
if (firstThrow == null) {
@ -111,5 +109,4 @@ class LastRound extends AbstractRound{
return 10 - (secondThrow ?? 0);
}
}
}

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

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

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

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

@ -51,15 +51,7 @@ class StubData extends IManager {
Achievement("Win a game")
],
[],
Stat(
0,
0,
0,
0,
0,
0,
0,
0)),
Stat(0, 0, 0, 0, 0, 0, 0, 0)),
User(
9,
"Dave",
@ -82,15 +74,7 @@ class StubData extends IManager {
Achievement("Win a game")
],
[],
Stat(
0,
0,
0,
0,
0,
0,
0,
0)),
Stat(0, 0, 0, 0, 0, 0, 0, 0)),
User(
22,
"Louison",
@ -102,15 +86,7 @@ class StubData extends IManager {
Achievement("Win a game")
],
[],
Stat(
10,
12,
150,
7,
6,
700,
58.33,
30.2)),
Stat(10, 12, 150, 7, 6, 700, 58.33, 30.2)),
User(
23,
"Owen",
@ -122,15 +98,7 @@ class StubData extends IManager {
Achievement("Win a game")
],
[],
Stat(
10,
12,
10,
7,
6,
700,
58.33,
30.2)),
Stat(10, 12, 10, 7, 6, 700, 58.33, 30.2)),
User(
24,
"LULU",
@ -142,15 +110,7 @@ class StubData extends IManager {
Achievement("Win a game")
],
[],
Stat(
10,
12,
40,
7,
6,
700,
58.33,
30.2)),
Stat(10, 12, 40, 7, 6, 700, 58.33, 30.2)),
User(
25,
"Raphael",
@ -162,25 +122,9 @@ class StubData extends IManager {
Achievement("Win a game")
],
[],
Stat(
10,
12,
76,
7,
6,
700,
58.33,
30.2)),
Stat(10, 12, 76, 7, 6, 700, 58.33, 30.2)),
],
Stat(
0,
0,
0,
0,
0,
0,
0,
0))
Stat(0, 0, 0, 0, 0, 0, 0, 0))
];
List<GameDetail> _gameDetails = [];
@ -229,8 +173,6 @@ class StubData extends IManager {
List<Round> get rounds => _rounds;
List<Game> _games = [];
void _initGame() {
// games.add(Game(
// gameDetails[0].id,

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

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

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

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

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

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

Loading…
Cancel
Save