package com.zaojiao.app.feat.settings

import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.geometry.Size
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.design.Colors
import com.zaojiao.app.feat.design.Expanded
import com.zaojiao.app.feat.design.Icons
import com.zaojiao.app.feat.design.Spacer

@Composable
fun SettingsIndexSelectorItem(
    title: String,
    value: String,
    onClick: () -> Unit,
    isFirst: Boolean = false,
    isLast: Boolean = false,
) {
    val top = if (isFirst) 16.dp else 7.dp
    val bottom = if (isLast) 7.dp else 16.dp

    Row(
        modifier = Modifier
            .padding(start = 12.dp, end = 12.dp, top = top, bottom = bottom)
            .wrapContentHeight()
            .fillMaxWidth(),
        verticalAlignment = Alignment.CenterVertically,
    ) {
        Text(
            text = title,
            style = TextStyle(
                color = Colors.FF333333,
                fontSize = 15.sp,
                lineHeight = 21.sp,
                fontWeight = FontWeight.Medium,
            )
        )
        Expanded()
        Text(
            text = value,
            style = TextStyle(
                color = Colors.FF666666,
                fontSize = 12.sp,
                lineHeight = 17.sp,
                fontWeight = FontWeight.Normal,
            )
        )
        Spacer(width = 6.dp)
        Icons.Forward(
            size = Size(width = 6f, height = 12f),
            color = Colors.from("#CBCBCB"),
            width = 1.5.dp,
        )
    }
}

@Composable
fun SettingsIndexForwardItem(
    title: String,
    onClick: () -> Unit = TODO(),
    isFirst: Boolean = false,
    isLast: Boolean = false,
) {
    val top = if (isFirst) 16.dp else 14.dp
    val bottom = if (isLast) 16.dp else 14.dp

    Row(
        modifier = Modifier
            .padding(start = 12.dp, end = 12.dp, top = top, bottom = bottom)
            .wrapContentHeight()
            .fillMaxWidth(),
        verticalAlignment = Alignment.CenterVertically,
    ) {
        Text(
            text = title,
            style = TextStyle(
                color = Colors.FF333333,
                fontSize = 15.sp,
                lineHeight = 21.sp,
                fontWeight = FontWeight.Medium,
            )
        )
        Expanded()
        Icons.Forward(
            size = Size(width = 6f, height = 12f),
            color = Colors.from("#CBCBCB"),
            width = 1.5.dp,
        )
    }
}

@Composable
fun SettingsIndexInfoItem(
    title: String,
    onClick: () -> Unit = TODO(),
    isFirst: Boolean = false,
    isLast: Boolean = false,
    value: @Composable () -> Unit,
) {
    val top = if (isFirst) 16.dp else 14.dp
    val bottom = if (isLast) 16.dp else 14.dp

    Row(
        modifier = Modifier
            .padding(start = 12.dp, end = 12.dp, top = top, bottom = bottom)
            .wrapContentHeight()
            .fillMaxWidth(),
        verticalAlignment = Alignment.CenterVertically,
    ) {
        Text(
            text = title,
            style = TextStyle(
                color = Colors.FF333333,
                fontSize = 15.sp,
                lineHeight = 21.sp,
                fontWeight = FontWeight.Medium,
            )
        )
        Expanded()
        value.invoke()
    }
}