mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-06-01 00:28:18 +08:00
@@ -124,9 +124,7 @@ class _CachedNetworkSVGImageState extends State<CachedNetworkSVGImage> {
|
|||||||
|
|
||||||
Future<void> _loadImage() async {
|
Future<void> _loadImage() async {
|
||||||
try {
|
try {
|
||||||
var file = (await widget._cacheManager.getFileFromMemory(
|
var file = (await widget._cacheManager.getFileFromCache(_cacheKey))?.file;
|
||||||
_cacheKey,
|
|
||||||
))?.file;
|
|
||||||
|
|
||||||
file ??= await widget._cacheManager.getSingleFile(
|
file ??= await widget._cacheManager.getSingleFile(
|
||||||
widget._url,
|
widget._url,
|
||||||
@@ -173,13 +171,12 @@ class _CachedNetworkSVGImageState extends State<CachedNetworkSVGImage> {
|
|||||||
if (mounted) {
|
if (mounted) {
|
||||||
setState(() {});
|
setState(() {});
|
||||||
} else {
|
} else {
|
||||||
SchedulerBinding.instance.addPostFrameCallback((_) => setState(() {}));
|
SchedulerBinding.instance.addPostFrameCallback((_) {
|
||||||
|
if (mounted) {
|
||||||
|
setState(() {});
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
|
||||||
void dispose() {
|
|
||||||
super.dispose();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -78,8 +78,8 @@ class InteractiveviewerGallery extends StatefulWidget {
|
|||||||
|
|
||||||
class _InteractiveviewerGalleryState extends State<InteractiveviewerGallery>
|
class _InteractiveviewerGalleryState extends State<InteractiveviewerGallery>
|
||||||
with SingleTickerProviderStateMixin {
|
with SingleTickerProviderStateMixin {
|
||||||
PageController? _pageController;
|
late final PageController _pageController;
|
||||||
TransformationController? _transformationController;
|
late final TransformationController _transformationController;
|
||||||
|
|
||||||
/// The controller to animate the transformation value of the
|
/// The controller to animate the transformation value of the
|
||||||
/// [InteractiveViewer] when it should reset.
|
/// [InteractiveViewer] when it should reset.
|
||||||
@@ -109,24 +109,25 @@ class _InteractiveviewerGalleryState extends State<InteractiveviewerGallery>
|
|||||||
duration: const Duration(milliseconds: 300),
|
duration: const Duration(milliseconds: 300),
|
||||||
)..addListener(listener);
|
)..addListener(listener);
|
||||||
|
|
||||||
var item = widget.sources[currentIndex.value];
|
final item = widget.sources[currentIndex.value];
|
||||||
if (item.sourceType == SourceType.livePhoto) {
|
if (item.sourceType == SourceType.livePhoto) {
|
||||||
_onPlay(item.liveUrl!);
|
_onPlay(item.liveUrl!);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void listener() {
|
void listener() {
|
||||||
_transformationController!.value = _animation?.value ?? Matrix4.identity();
|
_transformationController.value = _animation?.value ?? Matrix4.identity();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
widget.onClose?.call(true);
|
widget.onClose?.call(true);
|
||||||
_player?.dispose();
|
_player?.dispose();
|
||||||
_pageController?.dispose();
|
_pageController.dispose();
|
||||||
_animationController
|
_animationController
|
||||||
..removeListener(listener)
|
..removeListener(listener)
|
||||||
..dispose();
|
..dispose();
|
||||||
|
_transformationController.dispose();
|
||||||
for (var item in widget.sources) {
|
for (var item in widget.sources) {
|
||||||
if (item.sourceType == SourceType.networkImage) {
|
if (item.sourceType == SourceType.networkImage) {
|
||||||
CachedNetworkImageProvider(_getActualUrl(item.url)).evict();
|
CachedNetworkImageProvider(_getActualUrl(item.url)).evict();
|
||||||
@@ -160,7 +161,7 @@ class _InteractiveviewerGalleryState extends State<InteractiveviewerGallery>
|
|||||||
/// When the left boundary has been hit after scaling up the source, the page
|
/// When the left boundary has been hit after scaling up the source, the page
|
||||||
/// view swiping gets enabled if it has a page to swipe to.
|
/// view swiping gets enabled if it has a page to swipe to.
|
||||||
void _onLeftBoundaryHit() {
|
void _onLeftBoundaryHit() {
|
||||||
if (!_enablePageView && _pageController!.page!.floor() > 0) {
|
if (!_enablePageView && _pageController.page!.floor() > 0) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_enablePageView = true;
|
_enablePageView = true;
|
||||||
});
|
});
|
||||||
@@ -171,7 +172,7 @@ class _InteractiveviewerGalleryState extends State<InteractiveviewerGallery>
|
|||||||
/// view swiping gets enabled if it has a page to swipe to.
|
/// view swiping gets enabled if it has a page to swipe to.
|
||||||
void _onRightBoundaryHit() {
|
void _onRightBoundaryHit() {
|
||||||
if (!_enablePageView &&
|
if (!_enablePageView &&
|
||||||
_pageController!.page!.floor() < widget.sources.length - 1) {
|
_pageController.page!.floor() < widget.sources.length - 1) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_enablePageView = true;
|
_enablePageView = true;
|
||||||
});
|
});
|
||||||
@@ -206,12 +207,12 @@ class _InteractiveviewerGalleryState extends State<InteractiveviewerGallery>
|
|||||||
_onPlay(item.liveUrl!);
|
_onPlay(item.liveUrl!);
|
||||||
}
|
}
|
||||||
widget.onPageChanged?.call(page);
|
widget.onPageChanged?.call(page);
|
||||||
if (_transformationController!.value != Matrix4.identity()) {
|
if (_transformationController.value != Matrix4.identity()) {
|
||||||
// animate the reset for the transformation of the interactive viewer
|
// animate the reset for the transformation of the interactive viewer
|
||||||
|
|
||||||
_animation =
|
_animation =
|
||||||
Matrix4Tween(
|
Matrix4Tween(
|
||||||
begin: _transformationController!.value,
|
begin: _transformationController.value,
|
||||||
end: Matrix4.identity(),
|
end: Matrix4.identity(),
|
||||||
).animate(
|
).animate(
|
||||||
CurveTween(curve: Curves.easeOut).animate(_animationController),
|
CurveTween(curve: Curves.easeOut).animate(_animationController),
|
||||||
@@ -232,7 +233,7 @@ class _InteractiveviewerGalleryState extends State<InteractiveviewerGallery>
|
|||||||
widget.onClose!(false);
|
widget.onClose!(false);
|
||||||
} else {
|
} else {
|
||||||
Get.back();
|
Get.back();
|
||||||
widget.onDismissed?.call(_pageController!.page!.floor());
|
widget.onDismissed?.call(_pageController.page!.floor());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -322,19 +323,6 @@ class _InteractiveviewerGalleryState extends State<InteractiveviewerGallery>
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
: null,
|
: null,
|
||||||
child: Stack(
|
|
||||||
clipBehavior: Clip.none,
|
|
||||||
alignment: Alignment.center,
|
|
||||||
children: [
|
|
||||||
Align(
|
|
||||||
alignment: Alignment.centerLeft,
|
|
||||||
child: IconButton(
|
|
||||||
icon: const Icon(Icons.close, color: Colors.white),
|
|
||||||
onPressed: onClose,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
if (widget.sources.length > 1)
|
|
||||||
Align(
|
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
child: Obx(
|
child: Obx(
|
||||||
() => Text(
|
() => Text(
|
||||||
@@ -343,64 +331,6 @@ class _InteractiveviewerGalleryState extends State<InteractiveviewerGallery>
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (widget.sources[currentIndex.value].sourceType !=
|
|
||||||
SourceType.fileImage)
|
|
||||||
Align(
|
|
||||||
alignment: Alignment.centerRight,
|
|
||||||
child: PopupMenuButton(
|
|
||||||
itemBuilder: (context) {
|
|
||||||
final item = widget.sources[currentIndex.value];
|
|
||||||
return [
|
|
||||||
if (Utils.isMobile)
|
|
||||||
PopupMenuItem(
|
|
||||||
onTap: () => ImageUtils.onShareImg(item.url),
|
|
||||||
child: const Text("分享图片"),
|
|
||||||
),
|
|
||||||
PopupMenuItem(
|
|
||||||
onTap: () => Utils.copyText(item.url),
|
|
||||||
child: const Text("复制链接"),
|
|
||||||
),
|
|
||||||
PopupMenuItem(
|
|
||||||
onTap: () => ImageUtils.downloadImg(
|
|
||||||
this.context,
|
|
||||||
[item.url],
|
|
||||||
),
|
|
||||||
child: const Text("保存图片"),
|
|
||||||
),
|
|
||||||
if (Utils.isDesktop)
|
|
||||||
PopupMenuItem(
|
|
||||||
onTap: () => PageUtils.launchURL(item.url),
|
|
||||||
child: const Text("网页打开"),
|
|
||||||
)
|
|
||||||
else if (widget.sources.length > 1)
|
|
||||||
PopupMenuItem(
|
|
||||||
onTap: () => ImageUtils.downloadImg(
|
|
||||||
this.context,
|
|
||||||
widget.sources.map((item) => item.url).toList(),
|
|
||||||
),
|
|
||||||
child: const Text("保存全部"),
|
|
||||||
),
|
|
||||||
if (item.sourceType == SourceType.livePhoto)
|
|
||||||
PopupMenuItem(
|
|
||||||
onTap: () {
|
|
||||||
ImageUtils.downloadLivePhoto(
|
|
||||||
context: this.context,
|
|
||||||
url: item.url,
|
|
||||||
liveUrl: item.liveUrl!,
|
|
||||||
width: item.width!,
|
|
||||||
height: item.height!,
|
|
||||||
);
|
|
||||||
},
|
|
||||||
child: const Text("保存 Live Photo"),
|
|
||||||
),
|
|
||||||
];
|
|
||||||
},
|
|
||||||
child: const Icon(Icons.more_horiz, color: Colors.white),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
@@ -444,7 +374,7 @@ class _InteractiveviewerGalleryState extends State<InteractiveviewerGallery>
|
|||||||
}
|
}
|
||||||
|
|
||||||
void onDoubleTap() {
|
void onDoubleTap() {
|
||||||
Matrix4 matrix = _transformationController!.value.clone();
|
Matrix4 matrix = _transformationController.value.clone();
|
||||||
double currentScale = matrix.row0.x;
|
double currentScale = matrix.row0.x;
|
||||||
|
|
||||||
double targetScale = widget.minScale;
|
double targetScale = widget.minScale;
|
||||||
@@ -481,7 +411,7 @@ class _InteractiveviewerGalleryState extends State<InteractiveviewerGallery>
|
|||||||
|
|
||||||
_animation =
|
_animation =
|
||||||
Matrix4Tween(
|
Matrix4Tween(
|
||||||
begin: _transformationController!.value,
|
begin: _transformationController.value,
|
||||||
end: matrix,
|
end: matrix,
|
||||||
).animate(
|
).animate(
|
||||||
CurveTween(curve: Curves.easeOut).animate(_animationController),
|
CurveTween(curve: Curves.easeOut).animate(_animationController),
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import 'dart:math';
|
import 'dart:math';
|
||||||
|
|
||||||
import 'package:PiliPlus/common/widgets/cached_network_svg_image.dart';
|
import 'package:PiliPlus/common/widgets/image/cached_network_svg_image.dart';
|
||||||
import 'package:PiliPlus/common/widgets/image/custom_grid_view.dart';
|
import 'package:PiliPlus/common/widgets/image/custom_grid_view.dart';
|
||||||
import 'package:PiliPlus/common/widgets/image/network_img_layer.dart';
|
import 'package:PiliPlus/common/widgets/image/network_img_layer.dart';
|
||||||
import 'package:PiliPlus/http/constants.dart';
|
import 'package:PiliPlus/http/constants.dart';
|
||||||
|
|||||||
@@ -1965,10 +1965,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: win32
|
name: win32
|
||||||
sha256: "66814138c3562338d05613a6e368ed8cfb237ad6d64a9e9334be3f309acfca03"
|
sha256: d7cb55e04cd34096cd3a79b3330245f54cb96a370a1c27adb3c84b917de8b08e
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "5.14.0"
|
version: "5.15.0"
|
||||||
win32_registry:
|
win32_registry:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|||||||
Reference in New Issue
Block a user