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

Add restart game button in title bar

parent 136a318f
No related branches found
No related tags found
1 merge request!3Resolve "Add a restart game button"
Pipeline #1954 passed
org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true
android.enableJetifier=true
app.versionName=0.0.2
app.versionCode=2
app.versionName=0.0.3
app.versionCode=3
assets/icons/button_restart.png

8.43 KiB | W: | H:

assets/icons/button_restart.png

8.27 KiB | W: | H:

assets/icons/button_restart.png
assets/icons/button_restart.png
assets/icons/button_restart.png
assets/icons/button_restart.png
  • 2-up
  • Swipe
  • Onion skin
Add a restart game button in title bar, improve layout
Ajout d'un bouton pour recommencer la partie dans la barre de titre, amélioration de l'agencement
<?xml version="1.0" encoding="UTF-8"?>
<svg enable-background="new 0 0 100 100" version="1.1" viewBox="0 0 93.665 93.676" xml:space="preserve" xmlns="http://www.w3.org/2000/svg"><rect x=".44662" y=".89101" width="92.772" height="91.894" ry="11.689" fill="#49a1ee" stroke="#fff" stroke-width=".238"/><switch transform="matrix(.69484 0 0 .69484 12.09 12.096)" fill="#fefeff" stroke="#105ca1" stroke-width="5.7567"><foreignObject width="1" height="1" requiredExtensions="http://ns.adobe.com/AdobeIllustrator/10.0/"/><g fill="#fefeff" stroke="#105ca1" stroke-width="5.7567"><g fill="#fefeff" stroke="#105ca1" stroke-width="5.7567"><path d="m43.3 91.8-18.3 5.5c-2.5 0.7-5.1-0.7-5.9-3.1-0.7-2.5 0.7-5.1 3.1-5.9l6.8-2c-12.4-7.3-20.8-20.8-20.8-36.3 0-17.3 10.6-32.2 25.6-38.6 3.1-1.3 6.6 1 6.6 4.3 0 1.9-1.1 3.6-2.8 4.3-11.8 5-20 16.5-20 30 0 12.2 6.8 22.9 16.8 28.4l-2.4-8.1c-0.7-2.5 0.7-5.1 3.1-5.9 2.5-0.7 5.1 0.7 5.9 3.1l5.5 18.3c0.7 2.6-0.7 5.2-3.2 6z"/><path d="m77.7 11.7-6.8 2c12.5 7.3 20.9 20.8 20.9 36.3 0 17.3-10.6 32.2-25.6 38.6-3.1 1.3-6.6-1-6.6-4.3 0-1.9 1.1-3.6 2.8-4.3 11.8-5 20-16.5 20-30 0-12.2-6.8-22.9-16.8-28.4l2.4 8.1c0.7 2.5-0.7 5.1-3.1 5.9-2.5 0.7-5.1-0.7-5.9-3.1l-5.5-18.3c-0.7-2.5 0.7-5.1 3.2-5.9l18.3-5.6c2.5-0.7 5.1 0.7 5.9 3.1 0.7 2.5-0.7 5.2-3.2 5.9z"/></g></g></switch></svg>
<svg enable-background="new 0 0 100 100" version="1.1" viewBox="0 0 93.665 93.676" xml:space="preserve" xmlns="http://www.w3.org/2000/svg"><rect x=".44662" y=".89101" width="92.772" height="91.894" ry="11.689" fill="#ee494c" stroke="#fff" stroke-width=".238"/><switch transform="matrix(.69484 0 0 .69484 12.09 12.096)" fill="#fffefe" stroke="#a11010" stroke-width="5.7567"><foreignObject width="1" height="1" requiredExtensions="http://ns.adobe.com/AdobeIllustrator/10.0/"/><g fill="#fffefe" stroke="#a11010" stroke-width="5.7567"><g fill="#fffefe" stroke="#a11010" stroke-width="5.7567"><path d="m43.3 91.8-18.3 5.5c-2.5 0.7-5.1-0.7-5.9-3.1-0.7-2.5 0.7-5.1 3.1-5.9l6.8-2c-12.4-7.3-20.8-20.8-20.8-36.3 0-17.3 10.6-32.2 25.6-38.6 3.1-1.3 6.6 1 6.6 4.3 0 1.9-1.1 3.6-2.8 4.3-11.8 5-20 16.5-20 30 0 12.2 6.8 22.9 16.8 28.4l-2.4-8.1c-0.7-2.5 0.7-5.1 3.1-5.9 2.5-0.7 5.1 0.7 5.9 3.1l5.5 18.3c0.7 2.6-0.7 5.2-3.2 6z"/><path d="m77.7 11.7-6.8 2c12.5 7.3 20.9 20.8 20.9 36.3 0 17.3-10.6 32.2-25.6 38.6-3.1 1.3-6.6-1-6.6-4.3 0-1.9 1.1-3.6 2.8-4.3 11.8-5 20-16.5 20-30 0-12.2-6.8-22.9-16.8-28.4l2.4 8.1c0.7 2.5-0.7 5.1-3.1 5.9-2.5 0.7-5.1-0.7-5.9-3.1l-5.5-18.3c-0.7-2.5 0.7-5.1 3.2-5.9l18.3-5.6c2.5-0.7 5.1 0.7 5.9 3.1 0.7 2.5-0.7 5.2-3.2 5.9z"/></g></g></switch></svg>
......@@ -5,6 +5,7 @@
import 'dart:async';
import 'package:async/async.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart' show SystemChrome, DeviceOrientation;
import 'package:flutter/widgets.dart';
......@@ -19,11 +20,7 @@ import 'thinking_indicator.dart';
void main() {
WidgetsFlutterBinding.ensureInitialized();
SystemChrome.setEnabledSystemUIOverlays([]);
SystemChrome.setPreferredOrientations([
DeviceOrientation.portraitUp,
DeviceOrientation.portraitDown,
]);
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
runApp(FlutterFlipApp());
}
......@@ -33,14 +30,14 @@ void main() {
class FlutterFlipApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return WidgetsApp(
color: Color(0xffffffff), // Mandatory background color.
onGenerateRoute: (settings) {
return PageRouteBuilder<dynamic>(
settings: settings,
pageBuilder: (context, animation, secondaryAnimation) => GameScreen(),
);
},
return MaterialApp(
debugShowCheckedModeBanner: false,
theme: ThemeData(
primaryColor: Colors.blue,
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: GameScreen(),
);
}
}
......@@ -149,7 +146,7 @@ class _GameScreenState extends State<GameScreen> {
return Container(
padding: const EdgeInsets.symmetric(
vertical: 3.0,
horizontal: 30.0,
horizontal: 25.0,
),
decoration: (model.player == player)
? Styling.activePlayerIndicator
......@@ -157,8 +154,8 @@ class _GameScreenState extends State<GameScreen> {
child: Row(
children: <Widget>[
SizedBox(
width: 30.0,
height: 30.0,
width: 25.0,
height: 25.0,
child: Image(
image: AssetImage(assetImageName),
fit: BoxFit.fill,
......@@ -171,7 +168,7 @@ class _GameScreenState extends State<GameScreen> {
scoreText,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 50.0,
fontSize: 35.0,
color: Color(0xff000000),
),
),
......@@ -282,6 +279,7 @@ class _GameScreenState extends State<GameScreen> {
children: [
TableRow(
children: [
Column(children: [ decorationImage ]),
Column(children: [ decorationImage ]),
Column(children: [
GestureDetector(
......@@ -294,6 +292,7 @@ class _GameScreenState extends State<GameScreen> {
)
]),
Column(children: [ decorationImage ]),
Column(children: [ decorationImage ]),
],
),
]
......@@ -303,20 +302,42 @@ class _GameScreenState extends State<GameScreen> {
// Builds out the Widget tree using the most recent GameModel from the stream.
Widget _buildWidgets(BuildContext context, GameModel model) {
return Container(
padding: EdgeInsets.only(top: 30.0, left: 15.0, right: 15.0),
decoration: Styling.mainWidgetDecoration,
child: SafeArea(
child: Column(
children: [
_buildScoreBoxes(model),
SizedBox(height: 10),
_buildGameBoardDisplay(context, model),
SizedBox(height: 10),
_buildThinkingIndicator(model),
SizedBox(height: 30),
if (model.gameIsOver) _buildEndGameWidget(model),
],
return Scaffold(
appBar: AppBar(
actions: [
FlatButton(
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(4),
border: Border.all(
color: Colors.blue,
width: 4,
),
),
margin: EdgeInsets.all(8),
child: Image(
image: AssetImage('assets/icons/button_restart.png'),
fit: BoxFit.fill
),
),
onPressed: () => _restartController.add(GameModel(board: GameBoard())),
)
],
),
body: Container(
padding: EdgeInsets.only(top: 5.0, left: 5.0, right: 5.0),
decoration: Styling.mainWidgetDecoration,
child: SafeArea(
child: Column(
children: [
_buildScoreBoxes(model),
SizedBox(height: 5),
_buildGameBoardDisplay(context, model),
SizedBox(height: 5),
_buildThinkingIndicator(model),
if (model.gameIsOver) _buildEndGameWidget(model),
],
),
),
),
);
......
......@@ -41,8 +41,8 @@ class _ThinkingIndicatorState
child: SizedBox(
height: widget.height,
child: Opacity(
opacity: _opacityTween!.evaluate(animation!),
child: _opacityTween!.evaluate(animation!) != 0
opacity: _opacityTween!.evaluate(animation),
child: _opacityTween!.evaluate(animation) != 0
? _AnimatedCircles(
color: widget.color,
height: widget.height,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment