https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
m

McEna

11/14/2023, 8:02 AM
Hi! has anybody tried to run a Macrobenchmark in a multiplatform android app? I want to have a set of common composables & common code and pass along platform specific stuff. I can run the benchmark, but I can't locate any screen elements, neither by tag or description. I'm passing along the semantics from the android invocation of the common composables, while the tags and descriptions are being set inside the common code, in this fashion:
Copy code
MainView.MyApp( {
    if(it.isNotBlank()){
        searchTerms.add(it)
        viewModel.loadSearch(it)
    } else {
        searchTerms.clear()
    }
}, {
    MainView.Companion.ItemList(searchResult.data.results)
},
    modifier = Modifier.semantics {
    testTagsAsResourceId = true
}.testTag(ComposableIDs.searchRoot))
MainView.MyApp is the common scaffold. The modifier argument is applied there:
Copy code
@Composable
fun MyApp(onSearch: (String) -> Unit, content: @Composable () -> Unit, modifier: Modifier = Modifier) {
    MaterialTheme {
        Scaffold(
            topBar = {
                TopBarWithSearch(onSearch)
            },
            modifier = modifier
        ) { _ ->
            content()
        }
    }
}
So far my guess is, I may be missing some dependencies, but with the project structure being so different, I'm not sure which ones are relevant to this