izyaboi
10/14/2024, 12:43 PMprivate fun showLoggedOutDialog(showLoggedOutDialog: Boolean) {
binding.cvErrorDialog.apply {
setViewCompositionStrategy(ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed)
setContent {
Theme {
val localBreakpoint = LocalContext.current.resolveBreakpoint()
CompositionLocalProvider(LocalBreakpoints provides localBreakpoint) {
when {
showErrorDialog ->
DefaultDialog(
dialogHeadline = stringResource(R.string.error_dialog_headline),
dialogCopyText = stringResource(R.string.error_dialog_copy_text_g_20002),
dialogPrimaryButtonText = stringResource(R.string.error_dialog_one_more_time_login),
dialogSecondaryButtonText = stringResource(R.string.error_dialog_continue_without_login),
onConfirmation = {
viewModel.hideErrorDialog()
viewModel.onLoginClicked()
},
onDismissRequest = { viewModel.hideErrorDialog() },
)
}
}
}
i call this right now 2 times with different fun names private fun showErrorDialog(showErrorDialog: Boolean) and private fun showLoggedOutDialog(showLoggedOutDialog: Boolean) the only diffrence is the headline ,copytext and viewmodel methods ( its only for setting the vissibilty state) is it a good pattern to leave it in the activity like this . or can it be refactored in a more elegant way? side note we using android binding