2021-01-28 04:33:26 +00:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_platform_widgets/flutter_platform_widgets.dart';
|
|
|
|
import 'package:fluro/fluro.dart';
|
|
|
|
|
2021-02-10 22:42:57 +00:00
|
|
|
import 'package:imagini/core/app_provider.dart';
|
|
|
|
import 'package:imagini/blocs/splash_bloc.dart';
|
|
|
|
import 'package:imagini/graphql/imagini_graphql.dart';
|
2021-01-28 04:33:26 +00:00
|
|
|
|
|
|
|
class SplashScreen extends StatefulWidget {
|
|
|
|
static const String PATH = '/';
|
|
|
|
|
|
|
|
SplashScreen({Key key}) : super(key: key);
|
|
|
|
|
|
|
|
@override
|
|
|
|
_SplashScreenState createState() => _SplashScreenState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _SplashScreenState extends State<SplashScreen> {
|
|
|
|
|
|
|
|
SplashBloc bloc;
|
|
|
|
|
|
|
|
@override
|
|
|
|
void dispose() {
|
|
|
|
super.dispose();
|
|
|
|
bloc.dispose();
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
_init();
|
|
|
|
|
|
|
|
return Scaffold(
|
|
|
|
body: Center(
|
|
|
|
child: ConstrainedBox(
|
|
|
|
constraints: BoxConstraints(maxWidth: 500),
|
|
|
|
child: Container(
|
|
|
|
margin: EdgeInsets.fromLTRB(50, 0, 50, 0),
|
|
|
|
height: 270,
|
|
|
|
child: Column(
|
|
|
|
children: <Widget>[
|
|
|
|
Container(
|
|
|
|
child: FittedBox(
|
|
|
|
fit: BoxFit.contain,
|
|
|
|
child: const FlutterLogo(),
|
|
|
|
),
|
|
|
|
width: 175,
|
|
|
|
margin: EdgeInsets.fromLTRB(0, 0, 0, 50),
|
|
|
|
),
|
|
|
|
PlatformCircularProgressIndicator()
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
void _init(){
|
|
|
|
if(null == bloc){
|
|
|
|
bloc = SplashBloc(AppProvider.getApplication(context));
|
2021-02-10 22:42:57 +00:00
|
|
|
bloc.loginResult.listen((Login$Query$AuthResponse lr) {
|
2021-02-11 20:35:47 +00:00
|
|
|
if (lr.result == AuthResult.success) {
|
2021-01-28 04:33:26 +00:00
|
|
|
AppProvider.getRouter(context).navigateTo(context, "/Home", transition: TransitionType.fadeIn);
|
2021-02-10 22:42:57 +00:00
|
|
|
} else {
|
|
|
|
AppProvider.getRouter(context).navigateTo(context, "/Login", transition: TransitionType.fadeIn);
|
2021-01-28 04:33:26 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|