From dba3668c4cd00ac6c08075090753c3bfc91c5e59 Mon Sep 17 00:00:00 2001 From: MohammadTaha Basiri Date: Mon, 15 Apr 2024 22:38:05 +0330 Subject: [PATCH] "Update SearchPage itemBuilder to load more results and fix Checkbox layout" The SearchPage's itemBuilder has been updated to load more results as the user scrolls down. It now checks if the current index is a multiple of --- lib/views/home/search/search.dart | 19 +++++++++++++------ lib/views/widgets/didvan/checkbox.dart | 1 - 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/lib/views/home/search/search.dart b/lib/views/home/search/search.dart index b9d668f..86d5ae8 100644 --- a/lib/views/home/search/search.dart +++ b/lib/views/home/search/search.dart @@ -30,12 +30,19 @@ class SearchPage extends StatelessWidget { builder: (context, state) => ListView.builder( padding: const EdgeInsets.all(16) .copyWith(top: state.selectedCats.length <= 1 ? 72 : 16), - itemBuilder: (context, index) => Padding( - padding: const EdgeInsets.only(bottom: 8), - child: SearchResultItem( - item: state.results[index], - ), - ), + itemBuilder: (context, index) { + index += 2; + if (index % 15 == 0 && state.lastPage != state.page) { + state.searchAll(page: state.page + 1); + } + index -= 2; + return Padding( + padding: const EdgeInsets.only(bottom: 8), + child: SearchResultItem( + item: state.results[index], + ), + ); + }, itemCount: state.results.length, ), ), diff --git a/lib/views/widgets/didvan/checkbox.dart b/lib/views/widgets/didvan/checkbox.dart index d606663..e0df308 100644 --- a/lib/views/widgets/didvan/checkbox.dart +++ b/lib/views/widgets/didvan/checkbox.dart @@ -49,7 +49,6 @@ class _DidvanCheckboxState extends State { widget.onChanged(_value); }, ), - const SizedBox(width: 4), DidvanText(widget.title), ], ),