From a572a7c592df93ad13b1019107d0539648f170b2 Mon Sep 17 00:00:00 2001 From: Sikander Saleem Date: Thu, 6 May 2021 11:32:21 +0300 Subject: [PATCH] navigation drawer improvement. --- lib/ui/common_appbar.dart | 132 ++++++++++++++++++++------------------ 1 file changed, 69 insertions(+), 63 deletions(-) diff --git a/lib/ui/common_appbar.dart b/lib/ui/common_appbar.dart index 5ac0c01..6641b09 100644 --- a/lib/ui/common_appbar.dart +++ b/lib/ui/common_appbar.dart @@ -211,52 +211,58 @@ class _CommonAppbarState extends State { ), ), Expanded( - child: ListView.builder( - physics: BouncingScrollPhysics(), - padding: EdgeInsets.only(left: 24, right: 24), - itemCount: navigationList.length, - itemBuilder: (context, index) { - String icon = "assets/icons/${navigationList[index].mobileFontIcon}.svg"; - if (navigationList[index].parentId == 1) { - return myListItem(icon, navigationList[index].navigationText, navigationList[index].orderNo == 1 ? true : false, onTap: () { - String url = navigationList[index]?.mobileNavigationUrl ?? ""; - if (url.isEmpty || url.length < 2) { - return; - } - Navigator.pushNamed(context, url, arguments: null); - }); - } else { - return Container( - width: double.infinity, - child: Row( - children: [ - Expanded( - child: myListItem(icon, navigationList[index].navigationText, false, onTap: () { - String url = navigationList[index]?.mobileNavigationUrl ?? ""; - if (url.isEmpty) { - return; - } - var contentId; - if (navigationList[index].mobileNavigationUrl == "/introduction") { - url = ContentInfoScreen.routeName; - contentId = 2; - } else if (navigationList[index].mobileNavigationUrl == "/encyclopedia") { - url = ContentInfoScreen.routeName; - contentId = 1; - } - Navigator.pushNamed(context, url, arguments: contentId); - }), - ), - Container( - height: 40, - margin: EdgeInsets.only(right: 17, left: 10), - child: VerticalDivider(color: ColorConsts.primaryBlack, thickness: .7, width: 1), - ), - ], - ), - ); - } - })), + child: ListView.builder( + physics: BouncingScrollPhysics(), + padding: EdgeInsets.only(left: 24, right: 24), + itemCount: navigationList.length, + itemBuilder: (context, index) { + String icon = "assets/icons/${navigationList[index].mobileFontIcon}.svg"; + var subList = navigationList.where((element) => element.parentId == navigationList[index].navigationId).toList(); + return Column( + mainAxisSize: MainAxisSize.min, + children: [ + if (navigationList[index].parentId == 1) + myListItem(icon, navigationList[index].navigationText, navigationList[index].orderNo == 1 ? true : false, onTap: () { + String url = navigationList[index]?.mobileNavigationUrl ?? ""; + if (url.isEmpty || url.length < 2) { + return; + } + Navigator.pushNamed(context, url, arguments: null); + }), + for (var subItem in subList) + Container( + width: double.infinity, + child: Row( + children: [ + Expanded( + child: myListItem("assets/icons/${subItem.mobileFontIcon}.svg", subItem.navigationText, false, onTap: () { + String url = subItem.mobileNavigationUrl ?? ""; + if (url.isEmpty) { + return; + } + var contentId; + if (subItem.mobileNavigationUrl == "/introduction") { + url = ContentInfoScreen.routeName; + contentId = 2; + } else if (subItem.mobileNavigationUrl == "/encyclopedia") { + url = ContentInfoScreen.routeName; + contentId = 1; + } + Navigator.pushNamed(context, url, arguments: contentId); + }), + ), + Container( + height: 40, + margin: EdgeInsets.only(right: 17, left: 10), + child: VerticalDivider(color: ColorConsts.primaryBlack, thickness: .7, width: 1), + ), + ], + ), + ) + ], + ); + }), + ), Container( margin: EdgeInsets.only(top: 16, bottom: 12), padding: EdgeInsets.only(left: 32, right: 32), @@ -269,23 +275,23 @@ class _CommonAppbarState extends State { ], ), ), - Padding( - padding: EdgeInsets.only(left: 32, right: 32, bottom: 8), - child: Row( - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text( - "Powered by Cloud Solutions", - maxLines: 1, - textAlign: TextAlign.right, - style: TextStyle(fontSize: 14,color: Colors.black87), - ), - SizedBox(width: 8), - SvgPicture.asset("assets/logos/cloud_logo.svg", width: 30, height: 30) - ], - ), - ) + Padding( + padding: EdgeInsets.only(left: 32, right: 32, bottom: 8), + child: Row( + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + "Powered by Cloud Solutions", + maxLines: 1, + textAlign: TextAlign.right, + style: TextStyle(fontSize: 14, color: Colors.black87), + ), + SizedBox(width: 8), + SvgPicture.asset("assets/logos/cloud_logo.svg", width: 30, height: 30) + ], + ), + ) ], ), ),