Florian Eula
06/27/2023, 11:32 AMStylianos Gakis
06/27/2023, 12:50 PM@Composable
fun YourButton(foo: Any,..., config: YourButtonConfig) {
when(config) {
smth#1 -> //style 1
smth#2 -> //style 2
}
}
And on the call-site, depending on what config you want, you pass the appropriate one. If that comes from a CompositionLocal or not is up to you, but the composable itself doesn’t need to be hidden behind something like that.
And if you don’t even want to call the same composable in those cases, why not have 2 completely separate composables, and in your UI code, depending on the state do
fun AppUi(whichAppCurrenlyInUse: Any) {
Title()
Stuff()
when(whichAppCurrenlyInUse) {
.. -> Button()
.. -> WildButton()
}
Foo()
}
?Florian Eula
06/27/2023, 2:46 PMAbhimanyu
06/27/2023, 6:12 PM