Simon Stahl
02/16/2022, 11:30 PMtestTag
to the Text
node, but can i add it to Greeting
instead?
@Composable
fun Greeting(name: String) {
Text(
modifier = Modifier.semantics {
testTag = "My testTag"
},
text = "Hello $name!"
)
}
Eric Chee
02/16/2022, 11:43 PM@Composable
fun Greeting(…, modifier: Modifier = Modifier) {
Text(modifier = modifier, text = "Hello world")
}
Simon Stahl
02/17/2022, 12:04 AMEric Chee
02/17/2022, 12:38 AM@Composable
fun Greeting(…, block: Modifier.() -> Unit) {
Text(modifier = Modifier.apply { block() }, text = "Hello world")
}
Greeting(name = "Simon", block = { semantics { testTag = "tag" } } )
Simon Stahl
02/17/2022, 12:59 AMGreeting
. I tested it real quick anyways and it does not.mattinger
02/18/2022, 7:08 AM@Composable
fun Greeting(modifier: Modifier = Modifier, name: String) {
Text(
modifier = modifier.testTag("My Test Tag"),
text = "Hello $name!"
)
}
@Composable
fun Greeting2(modifier: Modifier = Modifier, name: String) {
Greeting(modifier, name)
}
They both output the EXACT SAME semantic tree, regardless of which one you call.
Node #1 at (l=0.0, t=0.0, r=11.0, b=41.0)px
|-Node #2 at (l=0.0, t=0.0, r=11.0, b=41.0)px, Tag: 'My Test Tag'
Text = '[Hello Matt!]'
Actions = [GetTextLayoutResult]
Simon Stahl
02/18/2022, 6:16 PMGreeting
in the composable tree, but I guess that is not the same as the semantics tree that is build internally.