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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
android
org.benoitharrault.wordguessing
Commits
5ab8c6d7
Commit
5ab8c6d7
authored
4 years ago
by
Benoît Harrault
Browse files
Options
Downloads
Plain Diff
Merge branch '34-clean-some-code' into 'master'
Resolve "Clean some code" Closes
#34
See merge request
!37
parents
b08d83f8
f7685c3d
No related branches found
No related tags found
1 merge request
!37
Resolve "Clean some code"
Pipeline
#1107
passed
4 years ago
Stage: update
Stage: build-debug
Changes
3
Pipelines
3
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
+72
-40
72 additions, 40 deletions
lib/screens/game_pick_word.dart
lib/utils/random_pick_image.dart
+1
-0
1 addition, 0 deletions
lib/utils/random_pick_image.dart
with
75 additions
and
42 deletions
android/gradle.properties
+
2
−
2
View file @
5ab8c6d7
org.gradle.jvmargs
=
-Xmx1536M
org.gradle.jvmargs
=
-Xmx1536M
android.useAndroidX
=
true
android.useAndroidX
=
true
android.enableJetifier
=
true
android.enableJetifier
=
true
app.versionName
=
0.1.
5
app.versionName
=
0.1.
6
app.versionCode
=
29
app.versionCode
=
30
This diff is collapsed.
Click to expand it.
lib/screens/game_pick_word.dart
+
72
−
40
View file @
5ab8c6d7
...
@@ -3,7 +3,7 @@ import 'package:provider/provider.dart';
...
@@ -3,7 +3,7 @@ import 'package:provider/provider.dart';
import
'../provider/data.dart'
;
import
'../provider/data.dart'
;
import
'../utils/random_pick_word.dart'
;
import
'../utils/random_pick_word.dart'
;
import
'../utils/
get_image_from_word
.dart'
;
import
'../utils/
random_pick_image
.dart'
;
class
GamePickWordPage
extends
StatelessWidget
{
class
GamePickWordPage
extends
StatelessWidget
{
int
_count
=
4
;
int
_count
=
4
;
...
@@ -73,56 +73,93 @@ class GamePickWordPage extends StatelessWidget {
...
@@ -73,56 +73,93 @@ class GamePickWordPage extends StatelessWidget {
}
}
}
}
Container
_buildScoreContainer
(
Data
myProvider
)
{
Container
_buildScoreItemContainer
(
String
text
,
Color
blockColor
)
{
TextStyle
style
=
TextStyle
(
Color
backgroundColor
=
blockColor
;
fontSize:
30
,
// Darken block color to get border color
double
amount
=
0.2
;
final
hsl
=
HSLColor
.
fromColor
(
blockColor
);
final
hslDark
=
hsl
.
withLightness
((
hsl
.
lightness
-
amount
)
.
clamp
(
0.0
,
1.0
));
Color
borderColor
=
hslDark
.
toColor
();
return
Container
(
margin:
EdgeInsets
.
symmetric
(
horizontal:
15
),
padding:
EdgeInsets
.
all
(
5
),
decoration:
BoxDecoration
(
color:
backgroundColor
,
borderRadius:
BorderRadius
.
circular
(
4
),
border:
Border
.
all
(
color:
borderColor
,
width:
4
,
),
),
child:
Text
(
text
,
style:
TextStyle
(
fontSize:
25
,
fontWeight:
FontWeight
.
w600
,
fontWeight:
FontWeight
.
w600
,
color:
Colors
.
black
,
color:
Colors
.
black
,
),
),
);
);
}
Container
_buildScoreContainer
(
Data
myProvider
)
{
return
Container
(
return
Container
(
padding:
EdgeInsets
.
all
(
5
),
padding:
EdgeInsets
.
all
(
5
),
child:
Row
(
child:
Row
(
mainAxisSize:
MainAxisSize
.
min
,
mainAxisSize:
MainAxisSize
.
min
,
mainAxisAlignment:
MainAxisAlignment
.
center
,
mainAxisAlignment:
MainAxisAlignment
.
center
,
children:
[
children:
[
Text
(
_buildScoreItemContainer
(
'❓ '
+
myProvider
.
questionsCount
.
toString
(),
'❓ '
+
myProvider
.
questionsCount
.
toString
(),
style:
styl
e
,
Colors
.
whit
e
,
),
),
SizedBox
(
width:
3
0
),
SizedBox
(
width:
2
0
),
Text
(
_buildScoreItemContainer
(
'☺️ '
+
myProvider
.
goodAnswers
.
toString
(),
'☺️ '
+
myProvider
.
goodAnswers
.
toString
(),
style:
style
,
Colors
.
green
,
),
),
SizedBox
(
width:
3
0
),
SizedBox
(
width:
2
0
),
Text
(
_buildScoreItemContainer
(
'😟 '
+
myProvider
.
wrongAnswers
.
toString
(),
'😟 '
+
myProvider
.
wrongAnswers
.
toString
(),
style:
styl
e
,
Colors
.
orang
e
,
),
),
],
],
),
),
);
);
}
}
Container
_buildImageContainer
(
String
image
,
Color
color
)
{
Container
_buildImageContainer
(
String
image
)
{
String
imageAsset
=
'assets/placeholder.png'
;
String
imageAsset
=
'assets/placeholder.png'
;
if
(
image
!=
null
)
{
if
(
image
!=
null
)
{
imageAsset
=
'assets/images/'
+
image
;
imageAsset
=
'assets/images/'
+
image
;
}
}
return
Container
(
return
Container
(
padding:
EdgeInsets
.
all
(
5
),
child:
FlatButton
(
child:
FlatButton
(
color:
Colors
.
teal
,
color:
Colors
.
teal
,
child:
Image
(
image:
AssetImage
(
imageAsset
)),
child:
Container
(
margin:
EdgeInsets
.
all
(
2
),
decoration:
BoxDecoration
(
borderRadius:
BorderRadius
.
circular
(
8
),
border:
Border
.
all
(
color:
Colors
.
teal
,
width:
8
,
),
),
child:
Image
(
image:
AssetImage
(
imageAsset
),
width:
150
,
height:
150
,
fit:
BoxFit
.
fill
),
),
),
),
);
);
}
}
Column
_buildImageItemsBlock
(
List
images
)
{
Column
_buildImageItemsBlock
(
List
images
)
{
Color
color
=
Colors
.
black
;
if
((
images
==
null
)
||
(
images
.
length
!=
_count
))
{
if
((
images
==
null
)
||
(
images
.
length
!=
_count
))
{
return
Column
();
return
Column
();
}
}
...
@@ -135,23 +172,23 @@ class GamePickWordPage extends StatelessWidget {
...
@@ -135,23 +172,23 @@ class GamePickWordPage extends StatelessWidget {
mainAxisSize:
MainAxisSize
.
min
,
mainAxisSize:
MainAxisSize
.
min
,
mainAxisAlignment:
MainAxisAlignment
.
center
,
mainAxisAlignment:
MainAxisAlignment
.
center
,
children:
[
children:
[
_buildImageContainer
(
images
[
0
]
,
color
),
_buildImageContainer
(
images
[
0
]),
_buildImageContainer
(
images
[
1
]
,
color
),
_buildImageContainer
(
images
[
1
]),
],
],
),
),
Row
(
Row
(
mainAxisSize:
MainAxisSize
.
min
,
mainAxisSize:
MainAxisSize
.
min
,
mainAxisAlignment:
MainAxisAlignment
.
center
,
mainAxisAlignment:
MainAxisAlignment
.
center
,
children:
[
children:
[
_buildImageContainer
(
images
[
2
]
,
color
),
_buildImageContainer
(
images
[
2
]),
_buildImageContainer
(
images
[
3
]
,
color
),
_buildImageContainer
(
images
[
3
]),
],
],
)
)
],
],
);
);
}
}
Container
_buildTextContainer
(
Data
myProvider
,
Map
word
,
Color
color
)
{
Container
_buildTextContainer
(
Data
myProvider
,
Map
word
)
{
return
Container
(
return
Container
(
child:
RaisedButton
(
child:
RaisedButton
(
color:
Colors
.
green
,
color:
Colors
.
green
,
...
@@ -161,7 +198,7 @@ class GamePickWordPage extends StatelessWidget {
...
@@ -161,7 +198,7 @@ class GamePickWordPage extends StatelessWidget {
style:
TextStyle
(
style:
TextStyle
(
fontSize:
20
,
fontSize:
20
,
fontWeight:
FontWeight
.
w400
,
fontWeight:
FontWeight
.
w400
,
color:
c
olor
,
color:
C
olor
s
.
white
,
),
),
),
),
onPressed:
()
{
checkWord
(
myProvider
,
word
);
},
onPressed:
()
{
checkWord
(
myProvider
,
word
);
},
...
@@ -173,8 +210,6 @@ class GamePickWordPage extends StatelessWidget {
...
@@ -173,8 +210,6 @@ class GamePickWordPage extends StatelessWidget {
Map
word
=
myProvider
.
word
;
Map
word
=
myProvider
.
word
;
List
otherWords
=
myProvider
.
otherWords
;
List
otherWords
=
myProvider
.
otherWords
;
Color
color
=
Colors
.
white
;
if
((
word
==
null
)
||
(
otherWords
.
length
!=
(
_count
-
1
)))
{
if
((
word
==
null
)
||
(
otherWords
.
length
!=
(
_count
-
1
)))
{
return
Column
();
return
Column
();
}
}
...
@@ -196,56 +231,53 @@ class GamePickWordPage extends StatelessWidget {
...
@@ -196,56 +231,53 @@ class GamePickWordPage extends StatelessWidget {
mainAxisSize:
MainAxisSize
.
min
,
mainAxisSize:
MainAxisSize
.
min
,
mainAxisAlignment:
MainAxisAlignment
.
center
,
mainAxisAlignment:
MainAxisAlignment
.
center
,
children:
[
children:
[
_buildTextContainer
(
myProvider
,
words
[
0
]
,
color
),
_buildTextContainer
(
myProvider
,
words
[
0
]),
SizedBox
(
width:
10
),
SizedBox
(
width:
10
),
_buildTextContainer
(
myProvider
,
words
[
1
]
,
color
),
_buildTextContainer
(
myProvider
,
words
[
1
]),
],
],
),
),
SizedBox
(
height:
10
),
SizedBox
(
height:
5
),
Row
(
Row
(
mainAxisSize:
MainAxisSize
.
min
,
mainAxisSize:
MainAxisSize
.
min
,
mainAxisAlignment:
MainAxisAlignment
.
center
,
mainAxisAlignment:
MainAxisAlignment
.
center
,
children:
[
children:
[
_buildTextContainer
(
myProvider
,
words
[
2
]
,
color
),
_buildTextContainer
(
myProvider
,
words
[
2
]),
SizedBox
(
width:
10
),
SizedBox
(
width:
10
),
_buildTextContainer
(
myProvider
,
words
[
3
]
,
color
),
_buildTextContainer
(
myProvider
,
words
[
3
]),
],
],
)
)
],
],
);
);
}
}
Column
_buildStartGameButton
(
Data
myProvider
)
{
Column
_buildStartGameBlock
(
Data
myProvider
)
{
return
Column
(
return
Column
(
mainAxisSize:
MainAxisSize
.
min
,
mainAxisSize:
MainAxisSize
.
min
,
mainAxisAlignment:
MainAxisAlignment
.
center
,
mainAxisAlignment:
MainAxisAlignment
.
center
,
children:
[
children:
[
Container
(
Container
(
child:
RaisedButton
(
child:
RaisedButton
(
color:
Colors
.
green
,
color:
Colors
.
teal
,
padding:
EdgeInsets
.
all
(
35
),
padding:
EdgeInsets
.
all
(
35
),
child:
Text
(
child:
Text
(
"🇫🇷"
,
"🇫🇷"
,
style:
TextStyle
(
style:
TextStyle
(
fontSize:
60
,
fontSize:
60
,
fontWeight:
FontWeight
.
w600
,
color:
Colors
.
black
,
color:
Colors
.
black
,
),
),
),
),
onPressed:
()
=
>
startGame
(
myProvider
,
'fr'
),
onPressed:
()
=
>
startGame
(
myProvider
,
'fr'
),
),
),
),
),
SizedBox
(
height:
20
),
SizedBox
(
height:
15
),
Container
(
Container
(
child:
RaisedButton
(
child:
RaisedButton
(
color:
Colors
.
green
,
color:
Colors
.
teal
,
padding:
EdgeInsets
.
all
(
35
),
padding:
EdgeInsets
.
all
(
35
),
child:
Text
(
child:
Text
(
"🇬🇧"
,
"🇬🇧"
,
style:
TextStyle
(
style:
TextStyle
(
fontSize:
60
,
fontSize:
60
,
fontWeight:
FontWeight
.
w600
,
color:
Colors
.
black
,
color:
Colors
.
black
,
),
),
),
),
...
@@ -280,7 +312,7 @@ class GamePickWordPage extends StatelessWidget {
...
@@ -280,7 +312,7 @@ class GamePickWordPage extends StatelessWidget {
_buildImageItemsBlock
(
_myProvider
.
images
),
_buildImageItemsBlock
(
_myProvider
.
images
),
SizedBox
(
height:
2
),
SizedBox
(
height:
2
),
((
_myProvider
.
word
==
null
)
||
(
_myProvider
.
word
[
'key'
]
==
''
))
?
((
_myProvider
.
word
==
null
)
||
(
_myProvider
.
word
[
'key'
]
==
''
))
?
_buildStartGameB
utton
(
_myProvider
)
:
_buildStartGameB
lock
(
_myProvider
)
:
_buildScoreContainer
(
_myProvider
),
_buildScoreContainer
(
_myProvider
),
SizedBox
(
height:
2
),
SizedBox
(
height:
2
),
_buildTextItemsBlock
(
_myProvider
),
_buildTextItemsBlock
(
_myProvider
),
...
...
This diff is collapsed.
Click to expand it.
lib/utils/
get_image_from_word
.dart
→
lib/utils/
random_pick_image
.dart
+
1
−
0
View file @
5ab8c6d7
...
@@ -8,6 +8,7 @@ class RandomPickImage {
...
@@ -8,6 +8,7 @@ class RandomPickImage {
List
_images
;
List
_images
;
init
(
String
word
,
int
count
)
async
{
init
(
String
word
,
int
count
)
async
{
_images
=
new
List
(
count
);
await
imageFromLocalFile
(
word
,
count
);
await
imageFromLocalFile
(
word
,
count
);
}
}
...
...
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