refactor: update allowedSwipeDirection param names
This commit is contained in:
parent
9976486d02
commit
fe77440a35
|
|
@ -10,22 +10,22 @@ class CardAnimation {
|
||||||
required this.maxAngle,
|
required this.maxAngle,
|
||||||
required this.initialScale,
|
required this.initialScale,
|
||||||
required this.initialOffset,
|
required this.initialOffset,
|
||||||
@Deprecated('Use [cardSwipeDirection] instead]')
|
@Deprecated('Use [allowedSwipeDirection] instead]')
|
||||||
this.isHorizontalSwipingEnabled = true,
|
this.isHorizontalSwipingEnabled = true,
|
||||||
@Deprecated('Use [cardSwipeDirection] instead]')
|
@Deprecated('Use [allowedSwipeDirection] instead]')
|
||||||
this.isVerticalSwipingEnabled = true,
|
this.isVerticalSwipingEnabled = true,
|
||||||
this.cardSwipeDirection = const AllowedSwipeDirection.all(),
|
this.allowedSwipeDirection = const AllowedSwipeDirection.all(),
|
||||||
}) : scale = initialScale;
|
}) : scale = initialScale;
|
||||||
|
|
||||||
final double maxAngle;
|
final double maxAngle;
|
||||||
final double initialScale;
|
final double initialScale;
|
||||||
final Offset initialOffset;
|
final Offset initialOffset;
|
||||||
final AnimationController animationController;
|
final AnimationController animationController;
|
||||||
@Deprecated('Use [cardSwipeDirection] instead]')
|
@Deprecated('Use [allowedSwipeDirection] instead]')
|
||||||
final bool isHorizontalSwipingEnabled;
|
final bool isHorizontalSwipingEnabled;
|
||||||
@Deprecated('Use [cardSwipeDirection] instead]')
|
@Deprecated('Use [allowedSwipeDirection] instead]')
|
||||||
final bool isVerticalSwipingEnabled;
|
final bool isVerticalSwipingEnabled;
|
||||||
final AllowedSwipeDirection cardSwipeDirection;
|
final AllowedSwipeDirection allowedSwipeDirection;
|
||||||
|
|
||||||
double left = 0;
|
double left = 0;
|
||||||
double top = 0;
|
double top = 0;
|
||||||
|
|
@ -61,22 +61,22 @@ class CardAnimation {
|
||||||
void update(double dx, double dy, bool inverseAngle) {
|
void update(double dx, double dy, bool inverseAngle) {
|
||||||
//TODO: remove [isHorizontalSwipingEnabled] checks in the next major release
|
//TODO: remove [isHorizontalSwipingEnabled] checks in the next major release
|
||||||
if (isHorizontalSwipingEnabled) {
|
if (isHorizontalSwipingEnabled) {
|
||||||
if (cardSwipeDirection.right && cardSwipeDirection.left) {
|
if (allowedSwipeDirection.right && allowedSwipeDirection.left) {
|
||||||
left += dx;
|
left += dx;
|
||||||
} else if (cardSwipeDirection.right) {
|
} else if (allowedSwipeDirection.right) {
|
||||||
if (left >= 0) left += dx;
|
if (left >= 0) left += dx;
|
||||||
} else if (cardSwipeDirection.left) {
|
} else if (allowedSwipeDirection.left) {
|
||||||
if (left <= 0) left += dx;
|
if (left <= 0) left += dx;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: remove [isHorizontalSwipingEnabled] checks in the next major release
|
//TODO: remove [isHorizontalSwipingEnabled] checks in the next major release
|
||||||
if (isVerticalSwipingEnabled) {
|
if (isVerticalSwipingEnabled) {
|
||||||
if (cardSwipeDirection.up && cardSwipeDirection.down) {
|
if (allowedSwipeDirection.up && allowedSwipeDirection.down) {
|
||||||
top += dy;
|
top += dy;
|
||||||
} else if (cardSwipeDirection.up) {
|
} else if (allowedSwipeDirection.up) {
|
||||||
if (top <= 0) top += dy;
|
if (top <= 0) top += dy;
|
||||||
} else if (cardSwipeDirection.down) {
|
} else if (allowedSwipeDirection.down) {
|
||||||
if (top >= 0) top += dy;
|
if (top >= 0) top += dy;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -227,7 +227,7 @@ class _CardSwiperState<T extends Widget> extends State<CardSwiper>
|
||||||
initialScale: widget.scale,
|
initialScale: widget.scale,
|
||||||
isVerticalSwipingEnabled: widget.isVerticalSwipingEnabled,
|
isVerticalSwipingEnabled: widget.isVerticalSwipingEnabled,
|
||||||
isHorizontalSwipingEnabled: widget.isHorizontalSwipingEnabled,
|
isHorizontalSwipingEnabled: widget.isHorizontalSwipingEnabled,
|
||||||
cardSwipeDirection: widget.allowedSwipeDirection,
|
allowedSwipeDirection: widget.allowedSwipeDirection,
|
||||||
initialOffset: widget.backCardOffset,
|
initialOffset: widget.backCardOffset,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue