B4A Library [B4X] AS Badges

I took the original Badger code from @Erel and modified it to create a new view.

I spend a lot of time in creating views, some views i need by my self, but some views not and to create a high quality view cost a lot of time. If you want to support me, then you can do it here by Paypal or with a coffee. :)

HaFwyUsG29gMKxUDFcgXVseSYIH7xmEVuheZnONObjKiy8NhV7.jpeg
eysUfXNkpcCfzvFJeFL293p5vK89yTavWluDGGIbjlVjkWhYSc.jpeg

McpTn9tnkol0FTSta3fZW89ZNCGsShrQh5LQuv1ruL32FEtxjG.jpeg
iJ57UPktsNucIj891KjywHOrhsFWKCSIIgBd718qi0HYXSpT5q.jpeg


TextAnimation_Slide
Badges_Slide.gif

TextAnimation_Growth
Badges_Growth.gif

TextAnimation_FadeIn
Badges_FadeIn.gif

B4X:
Dim BadgeProperties As AS_Badges_BadgeProperties = AS_Badges1.BadgeProperties
BadgeProperties.BackgroundColor = xui.Color_Red
BadgeProperties.Orientation = AS_Badges1.Orientation_TopLeft
AS_Badges1.SetBadge2(xlbl_Label,8,BadgeProperties)
ASBadges
Author: Alexander Stolte
Version: 1.01

  • AS_Badges
    • Functions:
      • Class_Globals As String
      • CreateAS_Badges_BadgeProperties (BackgroundColor As Int, TextColor As Int, xFont As B4XFont, Orientation As String) As AS_Badges_BadgeProperties
      • GetBadgeCounter (view As B4XView) As Int
        Gets the Count of the badge on this view
      • getBadgeProperties As AS_Badges_BadgeProperties
      • getFadeInDuration As Long
        Default: 250
      • getOrientation_BottomLeft As String
      • getOrientation_BottomRight As String
      • getOrientation_TopLeft As String
      • getOrientation_TopRight As String
      • getRadius As Float
      • getTextAnimation As String
      • getTextAnimation_FadeIn As String
      • getTextAnimation_Growth As String
      • getTextAnimation_Slide As String
      • getTextDuration As Long
        Default: 250
      • Initialize As String
      • IsInitialized As Boolean
        Tests whether the object has been initialized.
      • SetBadge (View As B4XView, Badge As Int) As String
      • SetBadge2 (View As B4XView, Badge As Int, Properties As AS_Badges_BadgeProperties) As String
      • setBadgeProperties (Properties As AS_Badges_BadgeProperties) As String
      • setFadeInDuration (Duration As Long) As String
      • setRadius (Radius As Float) As String
      • setTextAnimation (AnimationName As String) As String
      • setTextDuration (Duration As Long) As String
    • Properties:
      • BadgeProperties As AS_Badges_BadgeProperties
      • FadeInDuration As Long
        Default: 250
      • Orientation_BottomLeft As String [read only]
      • Orientation_BottomRight As String [read only]
      • Orientation_TopLeft As String [read only]
      • Orientation_TopRight As String [read only]
      • Radius As Float
      • TextAnimation As String
      • TextAnimation_FadeIn As String [read only]
      • TextAnimation_Growth As String [read only]
      • TextAnimation_Slide As String [read only]
      • TextDuration As Long
        Default: 250
  • AS_Badges_BadgeProperties
    • Fields:
      • BackgroundColor As Int
      • IsInitialized As Boolean
        Tests whether the object has been initialized.
      • Orientation As String
      • TextColor As Int
      • xFont As B4XFont
    • Functions:
      • Initialize
        Initializes the fields to their default value.
Changelog
  • 1.00
    • Release
  • 1.01 (read more)
    • B4J BugFix - The text animation now no longer slips outside the badge
    • Add get and set TextAnimation - Various text change animations
      • Default: TextAnimation_Slide
      • TextAnimation_Slide - The old text slides out to the right
      • TextAnimation_Growth - The font grows animated
      • TextAnimation_FadeIn - The alpha of the new text is increased animatedly
  • 1.02 (read more)
    • Breaking Change - Initialize needs now a CallBack and a EventName
    • Add Event Click
  • 1.03 (read more)
    • BugFixes
    • Add set AutoRemove - Removes the badge if the value is 0
      • Default: True
Have Fun :)
 

Attachments

  • AS Badges Example.zip
    10 KB · Views: 239
  • AS_Badges.b4xlib
    2.8 KB · Views: 82
Last edited:

Alexander Stolte

Expert
Licensed User
Longtime User
Update
  • 1.01
    • B4J BugFix - The text animation now no longer slips outside the badge
    • Add get and set TextAnimation - Various text change animations
      • Default: TextAnimation_Slide
      • TextAnimation_Slide - The old text slides out to the right
      • TextAnimation_Growth - The font grows animated
      • TextAnimation_FadeIn - The alpha of the new text is increased animatedly
TextAnimation_Slide
Badges_Slide.gif

TextAnimation_Growth
Badges_Growth.gif

TextAnimation_FadeIn
Badges_FadeIn.gif
 

Alexander Stolte

Expert
Licensed User
Longtime User
Update
  • 1.02
    • Breaking Change - Initialize needs now a CallBack and a EventName
    • Add Event Click
Initialize needs now a CallBack and a EventName
B4X:
AS_Badges1.Initialize(Me,"Badges1")
Click Event
You can do something like this
Badges_ClickEvent.gif

B4X:
Private Sub Badges1_Click (Parent As B4XView)
    AS_Badges1.SetBadge(Parent,AS_Badges1.GetBadgeCounter(Parent) +1)
End Sub
 
Top