lib
09/25/2020, 3:33 AMnglauber
09/25/2020, 3:37 AMlib
09/25/2020, 4:27 AMSaurabhS
09/25/2020, 4:28 AMlib
09/25/2020, 4:30 AMAfzal Najam
09/25/2020, 1:37 PMlib
09/25/2020, 2:55 PMBrian Beale
09/26/2020, 2:31 PMVal Salamakha
09/27/2020, 7:04 AMclass MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val backStack = BackStack()
onBackPressedDispatcher.addCallback(this, backStack.callback)
val buttonPressed = mutableStateOf(false)
setContent {
MaterialTheme {
// A surface container using the 'background' color from the theme
Surface(color = MaterialTheme.colors.background) {
Providers(AmbientBackStack provides backStack) {
NavHost(AmbientBackStack.current) {
println("NavHost")
Button(onClick = {
buttonPressed.value = true
println("1. Button pressed ${buttonPressed.value} ")
}) {
Text("Navigate forward")
}
if (buttonPressed.value) {
Push(true)
buttonPressed.value = false
println("2. Button pressed ${buttonPressed.value}")
}
}
}
}
}
}
}
}
@Composable
fun Push(yes : Boolean){
if (yes) {
AmbientBackStack.current.push {
Text("Use the back button to go back")
}
}
}
Brian Beale
09/27/2020, 3:28 PMVal Salamakha
09/27/2020, 11:19 PM