package com.laseroptek.raman.ui.screens.engineer

import android.content.res.Configuration
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.laseroptek.raman.R
import com.laseroptek.raman.ui.theme.RobotoTypography
import com.laseroptek.raman.utils.ext.dropShadow
import com.laseroptek.raman.utils.ext.px

@Composable
fun StandByButton(
    onClick: () -> Unit = {},
    title: String = stringResource(id = R.string.stand_by_title),
) {
    // StandBy Button
    TextButton(
        onClick = onClick,
        modifier = Modifier
            .size(388.px.dp, 70.px.dp)
            .clip(RoundedCornerShape(10.px.dp))
            .background(Color(35, 35, 35))
            .border(
                width = 0.5.px.dp,
                color = Color(222, 216, 185)
            )
            .dropShadow(
                shape = RoundedCornerShape(0.px.dp),
                color = Color(0, 0, 0),
                blur = 0.px.dp,
                offsetX = 0.px.dp,
                offsetY = 1.66.px.dp,
                spread = 0.px.dp
            )
    ) {
        Text(
            text = title, //stringResource(R.string.standby),
            style = RobotoTypography.bodyMedium.copy(
                brush = Brush.linearGradient(
                    colors = listOf(Color(255,238,204), Color(222,188,76)),
                    start = Offset(0f, 50f),
                    end = Offset(100f, 50f)
                ),
                fontWeight = FontWeight.Normal,
            ),
            fontSize = 36.px.sp
        )
    }
}

@Preview(
    uiMode = Configuration.UI_MODE_NIGHT_NO,
    showBackground = false,
    device = "spec:width=1920dp,height=1080dp,dpi=150,isRound=false,chinSize=0dp,orientation=landscape"
)
@Composable
fun PreviewStandByButton() {
    StandByButton(
        title = stringResource(id = R.string.stand_by_title)
    )
}