package com.syaroful.agrilinkvocpro.plant_disease_detection_feature.presentation.camera.component

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.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.syaroful.agrilinkvocpro.plant_disease_detection_feature.R
import com.syaroful.agrilinkvocpro.presentation.theme.MainGreen

@Composable
fun CustomCameraShutter(
    modifier: Modifier = Modifier,
    onShutterClick: () -> Unit = {},
    onFlashClick: () -> Unit = {},
    onHistoryClick: () -> Unit = {}
) {
    Row(
        modifier = modifier
            .fillMaxWidth()
            .padding(horizontal = 44.dp, vertical = 16.dp),
        horizontalArrangement = Arrangement.SpaceBetween,
        verticalAlignment = Alignment.CenterVertically,
    ) {
        // Tombol Flash
        IconButton(
            onClick = onFlashClick,
        ) {
            Icon(
                modifier = Modifier.size(32.dp),
                painter = painterResource(id = R.drawable.flash),
                contentDescription = "Flash",
                tint = MaterialTheme.colorScheme.onBackground
            )
        }

        IconButton(
            onClick = onShutterClick,
            modifier = Modifier
                .size(72.dp)
                .border(
                    width = 1.dp,
                    color = MaterialTheme.colorScheme.onBackground,
                    shape = CircleShape
                )
                .background(MaterialTheme.colorScheme.onBackground.copy(alpha = 0.1f), shape = CircleShape)
        ) {
            Box(
                modifier = Modifier
                    .size(56.dp)
                    .background(MainGreen, shape = CircleShape)
            )
        }

        IconButton(
            onClick = onHistoryClick,

            ) {
            Icon(
                modifier = Modifier.size(32.dp),
                painter = painterResource(id = R.drawable.solar_history),
                contentDescription = "Gallery",
                tint = MaterialTheme.colorScheme.onBackground
            )
        }
    }
}


@Preview
@Composable
fun CameraShutterPreview() {
    CustomCameraShutter()
}