refactor(dialog): 重构 FoodSearchDialog 和 SeasoningSearchDialog 继承 BottomSheetDialog
This commit is contained in:
@@ -251,10 +251,11 @@ class DeviceConfigActivity : BaseActivity() {
|
||||
val currentAddress = AddressUtil.getWeighAddressArray().get(sort)
|
||||
// val seasoningEntity = list.first{it.sort == sort}
|
||||
SeasoningSearchDialog(
|
||||
activity = this,
|
||||
weighIndex = sort,
|
||||
weighAddress = currentAddress,
|
||||
clickName = entity.goodsName
|
||||
).show(this) { item ->
|
||||
) { item ->
|
||||
syncItem(entity, item)
|
||||
//3-调料
|
||||
entity.materialType = 3
|
||||
@@ -265,7 +266,7 @@ class DeviceConfigActivity : BaseActivity() {
|
||||
val frameLayout = gridLayout.findViewWithTag<FrameLayout>(tag)
|
||||
TextCellAdapter.loadLayout(frameLayout, entity)
|
||||
}
|
||||
}
|
||||
}.show()
|
||||
}
|
||||
|
||||
private fun syncItem(oldItem: SeasoningEntity, newItem: SeasoningEntity) {
|
||||
|
||||
@@ -276,11 +276,14 @@ class DishSamplingActivity : BaseActivity() {
|
||||
|
||||
private fun searchDishType() {
|
||||
val inputText = binding.etInputDishType.text.toString().trim()
|
||||
FoodSearchDialog(defGoodsName = inputText).show(this@DishSamplingActivity) { item ->
|
||||
FoodSearchDialog(
|
||||
activity = this@DishSamplingActivity,
|
||||
defGoodsName = inputText
|
||||
) { item ->
|
||||
val filterResult = list.firstOrNull { it.goodsName == item.goodsName }
|
||||
if (filterResult != null) {
|
||||
toast("不允许重复添加同一食材")
|
||||
return@show
|
||||
return@FoodSearchDialog
|
||||
}
|
||||
binding.etInputDishType.run {
|
||||
setText(item.goodsName)
|
||||
@@ -297,7 +300,7 @@ class DishSamplingActivity : BaseActivity() {
|
||||
// TODO: 待定
|
||||
//allEdible = item.allEdible
|
||||
}
|
||||
}
|
||||
}.show()
|
||||
}
|
||||
|
||||
}
|
||||
@@ -201,7 +201,7 @@ class PrepareCookActivity : BaseActivity() {
|
||||
* 添加食材
|
||||
*/
|
||||
private fun addFood() {
|
||||
FoodSearchDialog().show(activity = this, callback = foodSelectCallback)
|
||||
FoodSearchDialog(activity = this, onItemSelected = foodSelectCallback).show()
|
||||
}
|
||||
|
||||
private fun openSubmitPage() {
|
||||
|
||||
@@ -242,10 +242,11 @@ class DeviceConfigFragment : BaseFragment<FragmentDeviceConfigBinding>() {
|
||||
private fun clickGridItem(sort: Int, entity: SeasoningEntity) {
|
||||
val currentAddress = AddressUtil.getWeighAddressArray().get(sort)
|
||||
SeasoningSearchDialog(
|
||||
activity = requireActivity() as BaseActivity,
|
||||
weighIndex = sort,
|
||||
weighAddress = currentAddress,
|
||||
clickName = entity.goodsName
|
||||
).show(requireActivity() as BaseActivity) { item ->
|
||||
) { item ->
|
||||
syncItem(entity, item)
|
||||
// 3-调料
|
||||
entity.materialType = 3
|
||||
@@ -256,7 +257,7 @@ class DeviceConfigFragment : BaseFragment<FragmentDeviceConfigBinding>() {
|
||||
val frameLayout = gridLayout.findViewWithTag<FrameLayout>(tag)
|
||||
TextCellAdapter.loadLayout(frameLayout, entity)
|
||||
}
|
||||
}
|
||||
}.show()
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user