diff --git a/mobile/lib/ui/home/memories/full_screen_memory.dart b/mobile/lib/ui/home/memories/full_screen_memory.dart index 4cca88027c..a72f33fbb3 100644 --- a/mobile/lib/ui/home/memories/full_screen_memory.dart +++ b/mobile/lib/ui/home/memories/full_screen_memory.dart @@ -741,6 +741,7 @@ class _MemoriesZoomWidgetState extends State : ClipRect( child: AnimatedBuilder( animation: _controller, + child: widget.child, builder: (context, child) { return Transform.scale( scale: _scaleAnimation.value, @@ -749,7 +750,7 @@ class _MemoriesZoomWidgetState extends State _panAnimation.value.dx * 100, _panAnimation.value.dy * 100, ), - child: widget.child, + child: child, ), ); }, diff --git a/mobile/lib/ui/home/memories/memories_widget.dart b/mobile/lib/ui/home/memories/memories_widget.dart index 5a47a7c46f..40d0b272f0 100644 --- a/mobile/lib/ui/home/memories/memories_widget.dart +++ b/mobile/lib/ui/home/memories/memories_widget.dart @@ -20,12 +20,11 @@ class MemoriesWidget extends StatefulWidget { } class _MemoriesWidgetState extends State { - late ScrollController _controller; late StreamSubscription _memoriesSettingSubscription; late StreamSubscription _memoriesChangedSubscription; late StreamSubscription _memorySeenSubscription; - late double _maxHeight; - late double _maxWidth; + late double _memoryheight; + late double _memoryWidth; @override void initState() { @@ -48,7 +47,6 @@ class _MemoriesWidgetState extends State { setState(() {}); } }); - _controller = ScrollController(); } @override @@ -57,8 +55,8 @@ class _MemoriesWidgetState extends State { final screenWidth = MediaQuery.sizeOf(context).width; //factor will be 2 for most phones in portrait mode final factor = (screenWidth / 220).ceil(); - _maxWidth = screenWidth / (factor * 2); - _maxHeight = _maxWidth / MemoryCoverWidget.aspectRatio; + _memoryWidth = screenWidth / (factor * 2); + _memoryheight = _memoryWidth / MemoryCoverWidget.aspectRatio; } @override @@ -66,7 +64,6 @@ class _MemoriesWidgetState extends State { _memoriesSettingSubscription.cancel(); _memoriesChangedSubscription.cancel(); _memorySeenSubscription.cancel(); - _controller.dispose(); super.dispose(); } @@ -84,7 +81,7 @@ class _MemoriesWidgetState extends State { builder: (context, snapshot) { if (snapshot.hasError || !snapshot.hasData) { return SizedBox( - height: _maxHeight + 12 + 10, + height: _memoryheight + 12 + 10, child: const EnteLoadingWidget(), ); } else { @@ -121,21 +118,19 @@ class _MemoriesWidgetState extends State { collatedMemories.addAll(seenMemories.map((e) => (e.memories, e.title))); return SizedBox( - height: _maxHeight + MemoryCoverWidget.outerStrokeWidth * 2, + height: _memoryheight + MemoryCoverWidget.outerStrokeWidth * 2, child: ListView.builder( physics: const AlwaysScrollableScrollPhysics( parent: BouncingScrollPhysics(), ), scrollDirection: Axis.horizontal, - controller: _controller, itemCount: collatedMemories.length, itemBuilder: (context, itemIndex) { return MemoryCoverWidget( memories: collatedMemories[itemIndex].$1, allMemories: collatedMemories.map((e) => e.$1).toList(), - controller: _controller, - maxHeight: _maxHeight, - maxWidth: _maxWidth, + maxHeight: _memoryheight, + maxWidth: _memoryWidth, title: collatedMemories[itemIndex].$2, allTitle: collatedMemories.map((e) => e.$2).toList(), currentMemoryIndex: itemIndex, diff --git a/mobile/lib/ui/home/memories/memory_cover_widget.dart b/mobile/lib/ui/home/memories/memory_cover_widget.dart index 6850d332a6..cfa77bbdda 100644 --- a/mobile/lib/ui/home/memories/memory_cover_widget.dart +++ b/mobile/lib/ui/home/memories/memory_cover_widget.dart @@ -12,7 +12,6 @@ import "package:photos/utils/navigation_util.dart"; class MemoryCoverWidget extends StatefulWidget { final List memories; final List> allMemories; - final ScrollController controller; final double maxHeight; final double maxWidth; static const outerStrokeWidth = 1.0; @@ -25,7 +24,6 @@ class MemoryCoverWidget extends StatefulWidget { const MemoryCoverWidget({ required this.memories, required this.allMemories, - required this.controller, required this.maxHeight, required this.maxWidth, required this.title, @@ -61,160 +59,162 @@ class _MemoryCoverWidgetState extends State { final brightness = SchedulerBinding.instance.platformDispatcher.platformBrightness; - return AnimatedBuilder( - animation: widget.controller, - builder: (context, child) { - return Padding( - padding: const EdgeInsets.symmetric( - horizontal: MemoryCoverWidget.horizontalPadding, - ), - child: GestureDetector( - onTap: () async { - await routeToPage( - context, - forceCustomPageRoute: true, - AllMemoriesPage( - initialPageIndex: widget.currentMemoryIndex, - allMemories: widget.allMemories, - allTitles: widget.allTitle, - ), - ); - setState(() {}); - }, //Adding this row is a workaround for making height of memory cover - //render as [MemoryCoverWidgetNew.height] * scale. Without this, height of rendered memory - //cover will be [MemoryCoverWidgetNew.height]. - child: Row( - children: [ - Container( - height: widget.maxHeight, - width: widget.maxWidth, - decoration: BoxDecoration( - boxShadow: brightness == Brightness.dark - ? [ - const BoxShadow( - color: strokeFainterDark, - spreadRadius: MemoryCoverWidget.outerStrokeWidth, - blurRadius: 0, - ), - ] - : [...shadowFloatFaintestLight], - borderRadius: BorderRadius.circular(5), - ), - child: ClipRRect( - borderRadius: BorderRadius.circular(5), - child: isSeen - ? ColorFiltered( - colorFilter: const ColorFilter.mode( - Color(0xFFBFBFBF), - BlendMode.hue, - ), - child: Stack( - fit: StackFit.expand, - alignment: Alignment.bottomCenter, - children: [ - child!, - Container( - decoration: BoxDecoration( - gradient: LinearGradient( - colors: [ - Colors.black.withOpacity(0.5), - Colors.transparent, - ], - stops: const [0, 1], - begin: Alignment.bottomCenter, - end: Alignment.topCenter, - ), - ), - ), - Positioned( - bottom: 8, - child: SizedBox( - width: widget.maxWidth, - child: Padding( - padding: const EdgeInsets.symmetric( - horizontal: 8.0, - ), - child: Hero( - tag: title, - child: Center( - child: Text( - title, - style: getEnteTextTheme(context) - .miniBold - .copyWith( - color: isSeen - ? textFaintDark - : Colors.white, - ), - textAlign: TextAlign.left, - ), - ), - ), - ), - ), - ), - ], - ), - ) - : Stack( - fit: StackFit.expand, - alignment: Alignment.bottomCenter, - children: [ - child!, - Container( - decoration: BoxDecoration( - gradient: LinearGradient( - colors: [ - Colors.black.withOpacity(0.5), - Colors.transparent, - ], - stops: const [0, 1], - begin: Alignment.bottomCenter, - end: Alignment.topCenter, - ), - ), - ), - Positioned( - bottom: 8, - child: SizedBox( - width: widget.maxWidth, - child: Padding( - padding: const EdgeInsets.symmetric( - horizontal: 8.0, - ), - child: Hero( - tag: title, - child: Center( - child: Text( - title, - style: getEnteTextTheme(context) - .miniBold - .copyWith( - color: Colors.white, - ), - textAlign: TextAlign.left, - ), - ), - ), - ), - ), - ), - ], - ), - ), - ), - ], + return Padding( + padding: const EdgeInsets.symmetric( + horizontal: MemoryCoverWidget.horizontalPadding, + ), + child: GestureDetector( + onTap: () async { + await routeToPage( + context, + forceCustomPageRoute: true, + AllMemoriesPage( + initialPageIndex: widget.currentMemoryIndex, + allMemories: widget.allMemories, + allTitles: widget.allTitle, ), - ), - ); - }, - child: Hero( - tag: "memories" + memory.file.tag, - child: ThumbnailWidget( - memory.file, - shouldShowArchiveStatus: false, - shouldShowSyncStatus: false, - key: Key("memories" + memory.file.tag), + ); + setState(() {}); + }, //Adding this row is a workaround for making height of memory cover + //render as [MemoryCoverWidgetNew.height] * scale. Without this, height of rendered memory + //cover will be [MemoryCoverWidgetNew.height]. + child: Row( + children: [ + Container( + height: widget.maxHeight, + width: widget.maxWidth, + decoration: BoxDecoration( + boxShadow: brightness == Brightness.dark + ? [ + const BoxShadow( + color: strokeFainterDark, + spreadRadius: MemoryCoverWidget.outerStrokeWidth, + blurRadius: 0, + ), + ] + : [...shadowFloatFaintestLight], + borderRadius: BorderRadius.circular(5), + ), + child: ClipRRect( + borderRadius: BorderRadius.circular(5), + child: isSeen + ? ColorFiltered( + colorFilter: const ColorFilter.mode( + Color(0xFFBFBFBF), + BlendMode.hue, + ), + child: Stack( + fit: StackFit.expand, + alignment: Alignment.bottomCenter, + children: [ + Hero( + tag: "memories" + memory.file.tag, + child: ThumbnailWidget( + memory.file, + shouldShowArchiveStatus: false, + shouldShowSyncStatus: false, + key: Key("memories" + memory.file.tag), + ), + ), + Container( + decoration: BoxDecoration( + gradient: LinearGradient( + colors: [ + Colors.black.withOpacity(0.5), + Colors.transparent, + ], + stops: const [0, 1], + begin: Alignment.bottomCenter, + end: Alignment.topCenter, + ), + ), + ), + Positioned( + bottom: 8, + child: SizedBox( + width: widget.maxWidth, + child: Padding( + padding: const EdgeInsets.symmetric( + horizontal: 8.0, + ), + child: Hero( + tag: title, + child: Center( + child: Text( + title, + style: getEnteTextTheme(context) + .miniBold + .copyWith( + color: isSeen + ? textFaintDark + : Colors.white, + ), + textAlign: TextAlign.left, + ), + ), + ), + ), + ), + ), + ], + ), + ) + : Stack( + fit: StackFit.expand, + alignment: Alignment.bottomCenter, + children: [ + Hero( + tag: "memories" + memory.file.tag, + child: ThumbnailWidget( + memory.file, + shouldShowArchiveStatus: false, + shouldShowSyncStatus: false, + key: Key("memories" + memory.file.tag), + ), + ), + Container( + decoration: BoxDecoration( + gradient: LinearGradient( + colors: [ + Colors.black.withOpacity(0.5), + Colors.transparent, + ], + stops: const [0, 1], + begin: Alignment.bottomCenter, + end: Alignment.topCenter, + ), + ), + ), + Positioned( + bottom: 8, + child: SizedBox( + width: widget.maxWidth, + child: Padding( + padding: const EdgeInsets.symmetric( + horizontal: 8.0, + ), + child: Hero( + tag: title, + child: Center( + child: Text( + title, + style: getEnteTextTheme(context) + .miniBold + .copyWith( + color: Colors.white, + ), + textAlign: TextAlign.left, + ), + ), + ), + ), + ), + ), + ], + ), + ), + ), + ], ), ), ); @@ -222,11 +222,13 @@ class _MemoryCoverWidgetState extends State { void _preloadFirstUnseenMemory() { Future.delayed(const Duration(seconds: 5), () { - if (widget.memories.isEmpty) return; + if (mounted) { + if (widget.memories.isEmpty) return; - final index = _getNextMemoryIndex(); - preloadThumbnail(widget.memories[index].file); - preloadFile(widget.memories[index].file); + final index = _getNextMemoryIndex(); + preloadThumbnail(widget.memories[index].file); + preloadFile(widget.memories[index].file); + } }); }