Colton Idle
07/26/2021, 4:42 AMSignInScreen
that should not follow the typical "back press = popBackStack". When on the SignInScreen, the MainScreen is in the stack, but in this case I want the app to just close.
Where is the more appropriate place to override this? In the SignInScreen
composable itself? Or on the activity level?Colton Idle
07/26/2021, 4:52 AM@Composable
fun SignInScreen(
backPressed: () -> Unit,
viewModel: SignInScreenViewModel = hiltViewModel()
) {
LocalOnBackPressedDispatcherOwner.current!!.onBackPressedDispatcher.addCallback {
backPressed()
}
... //my content
}
then in my activity I have
SignInScreen(
{ this@MainActivity.finish() },
)
Colton Idle
07/26/2021, 5:38 AMyousefa2
07/26/2021, 6:19 AMColton Idle
07/26/2021, 1:11 PMColton Idle
07/26/2021, 1:24 PMyousefa2
07/26/2021, 1:26 PMColton Idle
07/26/2021, 1:27 PMyousefa2
07/26/2021, 1:28 PMColton Idle
07/26/2021, 1:32 PMColton Idle
07/26/2021, 3:30 PMBackHandler { onBack() }
AWESOMEyousefa2
07/26/2021, 5:33 PM