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

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.RowScope
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
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.Spacer


@Composable
fun HomePersonalEngage(
    interactiveUiState: HomePersonalInteractiveUiState,
    navToPageWithLogin: (route: String) -> Unit,
    navToPageWithoutLogin: (route: String) -> Unit,
) {
    Row(
        modifier = Modifier
            .padding(bottom = 6.dp)
            .padding(vertical = 5.dp, horizontal = 8.dp)
            .fillMaxWidth(),
        horizontalArrangement = Arrangement.SpaceAround,
    ) {
        HomePersonalEngageItem(num = interactiveUiState.followerCount, title = "关注")
        HomePersonalEngageItem(num = interactiveUiState.fansCount, title = "粉丝")
        HomePersonalEngageItem(num = interactiveUiState.likeCount, title = "获赞")
        HomePersonalEngageItem(num = interactiveUiState.collectionCount, title = "收藏")
    }
}

@Composable
fun RowScope.HomePersonalEngageItem(
    num: Int = 0,
    title: String,
) {
    Column(
        modifier = Modifier.weight(1f),
        horizontalAlignment = Alignment.CenterHorizontally,
    ) {
        Text(
            text = if (num > 999) "999+" else num.toString(),
            style = TextStyle(
                fontSize = 17.sp,
                lineHeight = 17.sp,
                fontWeight = FontWeight.Medium,
                color = Colors.FF333333,
            ),
        )

        Spacer(height = 5.5.dp)

        Text(
            text = title,
            style = TextStyle(
                fontSize = 13.sp,
                lineHeight = 14.sp,
                fontWeight = FontWeight.Normal,
                color = Colors.FF999999,
            ),
        )
    }
}