forked from eatvio/eatvio_app
feat(feed): add lazy loading
This commit is contained in:
@@ -57,11 +57,23 @@ class _FeedScreenState extends State<FeedScreen> {
|
||||
}
|
||||
}
|
||||
|
||||
_onScrollRecipes() {}
|
||||
_onScrollRecipes() {
|
||||
if (recipesScrollController.offset >= recipesScrollController.position.maxScrollExtent && !recipesScrollController.position.outOfRange) {
|
||||
recipesCubit.loadNextPage();
|
||||
}
|
||||
}
|
||||
|
||||
_onScrollDiets() {}
|
||||
_onScrollDiets() {
|
||||
if (dietsScrollController.offset >= dietsScrollController.position.maxScrollExtent && !dietsScrollController.position.outOfRange) {
|
||||
dietsCubit.loadNextPage();
|
||||
}
|
||||
}
|
||||
|
||||
_onScrollPlans() {}
|
||||
_onScrollPlans() {
|
||||
if (plansScrollController.offset >= plansScrollController.position.maxScrollExtent && !plansScrollController.position.outOfRange) {
|
||||
// plansCubit.loadNextPage();
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
@@ -133,16 +145,17 @@ class _FeedScreenState extends State<FeedScreen> {
|
||||
},
|
||||
body: Builder(
|
||||
builder: (BuildContext context) {
|
||||
if (_selectedChipIndex == 0)
|
||||
if (_selectedChipIndex == 0) {
|
||||
return _buildAllBlogPosts();
|
||||
else if (_selectedChipIndex == 1)
|
||||
} else if (_selectedChipIndex == 1) {
|
||||
return _buildAllRecipes();
|
||||
else if (_selectedChipIndex == 2)
|
||||
} else if (_selectedChipIndex == 2) {
|
||||
return _buildDiets();
|
||||
else if (_selectedChipIndex == 3)
|
||||
} else if (_selectedChipIndex == 3) {
|
||||
return _buildPlans();
|
||||
else
|
||||
} else {
|
||||
return Center(child: Text(chipsLabelList[_selectedChipIndex]));
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
@@ -274,12 +287,12 @@ class _FeedScreenState extends State<FeedScreen> {
|
||||
shrinkWrap: true,
|
||||
physics: BouncingScrollPhysics(),
|
||||
itemBuilder: (context, index) {
|
||||
return DietsWidget(diet: state.diets.data[index]);
|
||||
return DietsWidget(diet: state.dietsList[index]);
|
||||
},
|
||||
separatorBuilder: (context, index) {
|
||||
return SizedBox(height: 8);
|
||||
},
|
||||
itemCount: state.diets.data.length,
|
||||
itemCount: state.dietsList.length,
|
||||
);
|
||||
} else if (state is DietsStateError) {
|
||||
return Scaffold(
|
||||
|
||||
Reference in New Issue
Block a user