package llc.arma.ble.app.ui.common

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.defaultMinSize
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material.ContentAlpha
import androidx.compose.material.LocalContentColor
import androidx.compose.material.Surface
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp

@Composable
fun SignalLevel(
    modifier: Modifier = Modifier,
    maxLevel: Int = 5,
    level: Int
){

    val step = (16 - 4) / 4

    Row(
        modifier = modifier.height(16.dp),
        horizontalArrangement = Arrangement.spacedBy(2.dp),
        verticalAlignment = Alignment.Bottom
    ) {

        for(col in 0..4 step 1){
            Surface(
                color = LocalContentColor.current.copy(
                    alpha = if(col <= level + 1) ContentAlpha.high else ContentAlpha.disabled
                ),
                shape = CircleShape,
                modifier = Modifier
                    .width(4.dp)
                    .defaultMinSize(minHeight = 4.dp)
                    .height(((col + 1) * step).dp)
            ) { }
        }

    }

}