package com.example.uitugasakhir.ui.komponen

import androidx.compose.foundation.layout.*
import androidx.compose.material3.*
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.compose.foundation.layout.Row
import androidx.compose.ui.Modifier



@Composable
fun WarningPopup(

    show: Boolean,
    message: String,

    onDismiss: () -> Unit,

    disablePopup1Minute: Boolean,
    onDisableChange: (Boolean) -> Unit
) {

    if (show) {

        AlertDialog(

            containerColor = Color(0xFF222831),

            onDismissRequest = onDismiss,

            title = {

                Text(
                    "🚨 PERINGATAN SISTEM",
                    color = Color.Red,
                    fontWeight = FontWeight.Bold
                )
            },

            text = {

                Column {

                    Text(
                        text = message,
                        color = Color.White
                    )

                    Spacer(
                        modifier = Modifier.height(12.dp)
                    )

                    Row(
                        verticalAlignment =
                        Alignment.CenterVertically
                    ) {

                        Checkbox(
                            checked = disablePopup1Minute,

                            onCheckedChange =
                            onDisableChange
                        )

                        Text(
                            text =
                            "Nonaktifkan selama 1 menit",

                            color = Color.White
                        )
                    }
                }
            },

            confirmButton = {

                TextButton(
                    onClick = onDismiss
                ) {

                    Text(
                        "OK",
                        color = Color.Green
                    )
                }
            }
        )
    }
}