package com.pixelized.desktop.lwa.ui.composable.decoratedBox

import androidx.compose.desktop.ui.tooling.preview.Preview
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.BoxScope
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.RectangleShape
import androidx.compose.ui.unit.dp
import com.pixelized.desktop.lwa.utils.preview.ContentPreview

@Composable
fun DecoratedBox(
    modifier: Modifier = Modifier,
    border: Color = Color(0xFF909090),
    padding: PaddingValues = remember { PaddingValues() },
    content: @Composable BoxScope.() -> Unit,
) {
    Box(
        modifier = modifier
            .border(width = 1.dp, color = border, shape = RoundedCornerShape(size = 16.dp))
            .padding(all = 2.dp)
            .border(width = 1.dp, color = border, shape = RectangleShape)
            .padding(paddingValues = padding),
        content = content,
    )
}

@Composable
@Preview
private fun DecoratedBoxPreview() {
    ContentPreview {
        DecoratedBox {
            Box(
                modifier = Modifier.width(width = 128.dp).height(64.dp),
                contentAlignment = Alignment.Center,
            ) {
                Text("Test")
            }
        }
    }
}