diff --git a/lib/dashboard_latest/widgets/app_bar_widget.dart b/lib/dashboard_latest/widgets/app_bar_widget.dart index ef7a95f7..f130d70c 100644 --- a/lib/dashboard_latest/widgets/app_bar_widget.dart +++ b/lib/dashboard_latest/widgets/app_bar_widget.dart @@ -128,24 +128,26 @@ class _AppBarWidgetState extends State with TickerProviderStateMix ), ), 8.width, - SlideTransition( - position: _leftSlideAnimation, - child: FadeTransition( - opacity: _leftFadeAnimation, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - spacing: 4, - children: [ - Text( - snapshot.user?.username ?? "", - style: AppTextStyles.heading6.copyWith(color: AppColor.headingTextColor(context), fontSize: context.isTablet() ? 14 : null), - ), - Text( - snapshot.user?.type?.name.toCamelCase ?? "", - style: AppTextStyles.bodyText.copyWith(color: AppColor.lightTextColor(context), fontSize: context.isTablet() ? 12 : null), - ), - ], - ).expanded, + Expanded( + child: SlideTransition( + position: _leftSlideAnimation, + child: FadeTransition( + opacity: _leftFadeAnimation, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + spacing: 4, + children: [ + Text( + snapshot.user?.username ?? "", + style: AppTextStyles.heading6.copyWith(color: AppColor.headingTextColor(context), fontSize: context.isTablet() ? 14 : null), + ), + Text( + snapshot.user?.type?.name.toCamelCase ?? "", + style: AppTextStyles.bodyText.copyWith(color: AppColor.lightTextColor(context), fontSize: context.isTablet() ? 12 : null), + ), + ], + ), + ), ), ), const Spacer(), @@ -232,91 +234,6 @@ class _AppBarWidgetState extends State with TickerProviderStateMix }); }, ); - - return Container( - padding: const EdgeInsets.all(10), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(8), - color: AppColor.assetGroupBackground(context), - border: Border.all(color: AppColor.white936.withValues(alpha: .03), width: 1), - boxShadow: [ - BoxShadow(color: Colors.black.withValues(alpha: 0.03), blurRadius: 4, offset: const Offset(0, 0), spreadRadius: 0), - ], - ), - child: Row( - mainAxisSize: MainAxisSize.min, - spacing: 16, - children: [ - Text(settingProvider.assetGroup?.name ?? "", style: AppTextStyles.bodyText2.copyWith(color: AppColor.headingTextColor(context))), - Icon(Icons.keyboard_arrow_down, color: AppColor.headingTextColor(context)), - ], - ), - ); - - return Container( - padding: const EdgeInsets.fromLTRB(12, 6, 6, 6), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(8), - color: AppColor.background(context), - boxShadow: const [ - BoxShadow( - color: Color(0x07000000), - blurRadius: 14, - offset: Offset(0, 0), - spreadRadius: 0, - ) - ], - ), - child: DropdownButton( - // Made AssetGroup nullable - value: settingProvider.assetGroup, - //iconSize: 24, - isDense: true, - icon: Icon(Icons.keyboard_arrow_down, color: AppColor.headingTextColor(context)), - elevation: 8, - // dropdownColor: Colors.amber, - borderRadius: BorderRadius.circular(8), - style: AppTextStyles.tinyFont.copyWith(color: AppColor.headingTextColor(context)), - underline: const SizedBox.shrink(), - onChanged: (newValue) async { - if (settingProvider.assetGroup != newValue) { - AssetGroup? tempGroup = ApiManager.instance.assetGroup; - ApiManager.instance.assetGroup = newValue; - - Utils.showLoading(context); - bool isSuccess = await context.userProvider.userChangeAssetGroup(); - Utils.hideLoading(context); - if (isSuccess) { - await context.userProvider.getMobilePermissionByUser(); - settingProvider.setAssetGroup(newValue); - WidgetsBinding.instance.addPostFrameCallback((_) { - context.settingProvider.setUser(ApiManager.instance.user!); - context.userProvider.setUser(ApiManager.instance.user!); - DashBoardProvider dashBoardProvider = Provider.of(context, listen: false); - dashBoardProvider.setTabs(userType: settingProvider.user!.type!, context: context); - dashBoardProvider.getDashBoardCount(usersType: settingProvider.user!.type!); - dashBoardProvider.resetRequestDataList(); - dashBoardProvider.getRequestDetail(usersType: settingProvider.user!.type!, status: dashBoardProvider.tabs[dashBoardProvider.currentListIndex].tag); - }); - } else { - ApiManager.instance.assetGroup = tempGroup; - context.showConfirmDialog("Failed, Please Try again"); - } - } - }, - items: Provider.of(context, listen: false).user?.assetGroups?.map>((value) { - // Added null check and made AssetGroup nullable - return DropdownMenuItem( - value: value, - child: Text( - value.name ?? "", - style: Theme.of(context).textTheme.bodyLarge, - ), - ); - }).toList() ?? - [], // Added null check and empty list default - ), - ); }), ), ),