From 4c9a09866b6fea3bbb1ab17b9ecacdd4a048fd91 Mon Sep 17 00:00:00 2001 From: laurenspriem Date: Wed, 11 Jun 2025 11:23:41 +0530 Subject: [PATCH] Use slivers instead --- .../result/people_section_all_page.dart | 47 ++++++++++--------- 1 file changed, 26 insertions(+), 21 deletions(-) diff --git a/mobile/lib/ui/viewer/search/result/people_section_all_page.dart b/mobile/lib/ui/viewer/search/result/people_section_all_page.dart index e363f150fb..1538df104a 100644 --- a/mobile/lib/ui/viewer/search/result/people_section_all_page.dart +++ b/mobile/lib/ui/viewer/search/result/people_section_all_page.dart @@ -140,16 +140,16 @@ class _PeopleSectionAllWidgetState extends State { ((crossAxisCount - 1) * gridPadding))) / crossAxisCount; - return Column( - children: [ - Expanded( - child: GridView.builder( - padding: const EdgeInsets.fromLTRB( - horizontalEdgePadding, - 16, - horizontalEdgePadding, - 96, - ), + return CustomScrollView( + slivers: [ + SliverPadding( + padding: const EdgeInsets.fromLTRB( + horizontalEdgePadding, + 16, + horizontalEdgePadding, + 96, + ), + sliver: SliverGrid( gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( mainAxisSpacing: gridPadding, crossAxisSpacing: gridPadding, @@ -157,17 +157,23 @@ class _PeopleSectionAllWidgetState extends State { childAspectRatio: itemSize / (itemSize + (24 * textScaleFactor)), ), - itemCount: results.length, - itemBuilder: (context, index) { - return PersonSearchExample( - searchResult: results[index], - size: itemSize, - selectedPeople: widget.selectedPeople, - ); - }, + delegate: SliverChildBuilderDelegate( + childCount: results.length, + (context, index) { + return PersonSearchExample( + searchResult: results[index], + size: itemSize, + selectedPeople: widget.selectedPeople, + ); + }, + ), ), ), - if (_showMoreLessOption) _buildShowMoreButton(context), + if (_showMoreLessOption) + SliverToBoxAdapter(child: _buildShowMoreButton(context)), + const SliverToBoxAdapter( + child: SizedBox(height: 96), + ), ], ); } @@ -181,7 +187,7 @@ class _PeopleSectionAllWidgetState extends State { child: SizedBox( width: double.infinity, child: TextButton( - onPressed: () async { + onPressed: () { if (_showingAllFaces) { setState(() { _showingAllFaces = false; @@ -192,7 +198,6 @@ class _PeopleSectionAllWidgetState extends State { } else { setState(() { _showingAllFaces = true; - sectionData = (normalFaces.isNotEmpty && extraFaces.isNotEmpty) ? Future.value([...normalFaces, ...extraFaces]) : getResults();