feat(activity): 制作/提交按钮增加二次确认弹窗,调整弹窗标题颜色及列表项背景属性
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,7 +1,11 @@
|
||||
package com.shuwei.dish.match.ui
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.graphics.Color
|
||||
import android.graphics.Typeface
|
||||
import android.os.Bundle
|
||||
import android.text.style.ForegroundColorSpan
|
||||
import android.text.style.StyleSpan
|
||||
import android.util.Log
|
||||
import androidx.activity.addCallback
|
||||
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.utils.AddressUtil
|
||||
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.gone
|
||||
import com.shuwei.dish.match.utils.ext.roundedDecimalPlace
|
||||
@@ -139,6 +145,7 @@ class SubmitFoodActivity : BaseActivity() {
|
||||
toast(state.msg)
|
||||
dismissLoading()
|
||||
}
|
||||
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
@@ -256,14 +263,18 @@ class SubmitFoodActivity : BaseActivity() {
|
||||
}
|
||||
|
||||
private fun addViewListener() {
|
||||
binding.btnCook.clickWithDebounce { cook() }
|
||||
binding.btnCook.clickWithDebounce {
|
||||
val content = getRemindSpannable("开始制作")
|
||||
showRemindDialog(content) { cook() }
|
||||
}
|
||||
binding.btnWeightClear.clickWithDebounce { WeightUtil.tareTwo(2) }
|
||||
binding.btnSubmit.clickWithDebounce {
|
||||
if (cookFoodEntity.foodWeight <= 0.toDouble()) {
|
||||
toast("未识别到菜品熟重")
|
||||
return@clickWithDebounce
|
||||
}
|
||||
submit()
|
||||
val content = getRemindSpannable("制作完成")
|
||||
showRemindDialog(content) { submit() }
|
||||
}
|
||||
|
||||
// 监听主设备 2格秤的熟重
|
||||
@@ -402,7 +413,6 @@ class SubmitFoodActivity : BaseActivity() {
|
||||
}
|
||||
|
||||
|
||||
|
||||
override fun onDestroy() {
|
||||
WeightUtil.removeWeightListener(TAG)
|
||||
super.onDestroy()
|
||||
@@ -421,4 +431,22 @@ class SubmitFoodActivity : BaseActivity() {
|
||||
.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(" ?")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
android:layout_marginTop="55dp"
|
||||
android:layout_marginEnd="40dp"
|
||||
android:gravity="center"
|
||||
android:textColor="@color/black"
|
||||
android:textColor="@color/black333"
|
||||
android:textSize="36sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/white"
|
||||
tools:background="@color/white"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
|
||||
Reference in New Issue
Block a user