Ken Shipley
11/01/2021, 3:20 PMAbstractComposeView
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?
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
val dialog = VerticalTwoOptionAlertDialogView(this)
dailog.apply{
setContent{
this.icon = icon
.
.
.
this.onDismiss = onDismiss
}
}
and this did not work either