Skip to content

armgit / ente

Public Imported from GitHub
0

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

[mob][photos] Adapt memories viewer scrim

ashilkn7044a0d2c252
diff --git a/mobile/apps/photos/changes/memory-viewer-adaptive-scrim.md b/mobile/apps/photos/changes/memory-viewer-adaptive-scrim.md
new file mode 100644
index 0000000000..15dedcc723
--- /dev/null
+++ b/mobile/apps/photos/changes/memory-viewer-adaptive-scrim.md
@@ -0,0 +1 @@
+- Improved memory controls with a lighter backdrop that adapts to social actions.
diff --git a/mobile/apps/photos/lib/ui/home/memories/full_screen_memory.dart b/mobile/apps/photos/lib/ui/home/memories/full_screen_memory.dart
index c32584753e..790f713be1 100644
--- a/mobile/apps/photos/lib/ui/home/memories/full_screen_memory.dart
+++ b/mobile/apps/photos/lib/ui/home/memories/full_screen_memory.dart
@@ -6,6 +6,7 @@ import "package:connectivity_plus/connectivity_plus.dart";
import "package:ente_components/theme/text_styles.dart" as component;
import "package:ente_icons/ente_icons.dart";
import "package:ente_pure_utils/ente_pure_utils.dart";
+import "package:flutter/foundation.dart" show ValueListenable;
import "package:flutter/material.dart";
import "package:flutter/services.dart";
import "package:flutter_svg/flutter_svg.dart";
@@ -70,6 +71,9 @@ bool _isValidMemoryIndex(int index, int length) {
return index >= 0 && index < length;
}
+const _memoryBottomActionBarHeight = 80.0;
+const _memorySocialScrimHeight = 296.0;
+
class FullScreenMemoryDataUpdater extends StatefulWidget {
final List<Memory> memories;
final int initialIndex;
@@ -358,6 +362,7 @@ class _FullScreenMemoryState extends State<FullScreenMemory> {
// invalidates the prior delayed forward.
Object? _kenBurnsStartToken;
bool _isAnimationPaused = false;
+ final _socialControlsVisible = ValueNotifier<bool>(false);
/// Used to check if any pointer is on the screen.
final hasPointerOnScreenNotifier = ValueNotifier<bool>(false);
@@ -400,6 +405,7 @@ class _FullScreenMemoryState extends State<FullScreenMemory> {
void dispose() {
hasPointerOnScreenNotifier.removeListener(_hasPointerListener);
_detailSheetEventSubscription.cancel();
+ _socialControlsVisible.dispose();
_progressAnimationController = null;
_zoomAnimationController = null;
_kenBurnsStartToken = null;
@@ -531,6 +537,7 @@ class _FullScreenMemoryState extends State<FullScreenMemory> {
inheritedData.indexNotifier.value += 1;
_onPageChange(inheritedData, currentIndex + 1);
} else if (widget.onNextMemory != null) {
+ _setSocialControlsVisible(false);
widget.onNextMemory!();
} else {
isAtFirstOrLastFile = true;
@@ -550,6 +557,7 @@ class _FullScreenMemoryState extends State<FullScreenMemory> {
inheritedData.indexNotifier.value -= 1;
_onPageChange(inheritedData, currentIndex - 1);
} else if (widget.onPreviousMemory != null) {
+ _setSocialControlsVisible(false);
widget.onPreviousMemory!();
} else {
isAtFirstOrLastFile = true;
@@ -560,6 +568,7 @@ class _FullScreenMemoryState extends State<FullScreenMemory> {
void _onPageChange(FullScreenMemoryData inheritedData, int index) {
if (!_isValidMemoryIndex(index, inheritedData.memories.length)) return;
+ _setSocialControlsVisible(false);
isAtFirstOrLastFile = false;
unawaited(
memoriesCacheService.markMemoryAsSeen(
@@ -571,6 +580,12 @@ class _FullScreenMemoryState extends State<FullScreenMemory> {
_resetAnimation();
}
+ void _setSocialControlsVisible(bool visible) {
+ if (_socialControlsVisible.value != visible) {
+ _socialControlsVisible.value = visible;
+ }
+ }
+
Future<T?> _runWithViewerPaused<T>(Future<T> Function() action) async {
if (!mounted) return null;
_pauseViewer();
@@ -699,7 +714,7 @@ class _FullScreenMemoryState extends State<FullScreenMemory> {
);
},
),
- const _MemoryViewerScrims(),
+ _MemoryViewerScrims(socialControlsVisible: _socialControlsVisible),
ValueListenableBuilder<int>(
valueListenable: inheritedData.indexNotifier,
builder: (context, index, _) {
@@ -713,6 +728,7 @@ class _FullScreenMemoryState extends State<FullScreenMemory> {
currentUserID: Configuration.instance.getUserID(),
onInteractionStart: _pauseViewer,
onInteractionEnd: _resumeViewer,
+ onVisibilityChanged: _setSocialControlsVisible,
);
},
),
@@ -850,6 +866,7 @@ class BottomIcons extends StatelessWidget {
context,
actionFile,
onFileRemoved: (file) {
+ fullScreenState._setSocialControlsVisible(false);
fullScreenState.hasFinalFileLoaded = false;
fullScreenState._resetAnimation();
inheritedData.removeCurrentMemory();
@@ -1069,7 +1086,9 @@ class _MemoryTopChrome extends StatelessWidget {
}
class _MemoryViewerScrims extends StatelessWidget {
- const _MemoryViewerScrims();
+ final ValueListenable<bool> socialControlsVisible;
+
+ const _MemoryViewerScrims({required this.socialControlsVisible});
@override
Widget build(BuildContext context) {
@@ -1099,25 +1118,33 @@ class _MemoryViewerScrims extends StatelessWidget {
),
),
),
- const Align(
+ Align(
alignment: Alignment.bottomCenter,
- child: SizedBox(
- width: double.infinity,
- height: 200,
- child: DecoratedBox(
- decoration: BoxDecoration(
- gradient: LinearGradient(
- begin: Alignment.topCenter,
- end: Alignment.bottomCenter,
- colors: [
- Colors.transparent,
- Color(0x8A000000),
- Colors.black,
- ],
- stops: [0, 0.55, 1],
+ child: ValueListenableBuilder<bool>(
+ valueListenable: socialControlsVisible,
+ builder: (context, isVisible, _) {
+ final bottomInset = MediaQuery.paddingOf(context).bottom;
+ return AnimatedContainer(
+ duration: const Duration(milliseconds: 200),
+ curve: Curves.easeOut,
+ width: double.infinity,
+ height: isVisible
+ ? _memorySocialScrimHeight
+ : bottomInset + _memoryBottomActionBarHeight,
+ decoration: const BoxDecoration(
+ gradient: LinearGradient(
+ begin: Alignment.bottomCenter,
+ end: Alignment.topCenter,
+ colors: [
+ Color.fromARGB(97, 0, 0, 0),
+ Color.fromARGB(42, 0, 0, 0),
+ Colors.transparent,
+ ],
+ stops: [0, 0.5, 1],
+ ),
),
- ),
- ),
+ );
+ },
),
),
],
diff --git a/mobile/apps/photos/lib/ui/social/widgets/file_social_overlay.dart b/mobile/apps/photos/lib/ui/social/widgets/file_social_overlay.dart
index 5bbc5c4117..26ec33ed5a 100644
--- a/mobile/apps/photos/lib/ui/social/widgets/file_social_overlay.dart
+++ b/mobile/apps/photos/lib/ui/social/widgets/file_social_overlay.dart
@@ -34,6 +34,7 @@ class FileSocialOverlay extends StatefulWidget {
final int? currentUserID;
final VoidCallback onInteractionStart;
final VoidCallback onInteractionEnd;
+ final ValueChanged<bool> onVisibilityChanged;
final bool includeHiddenCollections;
const FileSocialOverlay({
@@ -41,6 +42,7 @@ class FileSocialOverlay extends StatefulWidget {
required this.currentUserID,
required this.onInteractionStart,
required this.onInteractionEnd,
+ required this.onVisibilityChanged,
this.includeHiddenCollections = false,
super.key,
});
@@ -124,6 +126,7 @@ class _FileSocialOverlayState extends State<FileSocialOverlay> {
if (sharedCollections.isEmpty) {
setState(_clearSocialState);
+ widget.onVisibilityChanged(false);
return;
}
@@ -168,6 +171,7 @@ class _FileSocialOverlayState extends State<FileSocialOverlay> {
_latestComment = latestComment;
_latestCommentAuthor = latestCommentAuthor;
});
+ widget.onVisibilityChanged(true);
} catch (error, stackTrace) {
_logger.warning(
"Failed to refresh social overlay for file $fileID",