package lu.rewardflow.terminal.ui.terminal

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.FilledTonalButton
import androidx.compose.material3.Text
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.res.stringResource
import androidx.compose.ui.unit.dp
import lu.rewardflow.terminal.R
import lu.rewardflow.terminal.ui.scanner.QrScannerView

/**
 * Fullscreen QR scanner overlay used to look up a customer card by
 * scanning the QR printed on it / on their phone.
 *
 * Reuses [QrScannerView] from Phase B — same camera permission UX,
 * same one-shot fire semantics. The Cancel button bails without a scan.
 */
@Composable
fun QrScannerOverlay(
    onScanned: (String) -> Unit,
    onCancel: () -> Unit,
) {
    Box(
        modifier = Modifier
            .fillMaxSize()
            .background(Color.Black),
    ) {
        QrScannerView(onQrScanned = onScanned)

        FilledTonalButton(
            onClick = onCancel,
            modifier = Modifier
                .align(Alignment.TopEnd)
                .padding(16.dp),
        ) {
            Text(stringResource(R.string.action_cancel))
        }
    }
}
