import 'package:driverapp/pages/authentication/login_page.dart';
import 'package:driverapp/pages/dashboard/dashboard_screen.dart';
import 'package:driverapp/widgets/progress_indicator/app_circular_progress_Indeicator.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';

import 'core/viewModels/authentication_view_model.dart';

class RootPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    AuthenticationViewModel authenticationViewModel = Provider.of(context);
    APP_STATUS status = authenticationViewModel.status;
    Widget buildRoot() {
      switch (status) {
        case APP_STATUS.UNAUTHENTICATED:
          return LoginPage();
          break;
        case APP_STATUS.AUTHENTICATED:
          return DashboardScreen();
          break;
        case APP_STATUS.LOADING:
          return Center(child: AppCircularProgressIndicator());
          break;
      }
    }

    return AnimatedSwitcher(
      duration: Duration(microseconds: 350),
      child: Scaffold(
        body: buildRoot(),
      ),
    );
  }
}
