I am in the process of converting an existing app ...
# getting-started
k
I am in the process of converting an existing app to start using composables. I have started by taking a custom dialog that we have and I have made the same dialog implementing the base Dialog composable. How would I show this new composable in the existing app? I tried to create an
AbstractComposeView
the same file as my composable but I don’t know how to get that dialog to pop up when it should be. We used to do
VerticalAlertDialog{......}.show(...)
before using compose, is there a similar way to show the composable dialog?
Copy code
class VerticalTwoOptionAlertDialogView @JvmOverloads constructor(
    context: Context,
    attrs: AttributeSet? = null,
    defStyle: Int = 0
): AbstractComposeView(context = context, attrs = attrs, defStyleAttr = defStyle){

    var icon by mutableStateOf<Int?>(null)
    var title by mutableStateOf<String>("")
    var description by mutableStateOf<String>("")
    var topButton by mutableStateOf<ButtonConfiguration?>(null)
    var bottomButton by mutableStateOf<ButtonConfiguration?>(null)
    var suggestions by mutableStateOf<List<String>>(listOf())
    var suggestionType by mutableStateOf<SuggestionType>(SuggestionType.BULLET_LIST)
    var onDismiss by mutableStateOf<(() -> Unit)>({})

    @Composable
    override fun Content() {
        VerticalTwoOptionAlertDialog(
            icon = icon,
            title = title,
            description = description,
            topButton = topButton,
            bottomButton = bottomButton,
            suggestions = suggestions,
            suggestionType = suggestionType,
            onDismiss = onDismiss
        )
    }
}
In my activity I have tried to implement the
VerticalTwoOptionAlertDialogView
by
Copy code
val dialog = VerticalTwoOptionAlertDialogView(this)
dailog.apply{
    setContent{
        this.icon = icon
        .
        .
        .
        this.onDismiss = onDismiss
    }
}
and this did not work either