Need some help or some ideas , what a good pattern...
# compose
i
Need some help or some ideas , what a good pattern to refactor this => i `ve a Error Dialog written in Compose and want to reuse it in a Classic Activity which uses for that a Compose View . how can i avoid to doing this ->
Copy code
private 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
🧵 1