B4A Library [B4X] [XUI] FlipSwitch

FlipSwitch v1.00

My first attempt to create a CustomView.
It support B4A, B4J and B4i.
I want to Thank @LucaMs for giving me the will to do it and the beginning idea.
It's simply yet another ON/OFF switch.

FlipSwitch.gif


It feature a flap that got animated to change the state of the switch.
The colors (green and red) are fixed as they are images.

Features:
- Set the Initial Value (green or red)
- Customizable flipping speed
- Customizable text, text size and text color on both sides
- Value can be read or changed by code
- Size can be changed by code (max width as been set to 140dip to maintain graphic acceptable, larger size will be reduced to 140dip automatically)
- Left, Top, Right, Bottom, Width and Height are exposed and can both be read or changed by code
- ValueChanged Event is raised at every flip

Normally everything it's expected to be set from the Designer.
Thank You All!


ChangeLog:

Version 1.01
(09/09/2024)
- Added support for B4i. Thanks to @Sergio Haurat and @james_sgp for testing.

Version 1.00
(20/04/2024)
- Initial Release
 

Attachments

  • FlipSwitch_Demo.zip
    15.3 KB · Views: 154
  • FlipSwitch.b4xlib
    50.3 KB · Views: 59
Last edited:

Sergio Haurat

Active Member
Licensed User
Longtime User
In the case of B4I, change all SubExists as detailed below. B4I needs to know how many parameters the declared Sub should have. Additionally, use xui, which handles the arduous task of communication between different platforms.

Original:
If SubExists(mCallBack, mEventName & "_ValueChanged") Then
  CallSubDelayed2(mCallBack, mEventName & "_ValueChanged", mValue)
End If
Updated:
If xui.SubExists(mCallBack, mEventName & "_ValueChanged", 1) Then
  CallSubDelayed2(mCallBack, mEventName & "_ValueChanged", mValue)
End If

B4A IDE
1719083630991.png


B4I IDE
1719083948746.png
 

Sagenut

Expert
Licensed User
Longtime User
In the case of B4I, change all SubExists as detailed below. B4I needs to know how many parameters the declared Sub should have. Additionally, use xui, which handles the arduous task of communication between different platforms.

Original:
If SubExists(mCallBack, mEventName & "_ValueChanged") Then
  CallSubDelayed2(mCallBack, mEventName & "_ValueChanged", mValue)
End If
Updated:
If xui.SubExists(mCallBack, mEventName & "_ValueChanged", 1) Then
  CallSubDelayed2(mCallBack, mEventName & "_ValueChanged", mValue)
End If

B4A IDE
View attachment 154818

B4I IDE
View attachment 154819
Thank You for your help.
Anyway I would not be able to test it and I should create even the B4i layout.
 

james_sgp

Active Member
Licensed User
Longtime User
Hi, When I try to use the B4i Demo...I`m getting an error:

B4X:
Syntax error.
',' expected.

I`m running B4i 8.51.

James
 

Attachments

  • Screenshot 2024-08-25 112743.png
    Screenshot 2024-08-25 112743.png
    102.1 KB · Views: 35

Sagenut

Expert
Licensed User
Longtime User
Hi, When I try to use the B4i Demo...I`m getting an error:

B4X:
Syntax error.
',' expected.

I`m running B4i 8.51.

James
I am sorry but as wrote in the first post it actually support only B4A and B4J.
 
Top