Untitled

 avatar
unknown
plain_text
a month ago
1.1 kB
16
Indexable
@Composable
fun ErrorDialog(
    title: String = "Error",
    description: String = "Something went wrong",
    onAction: () -> Unit
) {
    Dialog(
        onDismissRequest = { },
        properties = DialogProperties(
            usePlatformDefaultWidth = false,
            decorFitsSystemWindows = false
        )
    ) {

        Box(modifier = Modifier.fillMaxSize().background(Color.Red))

        DialogWindowSideEffect()
    }
}

@Composable
fun DialogWindowSideEffect() {
    val view = LocalView.current.parent
    val window = (view as? DialogWindowProvider)?.window

    val useLightIcons = !isSystemInDarkTheme()

    SideEffect {
        if(window != null) {
            window.setDimAmount(0f)
            window.setWindowAnimations(-1)

            window.statusBarColor = Color.Transparent.value.toInt()

            window.navigationBarColor = Color.Transparent.value.toInt()

            WindowCompat.getInsetsController(window, view as View).apply {
                isAppearanceLightStatusBars = useLightIcons
                isAppearanceLightNavigationBars = useLightIcons
            }
        }
    }
}
Editor is loading...
Leave a Comment