https://kotlinlang.org logo
#compose
Title
# compose
l

Leland Richardson [G]

07/01/2019, 12:24 AM
you can do patterns like that with both component classes and composable functions, if that was what you were asking
s

SrSouza

07/01/2019, 8:56 PM
You can show an example of how it can be done with functions?
l

Leland Richardson [G]

07/01/2019, 11:24 PM
Depends on what you’re wanting to do, but for instance a real naive version of the above could be done like the following
Copy code
@Composable fun Scaffold(
  builder: ScaffoldScope.() -> Unit) {
  val scope = ScaffoldScope()
  scope.builder()
  // ... use `scope`
  scope.bodyComposable()
}
class ScaffoldScope(var bodyComposable: ...) {
  fun body(composable: @Composable() () -> Unit)  { bodyComposable = composable; }
}
2 Views