
import 'package:flutter_redux/flutter_redux.dart';
import 'package:flutter/material.dart';
import 'package:satu/core/redux/actions/user_actions.dart';
import 'package:satu/core/redux/state/user_state.dart';
import 'package:satu/core/redux/store.dart';
import 'package:satu/shared/app_colors.dart';


class StartUpView extends StatefulWidget {
  @override
  _StartUpViewState createState() => _StartUpViewState();
}

class _StartUpViewState extends State<StartUpView> {

  @override
  void initState() {
    super.initState();
    // Redux.store.dispatch(checkUserAction);
    redirect();
  }

  @override
  Widget build(BuildContext context) {
    return StoreConnector<AppState, UserState>(
        converter: (store) => store.state.userState!,
        builder: (context, userState) {
          return Scaffold(
            backgroundColor: whiteColor,
              body: Center(
            child: Column(
              mainAxisSize: MainAxisSize.min,
              children: <Widget>[
                SizedBox(
                  width: 500,
                  height: 200,
                  child: Image.asset('assets/images/icon_large.png'),
                ),
                CircularProgressIndicator(
                  strokeWidth: 3,
                  valueColor: AlwaysStoppedAnimation(
                    Colors.yellow[300],
                  ),
                )
              ],
            ),
          ));
        });
  }

  void redirect() async {
    await Future.delayed(Duration(milliseconds: 100));
    Redux.store!.dispatch(auth);
  }
}
