From 35b0a00ffd0a9a7c67f1648ea84b8f8fea15256b Mon Sep 17 00:00:00 2001 From: Sikander Saleem Date: Mon, 15 Jan 2024 16:45:26 +0300 Subject: [PATCH] all requests screen, wrong data show while switching tabs fixed. --- .../my_request/my_requests_page.dart | 102 +++++++++--------- 1 file changed, 53 insertions(+), 49 deletions(-) diff --git a/lib/new_views/pages/land_page/my_request/my_requests_page.dart b/lib/new_views/pages/land_page/my_request/my_requests_page.dart index 5457782a..cc94ef1e 100644 --- a/lib/new_views/pages/land_page/my_request/my_requests_page.dart +++ b/lib/new_views/pages/land_page/my_request/my_requests_page.dart @@ -24,7 +24,7 @@ class _MyRequestsPageState extends State { SearchAllRequestsModel _search; List requestsList; - int selectedRequest=0; + int selectedRequest = 0; @override Widget build(BuildContext context) { @@ -89,58 +89,62 @@ class _MyRequestsPageState extends State { ], ).paddingOnly(start: 16, end: 16), ), - body: Column( - children: [ - if (_filterIsEmpty()) - SizedBox( - height: 50.toScreenHeight, - child: ListView.separated( - scrollDirection: Axis.horizontal, - padding: const EdgeInsets.only(top: 16, right: 16, left: 16), - itemBuilder: (cxt, index) => Container( - alignment: Alignment.center, - padding: const EdgeInsets.symmetric(horizontal: 8), - foregroundDecoration: selectedRequest != index - ? null - : ShapeDecoration( - color: (context.isDark ? AppColor.neutral30 : AppColor.neutral50).withOpacity(0.1), - shape: RoundedRectangleBorder( - side: BorderSide(width: 1, color: AppColor.blueStatus(context)), - borderRadius: BorderRadius.circular(7), + body: Consumer(builder: (context, snapshot, _) { + return Column( + children: [ + if (_filterIsEmpty()) + SizedBox( + height: 50.toScreenHeight, + child: ListView.separated( + scrollDirection: Axis.horizontal, + padding: const EdgeInsets.only(top: 16, right: 16, left: 16), + itemBuilder: (cxt, index) => Container( + alignment: Alignment.center, + padding: const EdgeInsets.symmetric(horizontal: 8), + foregroundDecoration: selectedRequest != index + ? null + : ShapeDecoration( + color: (context.isDark ? AppColor.neutral30 : AppColor.neutral50).withOpacity(0.1), + shape: RoundedRectangleBorder( + side: BorderSide(width: 1, color: AppColor.blueStatus(context)), + borderRadius: BorderRadius.circular(7), + ), ), - ), - decoration: ShapeDecoration( - color: selectedRequest == index ? AppColor.selectedButtonColor(context) : AppColor.unSelectedButtonColor(context), - shape: RoundedRectangleBorder( - side: selectedRequest == index ? BorderSide(width: 1, color: AppColor.blueStatus(context)) : BorderSide.none, - borderRadius: BorderRadius.circular(7), + decoration: ShapeDecoration( + color: selectedRequest == index ? AppColor.selectedButtonColor(context) : AppColor.unSelectedButtonColor(context).withOpacity(snapshot.isAllLoading ? 0.7 : 1), + shape: RoundedRectangleBorder( + side: selectedRequest == index ? BorderSide(width: 1, color: AppColor.blueStatus(context)) : BorderSide.none, + borderRadius: BorderRadius.circular(7), + ), + shadows: [BoxShadow(color: Colors.black.withOpacity(0.05), blurRadius: 14, offset: const Offset(0, 0), spreadRadius: 0)], ), - shadows: [BoxShadow(color: Colors.black.withOpacity(0.05), blurRadius: 14, offset: const Offset(0, 0), spreadRadius: 0)], - ), - child: Text(requestsList[index], style: AppTextStyles.bodyText2.copyWith(height: 1, color: AppColor.filterButtonTextColor(context))), - ).onPress(() { - if (selectedRequest != index) { - setState(() { - selectedRequest = index; - }); - _provider.reset(); - _provider.getAllRequests(context, typeTransaction: selectedRequest == 0 ? null : selectedRequest); - } - }), - separatorBuilder: (cxt, index) => 8.width, - itemCount: requestsList.length), - ), - Consumer(builder: (context, snapshot, _) { - return LazyLoading( + child: Text(requestsList[index], style: AppTextStyles.bodyText2.copyWith(height: 1, color: AppColor.filterButtonTextColor(context))), + ).onPress(() { + if (snapshot.isAllLoading) { + return; + } + + if (selectedRequest != index) { + setState(() { + selectedRequest = index; + }); + _provider.reset(); + _provider.getAllRequests(context, typeTransaction: selectedRequest == 0 ? null : selectedRequest); + } + }), + separatorBuilder: (cxt, index) => 8.width, + itemCount: requestsList.length), + ), + LazyLoading( child: RequestItemViewList(snapshot.allRequestsAndCount?.requestsDetails ?? [], snapshot.isAllLoading), nextPage: snapshot.nextPage, - onLazyLoad: (){ - print(selectedRequest); - snapshot.getAllRequests(context, typeTransaction: selectedRequest == 0 ? null : selectedRequest);}, - ); - }).expanded, - ], - )); + onLazyLoad: () { + snapshot.getAllRequests(context, typeTransaction: selectedRequest == 0 ? null : selectedRequest); + }, + ).expanded, + ], + ); + })); } bool _filterIsEmpty() {