markolazic88 / swipecardview Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
When filtering the SwipeCardView.ItemSource programmatically no Biding field is showing data. Se an exemplo:
private void sbFilter_TextChanged(object sender, TextChangedEventArgs e) { //Filtro do listview, o parâmetro vem do SearchBox e pode ser o número ou nome da propriedade ou o nome da supervisora var name = sbFilter.Text; List<Technologie> selectItems = GlobalVar.dataBase.Query<Technologie>("SELECT * FROM tabcandidates WHERE fullName LIKE '%" + name + "%'"); SwipeCardView.ItemsSource = selectItems; lblCounter.Text = "Showing " + selectItems.Count.ToString() + " Candidate(s)"; }
Is there any support for multiple ItemTemplate, and then use the DataTemplateSelector to choose which DataTemplate to display.
I want to insert adverts every 5 cards and that has a different layout.
So define
ItemTemplate="{StaticResource EmptyViewTemplate}"
define your DataTemplate in the Resouces
and then reference a DataTemplateSelector. This works fine for a CarouselView, but errors with Failed on LoadTemplate for SwipeCardView - can you fix. I am pushed for time, so if you can either address this or let me know a work around I would really appreciate it.
<local:ResultTemplateSelector x:Key="ResultItemTemplateSelector"
AdvertViewTemplate="{StaticResource AdvertViewTemplate}"
DonorViewTemplate="{StaticResource DonorViewTemplate}"
EmptyViewTemplate="{StaticResource EmptyViewTemplate}" />
Thanks for awesome plugin.
Is this possible to add button or any other element on card? I have added button but its not clickable.
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".
If we use it using package manager, we will get this issue.
System.TypeLoadException: Could not resolve type with token 01000030 (from typeref, class/assembly Xamarin.Forms.Internals.ResourceLoader, Xamarin.Forms.Core, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null)
Hi! Is there any chance a new NuGet package could be published with the recent pull request fixes?
Thanks so much!
I'm currently try to swipe a card programatically so I use InvokeSwipe, but it appears that all my cards are swipped.
Is it a normal behavior ?
Ps: I'm on UWP if it can help
Currently it is not possible to "select" a card if tapped on it.
It would be great if this would be possible from the SwipeCardView level, as setting the GestureRecognizer on the Template interferes with the Pan Gesture Recognizer.
Hi, first, thank you for this amazing control. It works flawlessly and it is easy to work and customize.
Is there a way to go back to a card, something like the same function on tinder app? I mean, suppose you swipe a card and then want to go back to that card, on tinder specifically you press a button and the previous card comes from the left to the top of the "deck". Is this something possible?
xmls
config?xmlns:swipecards="clr-namespace:SwipeCards.Controls;assembly=SwipeCards.Controls"
Just added your (amazing) package to a new project and get something started. It looks and works really great, thank you for that!
To get started, I basically copied your Tinder example and start getting all the snippets I needed into my own project. I just forgot to set the BindingContext on my page which caused the items to be empty. Of course, totally on me. But when I swiped, it would give me an NRE and the whole app crashed. It might be nice to go about that a little more graceful. Here is the strack trace:
2018-12-05 08:52:23.706968+0100 SwipeConf.iOS[9516:7626443]
Unhandled Exception:
System.NullReferenceException: Object reference not set to an instance of an object
at MLToolkit.Forms.SwipeCardView.SwipeCardView.OnPanUpdated (System.Object sender, Xamarin.Forms.PanUpdatedEventArgs e) [0x00006] in <69a7c63c842440d492feb3399307c652>:0
at Xamarin.Forms.PanGestureRecognizer.SendPanStarted (Xamarin.Forms.Element sender, System.Int32 gestureId) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\PanGestureRecognizer.cs:38
at Xamarin.Forms.Platform.iOS.EventTracker+<>c__DisplayClass15_0.<GetNativeRecognizer>b__2 (UIKit.UIPanGestureRecognizer r) [0x000a2] in <18e93b810a4a4e2f919016f742528d37>:0
at UIKit.UIPanGestureRecognizer+Callback.Activated (UIKit.UIPanGestureRecognizer sender) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.2.1.11/src/Xamarin.iOS/UIKit/UIGestureRecognizer.cs:229
--- End of stack trace from previous location where exception was thrown ---
at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr)
at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.2.1.11/src/Xamarin.iOS/UIKit/UIApplication.cs:79
at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0002c] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.2.1.11/src/Xamarin.iOS/UIKit/UIApplication.cs:63
at SwipeConf.iOS.Application.Main (System.String[] args) [0x00001] in /Users/jfversluis/Projects/SwipeConf/SwipeConf.iOS/Main.cs:17
2018-12-05 08:52:23.707868+0100 SwipeConf.iOS[9516:7626443] Unhandled managed exception:
Object reference not set to an instance of an object (System.NullReferenceException)
at MLToolkit.Forms.SwipeCardView.SwipeCardView.OnPanUpdated (System.Object sender, Xamarin.Forms.PanUpdatedEventArgs e) [0x00006] in <69a7c63c842440d492feb3399307c652>:0
at Xamarin.Forms.PanGestureRecognizer.SendPanStarted (Xamarin.Forms.Element sender, System.Int32 gestureId) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\PanGestureRecognizer.cs:38
at Xamarin.Forms.Platform.iOS.EventTracker+<>c__DisplayClass15_0.<GetNativeRecognizer>b__2 (UIKit.UIPanGestureRecognizer r) [0x000a2] in <18e93b810a4a4e2f919016f742528d37>:0
at UIKit.UIPanGestureRecognizer+Callback.Activated (UIKit.UIPanGestureRecognizer sender) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.2.1.11/src/Xamarin.iOS/UIKit/UIGestureRecognizer.cs:229
--- End of stack trace from previous location where exception was thrown ---
at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr)
at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.2.1.11/src/Xamarin.iOS/UIKit/UIApplication.cs:79
at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0002c] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.2.1.11/src/Xamarin.iOS/UIKit/UIApplication.cs:63
at SwipeConf.iOS.Application.Main (System.String[] args) [0x00001] in /Users/jfversluis/Projects/SwipeConf/SwipeConf.iOS/Main.cs:17
2018-12-05 08:52:23.708208+0100 SwipeConf.iOS[9516:7626443] critical: Stacktrace:
2018-12-05 08:52:23.708315+0100 SwipeConf.iOS[9516:7626443] critical:
Native stacktrace:
2018-12-05 08:52:23.723877+0100 SwipeConf.iOS[9516:7626443] critical: 0 SwipeConf.iOS 0x00000001049f1cd4 mono_handle_native_crash + 244
2018-12-05 08:52:23.724097+0100 SwipeConf.iOS[9516:7626443] critical: 1 libsystem_platform.dylib 0x0000000112accb3d _sigtramp + 29
2018-12-05 08:52:23.724223+0100 SwipeConf.iOS[9516:7626443] critical: 2 ??? 0x000000000000ffff 0x0 + 65535
2018-12-05 08:52:23.724314+0100 SwipeConf.iOS[9516:7626443] critical: 3 libsystem_c.dylib 0x000000011284fc45 abort + 127
2018-12-05 08:52:23.724433+0100 SwipeConf.iOS[9516:7626443] critical: 4 SwipeConf.iOS 0x0000000104bfeccf xamarin_unhandled_exception_handler + 47
2018-12-05 08:52:23.724550+0100 SwipeConf.iOS[9516:7626443] critical: 5 SwipeConf.iOS 0x0000000104a8f18e mono_invoke_unhandled_exception_hook + 158
2018-12-05 08:52:23.724660+0100 SwipeConf.iOS[9516:7626443] critical: 6 SwipeConf.iOS 0x00000001049f167c mono_handle_exception_internal + 6140
2018-12-05 08:52:23.724756+0100 SwipeConf.iOS[9516:7626443] critical: 7 SwipeConf.iOS 0x00000001049efe79 mono_handle_exception + 25
2018-12-05 08:52:23.724864+0100 SwipeConf.iOS[9516:7626443] critical: 8 SwipeConf.iOS 0x0000000104970343 mono_amd64_throw_exception + 131
2018-12-05 08:52:23.724963+0100 SwipeConf.iOS[9516:7626443] critical: 9 ??? 0x000000013399b5a7 0x0 + 5160678823
2018-12-05 08:52:23.725065+0100 SwipeConf.iOS[9516:7626443] critical: 10 SwipeConf.iOS 0x00000001048d323d _ZL32native_to_managed_trampoline_192P11objc_objectP13objc_selectorPP11_MonoMethodP22UIPanGestureRecognizerj + 461
2018-12-05 08:52:23.725232+0100 SwipeConf.iOS[9516:7626443] critical: 11 SwipeConf.iOS 0x00000001048d3068 -[__UIPanGestureRecognizer target:] + 56
2018-12-05 08:52:23.725413+0100 SwipeConf.iOS[9516:7626443] critical: 12 UIKitCore 0x000000011adb7b81 -[UIGestureRecognizerTarget _sendActionWithGestureRecognizer:] + 57
2018-12-05 08:52:23.725597+0100 SwipeConf.iOS[9516:7626443] critical: 13 UIKitCore 0x000000011adc0a5f _UIGestureRecognizerSendTargetActions + 109
2018-12-05 08:52:23.725838+0100 SwipeConf.iOS[9516:7626443] critical: 14 UIKitCore 0x000000011adbe244 _UIGestureRecognizerSendActions + 305
2018-12-05 08:52:23.725983+0100 SwipeConf.iOS[9516:7626443] critical: 15 UIKitCore 0x000000011adbd49c -[UIGestureRecognizer _updateGestureWithEvent:buttonEvent:] + 858
2018-12-05 08:52:23.726143+0100 SwipeConf.iOS[9516:7626443] critical: 16 UIKitCore 0x000000011adaef20 _UIGestureEnvironmentUpdate + 1329
2018-12-05 08:52:23.726317+0100 SwipeConf.iOS[9516:7626443] critical: 17 UIKitCore 0x000000011adae9ad -[UIGestureEnvironment _deliverEvent:toGestureRecognizers:usingBlock:] + 478
2018-12-05 08:52:23.726527+0100 SwipeConf.iOS[9516:7626443] critical: 18 UIKitCore 0x000000011adae71d -[UIGestureEnvironment _updateForEvent:window:] + 200
2018-12-05 08:52:23.726791+0100 SwipeConf.iOS[9516:7626443] critical: 19 UIKitCore 0x000000011b21e78a -[UIWindow sendEvent:] + 4058
2018-12-05 08:52:23.726989+0100 SwipeConf.iOS[9516:7626443] critical: 20 UIKitCore 0x000000011b1fc394 -[UIApplication sendEvent:] + 352
2018-12-05 08:52:23.727213+0100 SwipeConf.iOS[9516:7626443] critical: 21 UIKitCore 0x000000011b2d15a9 __dispatchPreprocessedEventFromEventQueue + 3054
2018-12-05 08:52:23.727354+0100 SwipeConf.iOS[9516:7626443] critical: 22 UIKitCore 0x000000011b2d41cb __handleEventQueueInternal + 5948
2018-12-05 08:52:23.727508+0100 SwipeConf.iOS[9516:7626443] critical: 23 CoreFoundation 0x00000001052f3721 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
2018-12-05 08:52:23.727637+0100 SwipeConf.iOS[9516:7626443] critical: 24 CoreFoundation 0x00000001052f2f93 __CFRunLoopDoSources0 + 243
2018-12-05 08:52:23.727770+0100 SwipeConf.iOS[9516:7626443] critical: 25 CoreFoundation 0x00000001052ed63f __CFRunLoopRun + 1263
2018-12-05 08:52:23.728013+0100 SwipeConf.iOS[9516:7626443] critical: 26 CoreFoundation 0x00000001052ece11 CFRunLoopRunSpecific + 625
2018-12-05 08:52:23.728148+0100 SwipeConf.iOS[9516:7626443] critical: 27 GraphicsServices 0x0000000115cc31dd GSEventRunModal + 62
2018-12-05 08:52:23.728286+0100 SwipeConf.iOS[9516:7626443] critical: 28 UIKitCore 0x000000011b1e081d UIApplicationMain + 140
2018-12-05 08:52:23.728499+0100 SwipeConf.iOS[9516:7626443] critical: 29 ??? 0x00000001379a347e 0x0 + 5227820158
2018-12-05 08:52:23.728696+0100 SwipeConf.iOS[9516:7626443] critical: 30 ??? 0x00000001379a3213 0x0 + 5227819539
2018-12-05 08:52:23.728870+0100 SwipeConf.iOS[9516:7626443] critical:
=================================================================
Got a SIGABRT while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries
used by your application.
=================================================================
It seems that I am still allowed to swipe, even while there are no items and then it causes a NullReferenceException
because there are no items to work with.
Hi and thanks for a great component!
I noticed that if you use OptimizedObservableCollection (https://github.com/xamarinhq/xamu-infrastructure/blob/598f97d6f5cc68fc603873e913ccc9089dbc60df/src/XamU.Core/Collections/OptimizedObservableCollection.cs) with BeginMassUpdate, the deck is drawn as empty. Everything goes back to normal is the XAML is hot reloaded, but that is of course not shippable.
this.MyDeck = new OptimizedObservableCollection<MyCardType>()
{
EmptyCard
};
var newCards = ... ; // get from server
using (this.MyDeck.BeginMassUpdate())
this.MyDeck.AddRange(newCards);
<swipeCardView:SwipeCardView ItemsSource="{Binding MyDeck}">
Removing BeginMassUpdate() makes the problem go away. OptimizedObservableCollection is part of Microsoft's Xamarin University library and is quite convenient; it turns off sending events at start of BeginMassUpdate() and when exiting the using clause it sends reset event for the entire collection (which is of course faster than doing tons of updates). I haven't had problems using OptimizedObservableCollection with other components so I'm hopeful to get a fix for this :)
https://github.com/xamarinhq/xamu-infrastructure/blob/598f97d6f5cc68fc603873e913ccc9089dbc60df/src/XamU.Core/Collections/OptimizedObservableCollection.cs shows that OptimizedObservableCollection sends the following events when the operation is done:
public void Dispose ()
{
parent.shouldRaiseNotifications = true;
parent.OnPropertyChanged (new PropertyChangedEventArgs ("Count"));
parent.OnPropertyChanged (new PropertyChangedEventArgs ("Item[]"));
parent.OnCollectionChanged (new NotifyCollectionChangedEventArgs (NotifyCollectionChangedAction.Reset));
}
Maybe the order of events is something SwipeCardView doesn't understand?
Thanks so much!
Hey,
Less of a issue and more of a question but how did you make the card change colour when swiping between left and right , I went through your code but found no reference of it . Great plugin 👍
SwipedLeftCommand="{Binding SwipeCommand}"
SwipedRightCommand="{Binding SwipeCommand}"
Hi
I assigned a simple ObservableCollection to ItemsSource, and I soon as I swap a card, it crashes.
Error is in SwipeCardView.cs
Method: ShowNextCard()
Line: this.TopItem = this.ItemsSource[_itemIndex-1]; --> out of range exception
I only found a way to fix the issue by changing the code like this:
Instead of this.TopItem = this.ItemsSource[_itemIndex-1];
if (_itemIndex == 0)
_itemIndex = 1;
this.TopItem = this.ItemsSource[_itemIndex];
_itemIndex++;
And remove at the end of the method: _itemIndex++;
Regards
Bruno
Full method here:
private void ShowNextCard()
{
if (_cards[0].IsVisible == false && _cards[1].IsVisible == false)
{
this.Setup();
return;
}
if (_itemIndex == 0)
_itemIndex = 1;
this.TopItem = this.ItemsSource[_itemIndex];
_itemIndex++;
var topCard = _cards[_topCardIndex];
_topCardIndex = this.NextCardIndex(_topCardIndex);
// If there are more cards to show, show the next card in to place of
// the card that was swiped off the screen
if (_itemIndex < this.ItemsSource.Count)
{
// Push it to the back z order
((RelativeLayout)this.Content).LowerChild(topCard);
try
{
// Reset its scale, opacity and rotation
topCard.Scale = BackCardScale;
topCard.RotateTo(0, 0);
topCard.TranslateTo(0, -topCard.Y, 0);
}
catch (Exception exception)
{
Debug.WriteLine(exception);
}
topCard.BindingContext = this.ItemsSource[_itemIndex];
topCard.IsVisible = true;
}
}
Hi!
I noticed that no matter how I set the SwipeCardView up, it fills the entire area where it resides. So if I have it in a StackLayout, the SwipeCardView will the entire vertical space with FillAndExpand. If using anything else than FillAndExpand, the contents won't be shown.
I suspect this has to do with the relative layout that resides at root level inside the SwipeCardView. The reason I'd want the SwipeCardView to only fill the space of its children is;
If I replace the SwipeCardView with any other component the problem goes away, so it is definitely something it is doing internally. If there is a workaround or I've just missed something please advice!
Thank you.
Hi,
this is my problem: when I try to install your package in my Xamarin forms project, show this message:
Severity Code Description Project File Line Suppression State
Error NU1202 Package SwipeCardView 3.0.0 is not compatible with xamarinios10 (Xamarin.iOS,Version=v1.0) / win. Package SwipeCardView 3.0.0 supports: monoandroid81 (MonoAndroid,Version=v8.1) Glancy.iOS
Do you have any solution about this?
Hi, Do you can provide full example?
How to you binding TopItem ? I don't quite understand
Is it possible to resize the card?
If we swipe too fast on Android sometimes we get blank image.
Itemsource is bound to ObservableCollection of Imagesources
SwipedCommand is bound to async method and I am using await in it , also added some Task.Delay(200) in it
If I fast too fast like 3-4 images within a second I get blank image
Please note since ImageSources are generated from SkiaSharp SKImageImageSource I am unable to use FFImageLoading-CachedImage
it gives error invalid ImageSource
I have an issue with the swiping not working on android 9 and forms 4.8 it does not work any experience?
Is there any way to arrange data in vertical direction ?
so when user swipe left I want to remove that item and next item will shows up and we can scroll like a listview too.
I have SwipeCardView:
`ItemsSource="{Binding ImageSources}"`
My ImageSources have 10 items. How I can open 5 item? Is it possible?
My use case is this: the swipe direction of the current top item determines which item is added to the collection next, then removes the previous one, such that there is only one thing ever in the collection. It seems to get confused with this and causes a null reference error when removing the old item from the collection. Is there any way to implement my use case?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.