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

Fix layout, improve gameplay

parent 69a4c3e1
No related branches found
No related tags found
1 merge request!16Resolve "Improve layout and gameplay"
Pipeline #1156 passed
org.gradle.jvmargs=-Xmx1536M org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true android.useAndroidX=true
android.enableJetifier=true android.enableJetifier=true
app.versionName=1.2.7 app.versionName=1.2.8
app.versionCode=13 app.versionCode=14
...@@ -7,7 +7,7 @@ class Data extends ChangeNotifier { ...@@ -7,7 +7,7 @@ class Data extends ChangeNotifier {
bool _searchingLetter = false; bool _searchingLetter = false;
String _category = ''; String _category = '';
String _letter = ''; String _letter = '';
int _countdown = 0; int _countdown = -1;
bool get searchingCategory => _searchingCategory; bool get searchingCategory => _searchingCategory;
......
...@@ -17,7 +17,7 @@ class Home extends StatelessWidget { ...@@ -17,7 +17,7 @@ class Home extends StatelessWidget {
int _countdownStart = 10; int _countdownStart = 10;
Future<void> startMiniGame(Data myProvider) async { Future<void> startMiniGame(Data myProvider) async {
if (myProvider.countdown == 0) { if (myProvider.countdown <= 0) {
pickCategory(myProvider); pickCategory(myProvider);
pickLetter(myProvider); pickLetter(myProvider);
startTimer(myProvider); startTimer(myProvider);
...@@ -34,7 +34,7 @@ class Home extends StatelessWidget { ...@@ -34,7 +34,7 @@ class Home extends StatelessWidget {
_timer = new Timer.periodic( _timer = new Timer.periodic(
oneSec, oneSec,
(Timer timer) { (Timer timer) {
if (_countdownStart == 0) { if (_countdownStart < 0) {
timer.cancel(); timer.cancel();
} else { } else {
_countdownStart--; _countdownStart--;
...@@ -87,7 +87,7 @@ class Home extends StatelessWidget { ...@@ -87,7 +87,7 @@ class Home extends StatelessWidget {
return hslDark.toColor(); return hslDark.toColor();
} }
Container _buildPickedLetterContainer(Data myProvider, Color backgroundColor) { Container _buildPickedLetterContainer(Data myProvider, Color backgroundColor, double borderWidth) {
Color borderColor = darken(backgroundColor); Color borderColor = darken(backgroundColor);
return Container( return Container(
...@@ -96,14 +96,14 @@ class Home extends StatelessWidget { ...@@ -96,14 +96,14 @@ class Home extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
Container( Container(
margin: EdgeInsets.all(15), margin: EdgeInsets.all(borderWidth),
padding: EdgeInsets.all(15), padding: EdgeInsets.all(borderWidth),
decoration: BoxDecoration( decoration: BoxDecoration(
color: backgroundColor, color: backgroundColor,
borderRadius: BorderRadius.circular(4), borderRadius: BorderRadius.circular(borderWidth),
border: Border.all( border: Border.all(
color: borderColor, color: borderColor,
width: 4, width: borderWidth,
), ),
), ),
child: FlatButton( child: FlatButton(
...@@ -123,8 +123,7 @@ class Home extends StatelessWidget { ...@@ -123,8 +123,7 @@ class Home extends StatelessWidget {
); );
} }
Container _buildPickedCategoryContainer(Data myProvider, Color backgroundColor, double borderWidth) {
Container _buildPickedCategoryContainer(Data myProvider, Color backgroundColor) {
Color borderColor = darken(backgroundColor); Color borderColor = darken(backgroundColor);
return Container( return Container(
...@@ -133,22 +132,23 @@ class Home extends StatelessWidget { ...@@ -133,22 +132,23 @@ class Home extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
Container( Container(
margin: EdgeInsets.all(5), margin: EdgeInsets.all(borderWidth),
padding: EdgeInsets.all(5), padding: EdgeInsets.all(borderWidth),
decoration: BoxDecoration( decoration: BoxDecoration(
color: backgroundColor, color: backgroundColor,
borderRadius: BorderRadius.circular(4), borderRadius: BorderRadius.circular(borderWidth),
border: Border.all( border: Border.all(
color: borderColor, color: borderColor,
width: 4, width: borderWidth,
), ),
), ),
child: FlatButton( child: FlatButton(
onPressed: () => pickCategory(myProvider), onPressed: () => pickCategory(myProvider),
child: Text( child: Text(
myProvider.category == '' ? "🔀" : myProvider.category, myProvider.category == '' ? "🔀" : myProvider.category,
textAlign: TextAlign.center,
style: TextStyle( style: TextStyle(
fontSize: 40, fontSize: 30,
fontWeight: FontWeight.w600, fontWeight: FontWeight.w600,
color: Colors.black, color: Colors.black,
), ),
...@@ -160,33 +160,40 @@ class Home extends StatelessWidget { ...@@ -160,33 +160,40 @@ class Home extends StatelessWidget {
); );
} }
Container _buildMiniGameContainer(Data myProvider, Color backgroundColor) { Container _buildMiniGameContainer(Data myProvider, Color backgroundColor, double borderWidth) {
Color borderColor = darken(backgroundColor); Color borderColor = darken(backgroundColor);
Color countDownColor = Colors.black;
if (myProvider.countdown == 0) {
countDownColor = Colors.red;
}
return Container( return Container(
margin: EdgeInsets.all(5), child: Column(
padding: EdgeInsets.all(5), mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
margin: EdgeInsets.all(borderWidth),
padding: EdgeInsets.all(borderWidth),
decoration: BoxDecoration( decoration: BoxDecoration(
color: backgroundColor, color: backgroundColor,
borderRadius: BorderRadius.circular(4), borderRadius: BorderRadius.circular(borderWidth),
border: Border.all( border: Border.all(
color: borderColor, color: borderColor,
width: 4, width: borderWidth,
), ),
), ),
child: Column( child: FlatButton(
mainAxisSize: MainAxisSize.min, onPressed: (myProvider.countdown >= 0) ? null : () => startMiniGame(myProvider),
mainAxisAlignment: MainAxisAlignment.center,
children: [
FlatButton(
onPressed: (myProvider.countdown != 0) ? null : () => startMiniGame(myProvider),
padding: EdgeInsets.all(10.0),
child: Text( child: Text(
(myProvider.countdown != 0) ? myProvider.countdown.toString() : '🎲', (myProvider.countdown >= 0) ? myProvider.countdown.toString() : '🎲',
textAlign: TextAlign.center,
style: TextStyle( style: TextStyle(
fontSize: 50, fontSize: 50,
fontWeight: FontWeight.w600, fontWeight: FontWeight.w600,
color: Colors.black, color: countDownColor,
),
), ),
), ),
), ),
...@@ -198,6 +205,7 @@ class Home extends StatelessWidget { ...@@ -198,6 +205,7 @@ class Home extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
Data _myProvider = Provider.of<Data>(context); Data _myProvider = Provider.of<Data>(context);
double borderWidth = 8;
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
...@@ -207,11 +215,11 @@ class Home extends StatelessWidget { ...@@ -207,11 +215,11 @@ class Home extends StatelessWidget {
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[ children: <Widget>[
_buildPickedLetterContainer(_myProvider, Colors.orange), _buildPickedLetterContainer(_myProvider, Colors.orange, borderWidth),
SizedBox(height: 20), SizedBox(height: 5),
_buildPickedCategoryContainer(_myProvider, Colors.green), _buildMiniGameContainer(_myProvider, Colors.blue, borderWidth),
SizedBox(height: 40), SizedBox(height: 5),
_buildMiniGameContainer(_myProvider, Colors.blue), _buildPickedCategoryContainer(_myProvider, Colors.green, borderWidth),
], ],
), ),
), ),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment