fix home problem

This commit is contained in:
amirrezaghabeli
2025-09-07 12:29:25 +03:30
parent 6ad3fe723f
commit 79d986c12d
3 changed files with 101 additions and 110 deletions
+36 -39
View File
@@ -181,50 +181,47 @@ class MobileHomePage extends StatelessWidget {
}
Widget _bottomListView(HomeViewModel homeViewModel) {
final controller = ScrollController();
controller.addListener(() {
if (!homeViewModel.isRecommendedMode) {
// YourTenders
if (controller.position.pixels >=
controller.position.maxScrollExtent - 200) {
if (!homeViewModel.isLoadingMore && homeViewModel.hasMore) {
homeViewModel.getYourTenders();
}
}
} else {
// Recommended
if (controller.position.pixels >=
controller.position.maxScrollExtent - 200) {
if (!homeViewModel.isLoadingMore && homeViewModel.hasMore) {
homeViewModel.getHomeRecommendTenders();
}
}
}
});
return Container(
constraints: BoxConstraints(maxHeight: 387.0.h()),
width: double.infinity,
child: ListView.builder(
controller: controller,
padding: EdgeInsets.symmetric(horizontal: 24.0.w(), vertical: 15.0.h()),
itemCount:
homeViewModel.tenders.length +
(homeViewModel.isLoadingMore ? 1 : 0),
scrollDirection: Axis.horizontal,
itemBuilder: (context, index) {
if (index < homeViewModel.tenders.length) {
return TendersListItem(tender: homeViewModel.tenders[index]);
} else {
return Center(
child: Padding(
padding: EdgeInsets.all(16.0),
child: CircularProgressIndicator(color: AppColors.secondary50),
),
);
child: NotificationListener<ScrollNotification>(
onNotification: (ScrollNotification scrollInfo) {
if (scrollInfo.metrics.pixels >=
scrollInfo.metrics.maxScrollExtent - 200) {
if (!homeViewModel.isLoadingMore && homeViewModel.hasMore) {
if (!homeViewModel.isRecommendedMode) {
homeViewModel.getYourTenders();
} else {
homeViewModel.getHomeRecommendTenders();
}
}
}
return false;
},
child: ListView.builder(
padding: EdgeInsets.symmetric(
horizontal: 24.0.w(),
vertical: 15.0.h(),
),
itemCount:
homeViewModel.tenders.length +
(homeViewModel.isLoadingMore ? 1 : 0),
scrollDirection: Axis.horizontal,
itemBuilder: (context, index) {
if (index < homeViewModel.tenders.length) {
return TendersListItem(tender: homeViewModel.tenders[index]);
} else {
return Center(
child: Padding(
padding: EdgeInsets.all(16.0),
child: CircularProgressIndicator(
color: AppColors.secondary50,
),
),
);
}
},
),
),
);
}