Skip to content

Commit

Permalink
- Add Pull gesture to close full screen view of a picture #444
Browse files Browse the repository at this point in the history
- Removed unused Imports
  • Loading branch information
johann-gambol committed Aug 28, 2022
1 parent d61e379 commit 82795fd
Showing 1 changed file with 43 additions and 39 deletions.
82 changes: 43 additions & 39 deletions lib/tweet/_photo.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,49 +22,53 @@ class _TweetPhotoState extends State<TweetPhoto> with SingleTickerProviderStateM

@override
Widget build(BuildContext context) {
return ExtendedImage.network(
'${widget.uri}:${widget.size}',
cache: true,
width: 5000,
height: 5000,
fit: widget.fit,
mode: ExtendedImageMode.gesture,
initGestureConfigHandler: (state) {
return GestureConfig(
minScale: 0.9,
animationMinScale: 0.7,
maxScale: 4.0,
animationMaxScale: 4.0,
speed: 1.0,
inertialSpeed: 100.0,
initialScale: 1.0,
initialAlignment: InitialAlignment.center,
);
},
onDoubleTap: (ExtendedImageGestureState state) {
final Offset? pointerDownPosition = state.pointerDownPosition;
final double? begin = state.gestureDetails!.totalScale;
double end;
return ExtendedImageSlidePage(
slideAxis: SlideAxis.vertical,
child: ExtendedImage.network(
'${widget.uri}:${widget.size}',
cache: true,
width: 5000,
height: 5000,
fit: widget.fit,
mode: ExtendedImageMode.gesture,
enableSlideOutPage: true,
initGestureConfigHandler: (state) {
return GestureConfig(
minScale: 0.9,
animationMinScale: 0.7,
maxScale: 4.0,
animationMaxScale: 4.0,
speed: 1.0,
inertialSpeed: 100.0,
initialScale: 1.0,
initialAlignment: InitialAlignment.center,
);
},
onDoubleTap: (ExtendedImageGestureState state) {
final Offset? pointerDownPosition = state.pointerDownPosition;
final double? begin = state.gestureDetails!.totalScale;
double end;

// Remove and stop any old animation
_doubleClickAnimation?.removeListener(_doubleClickAnimationListener);
_doubleClickAnimationController.stop();
_doubleClickAnimationController.reset();
// Remove and stop any old animation
_doubleClickAnimation?.removeListener(_doubleClickAnimationListener);
_doubleClickAnimationController.stop();
_doubleClickAnimationController.reset();

if (begin == _doubleTapScales[0]) {
end = _doubleTapScales[1];
} else {
end = _doubleTapScales[0];
}
if (begin == _doubleTapScales[0]) {
end = _doubleTapScales[1];
} else {
end = _doubleTapScales[0];
}

_doubleClickAnimationListener = () {
state.handleDoubleTap(scale: _doubleClickAnimation!.value, doubleTapPosition: pointerDownPosition);
};
_doubleClickAnimationListener = () {
state.handleDoubleTap(scale: _doubleClickAnimation!.value, doubleTapPosition: pointerDownPosition);
};

_doubleClickAnimation = _doubleClickAnimationController.drive(Tween<double>(begin: begin, end: end));
_doubleClickAnimation!.addListener(_doubleClickAnimationListener);
_doubleClickAnimationController.forward();
},
_doubleClickAnimation = _doubleClickAnimationController.drive(Tween<double>(begin: begin, end: end));
_doubleClickAnimation!.addListener(_doubleClickAnimationListener);
_doubleClickAnimationController.forward();
},
),
);
}
}

0 comments on commit 82795fd

Please sign in to comment.