package com.lanyun.wanglaotou.public

import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.Card
import androidx.compose.material.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import com.lanyun.common.baseDate.updateMainEvent
import com.lanyun.common.model.MainEvent
import com.lanyun.wanglaotou.ui.theme.green1

/**
 * 首页采用的Card
 * 卡片高度可以设置
 */
@Composable
fun SimpleCard(
    cardHeight: Dp = 120.dp,
    elevation: Dp = 3.dp,
    shape: RoundedCornerShape = RoundedCornerShape(6.dp),
    content: @Composable () -> Unit
) {

    Card(
        modifier = Modifier
            //外边距
            .padding(bottom = 5.dp, start = 8.dp, end = 8.dp, top = 5.dp).fillMaxWidth()
            .height(cardHeight),
        elevation = elevation,
        backgroundColor = MaterialTheme.colors.background,
        shape = shape,
        border = if (isSystemInDarkTheme()) BorderStroke(1.dp, Color.White) else null
    ) {
        content()
    }

}

/**
 * 卡片高度自适应
 */
@Composable
fun SimpleCard(
    elevation: Dp = 3.dp,
    shape: RoundedCornerShape = RoundedCornerShape(6.dp),
    content: @Composable () -> Unit,

) {

    Card(
        modifier = Modifier
            //外边距
            .padding(bottom = 5.dp, start = 8.dp, end = 8.dp, top = 5.dp).fillMaxWidth(),
        elevation = elevation,
        backgroundColor = MaterialTheme.colors.background,
        shape = shape,
        border = if (isSystemInDarkTheme()) BorderStroke(1.dp, Color.White) else null
    ) {
        content()
    }

}


@Composable
fun CircleBox(content: @Composable BoxScope.() -> Unit) {
    Box(
        modifier = Modifier
            //1.裁剪
            .clip(CircleShape)
            //2.设置背景色，通过brush实现渐变色，Blue1,Blue2是自定义的颜色类型是Color
            .background(
                green1
            )
            //3.padding撑开
            .padding(10.dp),
        content = content,
    )
}