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

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.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Icon
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.layout.ContentScale
import androidx.compose.ui.platform.LocalContext
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.entity.AccountProfileEntity
import com.aiosman.ravenow.ui.composables.CustomAsyncImage

/**
 * 拉黑确认弹窗
 */
@Composable
fun BlockConfirmDialog(
    userProfile: AccountProfileEntity?,
    onConfirmBlock: () -> Unit = {},
    onDismiss: () -> Unit = {}
) {
    val AppColors = LocalAppTheme.current
    
    Box(
        modifier = Modifier.fillMaxSize(),
        contentAlignment = Alignment.BottomCenter
    ) {
        Column(
            modifier = Modifier
                .fillMaxWidth()
                .background(
                    color = AppColors.background,
                    shape = RoundedCornerShape(topStart = 16.dp, topEnd = 16.dp)
                )
                .padding(24.dp)
        ) {
            // 用户头像
            Box(
                modifier = Modifier
                    .align(Alignment.CenterHorizontally)
                    .padding(bottom = 16.dp)
            ) {
                CustomAsyncImage(
                    LocalContext.current,
                    userProfile?.avatar,
                    modifier = Modifier
                        .size(60.dp)
                        .clip(CircleShape)
                        .background(
                            color = AppColors.background,
                            shape = CircleShape
                        ),
                    contentDescription = "用户头像",
                    contentScale = ContentScale.Crop
                )
            }
            
            // 确认文本
            Text(
                text = stringResource(R.string.confirm_block_user, userProfile?.nickName ?: "该用户"),

                fontSize = 18.sp,
                fontWeight = FontWeight.Bold,
                color = AppColors.text,
                modifier = Modifier
                    .align(Alignment.CenterHorizontally)
                    .padding(bottom = 24.dp)
            )
            
            // 说明信息
            Column(
                modifier = Modifier.padding(bottom = 32.dp)
            ) {
                // 第一条说明
                Row(
                    modifier = Modifier.padding(bottom = 12.dp),
                    verticalAlignment = Alignment.CenterVertically
                ) {
                    Icon(
                        painter = painterResource(id = R.mipmap.icons_infor_off_eye),
                        contentDescription = "",
                        tint = AppColors.text,
                        modifier = Modifier.size(20.dp)
                    )
                    Spacer(modifier = Modifier.width(12.dp))
                    Text(
                        text = stringResource(R.string.block_description_1),
                        fontSize = 14.sp,
                        color = AppColors.text,
                        lineHeight = 20.sp
                    )
                }

                // 第二条说明
                Row(
                    modifier = Modifier.padding(bottom = 12.dp),
                    verticalAlignment = Alignment.CenterVertically
                ) {
                    Icon(
                        painter = painterResource(id = R.drawable.rider_pro_notice_mute),
                        contentDescription = "",
                        tint = AppColors.text,
                        modifier = Modifier.size(20.dp)
                    )
                    Spacer(modifier = Modifier.width(12.dp))
                    Text(
                        text = stringResource(R.string.block_description_2),
                        fontSize = 14.sp,
                        color = AppColors.text,
                        lineHeight = 20.sp
                    )
                }
                
                // 第三条说明
                Row(
                    verticalAlignment = Alignment.CenterVertically
                ) {
                    Icon(
                        painter = painterResource(id = R.mipmap.icons_infor_off_bell),
                        contentDescription = "",
                        tint = AppColors.text,
                        modifier = Modifier.size(20.dp)
                    )
                    Spacer(modifier = Modifier.width(12.dp))
                    Text(
                        text = stringResource(R.string.block_description_3),
                        fontSize = 14.sp,
                        color = AppColors.text,
                        lineHeight = 20.sp
                    )
                }
            }
            
            // 确认拉黑按钮
            androidx.compose.material3.Button(
                onClick = {
                    onConfirmBlock()
                    onDismiss()
                },
                modifier = Modifier
                    .fillMaxWidth()
                    .height(48.dp),
                colors = androidx.compose.material3.ButtonDefaults.buttonColors(
                    containerColor = AppColors.text
                ),
                shape = RoundedCornerShape(24.dp)
            ) {
                Text(
                    stringResource(R.string.block),
                    color = AppColors.background,
                    fontSize = 16.sp,
                    fontWeight = FontWeight.Bold
                )
            }
        }
    }
}
