fix #1641

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-10-26 20:10:40 +08:00
parent e9dc154642
commit 032dfd69be
14 changed files with 64 additions and 115 deletions

View File

@@ -21,7 +21,6 @@ import 'package:PiliPlus/common/constants.dart';
import 'package:PiliPlus/common/widgets/badge.dart';
import 'package:PiliPlus/common/widgets/custom_layout.dart';
import 'package:PiliPlus/common/widgets/image/network_img_layer.dart';
import 'package:PiliPlus/common/widgets/marquee.dart' show ContextSingleTicker;
import 'package:PiliPlus/models/common/badge_type.dart';
import 'package:PiliPlus/models/common/image_preview_type.dart';
import 'package:PiliPlus/utils/context_ext.dart';
@@ -65,7 +64,6 @@ class CustomGridView extends StatelessWidget {
required this.maxWidth,
required this.picArr,
this.onViewImage,
this.onDismissed,
this.fullScreen = false,
});
@@ -73,7 +71,6 @@ class CustomGridView extends StatelessWidget {
final double space;
final List<ImageModel> picArr;
final VoidCallback? onViewImage;
final ValueChanged<int>? onDismissed;
final bool fullScreen;
static bool horizontalPreview = Pref.horizontalPreview;
@@ -96,20 +93,18 @@ class CustomGridView extends StatelessWidget {
!context.mediaQuerySize.isPortrait) {
final scaffoldState = Scaffold.maybeOf(context);
if (scaffoldState != null) {
onViewImage?.call();
PageUtils.onHorizontalPreviewState(
scaffoldState,
ContextSingleTicker(scaffoldState.context),
imgList,
index,
);
return;
}
}
onViewImage?.call();
PageUtils.imageView(
initialPage: index,
imgList: imgList,
onDismissed: onDismissed,
);
}

View File

@@ -8,10 +8,10 @@ import 'package:flutter/material.dart';
/// show a [Hero] animation.
class HeroDialogRoute<T> extends PageRoute<T> {
HeroDialogRoute({
required this.builder,
required this.pageBuilder,
});
final WidgetBuilder builder;
final RoutePageBuilder pageBuilder;
@override
bool get opaque => false;
@@ -50,12 +50,10 @@ class HeroDialogRoute<T> extends PageRoute<T> {
Animation<double> animation,
Animation<double> secondaryAnimation,
) {
final Widget child = builder(context);
final Widget result = Semantics(
return Semantics(
scopesRoute: true,
explicitChildNodes: true,
child: child,
child: pageBuilder(context, animation, secondaryAnimation),
);
return result;
}
}

View File

@@ -44,16 +44,12 @@ class InteractiveviewerGallery extends StatefulWidget {
this.itemBuilder,
this.maxScale = 8,
this.minScale = 1.0,
this.onPageChanged,
this.onDismissed,
this.onClose,
required this.quality,
this.onClose,
});
final int quality;
final ValueChanged<bool>? onClose;
/// The sources to show.
final List<SourceModel> sources;
@@ -67,9 +63,7 @@ class InteractiveviewerGallery extends StatefulWidget {
final double minScale;
final ValueChanged<int>? onPageChanged;
final ValueChanged<int>? onDismissed;
final VoidCallback? onClose;
@override
State<InteractiveviewerGallery> createState() =>
@@ -121,7 +115,7 @@ class _InteractiveviewerGalleryState extends State<InteractiveviewerGallery>
@override
void dispose() {
widget.onClose?.call(true);
widget.onClose?.call();
_player?.dispose();
_pageController.dispose();
_animationController
@@ -206,7 +200,6 @@ class _InteractiveviewerGalleryState extends State<InteractiveviewerGallery>
if (item.sourceType == SourceType.livePhoto) {
_onPlay(item.liveUrl!);
}
widget.onPageChanged?.call(page);
if (_transformationController.value != Matrix4.identity()) {
// animate the reset for the transformation of the interactive viewer
@@ -228,15 +221,6 @@ class _InteractiveviewerGalleryState extends State<InteractiveviewerGallery>
: url.http2https;
}
void onClose() {
if (widget.onClose != null) {
widget.onClose!(false);
} else {
Get.back();
widget.onDismissed?.call(_pageController.page!.floor());
}
}
Player? _player;
VideoController? _videoController;
@@ -254,7 +238,7 @@ class _InteractiveviewerGalleryState extends State<InteractiveviewerGallery>
onNoBoundaryHit: _onNoBoundaryHit,
maxScale: widget.maxScale,
minScale: widget.minScale,
onDismissed: onClose,
onDismissed: Get.back,
onReset: () {
if (!_enablePageView) {
setState(() {
@@ -277,7 +261,7 @@ class _InteractiveviewerGalleryState extends State<InteractiveviewerGallery>
onTap: () => EasyThrottle.throttle(
'preview',
const Duration(milliseconds: 555),
onClose,
Get.back,
),
onDoubleTapDown: (TapDownDetails details) {
_doubleTapLocalPosition = details.localPosition;