
ViewModel-like retained model helper for dialogs and popups, composable integration with declarative entryProvider and metadata-based factories, typed PopupId, and synchronous showDialog result delivery.
A simple suspending API to show popups such as dialogs and bottom sheets.
Important: Popups shown using this library are not restored after process death.
libs.versions.toml
[versions]
popuphost = "1.0.0"
[dependencies]
popuphost = { group = "io.github.andannn", name = "popuphost", version.ref = "popuphost" }then
dependencies {
implementation(libs.popuphost)
}
object DialogA : PopupId<Long>@Composable
fun App() {
val popupHostState = remember { PopupHostState() }
PopupHost(
popupHostState = popupHostState,
entryProvider = entryProvider {
entry(
metadata = DialogFactoryProvider.metadata()
) { dialogId, onAction ->
Surface(
modifier = Modifier.wrapContentSize(),
shape = AlertDialogDefaults.shape,
tonalElevation = AlertDialogDefaults.TonalElevation,
) {
DialogAContent(dialogId, onAction)
}
}
}
)
}
@Composable
fun DialogAContent(dialogA: DialogA, onAction: (Long) -> Unit) {
Column(modifier = Modifier.padding(16.dp)) {
Text(text = "Dialog A")
Button(
onClick = {
// set Result
onAction(123L)
},
) {
Text(
text = "Set Result",
)
}
}
}
val result: Long? = popupHostState.showDialog(DialogA)A simple suspending API to show popups such as dialogs and bottom sheets.
Important: Popups shown using this library are not restored after process death.
libs.versions.toml
[versions]
popuphost = "1.0.0"
[dependencies]
popuphost = { group = "io.github.andannn", name = "popuphost", version.ref = "popuphost" }then
dependencies {
implementation(libs.popuphost)
}
object DialogA : PopupId<Long>@Composable
fun App() {
val popupHostState = remember { PopupHostState() }
PopupHost(
popupHostState = popupHostState,
entryProvider = entryProvider {
entry(
metadata = DialogFactoryProvider.metadata()
) { dialogId, onAction ->
Surface(
modifier = Modifier.wrapContentSize(),
shape = AlertDialogDefaults.shape,
tonalElevation = AlertDialogDefaults.TonalElevation,
) {
DialogAContent(dialogId, onAction)
}
}
}
)
}
@Composable
fun DialogAContent(dialogA: DialogA, onAction: (Long) -> Unit) {
Column(modifier = Modifier.padding(16.dp)) {
Text(text = "Dialog A")
Button(
onClick = {
// set Result
onAction(123L)
},
) {
Text(
text = "Set Result",
)
}
}
}
val result: Long? = popupHostState.showDialog(DialogA)