71 lines
1.8 KiB
Dart
71 lines
1.8 KiB
Dart
|
import 'package:flutter/material.dart';
|
||
|
import 'package:flutter_platform_widgets/flutter_platform_widgets.dart';
|
||
|
import 'package:fluro/fluro.dart';
|
||
|
|
||
|
import 'package:imagini/models/api/response/LoginResponse.dart';
|
||
|
import 'package:imagini/core/AppProvider.dart';
|
||
|
import 'package:imagini/blocs/SplashBloc.dart';
|
||
|
|
||
|
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));
|
||
|
bloc.loginResult.listen((LoginResponse lr) {
|
||
|
if (lr.error != null) {
|
||
|
AppProvider.getRouter(context).navigateTo(context, "/Login", transition: TransitionType.fadeIn);
|
||
|
} else {
|
||
|
AppProvider.getRouter(context).navigateTo(context, "/Home", transition: TransitionType.fadeIn);
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
}
|
||
|
}
|