Skip to content

Commit

Permalink
init splash screen (#5)
Browse files Browse the repository at this point in the history
* init splash screen

* modify splash image and test

* test: add snapshot MyHomePage

* test: remove wrong snapshot MyHomePage

* remove snapshot
  • Loading branch information
echoulen authored Jan 28, 2019
1 parent 8f4387d commit b72cbc1
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 19 deletions.
Binary file added assets/images/splash.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
50 changes: 33 additions & 17 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,26 +1,42 @@
import 'package:flutter/material.dart';
import 'package:splashscreen/splashscreen.dart';

void main() => runApp(MyApp());
void main() => runApp(MaterialApp(
title: 'Mafia',
home: Splash(),
theme: ThemeData(
// This is the theme of your application.
//
// Try running your application with "flutter run". You'll see the
// application has a blue toolbar. Then, without quitting the app, try
// changing the primarySwatch below to Colors.green and then invoke
// "hot reload" (press "r" in the console where you ran "flutter run",
// or simply save your changes to "hot reload" in a Flutter IDE).
// Notice that the counter didn't reset back to zero; the application
// is not restarted.
primarySwatch: Colors.blue,
),
));

class Splash extends StatefulWidget {
@override
_SplashState createState() => new _SplashState();
}

class MyApp extends StatelessWidget {
// This widget is the root of your application.
class _SplashState extends State<Splash> {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Mafia',
theme: ThemeData(
// This is the theme of your application.
//
// Try running your application with "flutter run". You'll see the
// application has a blue toolbar. Then, without quitting the app, try
// changing the primarySwatch below to Colors.green and then invoke
// "hot reload" (press "r" in the console where you ran "flutter run",
// or simply save your changes to "hot reload" in a Flutter IDE).
// Notice that the counter didn't reset back to zero; the application
// is not restarted.
primarySwatch: Colors.blue,
return new SplashScreen(
seconds: 3,
navigateAfterSeconds: MyHomePage(title: 'Mafia Home Page'),
title: Text('Welcome Mafia game',
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20, color: Colors.white),
),
home: MyHomePage(title: 'Mafia Home Page'),
image: Image.asset('assets/images/splash.png', scale: 2),
backgroundColor: Colors.black,
styleTextUnderTheLoader: TextStyle(),
photoSize: 200,
loaderColor: Colors.white
);
}
}
Expand Down
4 changes: 3 additions & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ dependencies:
cupertino_icons: ^0.1.2
socket_io_client: ^0.9.1
rxdart: ^0.20.0
splashscreen: 1.2.0

dev_dependencies:
flutter_test:
Expand All @@ -39,7 +40,8 @@ flutter:
uses-material-design: true

# To add assets to your application, add an assets section, like this:
# assets:
assets:
- assets/images/splash.png
# - images/a_dot_burr.jpeg
# - images/a_dot_ham.jpeg

Expand Down
10 changes: 9 additions & 1 deletion test/widget_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,15 @@ import 'package:mafia_app/main.dart';
void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
// Build our app and trigger a frame.
await tester.pumpWidget(MyApp());
await tester.pumpWidget(
StatefulBuilder(
builder: (BuildContext context, StateSetter setState) {
return MaterialApp(
home: MyHomePage(title: 'test title'),
);
}
)
);

// Verify that our counter starts at 0.
expect(find.text('0'), findsOneWidget);
Expand Down

0 comments on commit b72cbc1

Please sign in to comment.