import 'package:doctor_app_flutter/core/viewModel/auth_view_model.dart';
import 'package:doctor_app_flutter/screens/auth/login_screen.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 'landing_page.dart';

class RootPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    AuthViewModel authProvider = Provider.of(context);
    Widget buildRoot() {
      switch (authProvider.stutas) {
        case APP_STATUS.LOADING:
          return Scaffold(
            body: Center(
              child: DrAppCircularProgressIndeicator(),
            ),
          );
          break;
        case APP_STATUS.UNAUTHENTICATED:
          return Loginsreen();
          break;
        case APP_STATUS.AUTHENTICATED:
          return LandingPage();
          break;
      }
    }

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