diff --git a/app/src/main/java/com/shuwei/intelligent/shelves/dialog/ChipSelectDialog.kt b/app/src/main/java/com/shuwei/intelligent/shelves/dialog/ChipSelectDialog.kt index 9d2c366..bd57e81 100644 --- a/app/src/main/java/com/shuwei/intelligent/shelves/dialog/ChipSelectDialog.kt +++ b/app/src/main/java/com/shuwei/intelligent/shelves/dialog/ChipSelectDialog.kt @@ -7,12 +7,15 @@ import android.os.Bundle import android.view.Gravity import android.view.LayoutInflater import android.view.View +import android.view.ViewGroup import com.google.android.material.chip.Chip +import com.google.android.material.chip.ChipGroup import com.shuwei.intelligent.shelves.R import com.shuwei.intelligent.shelves.base.BaseDialog import com.shuwei.intelligent.shelves.databinding.DialogChipSelectBinding import com.shuwei.intelligent.shelves.utils.ext.dp import com.shuwei.intelligent.shelves.utils.ext.hideKeyboard +import com.shuwei.intelligent.shelves.utils.ext.toast /** * 带ChipGroup选择的弹窗,支持传入选项列表,回调返回选中索引 @@ -55,9 +58,11 @@ class ChipSelectDialog(context: Context) : Dialog(context, R.style.DialogTheme) } binding.btnConfirm.setOnClickListener { - if (selectedIndex >= 0) { - onItemSelected?.invoke(selectedIndex) + if (binding.chipGroup.checkedChipId == -1) { + context.toast("请选择净菜分类") + return@setOnClickListener } + onItemSelected?.invoke(selectedIndex) dismiss() } } @@ -80,9 +85,9 @@ class ChipSelectDialog(context: Context) : Dialog(context, R.style.DialogTheme) text = label isCheckable = true isCheckedIconVisible = false - textSize = 20f - chipStartPadding = 15.dp.toFloat() - chipEndPadding = 15.dp.toFloat() + textSize = 22f + chipStartPadding = 18.dp.toFloat() + chipEndPadding = 18.dp.toFloat() textStartPadding = 8.dp.toFloat() textEndPadding = 8.dp.toFloat() chipMinHeight = 50.dp.toFloat() @@ -94,7 +99,13 @@ class ChipSelectDialog(context: Context) : Dialog(context, R.style.DialogTheme) selectedIndex = index } } - binding.chipGroup.addView(chip) + val params = ChipGroup.LayoutParams( + ViewGroup.LayoutParams.WRAP_CONTENT, + ViewGroup.LayoutParams.WRAP_CONTENT + ).apply { + setMargins(8, 5.dp, 8.dp, 5.dp) // left, top, right, bottom + } + binding.chipGroup.addView(chip, params) } } } diff --git a/app/src/main/java/com/sw/scalefusion/shelf/HomeV3Activity.kt b/app/src/main/java/com/sw/scalefusion/shelf/HomeV3Activity.kt index fc0f1b8..b70f599 100644 --- a/app/src/main/java/com/sw/scalefusion/shelf/HomeV3Activity.kt +++ b/app/src/main/java/com/sw/scalefusion/shelf/HomeV3Activity.kt @@ -249,6 +249,8 @@ class HomeV3Activity : BaseActivity() { it.putExtra(ShelfV3Activity.EXTRA_CABINET_ID, model.cabinetId) it.putExtra(ShelfV3Activity.EXTRA_SLOT_NO, model.slotNo) it.putExtra(ShelfV3Activity.EXTRA_CANTEEN_ID, canteenId) + it.putExtra(ShelfV3Activity.EXTRA_MATER_NAME, model.materName) + it.putExtra(ShelfV3Activity.EXTRA_VEG_TYPE_NAME, model.vegTypeName) }) { result -> result?.let { onShelfActivityResult(position, it) } } diff --git a/app/src/main/java/com/sw/scalefusion/shelf/ShelfV3Activity.kt b/app/src/main/java/com/sw/scalefusion/shelf/ShelfV3Activity.kt index aed75ce..4a0bf6c 100644 --- a/app/src/main/java/com/sw/scalefusion/shelf/ShelfV3Activity.kt +++ b/app/src/main/java/com/sw/scalefusion/shelf/ShelfV3Activity.kt @@ -28,8 +28,6 @@ import com.shuwei.intelligent.shelves.utils.ext.toast import com.shuwei.intelligent.shelves.utils.ext.visible import com.sw.scalefusion.shelf.adapter.PendingInboundAdapter import com.sw.scalefusion.shelf.model.FoodItem -import com.sw.scalefusion.shelf.model.PendingInboundItem -import com.sw.scalefusion.shelf.model.PendingInboundRequest import com.sw.scalefusion.shelf.model.PutSlotRequest import com.sw.scalefusion.shelf.model.SearchFoodRequest import com.sw.scalefusion.shelf.model.SlotDetailRequest @@ -52,6 +50,8 @@ class ShelfV3Activity : BaseActivity() { const val EXTRA_CABINET_ID = "cabinetId" const val EXTRA_CANTEEN_ID = "canteenId" const val EXTRA_SLOT_NO = "slotNo" + const val EXTRA_MATER_NAME = "materName" + const val EXTRA_VEG_TYPE_NAME = "vegTypeName" const val YYYY_MM_DD__EEEE_HH_MM_SS = "yyyy年MM月dd日 EEEE***HH:mm:ss" } @@ -96,7 +96,7 @@ class ShelfV3Activity : BaseActivity() { val index = optionList[position].typeSelectedIndex val typeList = optionList[position].vegTypeList ?: emptyList() val selectType = typeList.getOrNull(index)?.vegTypeName ?: "" - binding.tvFoodType.text = selectType + binding.tvVegTypeName.text = selectType KeyboardUtil.hideKeyboard(this@ShelfV3Activity.window.decorView) } @@ -104,6 +104,8 @@ class ShelfV3Activity : BaseActivity() { private var canteenId: Long = 0 private var cabinetId: String = "" private var slotNo: String = "" + private var materName: String = "" + private var vegTypeName: String = "" @Suppress("DEPRECATION") override fun onCreate(savedInstanceState: Bundle?) { @@ -117,9 +119,12 @@ class ShelfV3Activity : BaseActivity() { canteenId = intent.getLongExtra(EXTRA_CANTEEN_ID, 0) cabinetId = intent.getStringExtra(EXTRA_CABINET_ID) ?: "" slotNo = intent.getStringExtra(EXTRA_SLOT_NO) ?: "" + materName = intent.getStringExtra(EXTRA_MATER_NAME) ?: "" + vegTypeName = intent.getStringExtra(EXTRA_VEG_TYPE_NAME) ?: "" binding.tvShelfName.text = slotNo - + binding.tvFoodName.text = materName.ifBlank { "-" } + binding.tvVegTypeName.text = vegTypeName initRecyclerView() initSearchBox() initButtons() @@ -142,7 +147,7 @@ class ShelfV3Activity : BaseActivity() { /** 从 slotDetail 响应更新 UI */ private fun updateUI(model: SlotModel) { binding.tvFoodName.text = if (model.materName.isNullOrBlank()) "-" else model.materName - binding.tvFoodType.text = "" + binding.tvVegTypeName.text = model.vegTypeName val weightG = model.weight ?: 0.0 realWeight = (weightG * 1000.0).toInt() binding.tvFoodWeight.text = if (weightG >= 1.0) "%.3f千克".format(weightG) @@ -185,7 +190,7 @@ class ShelfV3Activity : BaseActivity() { binding.btnClearEmpty.setOnClickListener { v -> clearZero() binding.tvFoodName.text = "-" - binding.tvFoodType.text = "" + binding.tvVegTypeName.text = "" Loading.show(this@ShelfV3Activity) v.postDelayed({ Loading.dismiss() @@ -211,6 +216,7 @@ class ShelfV3Activity : BaseActivity() { return@clickWithDebounce } val model = shelfModel ?: return@clickWithDebounce + val vegType = item.vegTypeList?.getOrNull(item.typeSelectedIndex) viewModel.put( request = PutSlotRequest( cabinetType = cabinetType, @@ -220,7 +226,7 @@ class ShelfV3Activity : BaseActivity() { materName = item.materName, weight = shelfModel?.weight ?: 0.0 ).also { - it.vegTypeId = item.vegTypeList?.getOrNull(item.typeSelectedIndex)?.vegTypeId + it.vegTypeId = vegType?.vegTypeId }, onLoading = { showProgress() }, onSuccess = onSuccess@{ inboundNo -> @@ -231,6 +237,8 @@ class ShelfV3Activity : BaseActivity() { // } val resultModel = item.toSlotModel(model).also { // it.inboundNo = inboundNo + it.vegTypeId = vegType?.vegTypeId + it.vegTypeName = vegType?.vegTypeName } val result = Intent().apply { putExtra(SHELF_MODEL, resultModel) diff --git a/app/src/main/java/com/sw/scalefusion/shelf/adapter/ShelfV3Adapter.kt b/app/src/main/java/com/sw/scalefusion/shelf/adapter/ShelfV3Adapter.kt index c1618e1..493b1a0 100644 --- a/app/src/main/java/com/sw/scalefusion/shelf/adapter/ShelfV3Adapter.kt +++ b/app/src/main/java/com/sw/scalefusion/shelf/adapter/ShelfV3Adapter.kt @@ -65,6 +65,7 @@ class ShelfV3Adapter(list: MutableList) : setTextColor(getColor(R.color.food_weight_blue)) text = "-" } + binding.tvFoodType.text = "" return } @@ -78,6 +79,8 @@ class ShelfV3Adapter(list: MutableList) : setTextColor(getColor(R.color.black999)) text = item.storeTime } + binding.tvFoodType.text = item.vegTypeName + binding.tvFoodType.setTextColor(getColor(R.color.black666)) } private fun getColor(@ColorRes id: Int) = ContextCompat.getColor(context, id) diff --git a/app/src/main/java/com/sw/scalefusion/shelf/model/SlotModel.kt b/app/src/main/java/com/sw/scalefusion/shelf/model/SlotModel.kt index 48f36a3..aeb403c 100644 --- a/app/src/main/java/com/sw/scalefusion/shelf/model/SlotModel.kt +++ b/app/src/main/java/com/sw/scalefusion/shelf/model/SlotModel.kt @@ -15,7 +15,8 @@ data class SlotModel( val materId: Long? = null, val materName: String? = null, val traceCode: String? = null, - val vegTypeId: String? = null, + var vegTypeId: Long? = null, + var vegTypeName: String? = null, //weight单位千克 var weight: Double? = 0.0, var storeTime: String? = null, diff --git a/app/src/main/res/drawable/bg_pressed.xml b/app/src/main/res/drawable/bg_pressed.xml new file mode 100644 index 0000000..ef0053e --- /dev/null +++ b/app/src/main/res/drawable/bg_pressed.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_shelf_v3.xml b/app/src/main/res/layout/activity_shelf_v3.xml index b604eb1..00a8880 100644 --- a/app/src/main/res/layout/activity_shelf_v3.xml +++ b/app/src/main/res/layout/activity_shelf_v3.xml @@ -75,7 +75,7 @@ tools:text="金针菇" /> @@ -30,7 +30,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginHorizontal="30dp" - android:layout_marginVertical="40dp" + android:layout_marginVertical="50dp" app:selectionRequired="false" app:singleSelection="true" /> @@ -52,7 +52,7 @@ android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" - android:background="@color/white" + android:background="@drawable/bg_pressed" android:text="取消" android:textColor="@android:color/darker_gray" android:textSize="24sp" /> @@ -67,7 +67,7 @@ android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" - android:background="@color/white" + android:background="@drawable/bg_pressed" android:text="确定" android:textColor="@color/bg_card_blue" android:textSize="24sp" /> diff --git a/app/src/main/res/layout/list_item_shelf_v3.xml b/app/src/main/res/layout/list_item_shelf_v3.xml index eb5b251..2c6cbc0 100644 --- a/app/src/main/res/layout/list_item_shelf_v3.xml +++ b/app/src/main/res/layout/list_item_shelf_v3.xml @@ -3,8 +3,8 @@ xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/layoutCard" - android:layout_width="0dp" - android:layout_height="0dp" + android:layout_width="wrap_content" + android:layout_height="wrap_content" android:layout_margin="12dp" app:cardBackgroundColor="@color/bg_card_blue" app:cardCornerRadius="12dp" @@ -38,15 +38,28 @@ android:layout_height="wrap_content" android:ellipsize="end" android:maxLines="1" + android:includeFontPadding="false" android:textColor="@color/white" android:textSize="30sp" android:textStyle="bold" tools:text="空" /> + + + android:layout_weight="0.8" /> + android:layout_weight="0.9" /> #C8C8FF #FF6400 #999999 + #666666 #F6F6F6 #E6EBF0 \ No newline at end of file