https://kotlinlang.org logo
#kobweb
Title
# kobweb
f

Filip Wiesner

03/05/2023, 4:44 PM
Is there a way to combine multiple `ComponentStyle`s into on
ComponentStyle
? And is that even something I want to do? I have
MaterialShadowStyle
and now I am creating some specific component that should have this shadow. Is my only option to combine modifiers in the composable?
d

David Herman

03/05/2023, 4:46 PM
You can listOf them together and convert the list into a modifier
If you want one component style to always include another as a dependency, you can also use the extraModifiers field for that. Use that with more caution but let me link to an example, one sec
f

Filip Wiesner

03/05/2023, 4:49 PM
If you want one component style to always include another as a dependency, you can also use the extraModifiers field for that
That's what I wanted to do initially but I need to be in Composable context to convert style into modifier.
Oh! I see 😄
d

David Herman

03/05/2023, 4:50 PM
Yeah, it was only added in the most recent version, but there's a callback version of extraModifiers now that's Composable
f

Filip Wiesner

03/05/2023, 4:51 PM
Sadly, I am using version 0.12.0 😕
d

David Herman

03/05/2023, 4:51 PM
In general, though, I try to share modifiers across component styles, for maximum flexibility if I need to pivot later.
Gotcha
I think Compose 1.3.1 is coming out very soon, so 0.12.1 should follow shortly after
Sorry you got caught in 0.12.0!
Downgrading to 0.11.11 might not be too bad -- just set Kotlin to 1.7.20 and Compose to 1.2.2 and it might just compile as is
f

Filip Wiesner

03/05/2023, 4:55 PM
I've tried that (and other combinations) but 0.12.0 was the only version that compiled. I think that it's because I have 3 sources of compose runtime - Android, Kobweb and Molecule
And I have 3 platforms (Android, iOS, web) with a few multiplatform libraries. It took me few hours to find working combinations so I don't want to go through that again anytime soon 😄
d

David Herman

03/05/2023, 4:57 PM
Ah wow
Ok well for you I promise I'll prioritize a 0.12.1 release! It will require Kotlin 1.8.10 though I believe
f

Filip Wiesner

03/05/2023, 5:04 PM
Thank you but no need to rush. I will have to wait for all my dependencies to be compatible again 😄 But hopefully Kotlin 1.7 -> 1.8 was the hurdle and now it will be smooth upgrade
d

David Herman

03/05/2023, 5:07 PM
Good to know! Yeah I get the feeling 1.8 was a pretty big change under the hood.
7 Views