|
|
|
@ -55,16 +55,59 @@ class PhotoViewer extends StatefulWidget {
|
|
|
|
|
_PhotoViewerState createState() => _PhotoViewerState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _PhotoViewerState extends State<PhotoViewer> {
|
|
|
|
|
class _PhotoViewerState extends State<PhotoViewer>
|
|
|
|
|
with SingleTickerProviderStateMixin {
|
|
|
|
|
TransformationController _controller = TransformationController();
|
|
|
|
|
Animation? _animationReset;
|
|
|
|
|
late AnimationController _controllerReset;
|
|
|
|
|
|
|
|
|
|
void reset() {
|
|
|
|
|
_controllerReset.reset();
|
|
|
|
|
_animationReset = Matrix4Tween(
|
|
|
|
|
begin: _controller.value,
|
|
|
|
|
end: Matrix4.identity(),
|
|
|
|
|
).animate(_controllerReset);
|
|
|
|
|
_animationReset!.addListener(_onAnimateReset);
|
|
|
|
|
_controllerReset.forward();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void _onAnimateReset() {
|
|
|
|
|
_controller.value = _animationReset!.value;
|
|
|
|
|
if (!_controllerReset.isAnimating) {
|
|
|
|
|
_animationReset?.removeListener(_onAnimateReset);
|
|
|
|
|
_animationReset = null;
|
|
|
|
|
_controllerReset.reset();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void initState() {
|
|
|
|
|
_controllerReset =
|
|
|
|
|
AnimationController(vsync: this, duration: Duration(milliseconds: 400));
|
|
|
|
|
super.initState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void dispose() {
|
|
|
|
|
_controllerReset.dispose();
|
|
|
|
|
_controller.dispose();
|
|
|
|
|
super.dispose();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
return Scaffold(
|
|
|
|
|
backgroundColor: Colors.black54,
|
|
|
|
|
body: GestureDetector(
|
|
|
|
|
onTap: () => Navigator.pop(context),
|
|
|
|
|
child: Center(
|
|
|
|
|
child: InteractiveViewer(
|
|
|
|
|
boundaryMargin: 100.edge,
|
|
|
|
|
return GestureDetector(
|
|
|
|
|
onTap: () => Navigator.pop(context),
|
|
|
|
|
onDoubleTap: () => reset(),
|
|
|
|
|
child: Scaffold(
|
|
|
|
|
backgroundColor: Colors.black54,
|
|
|
|
|
body: InteractiveViewer(
|
|
|
|
|
transformationController: _controller,
|
|
|
|
|
boundaryMargin: 100.edge,
|
|
|
|
|
child: Container(
|
|
|
|
|
width: double.infinity,
|
|
|
|
|
height: double.infinity,
|
|
|
|
|
alignment: Alignment.center,
|
|
|
|
|
child: Hero(
|
|
|
|
|
tag: widget.tag,
|
|
|
|
|
child: widget.file != null
|
|
|
|
|