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,
|
required super.child,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
static final memoryCountNotifier = ValueNotifier<int?>(null);
|
||||||
|
|
||||||
static InheritedLocationScreenState of(BuildContext context) {
|
static InheritedLocationScreenState of(BuildContext context) {
|
||||||
return context
|
return context
|
||||||
.dependOnInheritedWidgetOfExactType<InheritedLocationScreenState>()!;
|
.dependOnInheritedWidgetOfExactType<InheritedLocationScreenState>()!;
|
||||||
|
|
|
@ -66,6 +66,12 @@ class _LocationGalleryWidgetState extends State<LocationGalleryWidget> {
|
||||||
super.initState();
|
super.initState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
InheritedLocationScreenState.memoryCountNotifier.value = null;
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
//Todo: get radius of location tag here.
|
//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",
|
"Time taken to get all files in a location tag: ${stopWatch.elapsedMilliseconds} ms",
|
||||||
);
|
);
|
||||||
stopWatch.stop();
|
stopWatch.stop();
|
||||||
// widget.memoriesCountNotifier.value = copyOfFiles.length;
|
InheritedLocationScreenState.memoryCountNotifier.value =
|
||||||
|
copyOfFiles.length;
|
||||||
|
|
||||||
return Future.value(
|
return Future.value(
|
||||||
FileLoadResult(
|
FileLoadResult(
|
||||||
|
@ -126,12 +133,7 @@ class _LocationGalleryWidgetState extends State<LocationGalleryWidget> {
|
||||||
tagPrefix: "location_gallery",
|
tagPrefix: "location_gallery",
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return Column(
|
return galleryHeaderWidget;
|
||||||
children: [
|
|
||||||
galleryHeaderWidget,
|
|
||||||
const EnteLoadingWidget(),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
future: filterFiles(),
|
future: filterFiles(),
|
||||||
|
@ -171,10 +173,27 @@ class _GalleryHeaderWidgetState extends State<GalleryHeaderWidget> {
|
||||||
title: locationName,
|
title: locationName,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Text(
|
ValueListenableBuilder(
|
||||||
"51 memories",
|
valueListenable:
|
||||||
style: getEnteTextTheme(context).smallMuted,
|
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