import 'package:app_flowy/welcome/domain/deps.dart'; import 'package:app_flowy/welcome/presentation/widgets/body.dart'; import 'package:app_flowy/startup/startup.dart'; import 'package:app_flowy/welcome/application/welcome_bloc.dart'; import 'package:flowy_style/route/animation.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flowy_style/time/prelude.dart'; class WelcomeScreen extends StatelessWidget { const WelcomeScreen({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return BlocProvider( create: (context) => getIt()..add(const WelcomeEvent.check()), child: Scaffold( body: BlocListener( listener: (context, state) { state.auth.map( authenticated: (_) => _pushToScreen(context, getIt().home()), unauthenticated: (_) => _pushToScreen(context, getIt().signIn()), ); }, child: const Body(), ), ), ); } void _pushToScreen(BuildContext context, Widget screen) { /// Let the splash view sit for a bit. Mainly for aesthetics and to ensure a smooth intro animation. Future.delayed(1.0.seconds, () { Navigator.push( context, PageRoutes.fade( () => screen, RouteDurations.slow.inMilliseconds * .001)); }); } }