package com.example.livingai.pages.camera

import android.net.Uri
import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.ArrowBack
import androidx.compose.material3.Button
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.OutlinedButton
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import coil.compose.rememberAsyncImagePainter
import com.example.livingai.ui.theme.LivingAITheme

@Composable
fun ViewImageScreen(
    imageUri: String,
    shouldAllowRetake: Boolean,
    showAccept: Boolean,
    showBack: Boolean,
    onRetake: () -> Unit,
    onAccept: () -> Unit,
    onBack: () -> Unit
) {
    LivingAITheme {
        Scaffold {
            Box(modifier = Modifier
                .fillMaxSize()
                .padding(it)) {
                Image(
                    painter = rememberAsyncImagePainter(model = Uri.parse(imageUri)),
                    contentDescription = "Captured Image",
                    modifier = Modifier.fillMaxSize()
                )
                Row(
                    modifier = Modifier
                        .fillMaxWidth()
                        .align(Alignment.BottomCenter)
                        .padding(16.dp),
                    horizontalArrangement = Arrangement.SpaceEvenly
                ) {
                    if (shouldAllowRetake) {
                        OutlinedButton(onClick = onRetake) {
                            Text("Retake")
                        }
                    }
                    if (showAccept) {
                        Button(onClick = onAccept) {
                            Text("Accept")
                        }
                    } else {
                        Button(onClick = onBack) {
                            Text("Back")
                        }
                    }
                }
            }
        }
    }
}
