dimsuz
08/16/2020, 7:43 PMImageAsset
or VectorAsset
(for example Icon
). And this is done using overloads. So if my composable has Icon
as a child and I want to make the asset which I pass to it configurable, I have to introduce 2 overloads too. And this repeats up and up. The thought was: if ImageAsset
and VectorAsset
had some comon supertype this would be easier. For example some kind of sealed class Resource { class ImageAsset; class VectorAsset }
. I suspect that current state of affairs had some reasoning behind it, does anyone know more?romainguy
08/16/2020, 9:16 PMIcon
however it wants. Or better it can pass something else too.dimsuz
08/16/2020, 9:55 PMandylamax
08/16/2020, 10:05 PMIconifiedButton
and set the configure the common cases as you like. Now you have one Composable
wich takes an Icon
as a param (the one that changes) with the settings of our choosing. Makes sense? You wouldn't have to duplicate your configurations, all you'll have to do is call your IconifiedButton
and pass the Icon
you wanna passdimsuz
08/16/2020, 10:13 PMPrimaryButton
example. But then if 99% of usecases are interested in only changing R.drawable.some_icon
(which can be either image or vector asset) requiring passing a whole Icon
for that feels a bit verbose.
But it's just a thought, in the end I understand that Jepack Compose is about composables, so passing an Icon is probably more idiomatic.andylamax
08/16/2020, 10:20 PMPrimaryButton
can even have a default Icon
to make it simpleNader Jawad
08/19/2020, 6:01 AMdimsuz
08/20/2020, 8:22 PMsealed class Asset {
data class ImageAsset(...) : Asset()
data class VectorAsset(...) : Asset()
}
doesn't seem weird. Seems like a valid API-design choice. But I guess there were some other considerations.Nader Jawad
08/20/2020, 8:25 PMNader Jawad
08/20/2020, 8:25 PMdimsuz
08/20/2020, 8:30 PMwhen
in my example above. Also the fact that almost identical overloads for these assets present on Icon
class, indicates that these are quite similar.Nader Jawad
08/20/2020, 8:54 PMdimsuz
08/20/2020, 10:11 PMNader Jawad
08/20/2020, 10:13 PMdimsuz
08/20/2020, 11:25 PMromainguy
08/21/2020, 12:05 AMdimsuz
08/21/2020, 12:26 AMromainguy
08/21/2020, 3:01 AM