Show loading state and memory count in 'Location' screen
This commit is contained in:
parent
f677b5d60c
commit
5ca5a1a241
2 changed files with 32 additions and 11 deletions
|
@ -9,6 +9,8 @@ class InheritedLocationScreenState extends InheritedWidget {
|
|||
required super.child,
|
||||
});
|
||||
|
||||
static final memoryCountNotifier = ValueNotifier<int?>(null);
|
||||
|
||||
static InheritedLocationScreenState of(BuildContext context) {
|
||||
return context
|
||||
.dependOnInheritedWidgetOfExactType<InheritedLocationScreenState>()!;
|
||||
|
|
|
@ -66,6 +66,12 @@ class _LocationGalleryWidgetState extends State<LocationGalleryWidget> {
|
|||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
InheritedLocationScreenState.memoryCountNotifier.value = null;
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
//Todo: get radius of location tag here.
|
||||
|
@ -93,7 +99,8 @@ class _LocationGalleryWidgetState extends State<LocationGalleryWidget> {
|
|||
"Time taken to get all files in a location tag: ${stopWatch.elapsedMilliseconds} ms",
|
||||
);
|
||||
stopWatch.stop();
|
||||
// widget.memoriesCountNotifier.value = copyOfFiles.length;
|
||||
InheritedLocationScreenState.memoryCountNotifier.value =
|
||||
copyOfFiles.length;
|
||||
|
||||
return Future.value(
|
||||
FileLoadResult(
|
||||
|
@ -126,12 +133,7 @@ class _LocationGalleryWidgetState extends State<LocationGalleryWidget> {
|
|||
tagPrefix: "location_gallery",
|
||||
);
|
||||
} else {
|
||||
return Column(
|
||||
children: [
|
||||
galleryHeaderWidget,
|
||||
const EnteLoadingWidget(),
|
||||
],
|
||||
);
|
||||
return galleryHeaderWidget;
|
||||
}
|
||||
},
|
||||
future: filterFiles(),
|
||||
|
@ -171,10 +173,27 @@ class _GalleryHeaderWidgetState extends State<GalleryHeaderWidget> {
|
|||
title: locationName,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
"51 memories",
|
||||
style: getEnteTextTheme(context).smallMuted,
|
||||
ValueListenableBuilder(
|
||||
valueListenable:
|
||||
InheritedLocationScreenState.memoryCountNotifier,
|
||||
builder: (context, value, _) {
|
||||
if (value == null) {
|
||||
return RepaintBoundary(
|
||||
child: EnteLoadingWidget(
|
||||
size: 10,
|
||||
color: getEnteColorScheme(context).strokeMuted,
|
||||
alignment: Alignment.centerLeft,
|
||||
padding: 5,
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return Text(
|
||||
value == 1 ? "1 memory" : "$value memories",
|
||||
style: getEnteTextTheme(context).smallMuted,
|
||||
);
|
||||
}
|
||||
},
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
|
|
Loading…
Add table
Reference in a new issue