Sub edit_category_click(e As BANanoEvent)
Dim editOption As SHIonItemOption = Sender
app.ShowToastSuccess("", editOption.Tag)
End Sub
Sub delete_category_click(e As BANanoEvent)
Dim delOption As SHIonItemOption = Sender
app.ShowToastSuccess("", delOption.Tag)
End Sub
Sub MountCategories
'clear the list
PageList.Clear
'define the items to add to the list
Dim lstCategories As List
lstCategories.Initialize
lstCategories.Add(CreateMap("id":"1", "color":"#fe4a49", "name":"Holidays"))
lstCategories.Add(CreateMap("id":"2", "color":"#2ab7ca", "name":"Tournaments"))
lstCategories.Add(CreateMap("id":"3", "color":"#fed766", "name":"Birthdays"))
lstCategories.Add(CreateMap("id":"4", "color":"#e6e6ea", "name":"Meetings"))
'loop through each category
For Each cat As Map In lstCategories
'number for the layout
Dim Ret As Long
'add the views in the layout
Dim AllViews As Map
'load the first item and not clear the parent
Ret = banano.LoadLayoutArray(PageList.here, "categorylayout", False)
Log(Ret)
' ret returns a unique number you can use to get all views
AllViews = banano.GetAllViewsFromLayoutArray(Me, "categorylayout", Ret)
'get the color of the item
Dim categorycolor As SHLabel = AllViews.Get("categorycolor")
'change the background color
categorycolor.BackgroundColor = cat.Get("color")
Dim categoryname As SHIonLabel = AllViews.Get("categoryname")
categoryname.Text = cat.Get("name")
Dim categoryedit As SHIonItemOption = AllViews.Get("categoryedit")
categoryedit.Tag = cat.Get("id")
'assign event
categoryedit.OnEvent("click", Me, "edit_category_click", Null)
Dim categorydelete As SHIonItemOption = AllViews.Get("categorydelete")
categorydelete.Tag = cat.Get("id")
categorydelete.OnEvent("click", Me, "delete_category_click", Null)
'change the text of the label
'assign events to the options
Next
'mount event categories
'save To users collection
'Dim rsCategories As SithasoFireBaseCollection = fb.collection("categories")
'get the data model
'rsCategories.SetSchemaFromDataModel(app.DataModels)
'add categories to the list
End Sub