Correction model (UUID to int), more test and complete function for User and Game Manager
continuous-integration/drone/push Build is failing Details

pull/20/head
Emre KARTAL 2 years ago
commit 9aeca9c1de

@ -8,11 +8,15 @@ import 'package:flutter/services.dart';
import 'package:go_router/go_router.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/StubManager/StubData.dart';
void main() { void main() {
runApp(const MyApp()); runApp(const MyApp());
} }
class MyApp extends StatelessWidget { class MyApp extends StatelessWidget {
static IManager controller = StubData();
const MyApp({super.key}); const MyApp({super.key});
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {

@ -1,12 +1,12 @@
class Game { class Game {
int _id; int _id;
DateTime _time; DateTime _date;
int _pointsCurrentUser; int _pointsCurrentUser;
bool _isFinished; bool _isFinished;
List<int> _playersId = []; List<int> _playersId = [];
// Constructor // Constructor
Game(this._id, this._time, this._pointsCurrentUser, this._isFinished, Game(this._id, this._date, this._pointsCurrentUser, this._isFinished,
this._playersId); this._playersId);
// Getters and setters // Getters and setters
@ -16,10 +16,10 @@ class Game {
_id = value; _id = value;
} }
DateTime get time => _time; DateTime get date => _date;
set time(DateTime value) { set date(DateTime value) {
_time = value; _date = value;
} }
int get pointsCurrentUser => _pointsCurrentUser; int get pointsCurrentUser => _pointsCurrentUser;

@ -12,6 +12,11 @@ abstract class IManager {
// Getters and setters // Getters and setters
User get userCurrent => _userCurrent; User get userCurrent => _userCurrent;
set userCurrent(User user) {
_userCurrent = user;
}
Game get gameCurrent => _gameCurrent; Game get gameCurrent => _gameCurrent;
IUserManager get userMgr => _userMgr; IUserManager get userMgr => _userMgr;
IGameManager get gameMgr => _gameMgr; IGameManager get gameMgr => _gameMgr;

@ -1,5 +1,6 @@
import 'package:uuid/uuid.dart'; import 'package:uuid/uuid.dart';
import 'Player.dart'; import 'Player.dart';
import 'User.dart';
import 'IAuthManager.dart'; import 'IAuthManager.dart';
abstract class IUserManager { abstract class IUserManager {

@ -24,7 +24,8 @@ class StubData extends IManager {
_initRounds(); _initRounds();
_initGameDetails(); _initGameDetails();
_initGame(); _initGame();
players[8].games = games;
userCurrent = players[8];
} }
IUserManager get userMgr => _userMgr; IUserManager get userMgr => _userMgr;
@ -42,7 +43,7 @@ class StubData extends IManager {
User( User(
8, 8,
"Emre", "Emre",
"https://fastly.picsum.photos/id/1060/2000/2000.jpg?hmac=_RrU8GpkCDUlVKfgyWE-GcX-GS5TKNyUzdFbJAGXHV4", "./assets/images/image_user_cyan.png",
"emre.kartal@etu.uca.fr", "emre.kartal@etu.uca.fr",
[ [
Achievement("5 games"), Achievement("5 games"),
@ -55,7 +56,7 @@ class StubData extends IManager {
User( User(
9, 9,
"Dave", "Dave",
"https://fastly.picsum.photos/id/820/2000/2000.jpg?hmac=Ctxx2feJNZnG1S7UPx_YrWcEw89tKb7fR8i1W-VTOz4", "./assets/images/image_user_cyan.png",
"david.d_almeida@etu.uca.fr", "david.d_almeida@etu.uca.fr",
[ [
Achievement("5 games"), Achievement("5 games"),
@ -105,8 +106,14 @@ class StubData extends IManager {
List<Game> _games = []; List<Game> _games = [];
void _initGame() { void _initGame() {
games.add(Game(gameDetails[0].id, DateTime.now(), 123, true, [])); games.add(Game(
games.add(Game(gameDetails[1].id, DateTime.now(), 101, true, [])); gameDetails[0].id,
DateTime.now().subtract(Duration(days: 14)),
123,
true,
[players[0].id, players[1].id]));
games.add(Game(gameDetails[1].id, DateTime.now(), 101, true,
[players[1].id, players[0].id]));
} }
List<Game> get games => _games; List<Game> get games => _games;

@ -1,6 +1,8 @@
library StubLib; library StubLib;
import '../IUserManager.dart'; import '../IUserManager.dart';
import '../IAuthManager.dart'; import '../IAuthManager.dart';
import '../Player.dart';
import 'AuthManager.dart'; import 'AuthManager.dart';
import 'StubData.dart'; import 'StubData.dart';
import '../Player.dart'; import '../Player.dart';
@ -10,7 +12,7 @@ class UserManager extends IUserManager {
final StubData parent; final StubData parent;
// Constructor // Constructor
UserManager(this.parent):super(AuthManager(parent)); UserManager(this.parent) : super(AuthManager(parent));
// Methods // Methods
List<Player> getUsersByName(String name) { List<Player> getUsersByName(String name) {

@ -1,3 +1,4 @@
import 'package:bowl_in/main.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@ -42,15 +43,18 @@ class _AnalysisScreenState extends State<AnalysisScreen> {
children: [ children: [
Positioned( Positioned(
left: 34, left: 34,
child: SpareCard(score: 12), child: SpareCard(
score: MyApp.controller.userCurrent.stat.nbSpares),
), ),
Positioned( Positioned(
top: 0, top: 0,
child: StrikeCard(score: 12), child: StrikeCard(
score: MyApp.controller.userCurrent.stat.nbStrikes),
), ),
Positioned( Positioned(
right: 34, right: 34,
child: GameCard(score: 12), child: GameCard(
score: MyApp.controller.userCurrent.stat.nbGames),
) )
], ],
), ),

@ -1,3 +1,4 @@
import 'package:bowl_in/main.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';
@ -152,7 +153,7 @@ class ProfileWidget extends StatelessWidget {
width: 80, width: 80,
decoration: BoxDecoration( decoration: BoxDecoration(
image: DecorationImage( image: DecorationImage(
image: AssetImage("assets/images/image_user_orange.png"), image: AssetImage(MyApp.controller.userCurrent.image),
fit: BoxFit.cover), fit: BoxFit.cover),
borderRadius: BorderRadius.all(Radius.circular(100)), borderRadius: BorderRadius.all(Radius.circular(100)),
), ),
@ -163,7 +164,7 @@ class ProfileWidget extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Text( Text(
"Lucas", MyApp.controller.userCurrent.name,
style: GoogleFonts.roboto( style: GoogleFonts.roboto(
color: Colors.white, color: Colors.white,
fontStyle: FontStyle.italic, fontStyle: FontStyle.italic,
@ -186,7 +187,9 @@ class ProfileWidget extends StatelessWidget {
fontSize: 15), fontSize: 15),
), ),
TextSpan( TextSpan(
text: "122 pts", text: MyApp.controller.userCurrent.stat.highscore
.toString() +
" pts",
style: GoogleFonts.roboto( style: GoogleFonts.roboto(
color: Color(0xffF40375).withOpacity(0.75), color: Color(0xffF40375).withOpacity(0.75),
fontStyle: FontStyle.italic, fontStyle: FontStyle.italic,
@ -197,7 +200,8 @@ class ProfileWidget extends StatelessWidget {
), ),
), ),
), ),
RichText( MyApp.controller.userCurrent.games.length > 0
? RichText(
text: TextSpan( text: TextSpan(
text: '', text: '',
style: DefaultTextStyle.of(context).style, style: DefaultTextStyle.of(context).style,
@ -211,7 +215,11 @@ class ProfileWidget extends StatelessWidget {
fontSize: 15), fontSize: 15),
), ),
TextSpan( TextSpan(
text: "23", text: DateTime.now()
.difference(MyApp
.controller.userCurrent.games.first.date)
.inDays
.toString(),
style: GoogleFonts.roboto( style: GoogleFonts.roboto(
color: Colors.white, color: Colors.white,
fontStyle: FontStyle.italic, fontStyle: FontStyle.italic,
@ -228,7 +236,8 @@ class ProfileWidget extends StatelessWidget {
), ),
], ],
), ),
), )
: Container(),
], ],
), ),
) )

@ -1,13 +1,22 @@
import 'package:bowl_in/main.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 'package:intl/date_symbol_data_local.dart';
import 'package:intl/intl.dart';
import 'package:simple_gradient_text/simple_gradient_text.dart'; import 'package:simple_gradient_text/simple_gradient_text.dart';
import '../model/Game.dart';
class CardGame extends StatelessWidget { class CardGame extends StatelessWidget {
final Game game;
const CardGame({Key? key, required this.game}) : super(key: key);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
initializeDateFormatting();
return Padding( return Padding(
padding: EdgeInsets.fromLTRB(41, 0, 41, 10), padding: EdgeInsets.fromLTRB(41, 0, 41, 10),
child: GestureDetector( child: GestureDetector(
@ -29,7 +38,7 @@ class CardGame extends StatelessWidget {
), ),
), ),
child: Padding( child: Padding(
padding: EdgeInsets.fromLTRB(130, 3, 0, 0), padding: EdgeInsets.fromLTRB(120, 3, 3, 0),
child: ClipRect( child: ClipRect(
clipBehavior: Clip.hardEdge, clipBehavior: Clip.hardEdge,
child: Opacity( child: Opacity(
@ -37,7 +46,7 @@ class CardGame extends StatelessWidget {
child: Stack( child: Stack(
children: [ children: [
GradientText( GradientText(
"125", game.pointsCurrentUser.toString(),
style: GoogleFonts.karla( style: GoogleFonts.karla(
fontSize: 105.0, fontSize: 105.0,
fontWeight: FontWeight.w900, fontWeight: FontWeight.w900,
@ -56,7 +65,7 @@ class CardGame extends StatelessWidget {
], ],
), ),
GradientText( GradientText(
"125", game.pointsCurrentUser.toString(),
style: GoogleFonts.karla( style: GoogleFonts.karla(
fontSize: 105.0, fontSize: 105.0,
fontWeight: FontWeight.w900, fontWeight: FontWeight.w900,
@ -77,13 +86,17 @@ class CardGame extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Row( Padding(
padding: EdgeInsets.fromLTRB(5, 5, 10, 3),
child: Row(
mainAxisAlignment: MainAxisAlignment.end, mainAxisAlignment: MainAxisAlignment.end,
children: [ children: [
Toast(), Toast(
Toast(), value: DateFormat('dd MMMM', 'fr_FR')
.format(game.date)),
Toast(value: DateFormat('HH:mm').format(game.date)),
], ],
), )),
Stack( Stack(
children: [ children: [
Row( Row(
@ -97,21 +110,19 @@ class CardGame extends StatelessWidget {
child: Wrap( child: Wrap(
spacing: 5, spacing: 5,
runSpacing: 5, runSpacing: 5,
children: [ children: game.playersId
ProfilPicture(), .map((item) => ProfilPicture(
ProfilPicture(), path: MyApp.controller.userMgr
ProfilPicture(), .getUserById(item)
ProfilPicture(), .image,
ProfilPicture(), ))
ProfilPicture(), .toList(),
], ))),
),
)),
Spacer(), Spacer(),
Padding( Padding(
padding: EdgeInsets.fromLTRB(0, 30, 15, 0), padding: EdgeInsets.fromLTRB(0, 30, 15, 0),
child: GradientText( child: GradientText(
"125", game.pointsCurrentUser.toString(),
style: TextStyle( style: TextStyle(
fontSize: 40.0, fontSize: 40.0,
fontWeight: FontWeight.w900, fontWeight: FontWeight.w900,
@ -151,36 +162,27 @@ class ListCardGame extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return ScrollConfiguration( return ScrollConfiguration(
behavior: CustomScroll(), behavior: CustomScroll(),
child: ListView( child: ListView.builder(
shrinkWrap: false, shrinkWrap: false,
children: <Widget>[ itemCount: MyApp.controller.userCurrent.games.length,
CardGame(), itemBuilder: (BuildContext context, int index) {
CardGame(), return CardGame(game: MyApp.controller.userCurrent.games[index]);
CardGame(), },
CardGame(),
CardGame(),
CardGame(),
CardGame(),
CardGame(),
CardGame(),
CardGame(),
CardGame(),
CardGame(),
],
)); ));
} }
} }
class ProfilPicture extends StatelessWidget { class ProfilPicture extends StatelessWidget {
final String path;
const ProfilPicture({Key? key, required this.path}) : super(key: key);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Container( return Container(
height: 25, height: 25,
width: 25, width: 25,
decoration: BoxDecoration( decoration: BoxDecoration(
image: DecorationImage( image: DecorationImage(image: AssetImage(path), fit: BoxFit.cover),
image: AssetImage("assets/images/image_user_green.png"),
fit: BoxFit.cover),
borderRadius: BorderRadius.all(Radius.circular(20)), borderRadius: BorderRadius.all(Radius.circular(20)),
), ),
); );
@ -188,6 +190,9 @@ class ProfilPicture extends StatelessWidget {
} }
class Toast extends StatelessWidget { class Toast extends StatelessWidget {
final String value;
const Toast({Key? key, required this.value}) : super(key: key);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Padding( return Padding(
@ -200,7 +205,7 @@ class Toast extends StatelessWidget {
child: Padding( child: Padding(
padding: EdgeInsets.fromLTRB(11.0, 3, 11.0, 3), padding: EdgeInsets.fromLTRB(11.0, 3, 11.0, 3),
child: Text( child: Text(
"12 janv.", value,
style: TextStyle( style: TextStyle(
fontSize: 10, fontSize: 10,
color: Colors.white, color: Colors.white,

@ -192,6 +192,13 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "3.3.0" version: "3.3.0"
intl:
dependency: "direct main"
description:
name: intl
url: "https://pub.dartlang.org"
source: hosted
version: "0.18.0"
js: js:
dependency: transitive dependency: transitive
description: description:

@ -40,6 +40,8 @@ dependencies:
google_fonts: ^3.0.1 google_fonts: ^3.0.1
go_router: ^6.0.1 go_router: ^6.0.1
uuid: ^3.0.7 uuid: ^3.0.7
intl: ^0.18.0
dev_dependencies: dev_dependencies:
flutter_test: flutter_test:

Loading…
Cancel
Save