package com.zaojiao.app.feat.home.index

import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
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.foundation.layout.wrapContentHeight
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.geometry.Size
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.zaojiao.app.feat.home.R
import com.zaojiao.component.common.Colors
import com.zaojiao.component.common.Expanded
import com.zaojiao.component.common.Icons
import com.zaojiao.component.common.Spacer
import com.zaojiao.component.common.shadow

@Composable
fun HomeIndexGood() {
    Column(
        modifier = Modifier
            .padding(horizontal = 16.dp, vertical = 20.dp)
            .wrapContentHeight()
            .fillMaxWidth()
    ) {
        HomeIndexGoodTitle()
    }
}

@Composable
fun HomeIndexGoodTitle() {
    Row(
        modifier = Modifier.wrapContentHeight(),
        verticalAlignment = Alignment.CenterVertically,
    ) {

        Text(
            text = "提升好物",
            style = TextStyle(
                fontSize = 18.sp,
                lineHeight = 18.sp,
                fontWeight = FontWeight.SemiBold,
                color = Colors.FF333333,
            ),
        )

        Expanded()

        Text(
            text = "更多",
            style = TextStyle(
                fontSize = 12.sp,
                lineHeight = 16.sp,
                fontWeight = FontWeight.Normal,
                color = Colors.FF999999,
            ),
        )
        Spacer(width = 4.dp)

        Icons.Forward(
            size = Size(3.6f, 6f),
            color = Colors.FF999999,
            width = 0.5.dp,
        )
    }
}

@Composable
fun HomeIndexGoodRecommendItem() {
    Column(
        modifier = Modifier
            .shadow(
                color = Colors.from("#99E7EDF1"),
                offsetY = 4.dp,
                blurRadius = 19.dp,
                shadowRadius = 10.dp,
                spreadSize = 4.dp,
            )
            .clip(RoundedCornerShape(10.dp))
            .background(color = Color.White)
            .padding(12.dp)
            .wrapContentHeight()
            .fillMaxWidth(),
    ) {
        Image(
            painter = painterResource(id = R.mipmap.default_avatar),
            contentDescription = "课程封面",
            contentScale = ContentScale.Fit,
            modifier = Modifier
                .clip(RoundedCornerShape(10.dp))
                .size(140.dp),
        )

        Spacer(height = 12.dp)

        Text(
            text = "逻辑狗好盆友逻辑狗好狗好狗",
            style = TextStyle(
                fontSize = 14.sp,
                lineHeight = 20.sp,
                fontWeight = FontWeight.SemiBold,
                color = Colors.FF333333,
            ),
        )

        Spacer(height = 12.dp)

        Row(
            modifier = Modifier
                .wrapContentHeight()
                .fillMaxWidth(),
            verticalAlignment = Alignment.CenterVertically,
        ) {
            Text(
                text = "¥",
                style = TextStyle(
                    fontSize = 10.sp,
                    lineHeight = 10.sp,
                    fontWeight = FontWeight.Medium,
                    color = Colors.from("#FFFF5749"),
                ),
                modifier = Modifier.padding(top = 2.dp)
            )
            Text(
                text = "158.0",
                style = TextStyle(
                    fontSize = 14.sp,
                    lineHeight = 14.sp,
                    fontWeight = FontWeight.Medium,
                    color = Colors.from("#FFFF5749"),
                ),
            )

            Spacer(width = 4.dp)

            Text(
                text = "¥158.0",
                style = TextStyle(
                    fontSize = 10.sp,
                    lineHeight = 14.sp,
                    fontWeight = FontWeight.Normal,
                    color = Colors.FF999999,
                ),
            )
        }
    }
}