diff --git a/lib/states/location_screen_state.dart b/lib/states/location_screen_state.dart index f022ce351..4c4771d2b 100644 --- a/lib/states/location_screen_state.dart +++ b/lib/states/location_screen_state.dart @@ -9,6 +9,8 @@ class InheritedLocationScreenState extends InheritedWidget { required super.child, }); + static final memoryCountNotifier = ValueNotifier(null); + static InheritedLocationScreenState of(BuildContext context) { return context .dependOnInheritedWidgetOfExactType()!; diff --git a/lib/ui/viewer/location/location_screen.dart b/lib/ui/viewer/location/location_screen.dart index 284b90ec9..96c5da87b 100644 --- a/lib/ui/viewer/location/location_screen.dart +++ b/lib/ui/viewer/location/location_screen.dart @@ -66,6 +66,12 @@ class _LocationGalleryWidgetState extends State { 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 { "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 { tagPrefix: "location_gallery", ); } else { - return Column( - children: [ - galleryHeaderWidget, - const EnteLoadingWidget(), - ], - ); + return galleryHeaderWidget; } }, future: filterFiles(), @@ -171,10 +173,27 @@ class _GalleryHeaderWidgetState extends State { 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, + ); + } + }, + ) ], ), ),