diff --git a/lib/src/views/chats/chat_messages_components/in_chat_media_viewer.dart b/lib/src/views/chats/chat_messages_components/in_chat_media_viewer.dart index 206c518..77fed7d 100644 --- a/lib/src/views/chats/chat_messages_components/in_chat_media_viewer.dart +++ b/lib/src/views/chats/chat_messages_components/in_chat_media_viewer.dart @@ -97,8 +97,9 @@ class _InChatMediaViewerState extends State { if (galleryItemIndex == null) return; await Navigator.push( context, - MaterialPageRoute( - builder: (context) => MemoriesPhotoSliderView( + PageRouteBuilder( + opaque: false, + pageBuilder: (context, a1, a2) => MemoriesPhotoSliderView( galleryItems: widget.galleryItems, initialIndex: galleryItemIndex!, ), diff --git a/lib/src/views/memories/memories.view.dart b/lib/src/views/memories/memories.view.dart index fcf015a..2d16c24 100644 --- a/lib/src/views/memories/memories.view.dart +++ b/lib/src/views/memories/memories.view.dart @@ -166,14 +166,22 @@ class MemoriesViewState extends State { Future open(BuildContext context, int index) async { await Navigator.push( context, - MaterialPageRoute( - builder: (context) => MemoriesPhotoSliderView( + PageRouteBuilder( + opaque: false, + pageBuilder: (context, a1, a2) => MemoriesPhotoSliderView( galleryItems: galleryItems, initialIndex: index, scrollDirection: verticalGallery ? Axis.vertical : Axis.horizontal, ), + // transitionsBuilder: (context, animation, secondaryAnimation, child) { + // return child; + // }, + // transitionDuration: Duration.zero, + // reverseTransitionDuration: Duration.zero, ), - ); + ) as bool?; + setState(() {}); + await initAsync(); } } diff --git a/lib/src/views/memories/memories_photo_slider.view.dart b/lib/src/views/memories/memories_photo_slider.view.dart index f811656..62512d5 100644 --- a/lib/src/views/memories/memories_photo_slider.view.dart +++ b/lib/src/views/memories/memories_photo_slider.view.dart @@ -19,7 +19,6 @@ class MemoriesPhotoSliderView extends StatefulWidget { required this.galleryItems, super.key, this.loadingBuilder, - this.backgroundDecoration, this.minScale, this.maxScale, this.initialIndex = 0, @@ -27,7 +26,6 @@ class MemoriesPhotoSliderView extends StatefulWidget { }) : pageController = PageController(initialPage: initialIndex); final LoadingBuilder? loadingBuilder; - final BoxDecoration? backgroundDecoration; final dynamic minScale; final dynamic maxScale; final int initialIndex; @@ -43,6 +41,7 @@ class MemoriesPhotoSliderView extends StatefulWidget { class _MemoriesPhotoSliderViewState extends State { late int currentIndex = widget.initialIndex; + final GlobalKey> key = GlobalKey(); void onPageChanged(int index) { setState(() { @@ -102,97 +101,108 @@ class _MemoriesPhotoSliderViewState extends State { @override Widget build(BuildContext context) { - return Scaffold( - body: Container( - decoration: widget.backgroundDecoration, - constraints: BoxConstraints.expand( - height: MediaQuery.of(context).size.height, - ), - child: Stack( - alignment: Alignment.bottomRight, - children: [ - MediaViewSizing( - bottomNavigation: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - FilledButton.icon( - icon: const FaIcon(FontAwesomeIcons.solidPaperPlane), - onPressed: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => ShareImageEditorView( - videoFilePath: - widget.galleryItems[currentIndex].videoPath, - imageBytes: widget - .galleryItems[currentIndex].imagePath - ?.readAsBytes(), - mirrorVideo: false, - sharedFromGallery: true, - useHighQuality: true, + return Dismissible( + key: key, + direction: DismissDirection.vertical, + resizeDuration: null, + onDismissed: (d) { + Navigator.pop(context, false); + }, + child: Scaffold( + backgroundColor: Colors.white.withAlpha(0), + body: Container( + color: context.color.surface, + constraints: BoxConstraints.expand( + height: MediaQuery.of(context).size.height, + ), + child: Stack( + alignment: Alignment.bottomRight, + children: [ + MediaViewSizing( + bottomNavigation: Container( + color: context.color.surface, + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + FilledButton.icon( + icon: const FaIcon(FontAwesomeIcons.solidPaperPlane), + onPressed: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => ShareImageEditorView( + videoFilePath: + widget.galleryItems[currentIndex].videoPath, + imageBytes: widget + .galleryItems[currentIndex].imagePath + ?.readAsBytes(), + mirrorVideo: false, + sharedFromGallery: true, + useHighQuality: true, + ), + ), + ); + }, + style: ButtonStyle( + padding: WidgetStateProperty.all( + const EdgeInsets.symmetric( + vertical: 10, horizontal: 30), + ), + backgroundColor: WidgetStateProperty.all( + Theme.of(context).colorScheme.primary, + )), + label: Text( + context.lang.shareImagedEditorSendImage, + style: const TextStyle(fontSize: 17), + ), + ), + ], + ), + ), + child: Stack( + children: [ + PhotoViewGallery.builder( + scrollPhysics: const BouncingScrollPhysics(), + builder: _buildItem, + itemCount: widget.galleryItems.length, + loadingBuilder: widget.loadingBuilder, + pageController: widget.pageController, + onPageChanged: onPageChanged, + scrollDirection: widget.scrollDirection, + ), + Positioned( + right: 5, + child: PopupMenuButton( + onSelected: (String result) { + if (result == 'delete') { + deleteFile(); + } + if (result == 'export') { + exportFile(); + } + }, + itemBuilder: (BuildContext context) => + >[ + PopupMenuItem( + value: 'delete', + child: Text(context.lang.galleryDelete), ), - ), - ); - }, - style: ButtonStyle( - padding: WidgetStateProperty.all( - const EdgeInsets.symmetric( - vertical: 10, horizontal: 30), - ), - backgroundColor: WidgetStateProperty.all( - Theme.of(context).colorScheme.primary, - )), - label: Text( - context.lang.shareImagedEditorSendImage, - style: const TextStyle(fontSize: 17), - ), - ), - ], + PopupMenuItem( + value: 'export', + child: Text(context.lang.galleryExport), + ), + // PopupMenuItem( + // value: 'details', + // child: Text(context.lang.galleryDetails), + // ), + ], + ), + ) + ], + ), ), - child: Stack( - children: [ - PhotoViewGallery.builder( - scrollPhysics: const BouncingScrollPhysics(), - builder: _buildItem, - itemCount: widget.galleryItems.length, - loadingBuilder: widget.loadingBuilder, - backgroundDecoration: widget.backgroundDecoration, - pageController: widget.pageController, - onPageChanged: onPageChanged, - scrollDirection: widget.scrollDirection, - ), - Positioned( - right: 5, - child: PopupMenuButton( - onSelected: (String result) { - if (result == 'delete') { - deleteFile(); - } - if (result == 'export') { - exportFile(); - } - }, - itemBuilder: (BuildContext context) => - >[ - PopupMenuItem( - value: 'delete', - child: Text(context.lang.galleryDelete), - ), - PopupMenuItem( - value: 'export', - child: Text(context.lang.galleryExport), - ), - // PopupMenuItem( - // value: 'details', - // child: Text(context.lang.galleryDetails), - // ), - ], - ), - ) - ], - ), - ), - ], + ], + ), ), ), );