package com.example.smarthome.ui

import androidx.compose.foundation.layout.Arrangement
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.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.Column
import androidx.compose.ui.Alignment
import androidx.compose.ui.res.painterResource
import androidx.compose.foundation.Image
import com.example.smarthome.R
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.getValue
import androidx.compose.runtime.setValue

@Composable
fun NeumorphControls() {
    Column(verticalArrangement = Arrangement.spacedBy(24.dp), modifier = Modifier.fillMaxWidth()) {
        Row(horizontalArrangement = Arrangement.spacedBy(16.dp), modifier = Modifier.fillMaxWidth()) {
            ControlButton(iconRes = R.drawable.ic_light, label = "灯光")
            ControlButton(iconRes = R.drawable.ic_ac, label = "空调")
            ControlButton(iconRes = R.drawable.ic_curtain, label = "窗帘")
        }
        Row(horizontalArrangement = Arrangement.spacedBy(16.dp), modifier = Modifier.fillMaxWidth()) {
            ControlButton(iconRes = R.drawable.ic_security, label = "安防")
            ControlButton(iconRes = R.drawable.ic_media, label = "媒体")
        }
    }
}

@Composable
fun ControlButton(iconRes: Int, label: String) {
    var active by remember { mutableStateOf(false) }
    NeumorphButton(active = active, onToggle = { active = !active }) {
        Image(painter = painterResource(id = iconRes), contentDescription = null, modifier = Modifier.size(28.dp))
        Text(text = label)
    }
}
