Problem with RevealScope on hierarchy of components #33
-
Hey there, thank you developing this library. I'm loving it. There's one issue I'm facing with RevealScope, as its required to keep Reveal() as topmost element in compose tree, it becoming very difficult to make nth element revealable if UI component resides in other file or somewhere other place but not in the same file. Due to this I've to make all my middle UI components as extension to RevealScope to transfer the scope all the way from root to nth element. I hope you're able to understand my issue. e.g
as you can see, if I want to make UI component |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Hello Jayesh, I understand your problem 😃 As of version Also if you need to pass down the Reveal(…) {
Box {
SomeComposable(
revealScope = this@Reveal
)
}
@Composable
fun BoxScope.SomeComposable(
revealScope: RevealScope,
) {
Text(
modifier = with(revealScope) { Modifier.revealable(…) }
)
} However I recommend only having one |
Beta Was this translation helpful? Give feedback.
Hello Jayesh, I understand your problem 😃
As of version
0.0.14
it is not required anymore to only have oneReveal
instance at the root of your compose hierarchy. You can have oneReveal
instance per module or even per screen. Does this solve your problem?Also if you need to pass down the
RevealScope
but the function already has a context receiver and as long as Kotlin does not support multiple context receivers, you can work around it by passing down the scope as a parameter like this: