From 04520250a522386e9b91830f331d6e81d2399674 Mon Sep 17 00:00:00 2001 From: Sikander Saleem Date: Wed, 3 Aug 2022 11:09:18 +0300 Subject: [PATCH] badge on work list in bottom navigation bar. --- lib/ui/landing/dashboard.dart | 0 lib/ui/landing/dashboard_screen.dart | 112 ++++++++++++++------------- 2 files changed, 59 insertions(+), 53 deletions(-) delete mode 100644 lib/ui/landing/dashboard.dart diff --git a/lib/ui/landing/dashboard.dart b/lib/ui/landing/dashboard.dart deleted file mode 100644 index e69de29..0000000 diff --git a/lib/ui/landing/dashboard_screen.dart b/lib/ui/landing/dashboard_screen.dart index 6515b78..2e7e769 100644 --- a/lib/ui/landing/dashboard_screen.dart +++ b/lib/ui/landing/dashboard_screen.dart @@ -323,68 +323,74 @@ class _DashboardScreenState extends State { drawer: SafeArea( child: AppDrawer(), ), - bottomNavigationBar: BottomNavigationBar( - items: [ - BottomNavigationBarItem( - icon: Padding( - padding: const EdgeInsets.all(4.0), - child: SvgPicture.asset( + bottomNavigationBar: SizedBox( + height: 70, + child: BottomNavigationBar( + items: [ + BottomNavigationBarItem( + icon: SvgPicture.asset( "assets/icons/home.svg", - width: 20, - height: 20, - ), + color: currentIndex == 0 ? MyColors.grey3AColor : MyColors.grey98Color, + ).paddingAll(4), + label: LocaleKeys.home.tr(), ), - label: LocaleKeys.home.tr(), - ), - BottomNavigationBarItem( - icon: Padding( - padding: const EdgeInsets.all(4.0), - child: SvgPicture.asset( + BottomNavigationBarItem( + icon: SvgPicture.asset( "assets/icons/create_req.svg", - width: 20, - height: 20, - ), + color: currentIndex == 1 ? MyColors.grey3AColor : MyColors.grey98Color, + ).paddingAll(4), + label: LocaleKeys.createRequest.tr(), ), - label: LocaleKeys.createRequest.tr(), - ), - BottomNavigationBarItem( - icon: Padding( - padding: const EdgeInsets.all(4.0), - child: SvgPicture.asset( - "assets/icons/work_list.svg", - width: 20, - height: 20, + BottomNavigationBarItem( + icon: Stack( + alignment: Alignment.centerLeft, + children: [ + SvgPicture.asset( + "assets/icons/work_list.svg", + color: currentIndex == 2 ? MyColors.grey3AColor : MyColors.grey98Color, + ).paddingAll(4), + Consumer( + builder: (cxt, data, child) { + if (data.workListCounter == 0) { + return const SizedBox(); + } + return Positioned( + right: 0, + top: 0, + child: Container( + padding: const EdgeInsets.only(left: 4, right: 4), + alignment: Alignment.center, + decoration: BoxDecoration(color: MyColors.redColor, borderRadius: BorderRadius.circular(17)), + child: data.workListCounter.toString().toText10(color: Colors.white), + ), + ); + }, + ), + ], ), + label: LocaleKeys.workList.tr(), ), - label: LocaleKeys.workList.tr(), - ), - BottomNavigationBarItem( - icon: Padding( - padding: const EdgeInsets.all(4.0), - child: SvgPicture.asset( + BottomNavigationBarItem( + icon: SvgPicture.asset( "assets/icons/item_for_sale.svg", - width: 20, - height: 20, - ), + color: currentIndex == 3 ? MyColors.grey3AColor : MyColors.grey98Color, + ).paddingAll(4), + label: LocaleKeys.itemsForSale.tr(), ), - label: LocaleKeys.itemsForSale.tr(), - ), - ], - currentIndex: currentIndex, - selectedLabelStyle: TextStyle( - fontSize: 8, - color: Color(0xff989898), - fontWeight: FontWeight.w600, - ), - unselectedLabelStyle: TextStyle( - fontSize: 8, - color: Color(0xff989898), - fontWeight: FontWeight.w600, + ], + currentIndex: currentIndex, + selectedLabelStyle: const TextStyle(fontSize: 10, color: MyColors.grey3AColor, fontWeight: FontWeight.w600), + unselectedLabelStyle: const TextStyle(fontSize: 10, color: MyColors.grey98Color, fontWeight: FontWeight.w600), + type: BottomNavigationBarType.fixed, + selectedItemColor: MyColors.grey3AColor, + backgroundColor: MyColors.backgroundColor, + selectedIconTheme: const IconThemeData(color: MyColors.grey3AColor, size: 28), + unselectedIconTheme: const IconThemeData(color: MyColors.grey98Color, size: 28), + onTap: (int index) { + currentIndex = index; + setState(() {}); + }, ), - type: BottomNavigationBarType.fixed, - selectedItemColor: Colors.black, - backgroundColor: Color(0xffF8F8F8), - onTap: (index) {}, ), ); }