B4A Library [B4X] [XUI] AS Swipe Card - a tinder like swipeable card view

Hello Community,

This library is not free, because, it cost a lot of time and gray hair to create such views.
Donations from 5€ or 6$ are valid. (You can donate any amount you want :))
Please write SwipeCard in the order description, thanks.

Thanks for your understanding. :)

This library is compatible and tested with B4A,B4I and B4J!
If you have bugs or a wish then tell me it in the comments.

Features
  • cross-platform compatible
  • enable or disable events
  • add and remove cards
  • scroll to cards
  • animations
  • swipe with fingers
  • and more...
sc_1.gif
sc_2.gif
Bildschirmaufnahme 2020-05-06 um 19.47.082.gif


On B4J and B4I you need a base panel, only this way the events can be triggered by your other control elements, see the example projects to learn more.

ASSwipeCard
Author: Alexander Stolte
Version: 1.06

  • ASSwipeCard
    • Events:
      • BaseResize (Width As Double, Height As Double)
      • IndexChanged (index As Int)
      • ReachEnd
      • SwipeStateChange (state As Int)
      • SwipeStateChanged (state As Int)
    • Functions:
      • AddCard (xpnl As B4XView, Tag As Object) As String
      • Class_Globals As String
      • Clear As String
        Clears all cards
      • DesignerCreateView (Base As Object, Lbl As Label, Props As Map) As String
        Base type must be Object
      • getBase As B4XView
      • GetCard (Index As Int) As B4XView
      • getCardBackground As B4XView
      • getSize As Int
      • getTag (Index As Int) As Object
      • IniParent (parent As B4XView) As String
      • Initialize (Callback As Object, EventName As String) As String
      • IsInitialized As Boolean
        Tests whether the object has been initialized.
      • NextCard (swipe_state As Int)
      • PreviousCard (swipe_state As Int)
      • RemoveCard (Index As Int) As String
      • setCurrentIndex (index As Int) As String
      • SwipeState_BOTTOM As Int
      • SwipeState_LEFT As Int
      • SwipeState_NEUTRAL As Int
      • SwipeState_RIGHT As Int
      • SwipeState_TOP As Int
      • SwipeStateRandom As Int
    • Properties:
      • Base As B4XView [read only]
      • CardBackground As B4XView [read only]
      • CurrentIndex
      • Size As Int [read only]
  • SwipeCardItems
    • Fields:
      • IsInitialized As Boolean
        Tests whether the object has been initialized.
      • Tag As Object
      • xpnl_cardbase As B4XView
    • Functions:
      • Initialize
        Initializes the fields to their default value.
Changelog
  • 1.00
    • Release
  • 1.01
    • Add Designer Property: EnableLeftRightSwipe -Enabled or Disabled the swipe gesture for left and right swiping
    • Add Designer Property: EnableTopBottomSwipe -Enabled or Disabled the swipe gesture for top and bottom swiping
  • 1.02
    • Add Event "SwipeStateChange" - Triggers when the card is moved with the finger in one direction e.g. LEFT,RIGHT,TOP,BOTTOM or NEUTRAL
    • Event "SwipeStateChanged" - Triggers now only when the user has released the card
    • Add Clear - clears all cards
  • 1.03
    • get CurrentIndex is now readable
  • 1.04
    • Add Designer Properties - If true then the previous card is shown as next card if you swipe in the right direction
      • SwipeLeft2Previous
      • SwipeRight2Previous
      • SwipeTop2Previous
      • SwipeBottom2Previous
  • 1.05
    • BugFixes for the Features of V1.04
  • 1.06
    • BugFix
Have Fun :)
@Alexander Stolte
 

Attachments

  • B4A Example.zip
    4.3 KB · Views: 299
  • B4I Example.zip
    6.7 KB · Views: 154
  • B4J Example.zip
    3.6 KB · Views: 168
  • ASSwipeCard.zip
    4.2 KB · Views: 15
Last edited:

Alexander Stolte

Expert
Licensed User
tested on b4i on an iphone 6 (ios 12.4.5) - the demo works great - had it running in 2 minutes. Great work!!!
Thank you, on a real device? Was it smooth? because on my simulator the performance was not the best, but the same code is running well on B4A in debug mode.

Well done Alexander , well done 👍
Thanks! :)
 

miker2069

Active Member
Licensed User
Question - I notice that pressing the next and prev button will increment/decrement the cards. However swiping up or down (or left or right) always increments the cards. If I wanted the card sequence to say increment when I swipe up or swipe right and decrement when I swipe left or swipe down - how would I do that? I see that SwipeStateChanged is called and you can get the swipe action but it seems that the card is incremented before this event is called. Is there a way to get the swipe action and then set the card I'd like to display next?
 

miker2069

Active Member
Licensed User
Thank you, on a real device? Was it smooth? because on my simulator the performance was not the best, but the same code is running well on B4A in debug mode.


Thanks! :)
Well using the bext/previous button the transition was super smooth. Using swipe action, it wasn't as smooth but not bad or anything (release mode is a little faster than debug). The iphone 6 isn't considered latest/greatest and other apps to me feel sluggish so I would attribute this maybe to the phone itself. I have an iphone 10 and will try it on that in the next day or so. Still totally usable though with swipe actions
 

Alexander Stolte

Expert
Licensed User
Question - I notice that pressing the next and prev button will increment/decrement the cards. However swiping up or down (or left or right) always increments the cards. If I wanted the card sequence to say increment when I swipe up or swipe right and decrement when I swipe left or swipe down - how would I do that? I see that SwipeStateChanged is called and you can get the swipe action but it seems that the card is incremented before this event is called. Is there a way to get the swipe action and then set the card I'd like to display next?
Then I change it so that the cards are not automatically increased or decreased and the user has to do this himself in the event.

Well using the bext/previous button the transition was super smooth. Using swipe action, it wasn't as smooth but not bad or anything (release mode is a little faster than debug). The iphone 6 isn't considered latest/greatest and other apps to me feel sluggish so I would attribute this maybe to the phone itself. I have an iphone 10 and will try it on that in the next day or so. Still totally usable though with swipe actions
ok thank you, i am curious about the result of the iphone 10
 

Alexander Stolte

Expert
Licensed User
Question - I notice that pressing the next and prev button will increment/decrement the cards. However swiping up or down (or left or right) always increments the cards. If I wanted the card sequence to say increment when I swipe up or swipe right and decrement when I swipe left or swipe down - how would I do that? I see that SwipeStateChanged is called and you can get the swipe action but it seems that the card is incremented before this event is called. Is there a way to get the swipe action and then set the card I'd like to display next?
It's not possible. Have you ever seen someone wipe away a card to add another card? Well, I haven't. :)
 

saeed10051

Active Member
Licensed User
Hi Alexander very nice library. I need to know how can i put an image view to the swipe card and upload different image to every card. also is it possible to put different controls such as buttons or edittext or labels on each card and how to get the index of those controls so that coding can be done for different controls
 

Unobtainius

Active Member
Licensed User
I love the name ASSwhipe 😁👍
 

Unobtainius

Active Member
Licensed User
ASSwipeCard it's the name of the library unless I'm mistaken.
I've been playing with it and love it.
Awesome job
I want to learn more about about animation, it makes simple things look so much more interesting.
 

alimanam3386

Active Member
Licensed User
Thanks for this fantastic lib , how we can disable swipe_top and swipe_bottom ? I want use just swipe_left and swipe_right , what can I do with current lib to disable those swipe.
 

Alexander Stolte

Expert
Licensed User
how we can disable swipe_top and swipe_bottom ? I want use just swipe_left and swipe_right , what can I do with current lib to disable those swipe.
If you only want to diasable the top and bottom events then uncheck the designer properties:
1591458057165.png

But if you want to disable the swipe gestures to the top or to the bottom, then try to comment out all the code where "downy" occurs
 
Top