Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

## [0.5.5] #38

Merged
merged 1 commit into from
Aug 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## [0.5.5]

* Features:
Add call back [CanMovePage] for ExtendedImageGesturePageView. [related issue](https://github.com/fluttercandies/extended_image/issues/32)

## [0.5.4]

* Issues:
Expand Down
3 changes: 3 additions & 0 deletions example/lib/common/pic_swiper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@ class _PicSwiperState extends State<PicSwiper>
),
scrollDirection: Axis.horizontal,
physics: BouncingScrollPhysics(),
// //move page only when scale is not more than 1.0
// canMovePage: (GestureDetails gestureDetails) =>
// gestureDetails.totalScale <= 1.0,
//physics: ClampingScrollPhysics(),
),
StreamBuilder<bool>(
Expand Down
3 changes: 3 additions & 0 deletions lib/src/extended_image_typedef.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,6 @@ typedef InitGestureConfigHandler = GestureConfig Function(

///on sliding page
typedef OnSlidingPage = void Function(ExtendedImageSlidePageState state);

///whether we can move page
typedef CanMovePage = bool Function(GestureDetails gestureDetails);
15 changes: 13 additions & 2 deletions lib/src/gesture/extended_image_gesture_page_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ final PageController _defaultPageController = PageController();
//const PageScrollPhysics _kPagePhysics = PageScrollPhysics();
const ScrollPhysics _defaultScrollPhysics = NeverScrollableScrollPhysics();

bool _defaultCanMovePage(GestureDetails gestureDetails) => true;

///page view to support gesture for image
class ExtendedImageGesturePageView extends StatefulWidget {
ExtendedImageGesturePageView({
Expand All @@ -21,11 +23,13 @@ class ExtendedImageGesturePageView extends StatefulWidget {
this.pageSnapping = true,
this.onPageChanged,
List<Widget> children = const <Widget>[],
CanMovePage canMovePage,
}) : controller = controller ?? _defaultPageController,
childrenDelegate = SliverChildListDelegate(children),
physics = physics != null
? _defaultScrollPhysics.applyTo(physics)
: _defaultScrollPhysics,
canMovePage = canMovePage ?? _defaultCanMovePage,
super(key: key);

/// Creates a scrollable list that works page by page using widgets that are
Expand All @@ -50,12 +54,14 @@ class ExtendedImageGesturePageView extends StatefulWidget {
this.onPageChanged,
@required IndexedWidgetBuilder itemBuilder,
int itemCount,
CanMovePage canMovePage,
}) : controller = controller ?? _defaultPageController,
childrenDelegate =
SliverChildBuilderDelegate(itemBuilder, childCount: itemCount),
physics = physics != null
? _defaultScrollPhysics.applyTo(physics)
: _defaultScrollPhysics,
canMovePage = canMovePage ?? _defaultCanMovePage,
super(key: key);

/// Creates a scrollable list that works page by page with a custom child
Expand All @@ -68,12 +74,16 @@ class ExtendedImageGesturePageView extends StatefulWidget {
//this.physics,
this.pageSnapping = true,
this.onPageChanged,
CanMovePage canMovePage,
@required this.childrenDelegate,
}) : assert(childrenDelegate != null),
controller = controller ?? _defaultPageController,
physics = _defaultScrollPhysics,
canMovePage = canMovePage ?? _defaultCanMovePage,
super(key: key);

final CanMovePage canMovePage;

/// The axis along which the page view scrolls.
///
/// Defaults to [Axis.horizontal].
Expand Down Expand Up @@ -274,8 +284,9 @@ class ExtendedImageGesturePageViewState
// }
// }

if (gestureDetails.movePage(delta) ||
(currentPage != pageController.page)) {
if ((gestureDetails.movePage(delta) ||
(currentPage != pageController.page)) &&
widget.canMovePage(gestureDetails)) {
_drag?.update(details);
} else {
if (currentPage == pageController.page) {
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: extended_image
description: extended official image which support placeholder(loading)/ failed state,cache network,zoom pan image,photo view,slide out page,crop,save,paint etc.
version: 0.5.4
version: 0.5.5
author: zmtzawqlp <[email protected]>
homepage: https://github.com/fluttercandies/extended_image

Expand Down