package com.tsmobile.app.ui.components

import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.height
import androidx.compose.material3.*
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.tsmobile.app.data.ChatMessage

/**
 * 消息长按操作菜单。
 * 提供复制和 Poke 操作。
 */
@Composable
fun MessageContextMenu(
    message: ChatMessage,
    onCopy: () -> Unit,
    onPokeSender: () -> Unit,
    onDismiss: () -> Unit
) {
    AlertDialog(
        onDismissRequest = onDismiss,
        shape = MaterialTheme.shapes.extraLarge,
        containerColor = MaterialTheme.colorScheme.surfaceContainerHigh,
        titleContentColor = MaterialTheme.colorScheme.onSurface,
        textContentColor = MaterialTheme.colorScheme.onSurfaceVariant,
        title = { Text(message.senderName, style = MaterialTheme.typography.headlineSmall) },
        text = {
            Column {
                DropdownMenuItem(
                    text = { Text("📋 复制", style = MaterialTheme.typography.bodyLarge) },
                    onClick = {
                        onCopy()
                        onDismiss()
                    },
                    colors = MenuDefaults.itemColors(
                        textColor = MaterialTheme.colorScheme.onSurface
                    )
                )
                Spacer(Modifier.height(4.dp))
                DropdownMenuItem(
                    text = { Text("🫴 Poke", style = MaterialTheme.typography.bodyLarge) },
                    onClick = {
                        onPokeSender()
                        onDismiss()
                    },
                    colors = MenuDefaults.itemColors(
                        textColor = MaterialTheme.colorScheme.onSurface
                    )
                )
            }
        },
        confirmButton = {},
        dismissButton = {
            TextButton(onClick = onDismiss) { Text("取消") }
        }
    )
}
