Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

show loading icon when all search sections are getting loaded or reloaded

ashilkn9487c846a6e9
diff --git a/lib/states/all_sections_examples_state.dart b/lib/states/all_sections_examples_state.dart
index 376bb98f4b..1152ea17d1 100644
--- a/lib/states/all_sections_examples_state.dart
+++ b/lib/states/all_sections_examples_state.dart
@@ -78,6 +78,7 @@ class _AllSectionsExamplesProviderState
Widget build(BuildContext context) {
return InheritedAllSectionsExamples(
allSectionsExamplesFuture,
+ _debouncer.debounceActiveNotifier,
child: widget.child,
);
}
@@ -85,8 +86,10 @@ class _AllSectionsExamplesProviderState
class InheritedAllSectionsExamples extends InheritedWidget {
final Future<List<List<SearchResult>>> allSectionsExamplesFuture;
+ final ValueNotifier<bool> isDebouncingNotifier;
const InheritedAllSectionsExamples(
- this.allSectionsExamplesFuture, {
+ this.allSectionsExamplesFuture,
+ this.isDebouncingNotifier, {
super.key,
required super.child,
});
diff --git a/lib/ui/search_tab.dart b/lib/ui/search_tab.dart
index 56c1df518c..682c10bc1b 100644
--- a/lib/ui/search_tab.dart
+++ b/lib/ui/search_tab.dart
@@ -74,44 +74,59 @@ class _AllSearchSectionsState extends State<AllSearchSections> {
// remove face and content sectionType
searchTypes.remove(SectionType.face);
searchTypes.remove(SectionType.content);
- return FutureBuilder(
- future:
- InheritedAllSectionsExamples.of(context).allSectionsExamplesFuture,
- builder: (context, snapshot) {
- if (snapshot.hasData) {
- if (snapshot.data!.every((element) => element.isEmpty)) {
- return const Padding(
- padding: EdgeInsets.only(bottom: 72),
- child: SearchTabEmptyState(),
- );
- }
- return ListView.builder(
- padding: const EdgeInsets.only(bottom: 180),
- physics: const BouncingScrollPhysics(),
- itemCount: searchTypes.length,
- itemBuilder: (context, index) {
- return SearchSection(
- sectionType: searchTypes[index],
- examples: snapshot.data!.elementAt(index),
- limit: searchSectionLimit,
+ return Stack(
+ children: [
+ FutureBuilder(
+ future: InheritedAllSectionsExamples.of(context)
+ .allSectionsExamplesFuture,
+ builder: (context, snapshot) {
+ if (snapshot.hasData) {
+ if (snapshot.data!.every((element) => element.isEmpty)) {
+ return const Padding(
+ padding: EdgeInsets.only(bottom: 72),
+ child: SearchTabEmptyState(),
+ );
+ }
+ return ListView.builder(
+ padding: const EdgeInsets.only(bottom: 180),
+ physics: const BouncingScrollPhysics(),
+ itemCount: searchTypes.length,
+ itemBuilder: (context, index) {
+ return SearchSection(
+ sectionType: searchTypes[index],
+ examples: snapshot.data!.elementAt(index),
+ limit: searchSectionLimit,
+ );
+ },
);
- },
- );
- } else if (snapshot.hasError) {
- //todo: Show something went wrong here
- //Errors are handled and this else if condition will be false always
- //is the understanding.
- return const Padding(
- padding: EdgeInsets.only(bottom: 72),
- child: EnteLoadingWidget(),
- );
- } else {
- return const Padding(
- padding: EdgeInsets.only(bottom: 72),
- child: EnteLoadingWidget(),
- );
- }
- },
+ } else if (snapshot.hasError) {
+ //todo: Show something went wrong here
+ //Errors are handled and this else if condition will be false always
+ //is the understanding.
+ return const Padding(
+ padding: EdgeInsets.only(bottom: 72),
+ child: EnteLoadingWidget(),
+ );
+ } else {
+ return const Padding(
+ padding: EdgeInsets.only(bottom: 72),
+ child: EnteLoadingWidget(),
+ );
+ }
+ },
+ ),
+ ValueListenableBuilder(
+ valueListenable:
+ InheritedAllSectionsExamples.of(context).isDebouncingNotifier,
+ builder: (context, value, _) {
+ return value
+ ? const EnteLoadingWidget(
+ alignment: Alignment.topRight,
+ )
+ : const SizedBox.shrink();
+ },
+ ),
+ ],
);
}
}