diff --git a/lib/src/app.dart b/lib/src/app.dart index 6d72a7db63852e259943a0ace8dff12a87251f92..c33e29eaac255f31642b43010fb3ec489ed9e3f3 100644 --- a/lib/src/app.dart +++ b/lib/src/app.dart @@ -1,4 +1,5 @@ // app.dart +import 'screens/splashscreen.dart'; import 'package:flutter/material.dart'; import 'screens/home.dart'; import 'package:flutter/services.dart'; @@ -6,9 +7,22 @@ import 'dart:async'; import 'dart:developer'; import 'package:uni_links/uni_links.dart'; -import 'package:splashscreen/splashscreen.dart'; class App extends StatelessWidget { + Future<Widget> initApplication() async { + Uri initialUri; + + try { + initialUri = await getInitialUri(); + } on PlatformException { + initialUri = null; + } on FormatException { + initialUri = null; + } + + return new MainApp(initialUri: initialUri); + } + @override Widget build(BuildContext context) { return MaterialApp( @@ -20,16 +34,7 @@ class App extends StatelessWidget { button: TextStyle(color: Colors.white, fontSize: 18.0), title: TextStyle(color: Colors.red))), home: new SplashScreen( - seconds: 3, - title: new Text(''), - navigateAfterSeconds: new MainApp(), - image: new Image.asset('assets/images/vereign_logo_text.png'), - backgroundColor: Color(0xFFd51d32), - photoSize: 100.0, - loaderColor: Colors.white, - loadingText: new Text('Loading', style: new TextStyle( - color: Colors.white - )), + navigateAfterFuture: initApplication, ) ); @@ -38,6 +43,9 @@ class App extends StatelessWidget { } class MainApp extends StatefulWidget { + MainApp({ @required this.initialUri }); + final Uri initialUri; + @override _MainAppState createState() => _MainAppState(); } @@ -55,7 +63,6 @@ class _MainAppState extends State<MainApp> { initState() { super.initState(); initUniLinks(); -// FlutterWebBrowser.openWebPage(url: 'https://demo1.vereign.com', androidToolbarColor: Color(0xFFd51d32)); } @override @@ -65,16 +72,7 @@ class _MainAppState extends State<MainApp> { } Future<Null> initUniLinks() async { - Uri initialUri; - - try { - initialUri = await getInitialUri(); - } on PlatformException { - initialUri = null; - } on FormatException { - initialUri = null; - } - updateAppMode(initialUri); + updateAppMode(widget.initialUri); _sub = getUriLinksStream().listen((Uri uri) { updateAppMode(uri); diff --git a/lib/src/screens/splashscreen.dart b/lib/src/screens/splashscreen.dart new file mode 100644 index 0000000000000000000000000000000000000000..44bd75c3f7dd60a12da85c25d08f36369dbf0f09 --- /dev/null +++ b/lib/src/screens/splashscreen.dart @@ -0,0 +1,80 @@ +import 'dart:core'; +import 'dart:async'; +import 'package:flutter/material.dart'; + +class SplashScreen extends StatefulWidget { + final dynamic navigateAfterFuture; + SplashScreen({this.navigateAfterFuture}); + + @override + _SplashScreenState createState() => _SplashScreenState(); +} + +class _SplashScreenState extends State<SplashScreen> { + @override + void initState() { + super.initState(); + + load(); + } + + load() async { + var newWidget = await widget.navigateAfterFuture(); + + // Show loader additional 2 seconds + Timer( + Duration(seconds: 2), + () { + Navigator.of(context).pushReplacement(new MaterialPageRoute(builder: (BuildContext context) => newWidget)); + } + ); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: new InkWell( + child:new Stack( + fit: StackFit.expand, + children: <Widget>[ + new Container( + decoration: new BoxDecoration( + color: Color(0xFFd51d32), + ), + ), + new Column( + mainAxisAlignment: MainAxisAlignment.start, + children: <Widget>[ + new Expanded( + flex: 2, + child: new Container( + child: new Image.asset('assets/images/vereign_logo_text.png'), + padding: EdgeInsets.all(40) + ), + ), + Expanded( + flex: 1, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: <Widget>[ + + CircularProgressIndicator( + valueColor: new AlwaysStoppedAnimation<Color>(Colors.white), + ), + Padding( + padding: const EdgeInsets.only(top: 20.0), + ), + new Text('Loading', style: new TextStyle( + color: Colors.white + )) + ], + ), + ), + ], + ), + ], + ), + ), + ); + } +} diff --git a/pubspec.lock b/pubspec.lock index 5450bc068649e1d0595dd657f15b988090bd7eec..53b08bfe62cefec32de5db18794c149a3861c8bd 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -172,13 +172,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.5.5" - splashscreen: - dependency: "direct main" - description: - name: splashscreen - url: "https://pub.dartlang.org" - source: hosted - version: "1.2.0" stack_trace: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index b61d5897d2b9c3252dac1aa60e669e93f3ad16a3..fded95b9e52d65650a6a7fdd6ae8dcef527845bf 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -29,7 +29,6 @@ dependencies: http: ^0.12.0 flutter_app_auth_wrapper: ^0.1.1+3 url_launcher: 5.1.0 - splashscreen: 1.2.0 dev_dependencies: flutter_test: