Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
org.benoitharrault.wordguessing
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
android
org.benoitharrault.wordguessing
Commits
b52381b2
Commit
b52381b2
authored
4 years ago
by
Benoît Harrault
Browse files
Options
Downloads
Plain Diff
Merge branch '39-improve-code-to-get-random-words-and-images' into 'master'
Resolve "Improve code to get random words and images" Closes
#39
See merge request
!42
parents
1e507b03
ad7413d3
No related branches found
No related tags found
1 merge request
!42
Resolve "Improve code to get random words and images"
Pipeline
#1117
passed
4 years ago
Stage: update
Stage: build-debug
Stage: build-release
Stage: deploy
Changes
3
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
android/gradle.properties
+2
-2
2 additions, 2 deletions
android/gradle.properties
lib/screens/game_pick_word.dart
+13
-19
13 additions, 19 deletions
lib/screens/game_pick_word.dart
lib/utils/random_pick_data.dart
+45
-0
45 additions, 0 deletions
lib/utils/random_pick_data.dart
with
60 additions
and
21 deletions
android/gradle.properties
+
2
−
2
View file @
b52381b2
org.gradle.jvmargs
=
-Xmx1536M
org.gradle.jvmargs
=
-Xmx1536M
android.useAndroidX
=
true
android.useAndroidX
=
true
android.enableJetifier
=
true
android.enableJetifier
=
true
app.versionName
=
0.1.
8
app.versionName
=
0.1.
9
app.versionCode
=
3
2
app.versionCode
=
3
3
This diff is collapsed.
Click to expand it.
lib/screens/game_pick_word.dart
+
13
−
19
View file @
b52381b2
...
@@ -2,11 +2,11 @@ import 'package:flutter/material.dart';
...
@@ -2,11 +2,11 @@ import 'package:flutter/material.dart';
import
'package:provider/provider.dart'
;
import
'package:provider/provider.dart'
;
import
'../provider/data.dart'
;
import
'../provider/data.dart'
;
import
'../utils/random_pick_word.dart'
;
import
'../utils/random_pick_data.dart'
;
import
'../utils/random_pick_image.dart'
;
class
GamePickWordPage
extends
StatelessWidget
{
class
GamePickWordPage
extends
StatelessWidget
{
int
_count
=
4
;
int
_countWords
=
4
;
int
_countImages
=
4
;
Future
<
void
>
startGame
(
Data
myProvider
,
String
lang
)
async
{
Future
<
void
>
startGame
(
Data
myProvider
,
String
lang
)
async
{
await
resetGame
(
myProvider
);
await
resetGame
(
myProvider
);
...
@@ -31,32 +31,26 @@ class GamePickWordPage extends StatelessWidget {
...
@@ -31,32 +31,26 @@ class GamePickWordPage extends StatelessWidget {
Future
<
void
>
pickData
(
Data
myProvider
)
async
{
Future
<
void
>
pickData
(
Data
myProvider
)
async
{
List
words
;
List
words
;
List
images
;
List
images
;
RandomPickWord
randomPickWord
;
RandomPickData
randomPickData
;
RandomPickImage
randomPickImage
;
Map
word
;
Map
word
;
int
attempts
=
0
;
int
attempts
=
0
;
do
{
do
{
randomPick
Word
=
RandomPick
Word
();
randomPick
Data
=
RandomPick
Data
();
await
randomPick
Word
.
init
(
myProvider
.
lang
,
_count
);
await
randomPick
Data
.
init
(
myProvider
.
lang
,
_count
Words
,
_countImages
);
if
(
randomPick
Word
.
words
!=
null
)
{
if
(
randomPick
Data
.
words
!=
null
)
{
words
=
randomPick
Word
.
words
;
words
=
randomPick
Data
.
words
;
word
=
words
.
take
(
1
)
.
toList
()[
0
];
word
=
words
.
take
(
1
)
.
toList
()[
0
];
randomPickImage
=
RandomPickImage
();
images
=
word
[
'images'
];
await
randomPickImage
.
init
(
word
[
'key'
],
_count
);
if
(
randomPickImage
.
images
!=
null
)
{
images
=
randomPickImage
.
images
;
break
;
}
}
}
attempts
++
;
attempts
++
;
}
while
(
attempts
<
3
);
}
while
(
attempts
<
3
);
if
(
if
(
((
words
!=
null
)
&&
(
words
.
length
==
_count
))
((
words
!=
null
)
&&
(
words
.
length
==
_count
Words
))
&&
&&
((
images
!=
null
)
&&
(
images
.
length
==
_count
))
((
images
!=
null
)
&&
(
images
.
length
==
_count
Images
))
)
{
)
{
myProvider
.
updateWord
=
word
;
myProvider
.
updateWord
=
word
;
myProvider
.
updateOtherWords
=
words
.
skip
(
1
)
.
toList
();
myProvider
.
updateOtherWords
=
words
.
skip
(
1
)
.
toList
();
...
@@ -157,7 +151,7 @@ class GamePickWordPage extends StatelessWidget {
...
@@ -157,7 +151,7 @@ class GamePickWordPage extends StatelessWidget {
}
}
Column
_buildImageItemsBlock
(
List
images
)
{
Column
_buildImageItemsBlock
(
List
images
)
{
if
((
images
==
null
)
||
(
images
.
length
!=
_count
))
{
if
((
images
==
null
)
||
(
images
.
length
!=
_count
Images
))
{
return
Column
();
return
Column
();
}
}
...
@@ -207,7 +201,7 @@ class GamePickWordPage extends StatelessWidget {
...
@@ -207,7 +201,7 @@ class GamePickWordPage extends StatelessWidget {
Map
word
=
myProvider
.
word
;
Map
word
=
myProvider
.
word
;
List
otherWords
=
myProvider
.
otherWords
;
List
otherWords
=
myProvider
.
otherWords
;
if
((
word
==
null
)
||
(
otherWords
.
length
!=
(
_count
-
1
)))
{
if
((
word
==
null
)
||
(
otherWords
.
length
!=
(
_count
Words
-
1
)))
{
return
Column
();
return
Column
();
}
}
...
...
This diff is collapsed.
Click to expand it.
lib/utils/random_pick_data.dart
0 → 100644
+
45
−
0
View file @
b52381b2
import
'dart:async'
;
import
'dart:convert'
;
import
'package:flutter/services.dart'
;
import
'random_pick_word.dart'
;
import
'random_pick_image.dart'
;
class
RandomPickData
{
RandomPickData
();
List
_words
;
init
(
String
lang
,
int
wordsCount
,
int
imagesPerWordCount
)
async
{
_words
=
new
List
(
wordsCount
);
await
getWordsAndImages
(
lang
,
wordsCount
,
imagesPerWordCount
);
}
Future
<
void
>
getWordsAndImages
(
String
lang
,
int
wordsCount
,
int
imagesPerWordCount
)
async
{
RandomPickWord
randomPickWord
;
RandomPickImage
randomPickImage
;
List
pickedWords
;
randomPickWord
=
RandomPickWord
();
await
randomPickWord
.
init
(
lang
,
wordsCount
);
if
(
randomPickWord
.
words
!=
null
)
{
pickedWords
=
randomPickWord
.
words
;
for
(
var
i
=
0
;
i
<
pickedWords
.
length
;
i
++
)
{
Map
word
=
pickedWords
[
i
];
randomPickImage
=
RandomPickImage
();
await
randomPickImage
.
init
(
word
[
'key'
],
imagesPerWordCount
);
if
(
randomPickImage
.
images
!=
null
)
{
pickedWords
[
i
][
'images'
]
=
randomPickImage
.
images
;
}
}
}
_words
=
pickedWords
;
}
List
get
words
=
>
_words
;
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment