feat(activity): 制作/提交按钮增加二次确认弹窗,调整弹窗标题颜色及列表项背景属性

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-23 17:41:26 +08:00
co-authored by Claude Sonnet 4.6
parent 267628411a
commit f3d57177b8
3 changed files with 33 additions and 5 deletions
@@ -1,7 +1,11 @@
package com.shuwei.dish.match.ui package com.shuwei.dish.match.ui
import android.annotation.SuppressLint import android.annotation.SuppressLint
import android.graphics.Color
import android.graphics.Typeface
import android.os.Bundle import android.os.Bundle
import android.text.style.ForegroundColorSpan
import android.text.style.StyleSpan
import android.util.Log import android.util.Log
import androidx.activity.addCallback import androidx.activity.addCallback
import androidx.lifecycle.Lifecycle import androidx.lifecycle.Lifecycle
@@ -24,6 +28,8 @@ import com.shuwei.dish.match.scale.ScaleDeviceConfig
import com.shuwei.dish.match.scale.ScaleServiceManager import com.shuwei.dish.match.scale.ScaleServiceManager
import com.shuwei.dish.match.utils.AddressUtil import com.shuwei.dish.match.utils.AddressUtil
import com.shuwei.dish.match.utils.WeightUtil import com.shuwei.dish.match.utils.WeightUtil
import com.shuwei.dish.match.utils.ext.appendText
import com.shuwei.dish.match.utils.ext.buildSpannableString
import com.shuwei.dish.match.utils.ext.clickWithDebounce import com.shuwei.dish.match.utils.ext.clickWithDebounce
import com.shuwei.dish.match.utils.ext.gone import com.shuwei.dish.match.utils.ext.gone
import com.shuwei.dish.match.utils.ext.roundedDecimalPlace import com.shuwei.dish.match.utils.ext.roundedDecimalPlace
@@ -139,6 +145,7 @@ class SubmitFoodActivity : BaseActivity() {
toast(state.msg) toast(state.msg)
dismissLoading() dismissLoading()
} }
else -> {} else -> {}
} }
} }
@@ -256,14 +263,18 @@ class SubmitFoodActivity : BaseActivity() {
} }
private fun addViewListener() { private fun addViewListener() {
binding.btnCook.clickWithDebounce { cook() } binding.btnCook.clickWithDebounce {
val content = getRemindSpannable("开始制作")
showRemindDialog(content) { cook() }
}
binding.btnWeightClear.clickWithDebounce { WeightUtil.tareTwo(2) } binding.btnWeightClear.clickWithDebounce { WeightUtil.tareTwo(2) }
binding.btnSubmit.clickWithDebounce { binding.btnSubmit.clickWithDebounce {
if (cookFoodEntity.foodWeight <= 0.toDouble()) { if (cookFoodEntity.foodWeight <= 0.toDouble()) {
toast("未识别到菜品熟重") toast("未识别到菜品熟重")
return@clickWithDebounce return@clickWithDebounce
} }
submit() val content = getRemindSpannable("制作完成")
showRemindDialog(content) { submit() }
} }
// 监听主设备 2格秤的熟重 // 监听主设备 2格秤的熟重
@@ -402,7 +413,6 @@ class SubmitFoodActivity : BaseActivity() {
} }
override fun onDestroy() { override fun onDestroy() {
WeightUtil.removeWeightListener(TAG) WeightUtil.removeWeightListener(TAG)
super.onDestroy() super.onDestroy()
@@ -421,4 +431,22 @@ class SubmitFoodActivity : BaseActivity() {
.show() .show()
} }
/**
* 点击制作和提交按钮确认dialog
*/
private fun showRemindDialog(content: CharSequence, action: () -> Unit) {
CommonDialog(this)
.setTitle("温馨提示")
.setContent(content)
.setNegativeButton("取消")
.setPositiveButton("确认") { action() }
.show()
}
private fun getRemindSpannable(cookStateText: String) = buildSpannableString {
appendText("请确认是否 ")
appendText(cookStateText, StyleSpan(Typeface.BOLD), ForegroundColorSpan(Color.BLACK))
appendText(" ")
}
} }
+1 -1
View File
@@ -15,7 +15,7 @@
android:layout_marginTop="55dp" android:layout_marginTop="55dp"
android:layout_marginEnd="40dp" android:layout_marginEnd="40dp"
android:gravity="center" android:gravity="center"
android:textColor="@color/black" android:textColor="@color/black333"
android:textSize="36sp" android:textSize="36sp"
android:textStyle="bold" /> android:textStyle="bold" />
@@ -3,7 +3,7 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="@color/white" tools:background="@color/white"
android:orientation="vertical"> android:orientation="vertical">
<LinearLayout <LinearLayout