Commit 23f1a606 authored by m-spi's avatar m-spi

Backend integration into existing code

parent 77e2c373
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
"publisher": "No Starch Press", "publisher": "No Starch Press",
"pages": 472, "pages": 472,
"description": "JavaScript lies at the heart of almost every modern web application, from social apps to the newest browser-based games. Though simple for beginners to pick up and play with, JavaScript is a flexible, complex language that you can use to build full-scale applications.", "description": "JavaScript lies at the heart of almost every modern web application, from social apps to the newest browser-based games. Though simple for beginners to pick up and play with, JavaScript is a flexible, complex language that you can use to build full-scale applications.",
"image": "assets/images/passeur.png", "image": "assets/images/EloJS.png",
"website": "http://eloquentjavascript.net/" "website": "http://eloquentjavascript.net/"
}, },
{ {
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
"publisher": "O'Reilly Media", "publisher": "O'Reilly Media",
"pages": 254, "pages": 254,
"description": "With Learning JavaScript Design Patterns, you'll learn how to write beautiful, structured, and maintainable JavaScript by applying classical and modern design patterns to the language. If you want to keep your code efficient, more manageable, and up-to-date with the latest best practices, this book is for you.", "description": "With Learning JavaScript Design Patterns, you'll learn how to write beautiful, structured, and maintainable JavaScript by applying classical and modern design patterns to the language. If you want to keep your code efficient, more manageable, and up-to-date with the latest best practices, this book is for you.",
"image": "assets/images/1.jpg", "image": "assets/images/LearningJSDP.jpg",
"website": "http://www.addyosmani.com/resources/essentialjsdesignpatterns/book/" "website": "http://www.addyosmani.com/resources/essentialjsdesignpatterns/book/"
}, },
{ {
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
"publisher": "O'Reilly Media", "publisher": "O'Reilly Media",
"pages": 460, "pages": 460,
"description": "Like it or not, JavaScript is everywhere these days-from browser to server to mobile-and now you, too, need to learn the language or dive deeper than you have. This concise book guides you into and through JavaScript, written by a veteran programmer who once found himself in the same position.", "description": "Like it or not, JavaScript is everywhere these days-from browser to server to mobile-and now you, too, need to learn the language or dive deeper than you have. This concise book guides you into and through JavaScript, written by a veteran programmer who once found himself in the same position.",
"image": "assets/images/passeur.png", "image": "assets/images/SpeakingJS.jpeg",
"website": "http://speakingjs.com/" "website": "http://speakingjs.com/"
}, },
{ {
...@@ -45,7 +45,7 @@ ...@@ -45,7 +45,7 @@
"publisher": "O'Reilly Media", "publisher": "O'Reilly Media",
"pages": 254, "pages": 254,
"description": "Take advantage of JavaScript's power to build robust web-scale or enterprise applications that are easy to extend and maintain. By applying the design patterns outlined in this practical book, experienced JavaScript developers will learn how to write flexible and resilient code that's easier-yes, easier-to work with as your code base grows.", "description": "Take advantage of JavaScript's power to build robust web-scale or enterprise applications that are easy to extend and maintain. By applying the design patterns outlined in this practical book, experienced JavaScript developers will learn how to write flexible and resilient code that's easier-yes, easier-to work with as your code base grows.",
"image": "assets/images/1.jpg", "image": "assets/images/ProgramJSApp.jpg",
"website": "http://chimera.labs.oreilly.com/books/1234000000262/index.html" "website": "http://chimera.labs.oreilly.com/books/1234000000262/index.html"
}, },
{ {
...@@ -57,7 +57,7 @@ ...@@ -57,7 +57,7 @@
"publisher": "No Starch Press", "publisher": "No Starch Press",
"pages": 352, "pages": 352,
"description": "ECMAScript 6 represents the biggest update to the core of JavaScript in the history of the language. In Understanding ECMAScript 6, expert developer Nicholas C. Zakas provides a complete guide to the object types, syntax, and other exciting changes that ECMAScript 6 brings to JavaScript.", "description": "ECMAScript 6 represents the biggest update to the core of JavaScript in the history of the language. In Understanding ECMAScript 6, expert developer Nicholas C. Zakas provides a complete guide to the object types, syntax, and other exciting changes that ECMAScript 6 brings to JavaScript.",
"image": "assets/images/passeur.png", "image": "assets/images/UnderstandingECMAScript6.png",
"website": "https://leanpub.com/understandinges6/read" "website": "https://leanpub.com/understandinges6/read"
}, },
{ {
...@@ -69,7 +69,7 @@ ...@@ -69,7 +69,7 @@
"publisher": "O'Reilly Media", "publisher": "O'Reilly Media",
"pages": 278, "pages": 278,
"description": "No matter how much experience you have with JavaScript, odds are you don’t fully understand the language. As part of the \"You Don’t Know JS\" series, this compact guide focuses on new features available in ECMAScript 6 (ES6), the latest version of the standard upon which JavaScript is built.", "description": "No matter how much experience you have with JavaScript, odds are you don’t fully understand the language. As part of the \"You Don’t Know JS\" series, this compact guide focuses on new features available in ECMAScript 6 (ES6), the latest version of the standard upon which JavaScript is built.",
"image": "assets/images/2.jpg", "image": "assets/images/YouDontKnowJS.jpg",
"website": "https://github.com/getify/You-Dont-Know-JS/tree/master/es6%20&%20beyond" "website": "https://github.com/getify/You-Dont-Know-JS/tree/master/es6%20&%20beyond"
}, },
{ {
...@@ -81,7 +81,7 @@ ...@@ -81,7 +81,7 @@
"publisher": "O'Reilly Media", "publisher": "O'Reilly Media",
"pages": 234, "pages": 234,
"description": "This pocket guide is the perfect on-the-job companion to Git, the distributed version control system. It provides a compact, readable introduction to Git for new users, as well as a reference to common commands and procedures for those of you with Git experience.", "description": "This pocket guide is the perfect on-the-job companion to Git, the distributed version control system. It provides a compact, readable introduction to Git for new users, as well as a reference to common commands and procedures for those of you with Git experience.",
"image": "assets/images/passeur.png", "image": "assets/images/GitPocketGuide.jpg",
"website": "http://chimera.labs.oreilly.com/books/1230000000561/index.html" "website": "http://chimera.labs.oreilly.com/books/1230000000561/index.html"
}, },
{ {
...@@ -93,7 +93,7 @@ ...@@ -93,7 +93,7 @@
"publisher": "O'Reilly Media", "publisher": "O'Reilly Media",
"pages": 538, "pages": 538,
"description": "Design and build Web APIs for a broad range of clients—including browsers and mobile devices—that can adapt to change over time. This practical, hands-on guide takes you through the theory and tools you need to build evolvable HTTP services with Microsoft’s ASP.NET Web API framework. In the process, you’ll learn how design and implement a real-world Web API.", "description": "Design and build Web APIs for a broad range of clients—including browsers and mobile devices—that can adapt to change over time. This practical, hands-on guide takes you through the theory and tools you need to build evolvable HTTP services with Microsoft’s ASP.NET Web API framework. In the process, you’ll learn how design and implement a real-world Web API.",
"image": "assets/images/passeur.png", "image": "assets/images/DesigningEvolvableWebAPIswithASPNET.jpg",
"website": "http://chimera.labs.oreilly.com/books/1234000001708/index.html" "website": "http://chimera.labs.oreilly.com/books/1234000001708/index.html"
} }
] ]
......
...@@ -17,10 +17,6 @@ class TindBookState extends ChangeNotifier { ...@@ -17,10 +17,6 @@ class TindBookState extends ChangeNotifier {
notifyListeners(); notifyListeners();
} }
Map<String, dynamic> getData(int index) {
return this.data[index];
}
Map<String, dynamic> getFav(int index) { Map<String, dynamic> getFav(int index) {
return this.data[this.favorites[index]]; return this.data[this.favorites[index]];
} }
...@@ -31,7 +27,9 @@ class TindBookState extends ChangeNotifier { ...@@ -31,7 +27,9 @@ class TindBookState extends ChangeNotifier {
} }
void addIndexToFav(int index) { void addIndexToFav(int index) {
if (! favorites.contains(index)){
favorites.add(index); favorites.add(index);
notifyListeners(); notifyListeners();
} }
}
} }
...@@ -18,15 +18,22 @@ class _TindBookContentState extends State<TindBookContent> { ...@@ -18,15 +18,22 @@ class _TindBookContentState extends State<TindBookContent> {
double _deltaX = 0.0; double _deltaX = 0.0;
bool _isSwiping = false; bool _isSwiping = false;
int currentImageIndex = 0; int currentImageIndex = 0;
List<int> remainingI = [-1];
@override @override
void didChangeDependencies() { void didChangeDependencies() {
super.didChangeDependencies(); super.didChangeDependencies();
state = Provider.of<TindBookState>(context); state = Provider.of<TindBookState>(context);
if (remainingI.contains(-1)){
remainingI = List<int>.generate(state.data.length, (i) => i);
remainingI.shuffle();
currentImageIndex = remainingI.removeAt(0);
}
} }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return LayoutBuilder( return LayoutBuilder(
builder: (context, constraints) { builder: (context, constraints) {
double containerWidth = constraints.maxWidth; double containerWidth = constraints.maxWidth;
...@@ -35,15 +42,20 @@ class _TindBookContentState extends State<TindBookContent> { ...@@ -35,15 +42,20 @@ class _TindBookContentState extends State<TindBookContent> {
void handleSwipe(int direction) { void handleSwipe(int direction) {
if (direction == 1) { if (direction == 1) {
// Swipe right // Swipe right
if (currentImageIndex < state.data.length - 1) {
currentImageIndex++;
state.addIndexToFav(currentImageIndex); state.addIndexToFav(currentImageIndex);
} currentImageIndex = remainingI.removeAt(0);
} else { } else {
// Swipe left // Swipe left
if (currentImageIndex > 0) { currentImageIndex = remainingI.removeAt(0);
currentImageIndex--;
} }
// TODO : Change this maybe ?
if (remainingI.length == 0){
print("no more books");
remainingI = List<int>.generate(state.data.length, (i) => i);
remainingI.shuffle();
} }
} }
...@@ -128,7 +140,7 @@ class _TindBookContentState extends State<TindBookContent> { ...@@ -128,7 +140,7 @@ class _TindBookContentState extends State<TindBookContent> {
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Text( Text(
'Titre du livre ', state.data[currentImageIndex]['title'],
style: TextStyle( style: TextStyle(
color: Colors.white, color: Colors.white,
fontSize: 20, fontSize: 20,
...@@ -143,7 +155,7 @@ class _TindBookContentState extends State<TindBookContent> { ...@@ -143,7 +155,7 @@ class _TindBookContentState extends State<TindBookContent> {
), ),
padding: EdgeInsets.all(8), padding: EdgeInsets.all(8),
child: Text( child: Text(
'un tres bon livre qui parle de beaucoup chose , notamment mais aussi de lorem ipsum dolor sit amet a m Doctrine est pas de ', state.data[currentImageIndex]['description'],
style: TextStyle( style: TextStyle(
color: Colors.black, color: Colors.black,
fontSize: 16, fontSize: 16,
......
...@@ -24,8 +24,4 @@ dev_dependencies: ...@@ -24,8 +24,4 @@ dev_dependencies:
flutter: flutter:
uses-material-design: true uses-material-design: true
assets: assets:
- assets/images/1.jpg - assets/images/
- assets/images/2.jpg
- assets/images/3.jpg
- assets/images/4.jpg
- assets/images/passeur.png
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