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

Allow swipe to custom angles #46

Closed
wants to merge 3 commits into from
Closed

Conversation

HeySreelal
Copy link
Contributor

@HeySreelal HeySreelal commented Oct 5, 2024

Description

Added feature to swipe to custom angles.

Changes

So far the CardSwiperDirection was an enum and only had values left, right, top, bottom and none - which works pretty fine, but leaves the user with only limited choices to swipe with the controller.

  1. CardSwiperDirection was changed to a class containing an angle property.
  2. All cardinal directions (left, right, top, and bottom) are predefined as static getters. Hence, this won't be a breaking change.
  3. Added methods animateToAngle and animateUndoFromAngle inside the CardAnimation class to animate the card to any given angle.
  4. Since, CardAnimation.animateToAngle, CardAnimation.animateUndoFromAngle can now animate and undo animation to any given angle, we don't need previous implementations such as animateHorizontally, animateVertically, animateUndoHorizontally, and animateUndoVertically, hence these are removed.
  5. Since different parts of the library depended on CardSwiperDirection from src/enums.dart had to change the imports here and there.

Related Issues

Pre-launch Checklist

Visual Reference & Code

FloatingActionButton(
  onPressed: () {
    final dir = CardSwiperDirection.custom(290);
    controller.swipe(dir);
  },
  child: const Icon(Icons.keyboard_arrow_left),
),
FloatingActionButton(
  onPressed: () {
    final dir = CardSwiperDirection.custom(60);
    controller.swipe(dir);
  },
  child: const Icon(Icons.keyboard_arrow_right),
),
Screen.Recording.2024-10-06.at.1.21.26.PM.mov

@ricardodalarme
Copy link
Owner

Wow, what a great change! I really appreciate that. I've just merged your changes. Thank you so much for your contribution!

@HeySreelal
Copy link
Contributor Author

Yay! I'm so happy to be part of this library! 🦄

@HeySreelal
Copy link
Contributor Author

I'm not sure why - the #30 is not closed yet, I think it can be closed as this PR is merged now :)

Also, if you may please let me know your thoughts on #47 - I already have the changes ready - I'm a little bit confused about it - whether we actually need it or not :)

Thankss again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Controller swipeLeft/Right angle
2 participants