in LazyLayouts optimise performance by reusing the composeable. I am catering for a use-case where the user can toggle between grid and single row cells. More in 🧵
Ahmed
02/20/2025, 6:36 AM
Is this a valid contentType
Copy code
contentType = {
when (it) {
is ListingModel -> if (isFatCard) "FatCard" else if (isGridView) "ListingCell" else "ListingRow"
is AdModel -> "AdPlaceholderModel"
is HeaderModel -> "HeaderModel"
}
},
Ahmed
02/20/2025, 6:37 AM
The issue is that the same model can be a Cell in a grid or an entire row. I only change
GridItemSpan
Ahmed
02/20/2025, 6:38 AM
Depending on a selection, the same item can also be either lean or Fat.
Ahmed
02/20/2025, 6:40 AM
In short,
ListingModel can show up as a
1. Lean Rectangle
GridItemSpan(2)
2. Fat Rectangle
GridItemSpan(2)
3. Square
GridItemSpan(1)
Ahmed
02/20/2025, 6:41 AM
I am not quite clear on if I show provide
it
,
class
or if current way of doing it is the most optimal.
k
Kashismails
02/21/2025, 3:54 PM
Its valid but the only issue i could see is it relies on external states type should should be encapsulated within the models like in your case it can be a sealed class shape from which they can inherit and polymorphic type can be determined by a discriminator