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,97 +101,108 @@ class _MemoriesPhotoSliderViewState extends State<MemoriesPhotoSliderView> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Dismissible(
body: Container( key: key,
decoration: widget.backgroundDecoration, direction: DismissDirection.vertical,
constraints: BoxConstraints.expand( resizeDuration: null,
height: MediaQuery.of(context).size.height, onDismissed: (d) {
), Navigator.pop(context, false);
child: Stack( },
alignment: Alignment.bottomRight, child: Scaffold(
children: <Widget>[ backgroundColor: Colors.white.withAlpha(0),
MediaViewSizing( body: Container(
bottomNavigation: Row( color: context.color.surface,
mainAxisAlignment: MainAxisAlignment.center, constraints: BoxConstraints.expand(
children: [ height: MediaQuery.of(context).size.height,
FilledButton.icon( ),
icon: const FaIcon(FontAwesomeIcons.solidPaperPlane), child: Stack(
onPressed: () { alignment: Alignment.bottomRight,
Navigator.push( children: <Widget>[
context, MediaViewSizing(
MaterialPageRoute( bottomNavigation: Container(
builder: (context) => ShareImageEditorView( color: context.color.surface,
videoFilePath: child: Row(
widget.galleryItems[currentIndex].videoPath, mainAxisAlignment: MainAxisAlignment.center,
imageBytes: widget children: [
.galleryItems[currentIndex].imagePath FilledButton.icon(
?.readAsBytes(), icon: const FaIcon(FontAwesomeIcons.solidPaperPlane),
mirrorVideo: false, onPressed: () {
sharedFromGallery: true, Navigator.push(
useHighQuality: true, 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<EdgeInsets>(
const EdgeInsets.symmetric(
vertical: 10, horizontal: 30),
),
backgroundColor: WidgetStateProperty.all<Color>(
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<String>(
onSelected: (String result) {
if (result == 'delete') {
deleteFile();
}
if (result == 'export') {
exportFile();
}
},
itemBuilder: (BuildContext context) =>
<PopupMenuEntry<String>>[
PopupMenuItem<String>(
value: 'delete',
child: Text(context.lang.galleryDelete),
), ),
), PopupMenuItem<String>(
); value: 'export',
}, child: Text(context.lang.galleryExport),
style: ButtonStyle( ),
padding: WidgetStateProperty.all<EdgeInsets>( // PopupMenuItem<String>(
const EdgeInsets.symmetric( // value: 'details',
vertical: 10, horizontal: 30), // child: Text(context.lang.galleryDetails),
), // ),
backgroundColor: WidgetStateProperty.all<Color>( ],
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,
backgroundDecoration: widget.backgroundDecoration,
pageController: widget.pageController,
onPageChanged: onPageChanged,
scrollDirection: widget.scrollDirection,
),
Positioned(
right: 5,
child: PopupMenuButton<String>(
onSelected: (String result) {
if (result == 'delete') {
deleteFile();
}
if (result == 'export') {
exportFile();
}
},
itemBuilder: (BuildContext context) =>
<PopupMenuEntry<String>>[
PopupMenuItem<String>(
value: 'delete',
child: Text(context.lang.galleryDelete),
),
PopupMenuItem<String>(
value: 'export',
child: Text(context.lang.galleryExport),
),
// PopupMenuItem<String>(
// value: 'details',
// child: Text(context.lang.galleryDetails),
// ),
],
),
)
],
),
),
],
), ),
), ),
); );