added lazy loading

aamir_dev
Faiz Hashmi 12 months ago
parent 8cdbaf3007
commit 3d79db6afb

@ -76,7 +76,10 @@ class _ServicesListPageState extends State<ServicesListPage> {
);
context.read<ServiceVM>().applyFilterOnBranchServices(serviceStatusEnum: status);
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;
setState(() {});
}
@ -132,38 +135,44 @@ class _ServicesListPageState extends State<ServicesListPage> {
],
),
),
// TODO: NEED TO CONFIRM CATEGORY DEACTIVATION FROM ZAHOOR
const Expanded(
Expanded(
flex: 4,
child: Column(
children: [
// LocaleKeys.active.tr().toText(fontSize: 16),
// 8.width,
// Container(
// width: 50,
// height: 30,
// decoration: BoxDecoration(
// color: isCategoryActive ? MyColors.darkPrimaryColor : MyColors.white,
// borderRadius: BorderRadius.circular(25.0),
// border: Border.all(color: MyColors.lightTextColor, width: 1),
// ),
// child: Transform.scale(
// scale: 0.8,
// child: CupertinoSwitch(
// activeColor: MyColors.darkPrimaryColor,
// trackColor: MyColors.white,
// thumbColor: MyColors.greyACColor,
// value: isCategoryActive,
// onChanged: (value) async {
// if (isEditDisabled) return;
// isCategoryActive = value;
// // isCategoryActive = await updateServiceStatus(context, value);
// setState(() {});
// },
// ),
// ),
// ),
LocaleKeys.active.tr().toText(fontSize: 16),
8.width,
Container(
width: 50,
height: 30,
decoration: BoxDecoration(
color: isCategoryActive ? MyColors.darkPrimaryColor : MyColors.white,
borderRadius: BorderRadius.circular(25.0),
border: Border.all(color: MyColors.lightTextColor, width: 1),
),
child: Transform.scale(
scale: 0.8,
child: CupertinoSwitch(
activeColor: MyColors.darkPrimaryColor,
trackColor: MyColors.white,
thumbColor: MyColors.greyACColor,
value: isCategoryActive,
onChanged: (value) async {
if (isEditDisabled) return;
final status = await updateCategoryStatus(
isCategoryActive: value,
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);
}
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
Widget build(BuildContext context) {
categoryData = ModalRoute.of(context)!.settings.arguments as CategoryData;

@ -109,6 +109,7 @@ class HomeFragment extends StatelessWidget {
isAdsFragment: false,
adsList: adVM.myActiveAdsForHome,
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,
isAdsFragment: false,
scrollPhysics: const NeverScrollableScrollPhysics(),
hasMoreData: adVM.isExploreAdsTapped ? adVM.hasMoreDataForExploreAds : adVM.hasMoreDataForMyAds,
),
],
)

Loading…
Cancel
Save