import 'package:car_customer_app/view_models/dashboard_view_model.dart';
import 'package:car_customer_app/views/dashboard/fragments/home_fragment.dart';
import 'package:car_customer_app/views/dashboard/widgets/bottom_nav_bar.dart';
import 'package:car_customer_app/views/dashboard/widgets/drawer_widget.dart';
import 'package:flutter/material.dart';
import 'package:mc_common_app/widgets/app_bar.dart';
import 'package:provider/provider.dart';

class DashboardPage extends StatefulWidget {
  const DashboardPage({Key? key}) : super(key: key);

  @override
  State<DashboardPage> createState() => _DashboardPageState();
}

class _DashboardPageState extends State<DashboardPage> {
  late DashboardVM dashboardVM;

  @override
  void initState() {
    super.initState();
    dashboardVM = Provider.of<DashboardVM>(context, listen: false);
    fetchUsername();
  }

  fetchUsername() async {}

  List<Widget> fragments = [
    const HomeFragment(),
    const HomeFragment(),
    const HomeFragment(),
    const HomeFragment(),
  ];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: const CustomAppBar(title: "Logo/Brand", isRemoveBackButton: true),
      drawer: CustomDrawer(dashboardVM: dashboardVM),
      bottomNavigationBar: const CustomBottomNavbar(),
      body: fragments[dashboardVM.selectedNavbarBarIndex],
    );
  }
}
