[B4X] [XUI] AS Settings
Introducing a new library that allows you to create your own settings page with minimal code. This library comes equipped with automatic saving and loading features, making it incredibly easy to manage your settings. It supports booleans, free text, numbers, comboboxes, action buttons and more...
This setting allows users to select a color. For example, to change the main app color, which is a premium feature in most apps.
The size of the circles can be freely defined.
Example
Mixed example with group:
Dim lst_Colors As List
lst_Colors.Initialize
lst_Colors.Add(xui.Color_ARGB(255, 49, 208, 89))
lst_Colors.Add(xui.Color_ARGB(255, 25, 29, 31))
lst_Colors.Add(xui.Color_ARGB(255, 9, 131, 254))
lst_Colors.Add(xui.Color_ARGB(255, 255, 159, 10))
lst_Colors.Add(xui.Color_ARGB(255, 45, 136, 121))
lst_Colors.Add(AS_Settings1.CreateColorItem(xui.Color_ARGB(255, 73, 98, 164),False)) 'This item is deactivated and cannot be selected
lst_Colors.Add(AS_Settings1.CreateColorItem(xui.Color_ARGB(255, 221, 95, 96),False)) 'This item is deactivated and cannot be selected
lst_Colors.Add(AS_Settings1.CreateColorItem(xui.Color_ARGB(255, 141, 68, 173),False))'This item is deactivated and cannot be selected
lst_Colors.Add(xui.Color_Magenta)
lst_Colors.Add(xui.Color_Cyan)
'With Group
AS_Settings1.MainPage.AddProperty_ColorChooser("ColorChooser","AppColor",lst_Colors,xui.Color_Magenta,50dip,Null)
Icons
You can add an icon which is displayed in the center right, e.g. to show that this is a premium feature and not available for free users.
Disable Items
You can deactivate items that are then not selectable for users. If the user clicks on such a disabled item, the
DisabledItemClicked
event is triggered and the developer can react to it to signal to the user that this item is disabled.Just add a item to the list with the
CreateColorItem
function and set the enabled property to False
B4X:
Dim lst_Colors As List
lst_Colors.Initialize
lst_Colors.Add(xui.Color_Magenta) 'This item is selectable
lst_Colors.Add(AS_Settings1.CreateColorItem(xui.Color_ARGB(255, 73, 98, 164),False)) 'This item is deactivated and cannot be selected
lst_Colors.Add(AS_Settings1.CreateColorItem(xui.Color_ARGB(255, 221, 95, 96),False)) 'This item is deactivated and cannot be selected
AS_Settings1.MainPage.AddProperty_ColorChooser("ColorChooser","AppColor",lst_Colors,xui.Color_Magenta,50dip,Null)
DisabledItemClicked Event
This event is triggered when the user clicks on a deactivated item.
You can then react to this and, for example, inform the user that this is only selectable in the Premium version.
B4X:
Private Sub AS_Settings1_DisabledItemClicked(Property As AS_Settings_Property, Value As Object)
LogColor("DisabledItemClicked",Value)
End Sub
ValueChanged Event
When the user selects an item, the ValueChanged event is triggered as normal and the value is the color defined for the item.
B4X:
Private Sub AS_Settings1_ValueChanged(Property As AS_Settings_Property, Value As Object)
Select Property.PropertyName
Case "AppColor"
LogColor("ValueChanged AppColor",Value)
End Select
End Sub
Attachments
Last edited: