Skip to content

Commit 95a1852

Browse files
committed
1.优化 下载相关流程并添加校验
2.优化 多选,组卡片展开查看详情相关动画
1 parent e2acc34 commit 95a1852

7 files changed

Lines changed: 230 additions & 144 deletions

File tree

.idea/misc.xml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ android {
1414
applicationId = "com.Badnng.moe"
1515
minSdk = 35
1616
targetSdk = 36
17-
versionCode = 20260324_11
18-
versionName = "26.3.24.C01-Dev"
17+
versionCode = 20260324_12
18+
versionName = "26.3.24.C02-Dev"
1919

2020
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
2121
ndk {

app/src/main/java/com/Badnng/moe/CaptureScreen.kt

Lines changed: 85 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import android.content.IntentFilter
88
import android.graphics.Bitmap
99
import android.os.Build
1010
import androidx.compose.animation.*
11+
import androidx.compose.ui.draw.clipToBounds
1112
import androidx.compose.animation.core.FastOutSlowInEasing
1213
import androidx.compose.animation.core.animateFloatAsState
1314
import androidx.compose.animation.core.tween
@@ -419,11 +420,11 @@ fun CaptureScreenContent(
419420
modifier = Modifier.weight(1f).fillMaxWidth(),
420421
label = "listTransition",
421422
transitionSpec = {
422-
fadeIn(animationSpec = tween(300)) togetherWith
423-
fadeOut(animationSpec = tween(300))
423+
fadeIn(animationSpec = tween(300)) togetherWith fadeOut(animationSpec = tween(300))
424424
}
425-
) { (isCompletedOnly, currentStandaloneOrders, currentAllGroups) ->
426-
val currentState = if (isCompletedOnly) {
425+
) { (currentShowCompletedOnly, currentStandaloneOrders, currentAllGroups) ->
426+
// 使用外部定义的变量
427+
val currentState = if (currentShowCompletedOnly) {
427428
completedListState
428429
} else {
429430
incompleteListState
@@ -449,8 +450,8 @@ fun CaptureScreenContent(
449450
onClick = { onNavigateToDetail(group) },
450451
onMarkAllCompleted = { performHaptic(); onMarkGroupCompleted(group.id) },
451452
onDeleteGroup = { performHaptic(); onDeleteGroup(group) },
452-
isEditMode = isEditMode,
453453
initiallyExpanded = expandedGroupId == group.id,
454+
isEditMode = isEditMode,
454455
isSelectable = isEditMode,
455456
isSelected = selectedGroupIds.contains(group.id),
456457
onSelectionChange = { checked ->
@@ -493,7 +494,7 @@ fun CaptureScreenContent(
493494
onMarkCompleted = { performHaptic(); onMarkCompleted(order.id) },
494495
onDelete = { performHaptic(); orderToDelete = order },
495496
onShowQr = { performHaptic(); selectedOrderForQr = order },
496-
isCompleted = isCompletedOnly,
497+
isCompleted = currentShowCompletedOnly,
497498
isHighlighted = highlightOrderId == order.id,
498499
isEditMode = isEditMode,
499500
onNavigateToDetail = onNavigateToDetail,
@@ -763,7 +764,7 @@ fun OrderGroupCard(
763764
) {
764765
val context = LocalContext.current
765766
val viewModel: OrderViewModel = viewModel()
766-
var isExpanded by remember { mutableStateOf(initiallyExpanded) }
767+
var isExpanded by remember { mutableStateOf(false) }
767768
LaunchedEffect(initiallyExpanded) {
768769
if (initiallyExpanded) {
769770
isExpanded = true
@@ -847,54 +848,56 @@ fun OrderGroupCard(
847848
Text(text = "包含 ${groupOrders.size} 个取件码", fontSize = 12.sp, color = MaterialTheme.colorScheme.onSurfaceVariant)
848849

849850
// 操作按钮放在标题下面(只在非编辑模式下显示)
850-
AnimatedVisibility(
851-
visible = !isEditMode,
852-
enter = expandVertically() + fadeIn(),
853-
exit = shrinkVertically() + fadeOut()
851+
Box(
852+
modifier = Modifier
853+
.fillMaxWidth()
854+
.clipToBounds()
854855
) {
855-
Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {
856-
Row(modifier = Modifier.fillMaxWidth().padding(top = 8.dp), horizontalArrangement = Arrangement.spacedBy(12.dp)) {
857-
FilledTonalButton(
858-
onClick = { performHaptic(); onMarkAllCompleted() },
859-
modifier = Modifier.weight(1f),
860-
shape = RoundedCornerShape(15.dp)
861-
) {
862-
Text("全部完成")
863-
}
864-
OutlinedButton(
865-
onClick = { performHaptic(); onDeleteGroup() },
866-
modifier = Modifier.weight(1f),
867-
colors = ButtonDefaults.outlinedButtonColors(contentColor = MaterialTheme.colorScheme.error),
868-
shape = RoundedCornerShape(15.dp)
869-
) {
870-
Text("删除组")
856+
if (!isEditMode) {
857+
Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {
858+
Spacer(Modifier.height(0.dp))
859+
Row(modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.spacedBy(12.dp)) {
860+
FilledTonalButton(
861+
onClick = { performHaptic(); onMarkAllCompleted() },
862+
modifier = Modifier.weight(1f),
863+
shape = RoundedCornerShape(15.dp)
864+
) {
865+
Text("全部完成")
866+
}
867+
OutlinedButton(
868+
onClick = { performHaptic(); onDeleteGroup() },
869+
modifier = Modifier.weight(1f),
870+
colors = ButtonDefaults.outlinedButtonColors(contentColor = MaterialTheme.colorScheme.error),
871+
shape = RoundedCornerShape(15.dp)
872+
) {
873+
Text("删除组")
874+
}
871875
}
872-
}
873876

874-
// 再次推送实时通知按钮
875-
if (!group.isCompleted) {
876-
FilledTonalButton(
877-
onClick = {
878-
performHaptic()
879-
// 推送组通知
880-
val notificationGroup = OrderGroup(
881-
id = group.id,
882-
name = group.name,
883-
orderType = group.orderType,
884-
brandName = group.brandName,
885-
screenshotPath = group.screenshotPath,
886-
recognizedText = group.recognizedText,
887-
sourceApp = group.sourceApp
888-
)
889-
NotificationHelper(context).showGroupNotification(notificationGroup, groupOrders)
890-
},
891-
modifier = Modifier.fillMaxWidth().height(44.dp),
892-
shape = RoundedCornerShape(12.dp),
893-
colors = ButtonDefaults.filledTonalButtonColors(containerColor = MaterialTheme.colorScheme.secondaryContainer)
894-
) {
895-
Icon(Icons.Default.NotificationAdd, null, Modifier.size(18.dp))
896-
Spacer(Modifier.width(8.dp))
897-
Text("再次推送实时通知", fontSize = 12.sp, fontWeight = FontWeight.Bold)
877+
// 再次推送实时通知按钮
878+
if (!group.isCompleted) {
879+
FilledTonalButton(
880+
onClick = {
881+
performHaptic()
882+
val notificationGroup = OrderGroup(
883+
id = group.id,
884+
name = group.name,
885+
orderType = group.orderType,
886+
brandName = group.brandName,
887+
screenshotPath = group.screenshotPath,
888+
recognizedText = group.recognizedText,
889+
sourceApp = group.sourceApp
890+
)
891+
NotificationHelper(context).showGroupNotification(notificationGroup, groupOrders)
892+
},
893+
modifier = Modifier.fillMaxWidth().height(44.dp),
894+
shape = RoundedCornerShape(12.dp),
895+
colors = ButtonDefaults.filledTonalButtonColors(containerColor = MaterialTheme.colorScheme.secondaryContainer)
896+
) {
897+
Icon(Icons.Default.NotificationAdd, null, Modifier.size(18.dp))
898+
Spacer(Modifier.width(8.dp))
899+
Text("再次推送实时通知", fontSize = 12.sp, fontWeight = FontWeight.Bold)
900+
}
898901
}
899902
}
900903
}
@@ -959,10 +962,11 @@ fun OrderGroupCard(
959962
}
960963

961964
// 展开/折叠内容(只在非编辑模式下显示)
962-
AnimatedVisibility(
965+
Box(modifier = Modifier.fillMaxWidth().clipToBounds()) {
966+
androidx.compose.animation.AnimatedVisibility(
963967
visible = isExpanded && !isEditMode,
964-
enter = expandVertically() + fadeIn(),
965-
exit = shrinkVertically() + fadeOut()
968+
enter = expandVertically(expandFrom = Alignment.Top) + fadeIn(),
969+
exit = shrinkVertically(shrinkTowards = Alignment.Top) + fadeOut()
966970
) {
967971
Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {
968972
HorizontalDivider(modifier = Modifier.padding(vertical = 4.dp))
@@ -978,15 +982,16 @@ fun OrderGroupCard(
978982
onShowQr = { /* TODO: 显示二维码 */ },
979983
isCompleted = order.isCompleted,
980984
isEditMode = isEditMode,
981-
showRealtimeNotification = false,
982985
onNavigateToDetail = { /* TODO: 导航到详情 */ },
986+
showRealtimeNotification = false,
983987
modifier = Modifier.fillMaxWidth()
984988
)
985989
}
986990
}
987991
}
988992
}
989993
}
994+
}
990995
}
991996
}
992997
}
@@ -1038,7 +1043,7 @@ fun OrderCard(
10381043
text = order.takeoutCode,
10391044
fontSize = 22.sp,
10401045
fontWeight = FontWeight.ExtraBold,
1041-
color = MaterialTheme.colorScheme.primary,
1046+
color = if (isCompleted && !showRealtimeNotification) MaterialTheme.colorScheme.onSurfaceVariant.copy(alpha = 0.5f) else MaterialTheme.colorScheme.primary,
10421047
textDecoration = if (isCompleted) TextDecoration.LineThrough else TextDecoration.None
10431048
)
10441049
if (!order.pickupLocation.isNullOrEmpty()) {
@@ -1052,7 +1057,7 @@ fun OrderCard(
10521057
text = order.pickupLocation!!,
10531058
fontSize = 14.sp,
10541059
fontWeight = FontWeight.Bold,
1055-
color = MaterialTheme.colorScheme.primary,
1060+
color = if (isCompleted && !showRealtimeNotification) MaterialTheme.colorScheme.onSurfaceVariant.copy(alpha = 0.5f) else MaterialTheme.colorScheme.primary,
10561061
maxLines = 2,
10571062
overflow = TextOverflow.Ellipsis,
10581063
textDecoration = if (isCompleted) TextDecoration.LineThrough else TextDecoration.None
@@ -1071,27 +1076,30 @@ fun OrderCard(
10711076
}
10721077
Text(text = "时间: $timeStr", fontSize = 12.sp, color = MaterialTheme.colorScheme.onSurfaceVariant.copy(alpha = 0.7f) )
10731078

1074-
AnimatedVisibility(
1075-
visible = !isEditMode,
1076-
enter = expandVertically() + fadeIn(),
1077-
exit = shrinkVertically() + fadeOut()
1079+
Box(
1080+
modifier = Modifier
1081+
.fillMaxWidth()
1082+
.clipToBounds()
10781083
) {
1079-
Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {
1080-
Row(modifier = Modifier.fillMaxWidth().padding(top = 8.dp), horizontalArrangement = Arrangement.spacedBy(12.dp)) {
1081-
if (!isCompleted) { FilledTonalButton(onClick = onMarkCompleted, modifier = Modifier.weight(1f), shape = RoundedCornerShape(15.dp)) { Text("完成") } }
1082-
OutlinedButton(onClick = onDelete, modifier = Modifier.weight(1f), colors = ButtonDefaults.outlinedButtonColors(contentColor = MaterialTheme.colorScheme.error), shape = RoundedCornerShape(15.dp)) { Text("删除") }
1083-
}
1084+
if (!isEditMode) {
1085+
Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {
1086+
Spacer(Modifier.height(0.dp))
1087+
Row(modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.spacedBy(12.dp)) {
1088+
if (!isCompleted) { FilledTonalButton(onClick = onMarkCompleted, modifier = Modifier.weight(1f), shape = RoundedCornerShape(15.dp)) { Text("完成") } }
1089+
OutlinedButton(onClick = onDelete, modifier = Modifier.weight(1f), colors = ButtonDefaults.outlinedButtonColors(contentColor = MaterialTheme.colorScheme.error), shape = RoundedCornerShape(15.dp)) { Text("删除") }
1090+
}
10841091

1085-
if (!isCompleted && showRealtimeNotification) {
1086-
FilledTonalButton(
1087-
onClick = { NotificationHelper(context).showPromotedLiveUpdate(order) },
1088-
modifier = Modifier.fillMaxWidth().height(44.dp),
1089-
shape = RoundedCornerShape(15.dp),
1090-
colors = ButtonDefaults.filledTonalButtonColors(containerColor = MaterialTheme.colorScheme.secondaryContainer)
1091-
) {
1092-
Icon(Icons.Default.NotificationAdd, null, Modifier.size(18.dp))
1093-
Spacer(Modifier.width(8.dp))
1094-
Text("再次推送实时通知", fontSize = 14.sp, fontWeight = FontWeight.Bold)
1092+
if (!isCompleted && showRealtimeNotification) {
1093+
FilledTonalButton(
1094+
onClick = { NotificationHelper(context).showPromotedLiveUpdate(order) },
1095+
modifier = Modifier.fillMaxWidth().height(44.dp),
1096+
shape = RoundedCornerShape(15.dp),
1097+
colors = ButtonDefaults.filledTonalButtonColors(containerColor = MaterialTheme.colorScheme.secondaryContainer)
1098+
) {
1099+
Icon(Icons.Default.NotificationAdd, null, Modifier.size(18.dp))
1100+
Spacer(Modifier.width(8.dp))
1101+
Text("再次推送实时通知", fontSize = 14.sp, fontWeight = FontWeight.Bold)
1102+
}
10951103
}
10961104
}
10971105
}

app/src/main/java/com/Badnng/moe/HomeScreen.kt

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -331,11 +331,17 @@ fun HomeScreen(
331331
orders = groupOrders,
332332
onBack = { detailGroup = null },
333333
onMarkAllCompleted = {
334+
val completedAt = System.currentTimeMillis()
334335
groupOrders = groupOrders.map {
335-
if (it.isCompleted) it else it.copy(isCompleted = true, completedAt = System.currentTimeMillis())
336+
if (it.isCompleted) it else it.copy(isCompleted = true, completedAt = completedAt)
336337
}
337-
viewModel.markAllOrdersInGroupCompleted(displayGroup.id)
338-
detailGroup = null
338+
detailGroup = displayGroup.copy(
339+
isCompleted = true,
340+
completedAt = completedAt,
341+
orderCount = groupOrders.size
342+
)
343+
previousDetailGroup = detailGroup
344+
viewModel.markGroupAsCompleted(displayGroup.id)
339345
},
340346
onMarkOrderCompleted = { order ->
341347
groupOrders = groupOrders.map {

app/src/main/java/com/Badnng/moe/SettingsScreen.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,8 @@ fun AboutSettingsContent(performHaptic: () -> Unit) {
557557
showProgressDialog = false
558558
if (file != null) {
559559
UpdateHelper.installUpdate(context, file)
560+
} else {
561+
android.widget.Toast.makeText(context, "下载失败或更新包已失效", android.widget.Toast.LENGTH_SHORT).show()
560562
}
561563
}
562564
}
@@ -1563,4 +1565,4 @@ fun VendorKeepAliveItem(vendor: String, steps: List<String>, performHaptic: () -
15631565
}
15641566
}
15651567
}
1566-
}
1568+
}

0 commit comments

Comments
 (0)