This commit is contained in:
otsmr 2025-07-18 12:16:35 +02:00
parent 2b4ba6b81b
commit cd9a5bab97
3 changed files with 115 additions and 96 deletions

View file

@ -97,8 +97,9 @@ class _InChatMediaViewerState extends State<InChatMediaViewer> {
if (galleryItemIndex == null) return; if (galleryItemIndex == null) return;
await Navigator.push( await Navigator.push(
context, context,
MaterialPageRoute( PageRouteBuilder(
builder: (context) => MemoriesPhotoSliderView( opaque: false,
pageBuilder: (context, a1, a2) => MemoriesPhotoSliderView(
galleryItems: widget.galleryItems, galleryItems: widget.galleryItems,
initialIndex: galleryItemIndex!, initialIndex: galleryItemIndex!,
), ),

View file

@ -166,14 +166,22 @@ class MemoriesViewState extends State<MemoriesView> {
Future<void> open(BuildContext context, int index) async { Future<void> open(BuildContext context, int index) async {
await Navigator.push( await Navigator.push(
context, context,
MaterialPageRoute( PageRouteBuilder(
builder: (context) => MemoriesPhotoSliderView( opaque: false,
pageBuilder: (context, a1, a2) => MemoriesPhotoSliderView(
galleryItems: galleryItems, galleryItems: galleryItems,
initialIndex: index, initialIndex: index,
scrollDirection: verticalGallery ? Axis.vertical : Axis.horizontal, scrollDirection: verticalGallery ? Axis.vertical : Axis.horizontal,
), ),
// transitionsBuilder: (context, animation, secondaryAnimation, child) {
// return child;
// },
// transitionDuration: Duration.zero,
// reverseTransitionDuration: Duration.zero,
), ),
); ) as bool?;
setState(() {});
await initAsync(); await initAsync();
} }
} }

View file

@ -19,7 +19,6 @@ class MemoriesPhotoSliderView extends StatefulWidget {
required this.galleryItems, required this.galleryItems,
super.key, super.key,
this.loadingBuilder, this.loadingBuilder,
this.backgroundDecoration,
this.minScale, this.minScale,
this.maxScale, this.maxScale,
this.initialIndex = 0, this.initialIndex = 0,
@ -27,7 +26,6 @@ class MemoriesPhotoSliderView extends StatefulWidget {
}) : pageController = PageController(initialPage: initialIndex); }) : pageController = PageController(initialPage: initialIndex);
final LoadingBuilder? loadingBuilder; final LoadingBuilder? loadingBuilder;
final BoxDecoration? backgroundDecoration;
final dynamic minScale; final dynamic minScale;
final dynamic maxScale; final dynamic maxScale;
final int initialIndex; final int initialIndex;
@ -43,6 +41,7 @@ class MemoriesPhotoSliderView extends StatefulWidget {
class _MemoriesPhotoSliderViewState extends State<MemoriesPhotoSliderView> { class _MemoriesPhotoSliderViewState extends State<MemoriesPhotoSliderView> {
late int currentIndex = widget.initialIndex; late int currentIndex = widget.initialIndex;
final GlobalKey<State<StatefulWidget>> key = GlobalKey();
void onPageChanged(int index) { void onPageChanged(int index) {
setState(() { setState(() {
@ -102,9 +101,17 @@ class _MemoriesPhotoSliderViewState extends State<MemoriesPhotoSliderView> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Dismissible(
key: key,
direction: DismissDirection.vertical,
resizeDuration: null,
onDismissed: (d) {
Navigator.pop(context, false);
},
child: Scaffold(
backgroundColor: Colors.white.withAlpha(0),
body: Container( body: Container(
decoration: widget.backgroundDecoration, color: context.color.surface,
constraints: BoxConstraints.expand( constraints: BoxConstraints.expand(
height: MediaQuery.of(context).size.height, height: MediaQuery.of(context).size.height,
), ),
@ -112,7 +119,9 @@ class _MemoriesPhotoSliderViewState extends State<MemoriesPhotoSliderView> {
alignment: Alignment.bottomRight, alignment: Alignment.bottomRight,
children: <Widget>[ children: <Widget>[
MediaViewSizing( MediaViewSizing(
bottomNavigation: Row( bottomNavigation: Container(
color: context.color.surface,
child: Row(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
FilledButton.icon( FilledButton.icon(
@ -149,6 +158,7 @@ class _MemoriesPhotoSliderViewState extends State<MemoriesPhotoSliderView> {
), ),
], ],
), ),
),
child: Stack( child: Stack(
children: [ children: [
PhotoViewGallery.builder( PhotoViewGallery.builder(
@ -156,7 +166,6 @@ class _MemoriesPhotoSliderViewState extends State<MemoriesPhotoSliderView> {
builder: _buildItem, builder: _buildItem,
itemCount: widget.galleryItems.length, itemCount: widget.galleryItems.length,
loadingBuilder: widget.loadingBuilder, loadingBuilder: widget.loadingBuilder,
backgroundDecoration: widget.backgroundDecoration,
pageController: widget.pageController, pageController: widget.pageController,
onPageChanged: onPageChanged, onPageChanged: onPageChanged,
scrollDirection: widget.scrollDirection, scrollDirection: widget.scrollDirection,
@ -195,6 +204,7 @@ class _MemoriesPhotoSliderViewState extends State<MemoriesPhotoSliderView> {
], ],
), ),
), ),
),
); );
} }