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

Swiping like an arc with controller #47

Open
HeySreelal opened this issue Oct 6, 2024 · 2 comments
Open

Swiping like an arc with controller #47

HeySreelal opened this issue Oct 6, 2024 · 2 comments

Comments

@HeySreelal
Copy link
Contributor

Hi @ricardodalarme, I've recently added a PR #46 which contains the implementation for swiping to any given angle with the controller where as of now controller can only swipe the card to the predefined left, right, top, bottom directions.

#46 brings the ability to swipe to any given angle with the CardSwiperDirection.custom constructor to specify angle at which the card should be swiped.

But, along the way while I was implementing it, I had this idea in mind - generally humans swipe items on the screen like an arc or something - why can't we have that? Right now, even the swiping to custom angle basically moves the container in a linear path.

Can we add the CardSwiperController.swipeArc for this? Or do I sound way too stupid? :)

@HeySreelal
Copy link
Contributor Author

By the way, just taking a moment to thank you for this library! Truly makes lives easy - I should say best pick for card swiping packages out there in pub.dev.

Also, just want to let you know that, if this sounds good, I'll be happy to raise another PR for this. :)

In fact, I've tried implementing this in my fork here: HeySreelal/flutter_card_swiper/feat-arc-swipe.

Let me add couple of screen recording to illustrate this.

Screen Recordings

1. Normal Behavior

Code:

FloatingActionButton(
  onPressed: () {
    const dir = CardSwiperDirection.left;
    controller.swipe(dir);
  },
  child: const Icon(Icons.keyboard_arrow_left),
),
FloatingActionButton(
  onPressed: () {
    const dir = CardSwiperDirection.right;
    controller.swipe(dir);
  },
  child: const Icon(Icons.keyboard_arrow_right),
),
Screen.Recording.2024-10-06.at.1.20.52.PM.mov

2. Swiping to custom angle

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

3. Swiping to custom angle as arc

Code:

FloatingActionButton(
  onPressed: () {
    final dir = CardSwiperDirection.custom(290);
    controller.swipeArc(
      dir,
      curve: Curves.easeInOut,
    );
  },
  child: const Icon(Icons.undo),
),
FloatingActionButton(
  onPressed: () {
    final dir = CardSwiperDirection.custom(60);
    controller.swipeArc(
      dir,
      curve: Curves.easeInOut,
    );
  },
  child: const Icon(Icons.redo),
),
Screen.Recording.2024-10-06.at.1.21.03.PM.mov

That's it, hoping this would be a cool addition :)

Looking forward to hearing from you, thanks :)

@kvjoshi
Copy link

kvjoshi commented Dec 4, 2024

guys is this implemented ? i cannot find custom in the enums im at 7.0.2

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

No branches or pull requests

2 participants