buildMobileHeader method
Implementation
Widget buildMobileHeader(BuildContext context) {
final cs = Theme.of(context).colorScheme;
final isDark = Theme.of(context).brightness == Brightness.dark;
final style = fontSizeController.appBarStyle.value;
final bool isSolid = style == AppAppBarStyle.classicSolid;
final bool isGlass = style == AppAppBarStyle.modernGlass;
Color appBarBg;
double elevation;
Widget? flexibleSpace;
BorderSide bottomBorder = BorderSide.none;
Color headerTextColor;
Color headerIconColor;
if (isSolid) {
final accent = fontSizeController.getEffectiveAccentColor();
appBarBg = accent;
elevation = fontSizeController.appBarShadow.value.elevation;
headerTextColor = Colors.white;
headerIconColor = Colors.white.withOpacity(0.9);
} else if (isGlass) {
appBarBg = Theme.of(context).scaffoldBackgroundColor.withOpacity(0.65);
elevation = 0.0;
headerTextColor = cs.onSurface;
headerIconColor = cs.onSurface.withOpacity(0.8);
flexibleSpace = ClipRect(
child: BackdropFilter(
filter: ImageFilter.blur(sigmaX: 12.0, sigmaY: 12.0),
child: Container(color: Colors.transparent),
),
);
bottomBorder = BorderSide(
color: isDark ? Colors.white.withOpacity(0.1) : Colors.black.withOpacity(0.08),
width: 1.0,
);
} else {
// Minimalist
appBarBg = Theme.of(context).scaffoldBackgroundColor;
elevation = 0.0;
headerTextColor = cs.onSurface;
headerIconColor = cs.onSurface.withOpacity(0.8);
bottomBorder = BorderSide(
color: isDark ? Colors.white.withOpacity(0.12) : Colors.black.withOpacity(0.08),
width: 1.0,
);
}
List<Widget> newActionsForMobile =
actions != null ? List.from(actions!) : [];
if (Get.currentRoute != CommonRoutes.login) {
newActionsForMobile.add(IconButton(
icon: Builder(
builder: (btnContext) {
GetIt.I<DownloadUIRegistry>().downloadButtonContext = btnContext;
return Obx(() {
final count = GetIt.I<DownloadController>().downloadCount.value;
final icon = Icon(Icons.file_download_outlined, color: headerIconColor);
return count > 0
? Badge.count(
count: count,
backgroundColor: Colors.redAccent,
textColor: Colors.white,
child: icon)
: icon;
});
},
),
tooltip: 'Downloads',
onPressed: () async {
final controller = GetIt.I<DownloadController>();
await controller.loadDownloadsIfNeeded(); // 🔥 SMART LOAD
homeController.setEndDrawerContent(context, DownloadScreen());
},
));
}
if (Get.currentRoute != CommonRoutes.login && showAllApps) {
newActionsForMobile.add(IconButton(
icon: Obx(() {
final count = homeController.notificationCount.value;
final icon = Icon(CupertinoIcons.bell, color: headerIconColor);
return count > 0
? Badge.count(
count: count,
backgroundColor: Colors.redAccent,
textColor: Colors.white,
child: icon)
: icon;
}),
tooltip: 'Notifications',
onPressed: () {
homeController.setEndDrawerContent(context, NotificationView());
},
));
}
if (Get.currentRoute != CommonRoutes.login &&
Get.currentRoute != CommonRoutes.home) {
newActionsForMobile.add(IconButton(
icon: Icon(Icons.home_rounded, color: headerIconColor),
tooltip: 'Home',
onPressed: () {
homeController.navigateToHomeScreen();
},
));
}
// Add All Apps icon
if (Get.currentRoute != CommonRoutes.login) {
newActionsForMobile.add(IconButton(
icon: Icon(CupertinoIcons.square_grid_2x2, color: headerIconColor),
tooltip: 'Main Menu',
onPressed: () async {
await homeController.loadListingIfNeeded(); // 🔥 SMART LOAD
homeController.setEndDrawerContent(context, AllAppsDrawer());
},
));
}
// Mobile or small screen layout
return AppBar(
toolbarHeight: fontSizeController.appBarHeight.value.height,
title: title == 'simpliWORKSâ„¢'
? Row(
children: [
headerLogoAsset ?? AppImageAssets(
(_themeService.isThemeFromBox() || isSolid)
? '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, textColor: headerTextColor)),
actions: newActionsForMobile.isNotEmpty ? newActionsForMobile : null,
elevation: elevation,
backgroundColor: appBarBg,
surfaceTintColor: Colors.transparent,
flexibleSpace: flexibleSpace,
shape: Border(bottom: bottomBorder),
iconTheme: IconThemeData(color: headerIconColor),
actionsIconTheme: IconThemeData(color: headerIconColor),
automaticallyImplyLeading: automaticallyImplyLeading,
bottom: bottom,
centerTitle: fontSizeController.appBarTitleAlignment.value == AppAppBarTitleAlignment.center,
);
}