From dfb4fb6b77b721fb7c5181edc55069829e71c577 Mon Sep 17 00:00:00 2001 From: Yasien Mac Mini Date: Mon, 2 Jun 2025 10:44:13 +0200 Subject: [PATCH] display message when no packages found --- .../package_tools/mih_business_home.dart | 57 +++++++++++++----- .../package_tools/mih_personal_home.dart | 59 ++++++++++++++----- 2 files changed, 87 insertions(+), 29 deletions(-) diff --git a/Frontend/lib/mih_packages/mih_home/package_tools/mih_business_home.dart b/Frontend/lib/mih_packages/mih_home/package_tools/mih_business_home.dart index b91f9314..294f313e 100644 --- a/Frontend/lib/mih_packages/mih_home/package_tools/mih_business_home.dart +++ b/Frontend/lib/mih_packages/mih_home/package_tools/mih_business_home.dart @@ -259,20 +259,49 @@ class _MihBusinessHomeState extends State .contains(searchController.text.toLowerCase())) .map((package) => package.values.first) .toList(); - return GridView.builder( - physics: const NeverScrollableScrollPhysics(), - shrinkWrap: true, - padding: getPadding(width, height), - // shrinkWrap: true, - itemCount: filteredPackages.length, - gridDelegate: SliverGridDelegateWithMaxCrossAxisExtent( - maxCrossAxisExtent: packageSize, - crossAxisSpacing: 5, - ), - itemBuilder: (context, index) { - return filteredPackages[index]; - }, - ); + if (filteredPackages.isNotEmpty) { + return GridView.builder( + physics: const NeverScrollableScrollPhysics(), + shrinkWrap: true, + padding: getPadding(width, height), + // shrinkWrap: true, + itemCount: filteredPackages.length, + gridDelegate: SliverGridDelegateWithMaxCrossAxisExtent( + maxCrossAxisExtent: packageSize, + crossAxisSpacing: 5, + ), + itemBuilder: (context, index) { + return filteredPackages[index]; + }, + ); + } else { + return Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Icon( + MihIcons.mzansiAi, + size: 165, + color: MzanziInnovationHub.of(context)! + .theme + .secondaryColor(), + ), + const SizedBox(height: 10), + Text( + "Mzansi AI is here to help you!", + textAlign: TextAlign.center, + overflow: TextOverflow.visible, + style: TextStyle( + fontSize: 25, + fontWeight: FontWeight.bold, + color: MzanziInnovationHub.of(context)! + .theme + .secondaryColor(), + ), + ), + ], + ); + } }, ), ], diff --git a/Frontend/lib/mih_packages/mih_home/package_tools/mih_personal_home.dart b/Frontend/lib/mih_packages/mih_home/package_tools/mih_personal_home.dart index 86a9b2a6..3880abdf 100644 --- a/Frontend/lib/mih_packages/mih_home/package_tools/mih_personal_home.dart +++ b/Frontend/lib/mih_packages/mih_home/package_tools/mih_personal_home.dart @@ -302,21 +302,50 @@ class _MihPersonalHomeState extends State .contains(searchController.text.toLowerCase())) .map((package) => package.values.first) .toList(); - return GridView.builder( - physics: const NeverScrollableScrollPhysics(), - shrinkWrap: true, - padding: getPadding(width, height), - // shrinkWrap: true, - itemCount: filteredPackages.length, - gridDelegate: SliverGridDelegateWithMaxCrossAxisExtent( - maxCrossAxisExtent: packageSize, - crossAxisSpacing: 5, - ), - itemBuilder: (context, index) { - return filteredPackages[index]; - // return personalPackages[index]; - }, - ); + if (filteredPackages.isNotEmpty) { + return GridView.builder( + physics: const NeverScrollableScrollPhysics(), + shrinkWrap: true, + padding: getPadding(width, height), + // shrinkWrap: true, + itemCount: filteredPackages.length, + gridDelegate: SliverGridDelegateWithMaxCrossAxisExtent( + maxCrossAxisExtent: packageSize, + crossAxisSpacing: 5, + ), + itemBuilder: (context, index) { + return filteredPackages[index]; + // return personalPackages[index]; + }, + ); + } else { + return Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Icon( + MihIcons.mzansiAi, + size: 165, + color: MzanziInnovationHub.of(context)! + .theme + .secondaryColor(), + ), + const SizedBox(height: 10), + Text( + "Mzansi AI is here to help you!", + textAlign: TextAlign.center, + overflow: TextOverflow.visible, + style: TextStyle( + fontSize: 25, + fontWeight: FontWeight.bold, + color: MzanziInnovationHub.of(context)! + .theme + .secondaryColor(), + ), + ), + ], + ); + } }, ), ],