package com.nate.posedetection

import androidx.compose.foundation.layout.BoxWithConstraints
import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember

enum class Orientation {
    PORTRAIT, LANDSCAPE
}

@Composable
fun DetectOrientation(content: @Composable (orientation: Orientation) -> Unit) {
    BoxWithConstraints {
        val orientation = if (maxWidth > maxHeight) Orientation.LANDSCAPE else Orientation.PORTRAIT
        val currentOrientation = remember { mutableStateOf(orientation) }

        // Update if orientation changes
        if (currentOrientation.value != orientation) {
            currentOrientation.value = orientation
        }

        content(currentOrientation.value)
    }
}