Next up on SwiftUI/Compose comparison :slightly_s...
# compose
j
Next up on SwiftUI/Compose comparison ๐Ÿ™‚ ....in SwiftUI I can apply a font to all
Text
elements within something like
HStack
as shown below. Is anything similar possible right now with Compose (or planned)?
Copy code
HStack {
    Text("some text")
    Text("some more text")
}
.font(.caption)
b
Yeah, you can use Ambients (https://developer.android.com/reference/kotlin/androidx/compose/runtime/Ambient) for that. There are a few ambients built into Material, including text style, content color, etc TextStyles are a little bit of an oddball in that you should use
ProvideTextStyle
instead of the usual
Providers
, so the Compose equivalent would look something like:
Copy code
ProvideTextStyle(MaterialTheme.typography.caption) {
  Column {
    Text("some text")
    Text("some more text")
  }
}
๐Ÿ‘ 1
j
ah, interesting, thanks!
k
Probably it'd be best to start with reading on what Compose has, and then ask about specific things that are missing
๐Ÿ‘๐Ÿป 2
j
I do try and keep up with what's in Compose but clearly I missed a few things ๐Ÿ™‚
๐Ÿ‘ 1
k