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
  • 1.07
    • BugFix
Have Fun :)
@Alexander Stolte
 

Attachments

  • B4A Example.zip
    4.3 KB · Views: 335
  • B4I Example.zip
    6.7 KB · Views: 182
  • B4J Example.zip
    3.6 KB · Views: 195
  • ASSwipeCard.zip
    4.2 KB · Views: 25
Last edited:

Alexander Stolte

Expert
Licensed User
How can I fix the size of ASSwipeCard1.CardBackground ?
i'm lost, last time i used the iamir_glide i used the hosted builder and I was wondering why I can't compile...
How can I fix the size of ASSwipeCard1.CardBackground ?
by using this, a sleep:
B4X:
    Sleep(250)
    ASSwipeCard1.IniParent(xpnl_swipecard_background)
because the layout is resizing with a animation if you start the page...
It is not without reason that i have built a sleep into the example project at the beginning.

The view looks nice with the images. 😁
 

alimanam3386

Active Member
Licensed User
i'm lost, last time i used the iamir_glide i used the hosted builder and I was wondering why I can't compile...

by using this, a sleep:
B4X:
    Sleep(250)
    ASSwipeCard1.IniParent(xpnl_swipecard_background)
because the layout is resizing with a animation if you start the page...
It is not without reason that i have built a sleep into the example project at the beginning.

The view looks nice with the images. 😁

Works nice 😍 thank you so much. I made a small donate for your fantastic job.
 

ykucuk

Well-Known Member
Licensed User
Hello,
I have 2 questions.
1- i tried add CustomListView or scrollview into xpnl_cardbase but unfortunately it didn't work. Is there way to add such view into xpnl_cardbase.
2-is it possible show icon or paint xpnl_cardbase (red /green) during swipe event
 

Alexander Stolte

Expert
Licensed User
1- i tried add CustomListView or scrollview into xpnl_cardbase but unfortunately it didn't work. Is there way to add such view into xpnl_cardbase.
No, not without losing the touch gestures.
2-is it possible show icon or paint xpnl_cardbase (red /green) during swipe event
The " SwipeStateChanged" is triggered when you swipes or returns to the neutral position.
 

alimanam3386

Active Member
Licensed User
Update
  • 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

the attached file has password 👽 ?
 

Alexander Stolte

Expert
Licensed User

Drago Bratko

Member
Licensed User
No, read the text below, it says why.
Yes, that's true in scenario when control is used to 'remove' the card from the list.

In my case, I have bunch of cards, and swipe left moves to the previous card (if on the first, go to last) and swipe right moves to next card (if on last, move to the first).
What do you suggest, how can I implement that?
 

Alexander Stolte

Expert
Licensed User
Update
  • V1.03
    • get CurrentIndex is now readable
In my case, I have bunch of cards, and swipe left moves to the previous card (if on the first, go to last) and swipe right moves to next card (if on last, move to the first).
What do you suggest, how can I implement that?
B4X:
Private Sub ASSwipeCard1_SwipeStateChanged(state As Int)
    If state = ASSwipeCard1.SwipeState_LEFT Then
        ASSwipeCard1.CurrentIndex = ASSwipeCard1.CurrentIndex +1
    End If
End Sub
-SwipeStateChanged - Triggers only when the user has released the card
 

Drago Bratko

Member
Licensed User
-SwipeStateChanged - Triggers only when the user has released the card

You are more than great! :) Thank you.

Now, only issue which I see is when I slide to right (so I go one card back), then first is shown next card for a split of a second, and then it's replaced with previous one.
Any idea how to handle that?
 
Top