diff --git a/android/gradle.properties b/android/gradle.properties index 24add27a90a4accaf6a1ee28ec651d0d6bda4f8e..eeed3ef5a3d04530f5624cce71b2a57976938aed 100644 --- a/android/gradle.properties +++ b/android/gradle.properties @@ -1,5 +1,5 @@ org.gradle.jvmargs=-Xmx1536M android.useAndroidX=true android.enableJetifier=true -app.versionName=0.0.20 -app.versionCode=20 +app.versionName=0.0.21 +app.versionCode=21 diff --git a/lib/screens/game_pick_word.dart b/lib/screens/game_pick_word.dart index 237fc96e234930a97b5150823854523482539510..297404e17cee68e523026f42b13660a6b7eec0e0 100644 --- a/lib/screens/game_pick_word.dart +++ b/lib/screens/game_pick_word.dart @@ -12,6 +12,10 @@ class GamePickWordPage extends StatelessWidget { await pickData(context, myProvider); } + Future<void> nextWord(BuildContext context, Data myProvider) async { + await pickData(context, myProvider); + } + Future<void> pickData(BuildContext context, Data myProvider) async { List words; List images; @@ -48,6 +52,12 @@ class GamePickWordPage extends StatelessWidget { } } + Future<void> checkWord(BuildContext context, Data myProvider, word) async { + if (myProvider.word == word) { + nextWord(context, myProvider); + } + } + Container _buildImageContainer(String image, Color color) { String imageAsset = 'assets/placeholder.png'; if (image != null) { @@ -67,7 +77,7 @@ class GamePickWordPage extends StatelessWidget { Color color = Colors.black; if ((images == null) || (images.length != _count)) { - images = List(_count); + return Column(); } return Column( @@ -94,7 +104,7 @@ class GamePickWordPage extends StatelessWidget { ); } - Container _buildTextContainer(String word, Color color) { + Container _buildTextContainer(BuildContext context, Data myProvider, String word, Color color) { return Container( child: RaisedButton( color: Colors.green, @@ -107,14 +117,18 @@ class GamePickWordPage extends StatelessWidget { color: color, ), ), - onPressed: () { print("button text: " + word); }, + onPressed: () { checkWord(context, myProvider, word); }, ), ); } - Column _buildTextItemsBlock(String word, List otherWords) { + Column _buildTextItemsBlock(BuildContext context, Data myProvider, String word, List otherWords) { Color color = Colors.white; + if ((word == null) || (otherWords.length != (_count - 1))) { + return Column(); + } + List words = [ word, otherWords.length > 0 ? otherWords[0] : null, @@ -132,9 +146,9 @@ class GamePickWordPage extends StatelessWidget { mainAxisSize: MainAxisSize.min, mainAxisAlignment: MainAxisAlignment.center, children: [ - _buildTextContainer(words[0], color), + _buildTextContainer(context, myProvider, words[0], color), SizedBox(width: 10), - _buildTextContainer(words[1], color), + _buildTextContainer(context, myProvider, words[1], color), ], ), SizedBox(height: 10), @@ -142,15 +156,39 @@ class GamePickWordPage extends StatelessWidget { mainAxisSize: MainAxisSize.min, mainAxisAlignment: MainAxisAlignment.center, children: [ - _buildTextContainer(words[2], color), + _buildTextContainer(context, myProvider, words[2], color), SizedBox(width: 10), - _buildTextContainer(words[3], color), + _buildTextContainer(context, myProvider, words[3], color), ], ) ], ); } + Row _buildStartGameButton(BuildContext context, Data myProvider) { + return Row( + mainAxisSize: MainAxisSize.min, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Container( + child: RaisedButton( + color: Colors.orange, + padding: EdgeInsets.all(35), + child: Text( + "🔀", + style: TextStyle( + fontSize: 60, + fontWeight: FontWeight.w600, + color: Colors.black, + ), + ), + onPressed: () => startGame(context, myProvider), + ), + ) + ], + ); + } + @override Widget build(BuildContext context) { Data _myProvider = Provider.of<Data>(context); @@ -167,20 +205,10 @@ class GamePickWordPage extends StatelessWidget { mainAxisSize: MainAxisSize.max, children: <Widget>[ _buildImageItemsBlock(_myProvider.images), - SizedBox(height: 10), - FlatButton( - onPressed: () => startGame(context, _myProvider), - color: Colors.orange, - padding: EdgeInsets.all(10.0), - child: Row( - children: <Widget>[ - Icon(Icons.shuffle), - Text("Nouveau mot") - ], - ), - ), - SizedBox(height: 10), - _buildTextItemsBlock(_myProvider.word, _myProvider.otherWords), + ((_myProvider.word == null) || (_myProvider.word == '')) ? + _buildStartGameButton(context, _myProvider) : + SizedBox(height: 15), + _buildTextItemsBlock(context, _myProvider, _myProvider.word, _myProvider.otherWords), ], ), ), diff --git a/lib/screens/home.dart b/lib/screens/home.dart index 6c24f3108b6394c73939be5aa4dcf3251f6a2af0..dcda72875720e540257c6d04e12db91ac7599ee8 100644 --- a/lib/screens/home.dart +++ b/lib/screens/home.dart @@ -22,7 +22,7 @@ class Home extends StatelessWidget { color: Colors.green, padding: EdgeInsets.all(15), child: Text( - '🧑', + '🖼️ ➡️ 💬', style: Theme.of(context) .textTheme .display1 diff --git a/lib/utils/get_image_from_word.dart b/lib/utils/get_image_from_word.dart index 9465c382af9517c9062a180f4d09107919737a3a..1b41e84f7fee9159bad901984d8d4657f03d8b31 100644 --- a/lib/utils/get_image_from_word.dart +++ b/lib/utils/get_image_from_word.dart @@ -23,7 +23,7 @@ class RandomPickImage { } // Check we have enough images - if (imageList.length < count) { + if ((imageList == null) || (imageList.length < count)) { print('Not enough images in list for word "'+word+'".'); }