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

import android.content.res.Configuration
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
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.ui.theme.RobotoTypography
import com.laseroptek.raman.utils.ext.noRippleClickable
import com.laseroptek.raman.utils.ext.px

@Composable
fun EnergyDetectView(
    modifier: Modifier = Modifier,
    value: Float = 0f,
    onClick: (Int) -> Unit = {},
    title:String = "ENERGY \nDETECT"
) {
    Row(modifier = modifier,
        horizontalArrangement = Arrangement.SpaceBetween,
        verticalAlignment = Alignment.CenterVertically
    ) {
        // TITLE
        Column(
            modifier = Modifier
                .fillMaxWidth()
                .weight(1f)
                .height(30.px.dp),
            verticalArrangement = Arrangement.Center,
            horizontalAlignment = Alignment.Start
        ) {
            Text(
                text = title,
                style = RobotoTypography.bodyMedium.copy(
                    //letterSpacing = 3.px.sp,
                    lineHeight = 12.px.sp
                ),
                fontWeight = FontWeight.Normal,
                fontSize = 12.px.sp,
                color = Color.Black
            )
        }

        // VALUE
        Column(
            modifier = Modifier
                .noRippleClickable(onClick = { onClick.invoke(1) })
                .fillMaxWidth()
                .weight(1.15f)
                .height(30.px.dp)
                .clip(RoundedCornerShape(10.px.dp))
                .background(Color(47, 51, 57)),
            verticalArrangement = Arrangement.Center,
            horizontalAlignment = Alignment.CenterHorizontally
        ) {
            Text(
                text = "Refer 1.",
                style = RobotoTypography.bodyMedium,
                fontWeight = FontWeight.Light,
                fontSize = 11.px.sp,
                color = Color.White
            )
        }

        Spacer(modifier = Modifier.width(10.px.dp))

        // VALUE
        Column(
            modifier = Modifier
                .noRippleClickable(onClick = { onClick.invoke(2) })
                .fillMaxWidth()
                .weight(1.15f)
                .height(30.px.dp)
                .clip(RoundedCornerShape(10.px.dp))
                .background(Color(47, 51, 57)),
            verticalArrangement = Arrangement.Center,
            horizontalAlignment = Alignment.CenterHorizontally
        ) {
            Text(
                text = "Refer 2.",
                style = RobotoTypography.bodyMedium,
                fontWeight = FontWeight.Light,
                fontSize = 11.px.sp,
                color = Color.White
            )
        }
    }
}


@Preview(
    uiMode = Configuration.UI_MODE_NIGHT_NO,
    showBackground = false,
    device = "spec:width=640dp,height=60dp,dpi=150,isRound=false,chinSize=0dp,orientation=landscape"
)
@Composable
fun PreviewEnergyDetectView() {
    Row {
        EnergyDetectView(
            modifier = Modifier
                .fillMaxSize()
                .weight(1f),
            title = "ENERGY \nDETECT"
        )
    }
}