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

Support full-screen cards #65

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

nalbion
Copy link

@nalbion nalbion commented Mar 1, 2021

The main purpose of this PR is to allow cards to be full-screen without the odd behaviour mentioned in #55.

In order to achieve this I've had to make a number of changes:

  • Transform is used to translate and scale the card instead of Align and SizedBox
  • Switching from SizedBox means that text on the card is resized instead of moved to different lines when the card size animates.
  • Cards behind the front card are scaled in perspective, so you can have unlimited cards in your stack without cards at the back suddenly becoming larger
  • Instead of specifying a minimum height/width, you can specify a scaling factor.
  • card[0] is the front card - it removes a lot of complexity from the code
  • the rotation angle depends on whether you started dragging the top or bottom half of the card. The card stays pinned under your finger and the far end drags behind.

orientation = CardSwipeOrientation.recover;
}

if (widget.swipeCompleteCallback != null) {
widget.swipeCompleteCallback(orientation, index);
widget.swipeCompleteCallback(orientation);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any Reason why we are not sending the current card Index being swiped in the call back?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, because index = 0 is now the front card. You don't need to track _currentFront - the code becomes a lot simpler.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but on the client-side how do we track which card was swiped?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's always card[0]

Copy link

@maheshj01 maheshj01 Mar 29, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So how do we handle a case e.g ,
I have a set of 5 cards and I would like to show some text associated with each card.
so basically there will be a

List<String> ['A','B','C','D','E'];

so in order to show a appropriate text with each card we will need the index of the card being swiped.

Let me know If I am wrong or missing anything :)

Copy link
Author

@nalbion nalbion Mar 29, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could have left the index argument in, but it would be 0 every single time.

Copy link

@maheshj01 maheshj01 Mar 29, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So is it like if I have List mapped to cards.on each swipe complete callback I should remove the first element of this list.
And then the first element of the resulting list will be associated with the current card?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for asking too many questions

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, the top/first card gets special treatment - it's the only one that can be swiped, and then it's removed from the list

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the explanation

@xxJeevesxx
Copy link

Do we know if this will get reviewed and closed?

@maheshj01
Copy link

cc: @ShaunRain

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.

3 participants