Skip to content
Snippets Groups Projects
Commit 3965e54a authored by Benoît Harrault's avatar Benoît Harrault
Browse files

Merge pick words and image (fix missing images for words)

parent 9d3a6c6c
No related branches found
No related tags found
1 merge request!18Resolve "Merge pick random words and random images steps"
Pipeline #1039 passed
org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true
android.enableJetifier=true
app.versionName=0.0.17
app.versionCode=17
app.versionName=0.0.18
app.versionCode=18
......@@ -9,46 +9,41 @@ class GamePickWordPage extends StatelessWidget {
int _count = 4;
Future<void> startGame(BuildContext context, Data myProvider) async {
await pickWord(context, myProvider);
await pickImage(context, myProvider, myProvider.word);
await pickData(context, myProvider);
}
Future<void> pickWord(BuildContext context, Data myProvider) async {
Future<void> pickData(BuildContext context, Data myProvider) async {
List words;
List images;
RandomPickWord randomPickWord;
RandomPickImage randomPickImage;
String word;
int attempts = 0;
do {
randomPickWord = RandomPickWord();
await randomPickWord.init(_count);
if (randomPickWord.words != null) {
words = randomPickWord.words;
break;
}
attempts++;
} while (attempts < 3);
if ((words != null) && (words.length == _count)) {
myProvider.updateWord = words.take(1).toList()[0];
myProvider.updateOtherWords = words.skip(1).toList();
}
}
Future<void> pickImage(BuildContext context, Data myProvider, String word) async {
List images;
RandomPickImage randomPickImage;
int attempts = 0;
do {
word = words.take(1).toList()[0];
randomPickImage = RandomPickImage();
await randomPickImage.init(word, _count);
if (randomPickImage.images != null) {
images = randomPickImage.images;
break;
}
}
attempts++;
} while (attempts < 3);
if ((images != null) && (images.length == _count)) {
if (
((words != null) && (words.length == _count))
&&
((images != null) && (images.length == _count))
) {
myProvider.updateWord = word;
myProvider.updateOtherWords = words.skip(1).toList();
myProvider.updateImages = images;
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment