Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
org.benoitharrault.petitbac
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.petitbac
Commits
3fb0d285
Commit
3fb0d285
authored
4 years ago
by
Benoît Harrault
Browse files
Options
Downloads
Plain Diff
Merge branch '8-add-a-mini-game-mode' into 'master'
Resolve "Add a "mini game" mode" Closes
#8
See merge request
!8
parents
48d23035
402948df
No related branches found
No related tags found
1 merge request
!8
Resolve "Add a "mini game" mode"
Pipeline
#877
passed
4 years ago
Stage: update
Stage: build-debug
Changes
2
Pipelines
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
android/gradle.properties
+2
-2
2 additions, 2 deletions
android/gradle.properties
lib/main.dart
+59
-10
59 additions, 10 deletions
lib/main.dart
with
61 additions
and
12 deletions
android/gradle.properties
+
2
−
2
View file @
3fb0d285
org.gradle.jvmargs
=
-Xmx1536M
org.gradle.jvmargs
=
-Xmx1536M
android.useAndroidX
=
true
android.useAndroidX
=
true
android.enableJetifier
=
true
android.enableJetifier
=
true
app.versionName
=
1.
1.2
app.versionName
=
1.
2.0
app.versionCode
=
5
app.versionCode
=
6
This diff is collapsed.
Click to expand it.
lib/main.dart
+
59
−
10
View file @
3fb0d285
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
import
'dart:math'
;
import
'dart:math'
;
import
'dart:async'
;
void
main
()
{
void
main
()
{
runApp
(
MyApp
());
runApp
(
MyApp
());
...
@@ -124,6 +125,8 @@ class MyHomePage extends StatefulWidget {
...
@@ -124,6 +125,8 @@ class MyHomePage extends StatefulWidget {
class
_MyHomePageState
extends
State
<
MyHomePage
>
{
class
_MyHomePageState
extends
State
<
MyHomePage
>
{
String
_randomLetter
=
''
;
String
_randomLetter
=
''
;
String
_randomCategory
=
''
;
String
_randomCategory
=
''
;
Timer
_timer
;
int
_start
=
10
;
void
_pickRandomLetter
()
{
void
_pickRandomLetter
()
{
setState
(()
{
setState
(()
{
...
@@ -137,12 +140,46 @@ class _MyHomePageState extends State<MyHomePage> {
...
@@ -137,12 +140,46 @@ class _MyHomePageState extends State<MyHomePage> {
});
});
}
}
void
_startMiniGame
()
{
_pickRandomLetter
();
_pickRandomCategory
();
startTimer
();
}
@override
@override
void
initState
()
{
void
initState
()
{
_pickRandomLetter
();
_pickRandomLetter
();
_pickRandomCategory
();
_pickRandomCategory
();
}
}
void
startTimer
()
{
const
oneSec
=
const
Duration
(
seconds:
1
);
if
(
_timer
!=
null
)
{
_timer
.
cancel
();
}
_start
=
10
;
_timer
=
new
Timer
.
periodic
(
oneSec
,
(
Timer
timer
)
{
if
(
_start
==
0
)
{
setState
(()
{
timer
.
cancel
();
});
}
else
{
setState
(()
{
_start
--
;
});
}
},
);
}
@override
void
dispose
()
{
_timer
.
cancel
();
super
.
dispose
();
}
@override
@override
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
return
Scaffold
(
return
Scaffold
(
...
@@ -156,10 +193,6 @@ class _MyHomePageState extends State<MyHomePage> {
...
@@ -156,10 +193,6 @@ class _MyHomePageState extends State<MyHomePage> {
Column
(
Column
(
mainAxisAlignment:
MainAxisAlignment
.
center
,
mainAxisAlignment:
MainAxisAlignment
.
center
,
children:
<
Widget
>[
children:
<
Widget
>[
Text
(
'Lettre aléatoire :'
,
style:
Theme
.
of
(
context
)
.
textTheme
.
headline4
,
),
Text
(
Text
(
'
$_randomLetter
'
,
'
$_randomLetter
'
,
style:
Theme
.
of
(
context
)
.
textTheme
.
headline2
,
style:
Theme
.
of
(
context
)
.
textTheme
.
headline2
,
...
@@ -177,14 +210,10 @@ class _MyHomePageState extends State<MyHomePage> {
...
@@ -177,14 +210,10 @@ class _MyHomePageState extends State<MyHomePage> {
),
),
],
],
),
),
SizedBox
(
height:
5
0
),
SizedBox
(
height:
2
0
),
Column
(
Column
(
mainAxisAlignment:
MainAxisAlignment
.
center
,
mainAxisAlignment:
MainAxisAlignment
.
center
,
children:
<
Widget
>[
children:
<
Widget
>[
Text
(
'Catégorie aléatoire :'
,
style:
Theme
.
of
(
context
)
.
textTheme
.
headline4
,
),
Text
(
Text
(
'
$_randomCategory
'
,
'
$_randomCategory
'
,
style:
Theme
.
of
(
context
)
.
textTheme
.
headline3
,
style:
Theme
.
of
(
context
)
.
textTheme
.
headline3
,
...
@@ -201,7 +230,27 @@ class _MyHomePageState extends State<MyHomePage> {
...
@@ -201,7 +230,27 @@ class _MyHomePageState extends State<MyHomePage> {
),
),
),
),
],
],
)
),
SizedBox
(
height:
40
),
Column
(
mainAxisAlignment:
MainAxisAlignment
.
center
,
children:
<
Widget
>[
FlatButton
(
onPressed:
_startMiniGame
,
color:
Colors
.
blue
,
padding:
EdgeInsets
.
all
(
10.0
),
child:
Row
(
mainAxisAlignment:
MainAxisAlignment
.
center
,
children:
<
Widget
>[
Text
(
'
$_start
'
,
style:
Theme
.
of
(
context
)
.
textTheme
.
headline2
,
),
],
),
),
],
),
],
],
),
),
),
),
...
...
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