buildSidebar function

Widget buildSidebar(
  1. BuildContext context,
  2. VoidCallback logoutCallback
)

Builds a sidebar for navigation with expandable menus and hover effects.

This widget is a sidebar that contains various items such as navigation links. It supports expandable menus and a hover effect on items. When an item is hovered, it changes the background color. The sidebar is typically used in the main layout for navigating between different sections of the app.

Implementation

Widget buildSidebar(BuildContext context, VoidCallback logoutCallback) {
  final prefs = locator<PreferenceHelper>();
  final role = prefs.getUserRole();
  return Container(
    width: 210,
    color: const Color(0xFF282B2C),
    child: Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        _SidebarItem(
          icon: Icons.dashboard,
          title: "Dashboard",
          onTap: () {
            // Navigator.pushNamed(context, '/dashboard');
            context.pushReplacement(AppRoutes.dashboard);
          },
        ),
        role == UserRoles.admin
            ? const _ExpandableMenu(
              icon: Icons.app_registration,
              title: "Registration",
              children: [
                _SidebarItem(
                  title: "Organization",
                  route: '/organization-registration',
                ),
                _SidebarItem(title: "Device", route: '/device-registration'),
                _SidebarItem(title: "Generate QR", route: '/generate-qr'),
              ],
            )
            : Container(),
        const _ExpandableMenu(
          icon: Icons.pie_chart,
          title: "MIS",
          children: [
            _SidebarItem(
              icon: Icons.business,
              title: "Organizations",
              route: '/mis-organizations',
            ),
            _SidebarItem(
              icon: Icons.tablet_mac,
              title: "Device",
              route: '/mis-devices',
            ),
            _SidebarItem(
              icon: Icons.medical_services,
              title: "Doctor",
              route: '/mis-doctors',
            ),
            _SidebarItem(
              icon: Icons.pregnant_woman,
              title: "Mother",
              route: '/mis-mothers',
            ),
          ],
        ),
        // const _ExpandableMenu(
        //   icon: Icons.analytics,
        //   title: "Analytics",
        //   children: [
        //     _SidebarItem(
        //       icon: Icons.medical_services,
        //       title: "Doctors",
        //       route: '/analytics-doctors',
        //     ),
        //     _SidebarItem(
        //       icon: Icons.business,
        //       title: "Organizations",
        //       route: '/analytics-organizations',
        //     ),
        //   ],
        // ),
        // const _SidebarItem(icon: Icons.article, title: "Reports"),
        // const _SidebarItem(icon: Icons.settings, title: "Operations"),
        role == UserRoles.superAdmin ? const _SidebarItem(icon: Icons.people, title: "Users") : Container(),
        const Spacer(),
      ],
    ),
  );
}