Skip to content

Instantly share code, notes, and snippets.

@NikolaDespotoski
Created September 18, 2024 10:44
Show Gist options
  • Save NikolaDespotoski/b6a09a8c27b071fe290facd7e0e5011b to your computer and use it in GitHub Desktop.
Save NikolaDespotoski/b6a09a8c27b071fe290facd7e0e5011b to your computer and use it in GitHub Desktop.
val ModifierLocalMyScope =
modifierLocalOf<MyScope> { error("Scope not provided") }
@Composable
fun MyLayout(
modifier: Modifier = Modifier,
properties: MyProperties = MyProperties(),
colors: MyLayoutColors = MyLayoutDefaults.colors(),
content: @Composable (MyScope.() -> Unit)
) {
val scope = rememberMyScope(properties)
Surface(modifier = Modifier.fillMaxSize()
.modifierLocalProvider(ModifierLocalMyScope) { scope }
.then(modifier)
) {
scope.content()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment