package com.laseroptek.raman.ui.screens.home.count

import android.content.res.Configuration
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
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.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.laseroptek.raman.const.handPieceTypes
import com.laseroptek.raman.data.model.serial.HandPiece
import com.laseroptek.raman.ui.theme.RobotoTypography
import com.laseroptek.raman.utils.ext.px

@Composable
fun HpView(
    //mainViewModel: MainViewModel = hiltViewModel<MainViewModel>(),
    handPiece: HandPiece = HandPiece(),
    onClick: () -> Unit = {},
) {
    val handPieceTitle = handPieceTypes.get(handPiece.type)

    Box(
        modifier = Modifier
            .size(175.px.dp, 120.px.dp)
            .padding(start = 0.px.dp)
            .background(Color.Transparent),
        contentAlignment = Alignment.CenterStart
    ) {
        Row(
            modifier = Modifier
                .size(120.px.dp, 45.px.dp)
                .clip(RoundedCornerShape(45.px.dp))
                .background(
                    Color(45, 48, 53),
                    shape = RoundedCornerShape(45.px.dp)
                )
                .border(
                    width = 3.px.dp,
                    color = Color(236, 197, 66),
                    shape = RoundedCornerShape(45.px.dp)
                )
                .padding(start = 10.px.dp, end = 10.px.dp, top = 6.px.dp, bottom = 6.px.dp)
            ,
            horizontalArrangement = Arrangement.Center, // Push content to the right
            verticalAlignment = Alignment.CenterVertically
        ) {
            Text(
                text = handPieceTitle,
                style = RobotoTypography.bodySmall,
                fontSize = 24.px.sp,
                lineHeight = 26.px.sp,
                letterSpacing = 0.92.px.sp,
                fontWeight = FontWeight.Thin,
                color = Color(255,255,255),
                textAlign = TextAlign.Center
            )
        }
    }
}


@Preview(
    apiLevel = 34,
    uiMode = Configuration.UI_MODE_NIGHT_NO,
    showBackground = false,
    //device = "spec:width=1920dp,height=1080dp,dpi=150,isRound=false,chinSize=0dp,orientation=landscape"
)
@Composable
fun PreviewHpView() {
    HpView(
        handPiece = HandPiece(),
        onClick = {}
    )
}