import 'package:doctor_app_flutter/locator.dart';
import 'package:doctor_app_flutter/screens/auth/login_screen.dart';
import 'package:doctor_app_flutter/screens/auth/verification_methods_screen.dart';
import 'package:doctor_app_flutter/widgets/shared/app_loader_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/dr_app_circular_progress_Indeicator.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';

import 'core/viewModel/authentication_view_model.dart';
import 'landing_page.dart';

class RootPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    AuthenticationViewModel authenticationViewModel = Provider.of(context);
    Widget buildRoot() {
      switch (authenticationViewModel.status) {
        case APP_STATUS.LOADING:
          return Scaffold(
            body: AppLoaderWidget(),
          );
          break;
        case APP_STATUS.UNVERIFIED:
          return VerificationMethodsScreen(
            password: null,
          );
          break;
        case APP_STATUS.UNAUTHENTICATED:
          return LoginScreen();
          break;
        case APP_STATUS.AUTHENTICATED:
          return LandingPage();
          break;
      }
    }

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