import 'dart:async';
import 'package:e_commerce_training/res/R.dart';
import 'package:e_commerce_training/src/page/authentication/authentication.dart';
import 'package:e_commerce_training/src/page/home/home_page.dart';
import 'package:e_commerce_training/src/page/main/main.dart';
import 'package:e_commerce_training/src/util/navigation_util.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';

class SplashPage extends StatefulWidget {
  const SplashPage({Key? key}) : super(key: key);

  @override
  _SplashPageState createState() => _SplashPageState();
}

class _SplashPageState extends State<SplashPage> {
  @override
  void initState() {
    // TODO: implement initState

    Timer(
        Duration(seconds: 2),
        () => NavigationUtil.pushAndRemoveUtilPage(
            context, BlocProvider.value(value: BlocProvider.of<AuthenticationCubit>(context), child: MainPage())));

    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Material(
      color: R.color.white,
      child: Center(
        child: Image.asset(
          R.drawable.ic_logo,
          height: 120,
          width: 120,
        ),
      ),
    );
  }
}
