I have two composable screens. Basically, in my activity, I want to load ScreenOne then ScreenTwo will be loaded from ScreenOne.
I believe I have to pass navigator to my composable but I am lost on how to do that. Right now the app crushes as ScreenOne expects value for its navigator parameter.
I am using Composable Destinations library btw.
ScreenOne.kt
@UserNavGraph(start = true)
@Destination
@Composable
fun ScreenOne(d: String = "", navigator: DestinationsNavigator) {
Row(
modifier = Modifier
.clickable { navigator.navigate(ScreenTwo())) }
.fillMaxWidth()
.padding(vertical = Dimensions.Large, horizontal = Dimensions.Medium),
horizontalArrangement = Arrangement.SpaceBetween,
verticalAlignment = Alignment.CenterVertically
) {
Text(
text = "handled",
fontWeight = FontWeight.Bold,
style = MaterialTheme.typography.subtitle1
)
}
}
ScreenOneActivity.kt
@AndroidEntryPoint
class ScreenOneActivity: ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val screenOneData = generateData("One")
setContent {
ScreenOne(d = screenOneData)
}
}
}