andrea-vinci/Insulator

View on GitHub
app/src/main/kotlin/insulator/ui/component/Alert.kt

Summary

Maintainability
A
0 mins
Test Coverage
B
85%
package insulator.ui.component

import javafx.scene.control.Alert
import javafx.scene.control.ButtonType
import tornadofx.FX

fun insulatorAlert(level: Alert.AlertType, message: String, vararg buttons: ButtonType, fn: ((ButtonType) -> Unit)? = null) {
    val buttonClicked = Alert(level, "", *buttons).apply {
        headerText = message
        dialogPane.stylesheets.addAll(FX.stylesheets)
    }.showAndWait()
    if (buttonClicked.isPresent) fn?.invoke(buttonClicked.get())
}