最终版本 DONE

This commit is contained in:
amos
2025-12-16 17:39:13 +08:00
parent aec9592e6f
commit 8ebc0965b1
3 changed files with 238 additions and 46 deletions

View File

@@ -143,17 +143,29 @@ fun ArchiveScreen(
// Date List Title
item {
Text(
text = "${selectedYear}${getLastMonthOfQuarter(selectedQuarter)}",
fontSize = 14.sp,
fontWeight = FontWeight.Bold,
color = Slate900,
modifier = Modifier.padding(bottom = 16.dp)
)
Row(
modifier = Modifier
.fillMaxWidth()
.padding(bottom = 16.dp),
horizontalArrangement = Arrangement.SpaceBetween,
verticalAlignment = Alignment.CenterVertically
) {
Text(
text = "${selectedYear}${getLastMonthOfQuarter(selectedQuarter)}",
fontSize = 14.sp,
fontWeight = FontWeight.Bold,
color = Slate900
)
Text(
text = "${recentPosts.size}",
fontSize = 12.sp,
color = Slate400
)
}
}
// Recent posts list
items(recentPosts.take(10)) { post ->
// Recent posts list - 显示所有帖子,可滚动查看
items(recentPosts) { post ->
DatePostItem(
post = post,
onClick = { onPostClick(post.id) }

View File

@@ -6,6 +6,7 @@ import androidx.compose.animation.fadeOut
import androidx.compose.foundation.Canvas
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.text.KeyboardActions
import androidx.compose.foundation.text.KeyboardOptions
@@ -16,6 +17,7 @@ import androidx.compose.material3.*
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.draw.shadow
import androidx.compose.ui.focus.FocusDirection
import androidx.compose.ui.geometry.Offset
@@ -121,6 +123,7 @@ fun LoginScreen(
var password by remember { mutableStateOf("") }
var nickname by remember { mutableStateOf("") }
var isRegisterMode by remember { mutableStateOf(false) }
var showRegisterDisabledDialog by remember { mutableStateOf(false) }
val focusManager = LocalFocusManager.current
Box(
@@ -301,9 +304,8 @@ fun LoginScreen(
onClick = {
if (!isLoading) {
if (isRegisterMode) {
if (username.isNotBlank() && password.isNotBlank() && nickname.isNotBlank()) {
onRegister(username, password, nickname)
}
// 禁止注册
showRegisterDisabledDialog = true
} else {
if (username.isNotBlank() && password.isNotBlank()) {
onLogin(username, password)
@@ -367,4 +369,71 @@ fun LoginScreen(
}
}
}
// 注册禁止弹窗
if (showRegisterDisabledDialog) {
androidx.compose.ui.window.Dialog(onDismissRequest = { showRegisterDisabledDialog = false }) {
Surface(
shape = RoundedCornerShape(28.dp),
color = Color.White,
shadowElevation = 16.dp,
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 24.dp)
) {
Column(
modifier = Modifier.padding(24.dp),
horizontalAlignment = Alignment.CenterHorizontally
) {
// 图标
Box(
modifier = Modifier
.size(56.dp)
.clip(CircleShape)
.background(ErrorRed.copy(alpha = 0.1f)),
contentAlignment = Alignment.Center
) {
Text(
text = "🚫",
fontSize = 28.sp
)
}
Spacer(modifier = Modifier.height(16.dp))
Text(
text = "注册已关闭",
fontWeight = FontWeight.Bold,
fontSize = 20.sp,
color = Slate900
)
Spacer(modifier = Modifier.height(8.dp))
Text(
text = "系统目前禁止注册新用户",
fontSize = 15.sp,
color = Slate500,
textAlign = TextAlign.Center
)
Spacer(modifier = Modifier.height(24.dp))
Button(
onClick = { showRegisterDisabledDialog = false },
modifier = Modifier.fillMaxWidth(),
colors = ButtonDefaults.buttonColors(containerColor = Slate900),
shape = RoundedCornerShape(12.dp),
contentPadding = PaddingValues(vertical = 14.dp)
) {
Text(
"我知道了",
fontWeight = FontWeight.Bold,
fontSize = 15.sp
)
}
}
}
}
}
}

View File

@@ -21,6 +21,7 @@ import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.compose.ui.window.Dialog
import coil.compose.AsyncImage
import com.memory.app.data.model.Comment
import com.memory.app.data.model.Post
@@ -310,26 +311,83 @@ fun PostDetailScreen(
// Delete Dialog
if (showDeleteDialog) {
AlertDialog(
onDismissRequest = { showDeleteDialog = false },
title = { Text("删除帖子", fontWeight = FontWeight.Bold) },
text = { Text("确定要删除这条帖子吗?此操作不可撤销。") },
confirmButton = {
TextButton(
onClick = {
showDeleteDialog = false
onDeletePost()
}
Dialog(onDismissRequest = { showDeleteDialog = false }) {
Surface(
shape = RoundedCornerShape(28.dp),
color = Color.White,
shadowElevation = 16.dp,
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 24.dp)
) {
Column(
modifier = Modifier.padding(24.dp)
) {
Text("删除", color = ErrorRed, fontWeight = FontWeight.Bold)
}
},
dismissButton = {
TextButton(onClick = { showDeleteDialog = false }) {
Text("取消", color = Slate500)
// 标题
Row(verticalAlignment = Alignment.CenterVertically) {
Box(
modifier = Modifier
.size(4.dp, 24.dp)
.clip(RoundedCornerShape(2.dp))
.background(ErrorRed)
)
Spacer(modifier = Modifier.width(12.dp))
Text(
text = "删除帖子",
fontWeight = FontWeight.Bold,
fontSize = 20.sp,
color = Slate900
)
}
Spacer(modifier = Modifier.height(16.dp))
// 内容
Text(
text = "确定要删除这条帖子吗?此操作不可撤销。",
fontSize = 15.sp,
color = Slate600,
lineHeight = 22.sp
)
Spacer(modifier = Modifier.height(24.dp))
// 按钮
Row(
modifier = Modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.End
) {
TextButton(
onClick = { showDeleteDialog = false },
shape = RoundedCornerShape(12.dp)
) {
Text(
"取消",
color = Slate500,
fontSize = 15.sp,
fontWeight = FontWeight.Medium
)
}
Spacer(modifier = Modifier.width(8.dp))
Button(
onClick = {
showDeleteDialog = false
onDeletePost()
},
colors = ButtonDefaults.buttonColors(containerColor = ErrorRed),
shape = RoundedCornerShape(12.dp),
contentPadding = PaddingValues(horizontal = 24.dp, vertical = 12.dp)
) {
Text(
"删除",
fontWeight = FontWeight.Bold,
fontSize = 15.sp
)
}
}
}
}
)
}
}
// Image Viewer
@@ -465,25 +523,78 @@ private fun CommentItem(
}
if (showDeleteDialog) {
AlertDialog(
onDismissRequest = { showDeleteDialog = false },
title = { Text("删除评论", fontWeight = FontWeight.Bold) },
text = { Text("确定要删除这条评论吗?") },
confirmButton = {
TextButton(
onClick = {
showDeleteDialog = false
onDelete()
}
Dialog(onDismissRequest = { showDeleteDialog = false }) {
Surface(
shape = RoundedCornerShape(28.dp),
color = Color.White,
shadowElevation = 16.dp,
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 24.dp)
) {
Column(
modifier = Modifier.padding(24.dp)
) {
Text("删除", color = ErrorRed, fontWeight = FontWeight.Bold)
}
},
dismissButton = {
TextButton(onClick = { showDeleteDialog = false }) {
Text("取消", color = Slate500)
Row(verticalAlignment = Alignment.CenterVertically) {
Box(
modifier = Modifier
.size(4.dp, 24.dp)
.clip(RoundedCornerShape(2.dp))
.background(ErrorRed)
)
Spacer(modifier = Modifier.width(12.dp))
Text(
text = "删除评论",
fontWeight = FontWeight.Bold,
fontSize = 20.sp,
color = Slate900
)
}
Spacer(modifier = Modifier.height(16.dp))
Text(
text = "确定要删除这条评论吗?",
fontSize = 15.sp,
color = Slate600
)
Spacer(modifier = Modifier.height(24.dp))
Row(
modifier = Modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.End
) {
TextButton(
onClick = { showDeleteDialog = false },
shape = RoundedCornerShape(12.dp)
) {
Text(
"取消",
color = Slate500,
fontSize = 15.sp,
fontWeight = FontWeight.Medium
)
}
Spacer(modifier = Modifier.width(8.dp))
Button(
onClick = {
showDeleteDialog = false
onDelete()
},
colors = ButtonDefaults.buttonColors(containerColor = ErrorRed),
shape = RoundedCornerShape(12.dp),
contentPadding = PaddingValues(horizontal = 24.dp, vertical = 12.dp)
) {
Text(
"删除",
fontWeight = FontWeight.Bold,
fontSize = 15.sp
)
}
}
}
}
)
}
}
}