buildMobileHeader method

Widget buildMobileHeader(
  1. BuildContext context
)

Implementation

Widget buildMobileHeader(BuildContext context) {
  List<Widget> newActionsForMobile =
      actions != null ? List.from(actions!) : [];

  if (Get.currentRoute != CommonRoutes.login && showAllApps) {
    newActionsForMobile.add(IconButton(
      icon: Obx(() {
        return Badge.count(
            count: homeController.notificationCount.value,
            backgroundColor: Colors.redAccent,
            textColor: Colors.white,
            child: const Icon(CupertinoIcons.bell));
      }),
      tooltip: 'Notifications',
      onPressed: () {
        homeController.setEndDrawerContent(context, NotificationView());
      },
    ));
  }

  if (Get.currentRoute != CommonRoutes.login &&
      Get.currentRoute != CommonRoutes.home &&
      showAllApps) {
    newActionsForMobile.add(IconButton(
      icon: const Icon(Icons.home_rounded),
      tooltip: 'Home',
      onPressed: () {
        homeController.navigateToHomeScreen();
      },
    ));
  }

  // Add All Apps icon
  if (Get.currentRoute != CommonRoutes.login && showAllApps) {
    newActionsForMobile.add(IconButton(
      icon: const Icon(CupertinoIcons.square_grid_2x2),
      tooltip: 'Main Menu',
      onPressed: () {
        homeController.setEndDrawerContent(context, AllAppsDrawer());
      },
    ));
  }

  // Mobile or small screen layout
  return AppBar(
    title: title == 'simpliWORKS™'
        ? Row(
            children: [
              headerLogoAsset ?? AppImageAssets(
                _themeService.isThemeFromBox()
                    ? 'assets/images/simpliworks_logo_white.png'
                    : 'assets/images/simpliworks_logo.png',
                height: 45.0,
                width: 120.0,
                fit: BoxFit.contain, // or any fit you need
              ),
            ],
          )
        : AppText(title, style: TextStyles.medium(context)),
    actions: newActionsForMobile.isNotEmpty ? newActionsForMobile : null,
    elevation: 2.0,
    backgroundColor: Theme.of(context).drawerTheme.backgroundColor,
    surfaceTintColor: Theme.of(context).drawerTheme.backgroundColor,
    automaticallyImplyLeading: automaticallyImplyLeading,
    bottom: bottom,
    centerTitle: centerTitle,
  );
}