package com.aiosman.ravenow.ui.index.tabs.profile.composable

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.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
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.graphics.ColorFilter
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.aiosman.ravenow.LocalAppTheme
import com.aiosman.ravenow.R
import com.aiosman.ravenow.ui.composables.rememberDebouncer
import com.aiosman.ravenow.ui.modifiers.noRippleClickable

@Composable
fun SelfProfileAction(
    onEditProfile: () -> Unit,
    onPremiumClick: (() -> Unit)? = null
) {
    val AppColors = LocalAppTheme.current
    val editProfileDebouncer = rememberDebouncer()
    val premiumClickDebouncer = rememberDebouncer()

    Row(
        verticalAlignment = Alignment.CenterVertically,
        horizontalArrangement = Arrangement.spacedBy(12.dp),
        modifier = Modifier.fillMaxWidth()
    ) {
        // 编辑个人资料按钮（左侧）
        Row(
            verticalAlignment = Alignment.CenterVertically,
            horizontalArrangement = Arrangement.Center,
            modifier = Modifier
                .weight(1f)
                .clip(RoundedCornerShape(8.dp))
                .background(AppColors.nonActive)
                .padding(horizontal = 16.dp, vertical = 12.dp)
                .noRippleClickable {
                    editProfileDebouncer {
                        onEditProfile()
                    }
                }
        ) {
            Text(
                text = stringResource(R.string.edit_profile),
                fontSize = 14.sp,
                fontWeight = FontWeight.W600,
                color = AppColors.text,
            )
        }

        // Rave Premium 按钮（右侧）
        Row(
            verticalAlignment = Alignment.CenterVertically,
            horizontalArrangement = Arrangement.Center,
            modifier = Modifier
                .weight(1f)
                .clip(RoundedCornerShape(8.dp))
                .background(AppColors.premiumBackground)
                .padding(horizontal = 16.dp, vertical = 12.dp)
                .noRippleClickable {
                    premiumClickDebouncer {
                        onPremiumClick?.invoke()
                    }
                }
        ) {
            Image(
                painter = painterResource(id = R.drawable.ic_member),
                contentDescription = "",
                modifier = Modifier.size(18.dp),
                colorFilter = ColorFilter.tint(AppColors.premiumText)
            )
            Spacer(modifier = Modifier.width(8.dp))
            Text(
                text = "Rave Premium",
                fontSize = 14.sp,
                fontWeight = FontWeight.W600,
                color = AppColors.premiumText,
            )
        }
    }
}
