
import 'package:flutter/material.dart';
import 'package:twong/api/index.dart';
import 'package:twong/utils/index.dart';

class Loading extends StatefulWidget {
  final RouteSettings data;
  Loading({this.data});

  @override
  State<StatefulWidget> createState() {
    return _LoadingState();
  }
}

class _LoadingState extends State<Loading> {

  @override
  void initState() {
    loadData();
    super.initState();
  }

  loadData() async {
    Network.inst.autoLogin().then((res){
      Navigator.popAndPushNamed(context, widget.data.name,
          arguments: widget.data.arguments);
    });
  }

  @override
  Widget build(BuildContext context) {
    return Container(
            width: double.infinity,
            height: double.infinity,
            color: Color.fromARGB(100, 0, 0, 0),
            child: Center(
              child: Utils.loadingWidget,
            )
    );
  }
}