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

Merge branch '18-add-minimal-gameplay' into 'master'

Resolve "Add minimal gameplay"

Closes #18

See merge request !21
parents bf0748f6 7202a264
No related branches found
No related tags found
1 merge request!21Resolve "Add minimal gameplay"
Pipeline #1061 passed
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
......@@ -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),
],
),
),
......
......@@ -22,7 +22,7 @@ class Home extends StatelessWidget {
color: Colors.green,
padding: EdgeInsets.all(15),
child: Text(
'🧑',
'🖼️ ➡️ 💬',
style: Theme.of(context)
.textTheme
.display1
......
......@@ -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+'".');
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment