change: remove deprecated methods

This commit is contained in:
ricardodalarme 2023-06-03 13:29:58 -03:00
parent 44faeebb08
commit 5b1a3f80c7
4 changed files with 17 additions and 40 deletions

View File

@ -1,3 +1,8 @@
## NEXT
- **BREAKING CHANGE**:
- `isHorizontalSwipingEnabled` and `isVerticalSwipingEnabled` have been removed. Use `allowedSwipeDirection` instead.
## [5.1.0]
- Adds AllowedSwipeDirection to allow card to be swiped in any combination of left, right, up or down directions.

View File

@ -105,9 +105,7 @@ class Example extends StatelessWidget {
| duration | 200 milliseconds | The duration that every animation should last | false |
| initialIndex | 0 | Index of the first card when the swiper is initialized | false |
| isDisabled | false | Set to `true` if swiping should be disabled, has no impact when triggered from the outside | false |
| isHorizontalSwipingEnabled _(deprecated)_ | true | Set to `false` if you want your card to move only across the vertical axis when swiping. _(Deprecated: use allowedSwipeDirection instead)_ | false |
| isLoop | true | Set to `true` if the stack should loop | false |
| isVerticalSwipingEnabled _(deprecated)_ | true | Set to `false` if you want your card to move only across the horizontal axis when swiping. _(Deprecated: use allowedSwipeDirection instead)_ | false |
| maxAngle | 30 | Maximum angle that the card can reach during swiping | false |
| allowedSwipeDirection | AllowedSwipeDirection.all | Sets the direction in which the card can be swiped. It can be set to any combination of left, right up or down. | false |
| numberOfCardsDisplayed | 2 | Number of cards displayed at the same time | false |

View File

@ -55,26 +55,20 @@ class CardAnimation {
}
void update(double dx, double dy, bool inverseAngle) {
//TODO: remove [isHorizontalSwipingEnabled] checks in the next major release
if (isHorizontalSwipingEnabled) {
if (allowedSwipeDirection.right && allowedSwipeDirection.left) {
left += dx;
} else if (allowedSwipeDirection.right) {
if (left >= 0) left += dx;
} else if (allowedSwipeDirection.left) {
if (left <= 0) left += dx;
}
if (allowedSwipeDirection.right && allowedSwipeDirection.left) {
left += dx;
} else if (allowedSwipeDirection.right) {
if (left >= 0) left += dx;
} else if (allowedSwipeDirection.left) {
if (left <= 0) left += dx;
}
//TODO: remove [isHorizontalSwipingEnabled] checks in the next major release
if (isVerticalSwipingEnabled) {
if (allowedSwipeDirection.up && allowedSwipeDirection.down) {
top += dy;
} else if (allowedSwipeDirection.up) {
if (top <= 0) top += dy;
} else if (allowedSwipeDirection.down) {
if (top >= 0) top += dy;
}
if (allowedSwipeDirection.up && allowedSwipeDirection.down) {
top += dy;
} else if (allowedSwipeDirection.up) {
if (top <= 0) top += dy;
} else if (allowedSwipeDirection.down) {
if (top >= 0) top += dy;
}
total = left + top;

View File

@ -92,18 +92,6 @@ class CardSwiper extends StatefulWidget {
/// Defaults to [CardSwiperDirection.right].
final CardSwiperDirection direction;
/// A boolean value that determines whether the card can be swiped horizontally. The default value is true.
@Deprecated(
'Will be deprecated in the next major release. Use [AllowedSwipeDirection] instead',
)
final bool isHorizontalSwipingEnabled;
/// A boolean value that determines whether the card can be swiped vertically. The default value is true.
@Deprecated(
'Will be deprecated in the next major release. Use [AllowedSwipeDirection] instead',
)
final bool isVerticalSwipingEnabled;
/// Defined the directions in which the card is allowed to be swiped.
/// Defaults to [AllowedSwipeDirection.all]
final AllowedSwipeDirection allowedSwipeDirection;
@ -149,10 +137,6 @@ class CardSwiper extends StatefulWidget {
this.onSwipe,
this.onEnd,
this.direction = CardSwiperDirection.right,
@Deprecated('Will be deprecated in the next major release. Use [allowedSwipeDirection] instead')
this.isHorizontalSwipingEnabled = true,
@Deprecated('Will be deprecated in the next major release. Use [allowedSwipeDirection] instead')
this.isVerticalSwipingEnabled = true,
this.allowedSwipeDirection = const AllowedSwipeDirection.all(),
this.isLoop = true,
this.numberOfCardsDisplayed = 2,
@ -225,10 +209,6 @@ class _CardSwiperState<T extends Widget> extends State<CardSwiper>
animationController: _animationController,
maxAngle: widget.maxAngle,
initialScale: widget.scale,
// ignore: deprecated_member_use_from_same_package
isVerticalSwipingEnabled: widget.isVerticalSwipingEnabled,
// ignore: deprecated_member_use_from_same_package
isHorizontalSwipingEnabled: widget.isHorizontalSwipingEnabled,
allowedSwipeDirection: widget.allowedSwipeDirection,
initialOffset: widget.backCardOffset,
);