added lazy loading

aamir_dev
Faiz Hashmi 1 year ago
parent 8cdbaf3007
commit 3d79db6afb

@ -76,7 +76,10 @@ class _ServicesListPageState extends State<ServicesListPage> {
); );
context.read<ServiceVM>().applyFilterOnBranchServices(serviceStatusEnum: status); context.read<ServiceVM>().applyFilterOnBranchServices(serviceStatusEnum: status);
filteredServices = categoryData.services!.where((i) => i.serviceStatusEnum == status).toList(); filteredServices = categoryData.services!.where((i) => i.serviceStatusEnum == status).toList();
int index = categoryData.services!.indexWhere((i) => i.serviceStatusEnum != ServiceStatusEnum.deactivated);
if (index != -1) {
isCategoryActive = true;
}
screenState = ViewState.idle; screenState = ViewState.idle;
setState(() {}); setState(() {});
} }
@ -132,38 +135,44 @@ class _ServicesListPageState extends State<ServicesListPage> {
], ],
), ),
), ),
Expanded(
// TODO: NEED TO CONFIRM CATEGORY DEACTIVATION FROM ZAHOOR
const Expanded(
flex: 4, flex: 4,
child: Column( child: Column(
children: [ children: [
// LocaleKeys.active.tr().toText(fontSize: 16), LocaleKeys.active.tr().toText(fontSize: 16),
// 8.width, 8.width,
// Container( Container(
// width: 50, width: 50,
// height: 30, height: 30,
// decoration: BoxDecoration( decoration: BoxDecoration(
// color: isCategoryActive ? MyColors.darkPrimaryColor : MyColors.white, color: isCategoryActive ? MyColors.darkPrimaryColor : MyColors.white,
// borderRadius: BorderRadius.circular(25.0), borderRadius: BorderRadius.circular(25.0),
// border: Border.all(color: MyColors.lightTextColor, width: 1), border: Border.all(color: MyColors.lightTextColor, width: 1),
// ), ),
// child: Transform.scale( child: Transform.scale(
// scale: 0.8, scale: 0.8,
// child: CupertinoSwitch( child: CupertinoSwitch(
// activeColor: MyColors.darkPrimaryColor, activeColor: MyColors.darkPrimaryColor,
// trackColor: MyColors.white, trackColor: MyColors.white,
// thumbColor: MyColors.greyACColor, thumbColor: MyColors.greyACColor,
// value: isCategoryActive, value: isCategoryActive,
// onChanged: (value) async { onChanged: (value) async {
// if (isEditDisabled) return; if (isEditDisabled) return;
// isCategoryActive = value; final status = await updateCategoryStatus(
// // isCategoryActive = await updateServiceStatus(context, value); isCategoryActive: value,
// setState(() {}); categoryId: categoryData.id!,
// }, branchId: int.parse(categoryData.branchId!),
// ), );
// ),
// ), if (status) {
isCategoryActive = value;
_onRefresh(value ? ServiceStatusEnum.pending : ServiceStatusEnum.deactivated);
}
setState(() {});
},
),
),
),
], ],
), ),
), ),
@ -171,6 +180,19 @@ class _ServicesListPageState extends State<ServicesListPage> {
).toWhiteContainer(width: double.infinity, allPading: 12); ).toWhiteContainer(width: double.infinity, allPading: 12);
} }
Future<bool> updateCategoryStatus({required bool isCategoryActive, required int categoryId, required int branchId}) async {
log("isCategoryActive: $isCategoryActive");
final serviceVM = context.read<ServiceVM>();
bool status = await serviceVM.updateCategoryStatus(
context: context,
serviceStatusEnum: isCategoryActive ? ServiceStatusEnum.approvedOrActive : ServiceStatusEnum.deactivated,
branchId: branchId,
categoryId: categoryId,
);
return status;
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
categoryData = ModalRoute.of(context)!.settings.arguments as CategoryData; categoryData = ModalRoute.of(context)!.settings.arguments as CategoryData;

@ -109,6 +109,7 @@ class HomeFragment extends StatelessWidget {
isAdsFragment: false, isAdsFragment: false,
adsList: adVM.myActiveAdsForHome, adsList: adVM.myActiveAdsForHome,
scrollPhysics: const NeverScrollableScrollPhysics(), scrollPhysics: const NeverScrollableScrollPhysics(),
hasMoreData: adVM.isExploreAdsTapped ? adVM.hasMoreDataForExploreAds : adVM.hasMoreDataForMyAds,
), ),
], ],
) )
@ -131,6 +132,7 @@ class HomeFragment extends StatelessWidget {
adsList: adVM.exploreAds.length >= 3 ? adVM.exploreAds.take(3).toList() : adVM.exploreAds, adsList: adVM.exploreAds.length >= 3 ? adVM.exploreAds.take(3).toList() : adVM.exploreAds,
isAdsFragment: false, isAdsFragment: false,
scrollPhysics: const NeverScrollableScrollPhysics(), scrollPhysics: const NeverScrollableScrollPhysics(),
hasMoreData: adVM.isExploreAdsTapped ? adVM.hasMoreDataForExploreAds : adVM.hasMoreDataForMyAds,
), ),
], ],
) )

Loading…
Cancel
Save