package com.birdsounds.identify.presentation

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import androidx.navigation.NavHostController
import androidx.wear.compose.material.CompactChip
import androidx.wear.compose.material.MaterialTheme
import androidx.wear.compose.material.Text

@Composable
fun ControlDashboard(controlDashboardUiState: ControlDashboardUiState,
                     onMicClicked: () -> Unit,
                     modifier: Modifier = Modifier,
                     navController: NavHostController) {
    Box(contentAlignment = Alignment.Center, modifier = modifier.fillMaxSize()) {
        Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) {

            ControlDashboardButton(buttonState = controlDashboardUiState.micState,
                onClick = onMicClicked,
                labelText = if (controlDashboardUiState.micState.expanded) {
                    "Stop"
                } else {
                    "Start"
                })
        }
    }
}


@Composable
private fun ControlDashboardButton(buttonState: ControlDashboardButtonUiState,
                                   onClick: () -> Unit,
                                   labelText: String,
                                   modifier: Modifier = Modifier) {
    CompactChip(modifier = Modifier,
        onClick = onClick,
        enabled = true,
        contentPadding = PaddingValues(5.dp, 1.dp, 5.dp, 1.dp),
        shape = MaterialTheme.shapes.small,
        label = {
            Text(text = labelText)
        })
}


//        Button(modifier = modifier, enabled = buttonState.enabled && buttonState.visible, onClick = onClick) {
//        Text(contentDescription);
////        Icon(imageVector = imageVector, contentDescription = contentDescription)
//    }
//}


data class ControlDashboardButtonUiState(val expanded: Boolean, val enabled: Boolean, val visible: Boolean)


data class ControlDashboardUiState(val micState: ControlDashboardButtonUiState) {
    init { // Check that at most one of the buttons is expanded

    }
}
