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

[Enhancement] Add EmptyView property #8

Open
jfversluis opened this issue Dec 5, 2018 · 6 comments
Open

[Enhancement] Add EmptyView property #8

jfversluis opened this issue Dec 5, 2018 · 6 comments

Comments

@jfversluis
Copy link

It would be great if an EmptyView property was added which can take in a ContentView that is shown whenever there are no items or no items left. Basically, Tinder saying like: "you swiped through all your matches, come back later".

@markolazic88
Copy link
Owner

This is a cool idea! I will add it to the new features list. Thanks!

@jfversluis
Copy link
Author

If I can find some time I will see to contribute something(s) myself 🙂

@bgaprogrammer
Copy link

Hello, just wondering with the current release how can I identify when there are no more cards to swipe? maybe to execute a command or reload the ItemSource when this happens #Thanks

@markolazic88
Copy link
Owner

@bgaprogrammer In your OnSwipedCommand method you could check if the swiped item equals to the last item in ItemsSource:

private void OnSwipedCommand(SwipedCardEventArgs eventArgs) { var item = eventArgs.Item as string; var noMoreItemsToSwipe = item == CardItems.LastOrDefault(); }

@bgaprogrammer
Copy link

Thanks @markolazic88 that did the trick.

Regarding reloading the ItemSource list, I've noticed there is some kind of issue with the card rendering. In my scenario I'm pulling new items from my API and replacing the entire ItemSource, the problem is that the last card visible to the user continues visible despite I changed the whole ItemSource list, any idea how to refresh the current visible card to the new one (top one)?

I've tried assiging the TopItem to the First one of the new list, but don't work

@Tommigun1980
Copy link
Contributor

Tommigun1980 commented Jul 21, 2020

Imho an 'empty' card should be handled by the application programmer by pushing one at the end of the stack and disable any functionality in the bindings by checking whether it's the end card, instead of being built into the component (which would complicate it unnecessarily). The app programmer also has a choice of adding a UI element below the deck that gets drawn when the deck is empty, while hiding the swipe view when empty.

The recent fixes to swipe view will set TopItem to null when the deck is empty, making it easy to use bindings to detect this (something like IsVisible={Binding TopItem, Source={x:Reference myDeck}, Converter={StaticResource IsNullConverter / IsNotNullConverter}}.

So TLDR: I don't think it'd be a good idea to build this functionality into the swipe view itself, as it can be handled by the app programmer.

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

No branches or pull requests

4 participants