Commit 21990afe authored by Benjamin LEROUX's avatar Benjamin LEROUX

Favoris commit

parent 063ab665
...@@ -23,6 +23,9 @@ class DataBase{ ...@@ -23,6 +23,9 @@ class DataBase{
static List<GridView> _gameItem = <GridView>[]; static List<GridView> _gameItem = <GridView>[];
static List<Game> games = <Game>[]; static List<Game> games = <Game>[];
static List<Object> all =<Object>[];
static List<GridView> allGrid =<GridView>[];
DataBase(){ DataBase(){
mangas.add(Manga('Arte', '', 'https://www.manga-news.com/public/images/series/arte-1-komikku.jpg', 'Kei Ookubo', '14', 'En cours', 'Seinen - Historique - Tranche de vie', '7.94', '2013-??', mangas.add(Manga('Arte', '', 'https://www.manga-news.com/public/images/series/arte-1-komikku.jpg', 'Kei Ookubo', '14', 'En cours', 'Seinen - Historique - Tranche de vie', '7.94', '2013-??',
"L'histoire commence au début du xvie siècle à Florence en Italie, centre de la culture de la Renaissance, où de grands maîtres tels que Léonard de Vinci, Michel-Ange et Raphaël se sont épanouis.Arte est la seule fille des Spalletti, une famille de nobles en déclin. Depuis son enfance, Arte s'est révélée être dotée d'un talent inhabituel pour la peinture, mais quand son père meurt, sa mère essaie de la forcer à abandonner son amour pour l'art et à trouver un jeune homme noble à se marier dès que possible afin de sauver les Spalletti de la ruine.Arte, cependant, refuse de renoncer à ses rêves, et, allant à l'encontre des opinions de son temps, elle commence à chercher à travailler pour un maître peintre, en espérant un jour devenir elle-même une peintre accomplie.Sa forte détermination finit par attirer l'attention de Léo, un jeune peintre mais bien connu, qui l'accepte enfin comme sa disciple.")); "L'histoire commence au début du xvie siècle à Florence en Italie, centre de la culture de la Renaissance, où de grands maîtres tels que Léonard de Vinci, Michel-Ange et Raphaël se sont épanouis.Arte est la seule fille des Spalletti, une famille de nobles en déclin. Depuis son enfance, Arte s'est révélée être dotée d'un talent inhabituel pour la peinture, mais quand son père meurt, sa mère essaie de la forcer à abandonner son amour pour l'art et à trouver un jeune homme noble à se marier dès que possible afin de sauver les Spalletti de la ruine.Arte, cependant, refuse de renoncer à ses rêves, et, allant à l'encontre des opinions de son temps, elle commence à chercher à travailler pour un maître peintre, en espérant un jour devenir elle-même une peintre accomplie.Sa forte détermination finit par attirer l'attention de Léo, un jeune peintre mais bien connu, qui l'accepte enfin comme sa disciple."));
...@@ -66,5 +69,31 @@ class DataBase{ ...@@ -66,5 +69,31 @@ class DataBase{
List<Game> getGameList(){ return games;} List<Game> getGameList(){ return games;}
List<GridView> getGameViews(){ return _gameItem;} List<GridView> getGameViews(){ return _gameItem;}
bool getIsSaved(Object o){
if(o is Manga) return o.isSaved;
if(o is Game) return o.isSaved;
}
bool IsNoneSaved(List<Object> list){
bool res= true;
for(int i=0; i<list.length; i++){
if(getIsSaved(list[i])==true){res=false;}
}
return res;
}
List<Object> getAll(){
all+=mangas;
all+=games;
return all;
}
List<GridView> getAllViews(){
allGrid+=_mangaItem;
allGrid+=_gameItem;
return allGrid;
}
} }
...@@ -11,11 +11,12 @@ class Game { ...@@ -11,11 +11,12 @@ class Game {
final String score; final String score;
final String releaseDate; final String releaseDate;
final String description; final String description;
bool isSaved=false;
Game(this.title, this.url, this.dev, this.editor, this.plateformes, this.genres, this.score, this.releaseDate, this.description ); Game(this.title, this.url, this.dev, this.editor, this.plateformes, this.genres, this.score, this.releaseDate, this.description );
} }
class DetailGameScreen extends StatelessWidget { class DetailGameScreen extends StatefulWidget {
final Game game; final Game game;
static const TextStyle boldStyle = TextStyle( fontWeight: FontWeight.bold,color: Colors.black); static const TextStyle boldStyle = TextStyle( fontWeight: FontWeight.bold,color: Colors.black);
static const TextStyle classicStyle = TextStyle(color: Colors.black); static const TextStyle classicStyle = TextStyle(color: Colors.black);
...@@ -25,6 +26,11 @@ class DetailGameScreen extends StatelessWidget { ...@@ -25,6 +26,11 @@ class DetailGameScreen extends StatelessWidget {
// In the constructor, require a manga // In the constructor, require a manga
DetailGameScreen({Key key, @required this.game}) : super(key: key); DetailGameScreen({Key key, @required this.game}) : super(key: key);
@override
_DetailGameScreenState createState() => _DetailGameScreenState();
}
class _DetailGameScreenState extends State<DetailGameScreen> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
...@@ -39,8 +45,8 @@ class DetailGameScreen extends StatelessWidget { ...@@ -39,8 +45,8 @@ class DetailGameScreen extends StatelessWidget {
Container( Container(
height: 25, height: 25,
child: RichText(text: TextSpan(children: <TextSpan>[ child: RichText(text: TextSpan(children: <TextSpan>[
TextSpan(text: "Titre: ", style: boldTitleStyle,), TextSpan(text: "Titre: ", style: DetailGameScreen.boldTitleStyle,),
TextSpan(text: "${game.title}", style: classicTitleStyle,), TextSpan(text: "${widget.game.title}", style: DetailGameScreen.classicTitleStyle,),
],),) ],),)
), ),
Container( Container(
...@@ -50,32 +56,49 @@ class DetailGameScreen extends StatelessWidget { ...@@ -50,32 +56,49 @@ class DetailGameScreen extends StatelessWidget {
crossAxisCount: 2, crossAxisCount: 2,
physics: new NeverScrollableScrollPhysics(), physics: new NeverScrollableScrollPhysics(),
children: <Widget>[ children: <Widget>[
Image.network(game.url), Image.network(widget.game.url),
Align(alignment: Alignment.center, child: RichText(text: TextSpan(children: <TextSpan>[ Align(alignment: Alignment.center, child: RichText(text: TextSpan(children: <TextSpan>[
TextSpan(text: "Développeurs: ", style: boldStyle,), TextSpan(text: "Développeurs: ", style: DetailGameScreen.boldStyle,),
TextSpan(text: "${game.dev}\n", style: classicStyle,), TextSpan(text: "${widget.game.dev}\n", style: DetailGameScreen.classicStyle,),
TextSpan(text: "Éditeurs: ", style: boldStyle,), TextSpan(text: "Éditeurs: ", style: DetailGameScreen.boldStyle,),
TextSpan(text: "${game.editor}\n", style: classicStyle,), TextSpan(text: "${widget.game.editor}\n", style: DetailGameScreen.classicStyle,),
TextSpan(text: "Genres: ", style: boldStyle,), TextSpan(text: "Genres: ", style: DetailGameScreen.boldStyle,),
TextSpan(text: "${game.genres}\n", style: classicStyle,), TextSpan(text: "${widget.game.genres}\n", style: DetailGameScreen.classicStyle,),
TextSpan(text: "Plateformes: ", style: boldStyle,), TextSpan(text: "Plateformes: ", style: DetailGameScreen.boldStyle,),
TextSpan(text: "${game.plateformes}\n", style: classicStyle,), TextSpan(text: "${widget.game.plateformes}\n", style: DetailGameScreen.classicStyle,),
TextSpan(text: "Date de sortie: ", style: boldStyle,), TextSpan(text: "Date de sortie: ", style: DetailGameScreen.boldStyle,),
TextSpan(text: "${game.releaseDate}\n", style: classicStyle,), TextSpan(text: "${widget.game.releaseDate}\n", style: DetailGameScreen.classicStyle,),
TextSpan(text: "Note communautaire: ", style: boldStyle,), TextSpan(text: "Note communautaire: ", style: DetailGameScreen.boldStyle,),
TextSpan(text: "${game.score}\n", style: classicStyle,), TextSpan(text: "${widget.game.score}\n", style: DetailGameScreen.classicStyle,),
],),)) ],),))
]), ]),
), ),
Container( Container(
height: 400, height: 400,
child:RichText(textAlign: TextAlign.justify,text: TextSpan(children: <TextSpan>[ child:RichText(textAlign: TextAlign.justify,text: TextSpan(children: <TextSpan>[
TextSpan(text: "En bref:\n", style: boldTitleStyle,), TextSpan(text: "En bref:\n", style: DetailGameScreen.boldTitleStyle,),
TextSpan(text: "${game.description}\n", style: classicStyle,), TextSpan(text: "${widget.game.description}\n", style: DetailGameScreen.classicStyle,),
],),) ],),)
)], )],
), ),
), ),
floatingActionButtonLocation: FloatingActionButtonLocation.endFloat,
floatingActionButton: new FloatingActionButton(
onPressed:(){
setState(() {
if (widget.game.isSaved) {
widget.game.isSaved=false;
} else {
widget.game.isSaved=true;
}
});
},
tooltip: 'Increment',
child: new Icon( widget.game.isSaved ? Icons.favorite : Icons.favorite_border,
color: widget.game.isSaved ? Colors.red : null,),
),
); );
} }
} }
\ No newline at end of file
...@@ -12,12 +12,13 @@ class Manga { ...@@ -12,12 +12,13 @@ class Manga {
final String score; final String score;
final String releaseDates; final String releaseDates;
final String description; final String description;
bool isSaved=false;
Manga(this.title, this.alternativeTitle, this.url, this.author, this.volumes, this.status, this.genres, this.score, this.releaseDates, this.description ); Manga(this.title, this.alternativeTitle, this.url, this.author, this.volumes, this.status, this.genres, this.score, this.releaseDates, this.description );
} }
class DetailMangaScreen extends StatelessWidget { class DetailMangaScreen extends StatefulWidget {
final Manga manga; Manga manga;
static const TextStyle boldStyle = TextStyle( fontWeight: FontWeight.bold,color: Colors.black); static const TextStyle boldStyle = TextStyle( fontWeight: FontWeight.bold,color: Colors.black);
static const TextStyle classicStyle = TextStyle(color: Colors.black); static const TextStyle classicStyle = TextStyle(color: Colors.black);
static const TextStyle boldTitleStyle = TextStyle( fontWeight: FontWeight.bold,color: Colors.black,fontSize: 20); static const TextStyle boldTitleStyle = TextStyle( fontWeight: FontWeight.bold,color: Colors.black,fontSize: 20);
...@@ -26,6 +27,11 @@ class DetailMangaScreen extends StatelessWidget { ...@@ -26,6 +27,11 @@ class DetailMangaScreen extends StatelessWidget {
// In the constructor, require a manga // In the constructor, require a manga
DetailMangaScreen({Key key, @required this.manga}) : super(key: key); DetailMangaScreen({Key key, @required this.manga}) : super(key: key);
@override
_DetailMangaScreenState createState() => _DetailMangaScreenState();
}
class _DetailMangaScreenState extends State<DetailMangaScreen> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
...@@ -37,20 +43,20 @@ class DetailMangaScreen extends StatelessWidget { ...@@ -37,20 +43,20 @@ class DetailMangaScreen extends StatelessWidget {
child: ListView( child: ListView(
padding: const EdgeInsets.all(8), padding: const EdgeInsets.all(8),
children: <Widget>[ children: <Widget>[
if(manga.alternativeTitle!='') Container( if(widget.manga.alternativeTitle!='') Container(
height: 50, height: 50,
child: RichText(text: TextSpan(children: <TextSpan>[ child: RichText(text: TextSpan(children: <TextSpan>[
TextSpan(text: "Titre: ", style: boldTitleStyle,), TextSpan(text: "Titre: ", style: DetailMangaScreen.boldTitleStyle,),
TextSpan(text: "${manga.title}\n", style: classicTitleStyle,), TextSpan(text: "${widget.manga.title}\n", style: DetailMangaScreen.classicTitleStyle,),
TextSpan(text: "Titre alternatif: ", style: boldTitleStyle,), TextSpan(text: "Titre alternatif: ", style: DetailMangaScreen.boldTitleStyle,),
TextSpan(text: "${manga.alternativeTitle}", style: classicTitleStyle,), TextSpan(text: "${widget.manga.alternativeTitle}", style: DetailMangaScreen.classicTitleStyle,),
],),) ],),),
)else Container( )else Container(
height: 25, height: 25,
child: RichText(text: TextSpan(children: <TextSpan>[ child: RichText(text: TextSpan(children: <TextSpan>[
TextSpan(text: "Titre: ", style: boldTitleStyle,), TextSpan(text: "Titre: ", style: DetailMangaScreen.boldTitleStyle,),
TextSpan(text: "${manga.title}", style: classicTitleStyle,), TextSpan(text: "${widget.manga.title}\n", style: DetailMangaScreen.classicTitleStyle,),
],),) ],),),
), ),
Container( Container(
height: 225, height: 225,
...@@ -59,32 +65,50 @@ class DetailMangaScreen extends StatelessWidget { ...@@ -59,32 +65,50 @@ class DetailMangaScreen extends StatelessWidget {
crossAxisCount: 2, crossAxisCount: 2,
physics: new NeverScrollableScrollPhysics(), physics: new NeverScrollableScrollPhysics(),
children: <Widget>[ children: <Widget>[
Image.network(manga.url), Image.network(widget.manga.url),
Align(alignment: Alignment.center, child: RichText(text: TextSpan(children: <TextSpan>[ Align(alignment: Alignment.center, child: RichText(text: TextSpan(children: <TextSpan>[
TextSpan(text: "Auteur: ", style: boldStyle,), TextSpan(text: "Auteur: ", style: DetailMangaScreen.boldStyle,),
TextSpan(text: "${manga.author}\n", style: classicStyle,), TextSpan(text: "${widget.manga.author}\n", style: DetailMangaScreen.classicStyle,),
TextSpan(text: "Genres: ", style: boldStyle,), TextSpan(text: "Genres: ", style: DetailMangaScreen.boldStyle,),
TextSpan(text: "${manga.genres}\n", style: classicStyle,), TextSpan(text: "${widget.manga.genres}\n", style: DetailMangaScreen.classicStyle,),
TextSpan(text: "Statut: ", style: boldStyle,), TextSpan(text: "Statut: ", style: DetailMangaScreen.boldStyle,),
TextSpan(text: "${manga.status}\n", style: classicStyle,), TextSpan(text: "${widget.manga.status}\n", style: DetailMangaScreen.classicStyle,),
TextSpan(text: "Dates: ", style: boldStyle,), TextSpan(text: "Dates: ", style: DetailMangaScreen.boldStyle,),
TextSpan(text: "${manga.releaseDates}\n", style: classicStyle,), TextSpan(text: "${widget.manga.releaseDates}\n", style: DetailMangaScreen.classicStyle,),
TextSpan(text: "Volumes: ", style: boldStyle,), TextSpan(text: "Volumes: ", style: DetailMangaScreen.boldStyle,),
TextSpan(text: "${manga.volumes}\n", style: classicStyle,), TextSpan(text: "${widget.manga.volumes}\n", style: DetailMangaScreen.classicStyle,),
TextSpan(text: "Note communautaire: ", style: boldStyle,), TextSpan(text: "Note communautaire: ", style: DetailMangaScreen.boldStyle,),
TextSpan(text: "${manga.score}\n", style: classicStyle,), TextSpan(text: "${widget.manga.score}\n", style: DetailMangaScreen.classicStyle,),
],),)) ],),))
]), ]),
), ),
Container( Container(
height: 400, height: 400,
child:RichText(textAlign: TextAlign.justify,text: TextSpan(children: <TextSpan>[ child:RichText(textAlign: TextAlign.justify,text: TextSpan(children: <TextSpan>[
TextSpan(text: "Synopsis:\n", style: boldTitleStyle,), TextSpan(text: "Synopsis:\n", style: DetailMangaScreen.boldTitleStyle,),
TextSpan(text: "${manga.description}\n", style: classicStyle,), TextSpan(text: "${widget.manga.description}\n", style: DetailMangaScreen.classicStyle,),
],),) ],),)
)], )],
), ),
), ),
floatingActionButtonLocation: FloatingActionButtonLocation.endFloat,
floatingActionButton: new FloatingActionButton(
onPressed:(){
setState(() {
if (widget.manga.isSaved) {
widget.manga.isSaved=false;
} else {
widget.manga.isSaved=true;
}
});
},
tooltip: 'Increment',
child: new Icon( widget.manga.isSaved ? Icons.favorite : Icons.favorite_border,
color: widget.manga.isSaved ? Colors.red : null,),
),
); );
} }
} }
......
...@@ -9,7 +9,7 @@ void main() => runApp(MyApp()); ...@@ -9,7 +9,7 @@ void main() => runApp(MyApp());
/// This is the main application widget. /// This is the main application widget.
class MyApp extends StatelessWidget { class MyApp extends StatelessWidget {
static const String _title = 'Flutter Code Sample'; static const String _title = 'Media';
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
...@@ -40,19 +40,7 @@ class _MyStatefulWidgetState extends State<MyStatefulWidget> { ...@@ -40,19 +40,7 @@ class _MyStatefulWidgetState extends State<MyStatefulWidget> {
static const TextStyle titleStyle2 = static const TextStyle titleStyle2 =
TextStyle(fontSize: 44, fontWeight: FontWeight.bold, color: Colors.blue); TextStyle(fontSize: 44, fontWeight: FontWeight.bold, color: Colors.blue);
/* List<Widget> _widgetOptions = <Widget>[
static List<Game> todosGame=new List.generate(
dataBase.getMangaViews().length,
(i) => Game(
dataBase.getGameNames()[i] ,
//db+getdescription
//db.getannee
//db.geten cours ?
'A description of what needs to be done for Todo'+ (i+1).toString(),
),
);
*/
static final List<Widget> _widgetOptions = <Widget>[
Text( Text(
'Accueil', 'Accueil',
style: optionStyle, style: optionStyle,
...@@ -93,10 +81,32 @@ class _MyStatefulWidgetState extends State<MyStatefulWidget> { ...@@ -93,10 +81,32 @@ class _MyStatefulWidgetState extends State<MyStatefulWidget> {
}, },
separatorBuilder: (BuildContext context, int index) => const Divider(thickness: 5 ,color: Colors.blue, indent: 10, endIndent: 10,), separatorBuilder: (BuildContext context, int index) => const Divider(thickness: 5 ,color: Colors.blue, indent: 10, endIndent: 10,),
), ),
ListView.builder(
Text( physics: ScrollPhysics(),
'Oeuvres favorites', padding: const EdgeInsets.all(8),
style: optionStyle, itemCount: dataBase.getAll().length+1,
itemBuilder: (BuildContext context, int index) {
if(index==0) return Container(
height: 60,
child: Text('Mes Favoris',style: titleStyle,textAlign: TextAlign.center),
);
else if(dataBase.getIsSaved(dataBase.getAll()[index-1])) return Container(
height: 180,
child: InkWell( onTap: () {
if(dataBase.getAll()[index-1] is Manga)
Navigator.push(context, MaterialPageRoute(builder: (context) => DetailMangaScreen(manga: dataBase.getAll()[index-1])),);
else Navigator.push(context, MaterialPageRoute (builder: (context) => DetailGameScreen(game: dataBase.getAll()[index-1])),);
},
child: Center(child: dataBase.getAllViews()[index-1]),),
);else if(index==1 && dataBase.IsNoneSaved(dataBase.getAll())) return Container(
height: 500,
child: Center(child: Text("Aucun favoris" ,style: optionStyle,)),
);
else return Container(
height: 0,
child: Text("Empty"),
);
},
), ),
Text( Text(
'Informations', 'Informations',
...@@ -151,3 +161,6 @@ class _MyStatefulWidgetState extends State<MyStatefulWidget> { ...@@ -151,3 +161,6 @@ class _MyStatefulWidgetState extends State<MyStatefulWidget> {
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment