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:bowl_in/config/app_router.dart';
import 'model/IManager.dart';
import 'model/StubManager/StubData.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
static IManager controller = StubData();
const MyApp({super.key});
@override
Widget build(BuildContext context) {

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

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

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

@ -24,7 +24,8 @@ class StubData extends IManager {
_initRounds();
_initGameDetails();
_initGame();
players[8].games = games;
userCurrent = players[8];
}
IUserManager get userMgr => _userMgr;
@ -42,7 +43,7 @@ class StubData extends IManager {
User(
8,
"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",
[
Achievement("5 games"),
@ -55,7 +56,7 @@ class StubData extends IManager {
User(
9,
"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",
[
Achievement("5 games"),
@ -105,8 +106,14 @@ class StubData extends IManager {
List<Game> _games = [];
void _initGame() {
games.add(Game(gameDetails[0].id, DateTime.now(), 123, true, []));
games.add(Game(gameDetails[1].id, DateTime.now(), 101, true, []));
games.add(Game(
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;

@ -1,6 +1,8 @@
library StubLib;
import '../IUserManager.dart';
import '../IAuthManager.dart';
import '../Player.dart';
import 'AuthManager.dart';
import 'StubData.dart';
import '../Player.dart';

@ -1,3 +1,4 @@
import 'package:bowl_in/main.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
@ -42,15 +43,18 @@ class _AnalysisScreenState extends State<AnalysisScreen> {
children: [
Positioned(
left: 34,
child: SpareCard(score: 12),
child: SpareCard(
score: MyApp.controller.userCurrent.stat.nbSpares),
),
Positioned(
top: 0,
child: StrikeCard(score: 12),
child: StrikeCard(
score: MyApp.controller.userCurrent.stat.nbStrikes),
),
Positioned(
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/material.dart';
import 'package:google_fonts/google_fonts.dart';
@ -152,7 +153,7 @@ class ProfileWidget extends StatelessWidget {
width: 80,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage("assets/images/image_user_orange.png"),
image: AssetImage(MyApp.controller.userCurrent.image),
fit: BoxFit.cover),
borderRadius: BorderRadius.all(Radius.circular(100)),
),
@ -163,7 +164,7 @@ class ProfileWidget extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"Lucas",
MyApp.controller.userCurrent.name,
style: GoogleFonts.roboto(
color: Colors.white,
fontStyle: FontStyle.italic,
@ -186,7 +187,9 @@ class ProfileWidget extends StatelessWidget {
fontSize: 15),
),
TextSpan(
text: "122 pts",
text: MyApp.controller.userCurrent.stat.highscore
.toString() +
" pts",
style: GoogleFonts.roboto(
color: Color(0xffF40375).withOpacity(0.75),
fontStyle: FontStyle.italic,
@ -197,7 +200,8 @@ class ProfileWidget extends StatelessWidget {
),
),
),
RichText(
MyApp.controller.userCurrent.games.length > 0
? RichText(
text: TextSpan(
text: '',
style: DefaultTextStyle.of(context).style,
@ -211,7 +215,11 @@ class ProfileWidget extends StatelessWidget {
fontSize: 15),
),
TextSpan(
text: "23",
text: DateTime.now()
.difference(MyApp
.controller.userCurrent.games.first.date)
.inDays
.toString(),
style: GoogleFonts.roboto(
color: Colors.white,
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/material.dart';
import 'package:go_router/go_router.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 '../model/Game.dart';
class CardGame extends StatelessWidget {
final Game game;
const CardGame({Key? key, required this.game}) : super(key: key);
@override
Widget build(BuildContext context) {
initializeDateFormatting();
return Padding(
padding: EdgeInsets.fromLTRB(41, 0, 41, 10),
child: GestureDetector(
@ -29,7 +38,7 @@ class CardGame extends StatelessWidget {
),
),
child: Padding(
padding: EdgeInsets.fromLTRB(130, 3, 0, 0),
padding: EdgeInsets.fromLTRB(120, 3, 3, 0),
child: ClipRect(
clipBehavior: Clip.hardEdge,
child: Opacity(
@ -37,7 +46,7 @@ class CardGame extends StatelessWidget {
child: Stack(
children: [
GradientText(
"125",
game.pointsCurrentUser.toString(),
style: GoogleFonts.karla(
fontSize: 105.0,
fontWeight: FontWeight.w900,
@ -56,7 +65,7 @@ class CardGame extends StatelessWidget {
],
),
GradientText(
"125",
game.pointsCurrentUser.toString(),
style: GoogleFonts.karla(
fontSize: 105.0,
fontWeight: FontWeight.w900,
@ -77,13 +86,17 @@ class CardGame extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
Padding(
padding: EdgeInsets.fromLTRB(5, 5, 10, 3),
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Toast(),
Toast(),
Toast(
value: DateFormat('dd MMMM', 'fr_FR')
.format(game.date)),
Toast(value: DateFormat('HH:mm').format(game.date)),
],
),
)),
Stack(
children: [
Row(
@ -97,21 +110,19 @@ class CardGame extends StatelessWidget {
child: Wrap(
spacing: 5,
runSpacing: 5,
children: [
ProfilPicture(),
ProfilPicture(),
ProfilPicture(),
ProfilPicture(),
ProfilPicture(),
ProfilPicture(),
],
),
)),
children: game.playersId
.map((item) => ProfilPicture(
path: MyApp.controller.userMgr
.getUserById(item)
.image,
))
.toList(),
))),
Spacer(),
Padding(
padding: EdgeInsets.fromLTRB(0, 30, 15, 0),
child: GradientText(
"125",
game.pointsCurrentUser.toString(),
style: TextStyle(
fontSize: 40.0,
fontWeight: FontWeight.w900,
@ -151,36 +162,27 @@ class ListCardGame extends StatelessWidget {
Widget build(BuildContext context) {
return ScrollConfiguration(
behavior: CustomScroll(),
child: ListView(
child: ListView.builder(
shrinkWrap: false,
children: <Widget>[
CardGame(),
CardGame(),
CardGame(),
CardGame(),
CardGame(),
CardGame(),
CardGame(),
CardGame(),
CardGame(),
CardGame(),
CardGame(),
CardGame(),
],
itemCount: MyApp.controller.userCurrent.games.length,
itemBuilder: (BuildContext context, int index) {
return CardGame(game: MyApp.controller.userCurrent.games[index]);
},
));
}
}
class ProfilPicture extends StatelessWidget {
final String path;
const ProfilPicture({Key? key, required this.path}) : super(key: key);
@override
Widget build(BuildContext context) {
return Container(
height: 25,
width: 25,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage("assets/images/image_user_green.png"),
fit: BoxFit.cover),
image: DecorationImage(image: AssetImage(path), fit: BoxFit.cover),
borderRadius: BorderRadius.all(Radius.circular(20)),
),
);
@ -188,6 +190,9 @@ class ProfilPicture extends StatelessWidget {
}
class Toast extends StatelessWidget {
final String value;
const Toast({Key? key, required this.value}) : super(key: key);
@override
Widget build(BuildContext context) {
return Padding(
@ -200,7 +205,7 @@ class Toast extends StatelessWidget {
child: Padding(
padding: EdgeInsets.fromLTRB(11.0, 3, 11.0, 3),
child: Text(
"12 janv.",
value,
style: TextStyle(
fontSize: 10,
color: Colors.white,

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

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

Loading…
Cancel
Save