@@ -8,6 +8,7 @@ import android.content.IntentFilter
88import android.graphics.Bitmap
99import android.os.Build
1010import androidx.compose.animation.*
11+ import androidx.compose.ui.draw.clipToBounds
1112import androidx.compose.animation.core.FastOutSlowInEasing
1213import androidx.compose.animation.core.animateFloatAsState
1314import 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 }
0 commit comments