package com.zaojiao.app.feat.home.personal

import androidx.annotation.DrawableRes
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
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.foundation.layout.statusBarsPadding
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.graphics.Color
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.Spacer

@Composable
fun HomePersonalTopBar() {
    Row(
        modifier = Modifier
            .statusBarsPadding()
            .padding(vertical = 9.dp)
            .fillMaxWidth()
            .wrapContentHeight(),
        horizontalArrangement = Arrangement.End,
        verticalAlignment = Alignment.CenterVertically,
    ) {
        HomePersonalTopBarItem(iconRes = R.mipmap.personal_message)
        Spacer(width = 21.dp)
        HomePersonalTopBarItem(iconRes = R.mipmap.personal_cart)
        Spacer(width = 21.dp)
        HomePersonalTopBarItem(iconRes = R.mipmap.personal_qrcode)
        Spacer(width = 13.dp)
    }
}

@Composable
fun HomePersonalScrollTopBar() {
    Row(
        modifier = Modifier
            .background(Color.White)
            .statusBarsPadding()
            .padding(vertical = 9.dp)
            .fillMaxWidth()
            .wrapContentHeight(),
        horizontalArrangement = Arrangement.End,
        verticalAlignment = Alignment.CenterVertically,
    ) {
        Spacer(width = 16.dp)
        Image(
            painter = painterResource(id = R.mipmap.default_avatar),
            contentDescription = "用户头像",
            modifier = Modifier.size(30.dp, 30.dp)
        )
        Spacer(width = 8.dp)
        Text(
            text = "逻辑狗",
            modifier = Modifier.weight(1f),
            style = TextStyle(
                fontSize = 14.sp,
                lineHeight = 14.sp,
                fontWeight = FontWeight.Medium,
                color = Colors.FF000000,
            ),
        )
        HomePersonalTopBarItem(iconRes = R.mipmap.personal_message)
        Spacer(width = 21.dp)
        HomePersonalTopBarItem(iconRes = R.mipmap.personal_cart)
        Spacer(width = 21.dp)
        HomePersonalTopBarItem(iconRes = R.mipmap.personal_qrcode)
        Spacer(width = 13.dp)
    }
}

@Composable
fun HomePersonalTopBarItem(
    @DrawableRes iconRes: Int,
    description: String = "",
) {
    Image(
        painter = painterResource(id = iconRes),
        contentDescription = description,
        modifier = Modifier.size(25.dp, 23.dp)
    )
}