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

import android.content.res.Configuration
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.aspectRatio
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.size
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.laseroptek.raman.const.Fluences
import com.laseroptek.raman.const.LaserStatusType
import com.laseroptek.raman.const.UpDownState
import com.laseroptek.raman.utils.ext.px
import timber.log.Timber


@Composable
fun LaserControlView(
    modifier: Modifier = Modifier,
    //mainViewModel: MainViewModel = hiltViewModel<MainViewModel>(),
    fluenceList: List<Float> = Fluences,
    repetitionList: List<Float> = listOf(1f),
    pulseType: Int = 1,
    handPieceType: Int = 0,
    type: LaserStatusType = LaserStatusType.PULSE_DURATION,
    angle: Float = 0f,
    onChange: (Float) -> Unit = {},
    onClick: (UpDownState) -> Unit = {},
) {
    Timber.d("angle: ${angle}")

    Box(modifier = modifier) {
        SliderBox(
            //mainViewModel = mainViewModel,
            fluenceList = fluenceList,
            repetitionList = repetitionList,
            pulseType = pulseType,
            handPieceType = handPieceType,
            type = type,
            angle = angle,
            modifier = Modifier
                .fillMaxWidth()
                .aspectRatio(1f)
                .background(Color.Transparent)
                .align(Alignment.TopCenter),
            onChange = onChange
        )

        UpDownButton(
            modifier = Modifier
                .size(190.px.dp, 42.px.dp)
                .background(color = Color.Transparent)
                .align(Alignment.BottomCenter),
            onClick = onClick,
        )
    }
}


@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 PreviewLaserControlView(
) {
    LaserControlView(
        modifier = Modifier
            .size(330.px.dp, 380.px.dp),
        type = LaserStatusType.REPETITION,
        //mainViewModel = mainViewModel
    )
}