123 lines
4.8 KiB
Kotlin
123 lines
4.8 KiB
Kotlin
package com.unogame.ui.screens
|
||
|
||
import androidx.compose.animation.*
|
||
import androidx.compose.foundation.background
|
||
import androidx.compose.foundation.layout.*
|
||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||
import androidx.compose.material.icons.Icons
|
||
import androidx.compose.material.icons.filled.*
|
||
import androidx.compose.material3.*
|
||
import androidx.compose.runtime.*
|
||
import androidx.compose.ui.Alignment
|
||
import androidx.compose.ui.Modifier
|
||
import androidx.compose.ui.graphics.Color
|
||
import androidx.compose.ui.text.font.FontWeight
|
||
import androidx.compose.ui.text.style.TextAlign
|
||
import androidx.compose.ui.unit.dp
|
||
import androidx.compose.ui.unit.sp
|
||
import com.unogame.ui.theme.*
|
||
|
||
@Composable
|
||
fun GameOverScreen(
|
||
winnerName: String,
|
||
isYouWinner: Boolean,
|
||
onBackToMenu: () -> Unit,
|
||
points: Int = 0,
|
||
difficulty: String = "",
|
||
duration: Int = 0,
|
||
turnNumber: Int = 0,
|
||
playerCount: Int = 0
|
||
) {
|
||
val durationText = if (duration >= 60) "${duration / 60}分${duration % 60}秒" else "${duration}秒"
|
||
|
||
Box(
|
||
modifier = Modifier
|
||
.fillMaxSize()
|
||
.background(LocalTableBg.current.color),
|
||
contentAlignment = Alignment.Center
|
||
) {
|
||
Column(
|
||
modifier = Modifier
|
||
.fillMaxWidth()
|
||
.padding(32.dp),
|
||
horizontalAlignment = Alignment.CenterHorizontally
|
||
) {
|
||
Icon(
|
||
Icons.Default.EmojiEvents,
|
||
contentDescription = null,
|
||
tint = GoldAccent,
|
||
modifier = Modifier.size(80.dp)
|
||
)
|
||
|
||
Spacer(modifier = Modifier.height(24.dp))
|
||
|
||
Text(
|
||
text = if (isYouWinner) "恭喜你赢了!" else "游戏结束",
|
||
fontSize = 36.sp,
|
||
fontWeight = FontWeight.Black,
|
||
color = LocalAccentOnTable.current,
|
||
textAlign = TextAlign.Center
|
||
)
|
||
|
||
Spacer(modifier = Modifier.height(12.dp))
|
||
|
||
Text(
|
||
text = if (isYouWinner) "你是UNO冠军!" else "$winnerName 赢得了比赛",
|
||
fontSize = 18.sp,
|
||
color = LocalTextOnTable.current.copy(alpha = 0.8f),
|
||
textAlign = TextAlign.Center
|
||
)
|
||
|
||
if (isYouWinner && points > 0) {
|
||
Spacer(modifier = Modifier.height(24.dp))
|
||
Text(
|
||
text = "+$points 分",
|
||
fontSize = 32.sp,
|
||
fontWeight = FontWeight.Black,
|
||
color = LocalAccentOnTable.current
|
||
)
|
||
Spacer(modifier = Modifier.height(12.dp))
|
||
Row(
|
||
modifier = Modifier.fillMaxWidth(),
|
||
horizontalArrangement = Arrangement.SpaceEvenly
|
||
) {
|
||
Column(horizontalAlignment = Alignment.CenterHorizontally) {
|
||
Text("难度", color = LocalTextOnTable.current.copy(alpha = 0.5f), fontSize = 12.sp)
|
||
Text(difficulty, color = LocalTextOnTable.current, fontSize = 14.sp, fontWeight = FontWeight.Bold)
|
||
}
|
||
Column(horizontalAlignment = Alignment.CenterHorizontally) {
|
||
Text("时长", color = LocalTextOnTable.current.copy(alpha = 0.5f), fontSize = 12.sp)
|
||
Text(durationText, color = LocalTextOnTable.current, fontSize = 14.sp, fontWeight = FontWeight.Bold)
|
||
}
|
||
Column(horizontalAlignment = Alignment.CenterHorizontally) {
|
||
Text("人数", color = LocalTextOnTable.current.copy(alpha = 0.5f), fontSize = 12.sp)
|
||
Text("${playerCount}人", color = LocalTextOnTable.current, fontSize = 14.sp, fontWeight = FontWeight.Bold)
|
||
}
|
||
Column(horizontalAlignment = Alignment.CenterHorizontally) {
|
||
Text("轮次", color = LocalTextOnTable.current.copy(alpha = 0.5f), fontSize = 12.sp)
|
||
Text("$turnNumber 轮", color = LocalTextOnTable.current, fontSize = 14.sp, fontWeight = FontWeight.Bold)
|
||
}
|
||
}
|
||
}
|
||
|
||
Spacer(modifier = Modifier.height(48.dp))
|
||
|
||
Button(
|
||
onClick = onBackToMenu,
|
||
modifier = Modifier
|
||
.fillMaxWidth()
|
||
.height(56.dp),
|
||
shape = RoundedCornerShape(16.dp),
|
||
colors = ButtonDefaults.buttonColors(
|
||
containerColor = GoldAccent,
|
||
contentColor = Color.Black
|
||
)
|
||
) {
|
||
Icon(Icons.Default.Home, null)
|
||
Spacer(modifier = Modifier.width(8.dp))
|
||
Text("返回主菜单", fontSize = 18.sp, fontWeight = FontWeight.Bold)
|
||
}
|
||
}
|
||
}
|
||
}
|