Creating a Multi Product Card using a single SDUICard
The above product listing is created from a single SDUICard, unlike the other example.
1. create a page... (use layout)
2. Add a div to the page
3. Add a SDUICard
We load the layout and then add thee button icons
We then load the template and bind the action buttons..
See demoMultiCard code module
Happy Coding!
The above product listing is created from a single SDUICard, unlike the other example.
1. create a page... (use layout)
2. Add a div to the page
3. Add a SDUICard
We load the layout and then add thee button icons
B4X:
banano.LoadLayout(app.PageViewer, "admulticardlayout")
btnLike = pcard.AddActionButtonIcon("like", "fa-solid fa-thumbs-up", app.COLOR_GHOST)
btnLike.Circle.Icon.SizeXLarge.Color = "success"
'
btnComment = pcard.AddActionButtonIcon("comment", "fa-solid fa-comment", app.COLOR_GHOST)
btnComment.Circle.Icon.SizeXLarge.Color = "warning"
'
btnShare = pcard.AddActionButtonIcon("share", "fa-solid fa-share", app.COLOR_GHOST)
btnShare.Circle.Icon.SizeXLarge.Color = "accent"
'
btnWish = pcard.AddActionButtonIcon("wish", "fa-solid fa-heart", app.COLOR_GHOST)
btnWish.Circle.Icon.SizeXLarge.Color = "red"
'
btnBuy = pcard.AddActionButton("buy", "Buy", "")
We then load the template and bind the action buttons..
B4X:
'save the template to the app and hide it
app.AddTemplateFromLayout("pcard", True, pcard.Children)
'template:
'{{image}}
'{{title}}
'{{price}}
'{{pricecolor}}
'{{description}}
'create list with same fields
Dim products As List
products.Initialize
products.Add(CreateMap("id":"p1", "image":"./assets/banner_7.jpg", "alt":"","title":"Amazing Product 1", "price":"3.00", "pricecolor":"success","description":"This product is..."))
products.Add(CreateMap("id":"p2", "image":"./assets/10.jpg", "alt":"","title":"Amazing Product 2", "price":"29.00", "pricecolor":"accent","description":"This product is..."))
products.Add(CreateMap("id":"p3", "image":"./assets/9.jpg", "alt":"","title":"Amazing Product 3", "price":"35.00", "pricecolor":"neutral","description":"This product is..."))
products.Add(CreateMap("id":"p4", "image":"./assets/banner_8.jpg", "alt":"","title":"Amazing Product 4", "price":"360.00", "pricecolor":"secondary","description":"This product is..."))
products.Add(CreateMap("id":"p5", "image":"./assets/nature_01.jpg", "alt":"","title":"Amazing Product 5", "price":"530.00", "pricecolor":"info","description":"This product is..."))
products.Add(CreateMap("id":"p6", "image":"./assets/nature_09.jpg", "alt":"","title":"Amazing Product 6", "price":"333.00", "pricecolor":"warning","description":"This product is..."))
products.Add(CreateMap("id":"p7", "image":"./assets/12.jpg", "alt":"","title":"Amazing Product 7", "price":"100.00", "pricecolor":"error","description":"This product is..."))
'update the parent fom the template using the list
app.SetItemsFromTemplate(Me, "dprojects", "pcard", "", products)
'bind the action buttons
pcard.BindActions(products)
See demoMultiCard code module
Happy Coding!
Last edited: