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

Merge branch '12-improve-clean-layout' into 'master'

Resolve "Improve/clean layout"

Closes #12

See merge request !13
parents fb3486bd b6522c95
No related branches found
No related tags found
1 merge request!13Resolve "Improve/clean layout"
Pipeline #1149 canceled
org.gradle.jvmargs=-Xmx1536M org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true android.useAndroidX=true
android.enableJetifier=true android.enableJetifier=true
app.versionName=1.2.4 app.versionName=1.2.5
app.versionCode=10 app.versionCode=11
...@@ -16,15 +16,15 @@ class Home extends StatelessWidget { ...@@ -16,15 +16,15 @@ class Home extends StatelessWidget {
Timer _timer; Timer _timer;
int _countdownStart = 10; int _countdownStart = 10;
Future<void> startMiniGame(BuildContext context, Data myProvider) async { Future<void> startMiniGame(Data myProvider) async {
if (myProvider.countdown == 0) { if (myProvider.countdown == 0) {
pickCategory(context, myProvider); pickCategory(myProvider);
pickLetter(context, myProvider); pickLetter(myProvider);
startTimer(context, myProvider); startTimer(myProvider);
} }
} }
Future<void> startTimer(BuildContext context, Data myProvider) async { Future<void> startTimer(Data myProvider) async {
const oneSec = const Duration(seconds: 1); const oneSec = const Duration(seconds: 1);
if (_timer != null) { if (_timer != null) {
dispose(); dispose();
...@@ -49,7 +49,7 @@ class Home extends StatelessWidget { ...@@ -49,7 +49,7 @@ class Home extends StatelessWidget {
_timer.cancel(); _timer.cancel();
} }
Future<void> pickCategory(BuildContext context, Data myProvider) async { Future<void> pickCategory(Data myProvider) async {
myProvider.searchingCategory = true; myProvider.searchingCategory = true;
RandomPickCategory randomPickCategory; RandomPickCategory randomPickCategory;
int attempts = 0; int attempts = 0;
...@@ -65,7 +65,7 @@ class Home extends StatelessWidget { ...@@ -65,7 +65,7 @@ class Home extends StatelessWidget {
} while (attempts < 3); } while (attempts < 3);
} }
Future<void> pickLetter(BuildContext context, Data myProvider) async { Future<void> pickLetter(Data myProvider) async {
myProvider.searchingLetter = true; myProvider.searchingLetter = true;
RandomPickLetter randomPickLetter; RandomPickLetter randomPickLetter;
int attempts = 0; int attempts = 0;
...@@ -81,80 +81,139 @@ class Home extends StatelessWidget { ...@@ -81,80 +81,139 @@ class Home extends StatelessWidget {
} while (attempts < 3); } while (attempts < 3);
} }
Color darken(Color baseColor, {double amount = 0.2}) {
final hsl = HSLColor.fromColor(baseColor);
final hslDark = hsl.withLightness((hsl.lightness - amount).clamp(0.0, 1.0));
return hslDark.toColor();
}
@override Container _buildPickedLetterContainer(Data myProvider, Color backgroundColor) {
Widget build(BuildContext context) { Color borderColor = darken(backgroundColor);
Data _myProvider = Provider.of<Data>(context);
return Scaffold( return Container(
appBar: AppBar(
title: Text('Petit bac'),
),
body: Center(
child: Column( child: Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[ children: [
Column( FlatButton(
mainAxisAlignment: MainAxisAlignment.center, onPressed: () => pickLetter(myProvider),
children: <Widget>[ child: Text("🔀"),
Text( ),
_myProvider.letter, myProvider.letter == '' ? null : Container(
style: Theme.of(context).textTheme.headline2, margin: EdgeInsets.all(5),
padding: EdgeInsets.all(5),
decoration: BoxDecoration(
color: backgroundColor,
borderRadius: BorderRadius.circular(4),
border: Border.all(
color: borderColor,
width: 4,
),
),
child: Text(
myProvider.letter,
style: TextStyle(
fontSize: 40,
fontWeight: FontWeight.w600,
color: Colors.black,
), ),
RaisedButton(
onPressed: () => pickLetter(context, _myProvider),
color: Colors.orange,
padding: EdgeInsets.all(10.0),
child: Row(
children: <Widget>[
Icon(Icons.shuffle),
Text("Piocher une lettre")
],
), ),
), ),
], ],
), ),
SizedBox(height: 20), );
Column( }
Container _buildPickedCategoryContainer(Data myProvider, Color backgroundColor) {
Color borderColor = darken(backgroundColor);
return Container(
child: Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[ children: [
Text(
_myProvider.category,
style: Theme.of(context).textTheme.headline3,
),
FlatButton( FlatButton(
onPressed: () => pickCategory(context, _myProvider), onPressed: () => pickCategory(myProvider),
color: Colors.orange, child: Text("🔀"),
padding: EdgeInsets.all(10.0), ),
child: Row( myProvider.category == '' ? null : Container(
children: <Widget>[ margin: EdgeInsets.all(5),
Icon(Icons.shuffle), padding: EdgeInsets.all(5),
Text("Piocher une catégorie") decoration: BoxDecoration(
], color: backgroundColor,
borderRadius: BorderRadius.circular(4),
border: Border.all(
color: borderColor,
width: 4,
),
),
child: Text(
myProvider.category,
style: TextStyle(
fontSize: 40,
fontWeight: FontWeight.w600,
color: Colors.black,
),
), ),
), ),
], ],
), ),
SizedBox(height: 40), );
Column( }
Container _buildMiniGameContainer(Data myProvider, Color backgroundColor) {
Color borderColor = darken(backgroundColor);
return Container(
margin: EdgeInsets.all(5),
padding: EdgeInsets.all(5),
decoration: BoxDecoration(
color: backgroundColor,
borderRadius: BorderRadius.circular(4),
border: Border.all(
color: borderColor,
width: 4,
),
),
child: Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[ children: [
FlatButton( FlatButton(
onPressed: (_myProvider.countdown != 0) ? null : () => startMiniGame(context, _myProvider), onPressed: (myProvider.countdown != 0) ? null : () => startMiniGame(myProvider),
color: Colors.blue,
padding: EdgeInsets.all(10.0), padding: EdgeInsets.all(10.0),
child: Row( child: Text(
mainAxisAlignment: MainAxisAlignment.center, (myProvider.countdown != 0) ? myProvider.countdown.toString() : '🎲',
children: <Widget>[ style: TextStyle(
Text( fontSize: 50,
_myProvider.countdown.toString(), fontWeight: FontWeight.w600,
style: Theme.of(context).textTheme.headline2, color: Colors.black,
), ),
],
), ),
), ),
], ],
), ),
);
}
@override
Widget build(BuildContext context) {
Data _myProvider = Provider.of<Data>(context);
return Scaffold(
appBar: AppBar(
title: Text('Petit bac'),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
_buildPickedLetterContainer(_myProvider, Colors.orange),
SizedBox(height: 20),
_buildPickedCategoryContainer(_myProvider, Colors.green),
SizedBox(height: 40),
_buildMiniGameContainer(_myProvider, Colors.blue),
], ],
), ),
), ),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment