I have a Boolean variable called showSerialTrackin...
# compose-android
b
I have a Boolean variable called showSerialTrackingDialog() on my state class. on confirmation click of the AlertDialog I call a lambda method Visually though the dialog is being dismissed after onPressBack is called and it's navigated back to the previous screen, and so I can see the dialog still, instead of it seeming more immediate. Any suggestions, see thread for images and code. 🧵
Copy code
onSelectTracking = { ignoreValidation ->
    if (ignoreValidation) {
        if (uiState.isShowingSerialTrackingDialog) {
            // Make sure dismissSerialTrackingDialog is synchronous
            viewModel.dismissSerialTrackingDialog()
        }
        viewModel.setTemporarySerialTrackingToSerialTracking()
        onPressBack(false)
    } else {
        if (viewModel.validateSerialTrackingSelection()) {
            viewModel.setTemporarySerialTrackingToSerialTracking()

            // Make sure dismissSerialTrackingDialog is synchronous
            viewModel.dismissSerialTrackingDialog()

            onPressBack(false)
        }
    }
},
the second image is the screen that is being navigated back to and you can see the dialog from the first images screen is still visible briefly before the dismiss is called.
Copy code
fun dismissSerialTrackingDialog() {
    _inventoryAddUiState.update {
        it.copy(
            isShowingSerialTrackingDialog = false
        )
    }
}