import 'package:driverapp/pages/authentication/login_page.dart';
import 'package:driverapp/pages/base/base_view.dart';
import 'package:driverapp/pages/landing/landing_page.dart';
import 'package:driverapp/widgets/others/app_scaffold_widget.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:driverapp/pages/dashboard/dashboard_screen.dart';

import 'core/viewModels/authentication_view_model.dart';

class RootPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    Widget buildRoot(APP_STATUS status) {
      switch (status) {
        case APP_STATUS.UNAUTHENTICATED:
          return LoginPage ();
          break;
        case APP_STATUS.AUTHENTICATED:
          return DashboardScreen();
          break;
      }
    }

    return AnimatedSwitcher(
      duration: Duration(microseconds: 350),
      child: BaseView<AuthenticationViewModel>(
        builder: (_, model, widget) => AppScaffold(
          baseViewModel: model,
          body: buildRoot((model.status)),
        ),
      ),
    );
  }
}
