I have a Composable which has different views (see the code for better understanding)
When user clicks on the button it navigates to different view but when user press the back button it navigates to previous screen but I want to navigate to pervious view
Something like on Back press viewState changes it's value
Note: I don't found nice explanation than this
var viewState by remember { mutableStateOf(0) }
Column {
when (viewState) {
0 -> { Button(onClick = { viewState = 1 }) { Text(text = "Goto 1") } }
1 -> { Button(onClick = { viewState = 2 }) { Text(text = "Goto 2") } }
2 -> { Button(onClick = { viewState = 3 }) { Text(text = "Goto 3") } }
3 -> { Button(onClick = { viewState = 4 }) { Text(text = "Goto 0") } }
}
}