Jelajahi Sumber

添加一键检查弹框

Frankensteinly 8 bulan lalu
induk
melakukan
058b16c045

+ 101 - 0
app/src/main/java/com/grkj/iscs_mc/view/dialog/InspectionDialog.kt

@@ -0,0 +1,101 @@
+package com.grkj.iscs_mc.view.dialog
+
+import android.content.Context
+import android.content.res.ColorStateList
+import android.view.View
+import android.widget.RelativeLayout
+import com.grkj.iscs_mc.R
+import com.grkj.iscs_mc.databinding.DialogInspectionBinding
+import com.grkj.iscs_mc.view.base.BaseDialog
+
+/**
+ * 一键检查弹框
+ */
+class InspectionDialog(val ctx: Context) : BaseDialog<DialogInspectionBinding>(ctx) {
+
+    private var mBtnList: MutableList<RelativeLayout?> ? = null
+    private var confirmListener: ((Int) -> Unit)? = null
+    private var mSelected = -1
+
+    override val viewBinding: DialogInspectionBinding
+        get() = DialogInspectionBinding.inflate(layoutInflater)
+
+    override fun initView() {
+        mBtnList = mutableListOf(mBinding?.rlNormal, mBinding?.rlExpired, mBinding?.rlDamaged)
+
+        mBinding?.btnConfirm?.setOnClickListener {
+            dismiss()
+            confirmListener?.invoke(mSelected)
+        }
+        mBinding?.btnCancel?.setOnClickListener {
+            dismiss()
+        }
+
+        mBinding?.rlNormal?.setOnClickListener {
+            setSelect(it)
+        }
+
+        mBinding?.rlExpired?.setOnClickListener {
+            setSelect(it)
+        }
+
+        mBinding?.rlDamaged?.setOnClickListener {
+            setSelect(it)
+        }
+    }
+
+    fun showCount(count: Int) {
+        super.show()
+        mBinding?.tvTip?.text = ctx.getString(R.string.inspection_dialog_tip, count)
+    }
+
+    private fun setSelect(btn: View?) {
+        when(btn) {
+            mBinding?.rlNormal -> {
+                mBinding?.rlNormal?.backgroundTintList =
+                    ColorStateList.valueOf(ctx.getColor(R.color.common_btn_green_bg))
+                mBinding?.rlExpired?.backgroundTintList =
+                    ColorStateList.valueOf(ctx.getColor(R.color.common_btn_yellow_bg_40))
+                mBinding?.rlDamaged?.backgroundTintList =
+                    ColorStateList.valueOf(ctx.getColor(R.color.common_btn_red_bg_40))
+                mSelected = 0
+            }
+            mBinding?.rlExpired -> {
+                mBinding?.rlNormal?.backgroundTintList =
+                    ColorStateList.valueOf(ctx.getColor(R.color.common_btn_green_bg_40))
+                mBinding?.rlExpired?.backgroundTintList =
+                    ColorStateList.valueOf(ctx.getColor(R.color.common_btn_yellow_bg))
+                mBinding?.rlDamaged?.backgroundTintList =
+                    ColorStateList.valueOf(ctx.getColor(R.color.common_btn_red_bg_40))
+                mSelected = 1
+            }
+            mBinding?.rlDamaged -> {
+                mBinding?.rlNormal?.backgroundTintList =
+                    ColorStateList.valueOf(ctx.getColor(R.color.common_btn_green_bg_40))
+                mBinding?.rlExpired?.backgroundTintList =
+                    ColorStateList.valueOf(ctx.getColor(R.color.common_btn_yellow_bg_40))
+                mBinding?.rlDamaged?.backgroundTintList =
+                    ColorStateList.valueOf(ctx.getColor(R.color.common_btn_red_bg))
+                mSelected = 2
+            }
+            null -> {
+                mBinding?.rlNormal?.backgroundTintList =
+                    ColorStateList.valueOf(ctx.getColor(R.color.common_btn_green_bg_40))
+                mBinding?.rlExpired?.backgroundTintList =
+                    ColorStateList.valueOf(ctx.getColor(R.color.common_btn_yellow_bg_40))
+                mBinding?.rlDamaged?.backgroundTintList =
+                    ColorStateList.valueOf(ctx.getColor(R.color.common_btn_red_bg_40))
+                mSelected = 3
+            }
+        }
+    }
+
+    override fun dismiss() {
+        super.dismiss()
+        setSelect(null)
+    }
+
+    fun setConfirmListener(listener: (Int) -> Unit) {
+        confirmListener = listener
+    }
+}

+ 139 - 0
app/src/main/res/layout/dialog_inspection.xml

@@ -0,0 +1,139 @@
+<?xml version="1.0" encoding="utf-8"?>
+<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    android:layout_width="wrap_content"
+    android:layout_height="wrap_content"
+    app:cardCornerRadius="@dimen/common_radius">
+
+    <RelativeLayout
+        android:layout_width="@dimen/dialog_tip_width"
+        android:layout_height="@dimen/dialog_tip_height">
+
+        <TextView
+            style="@style/CommonTextView"
+            android:layout_width="match_parent"
+            android:background="@color/main_color"
+            android:gravity="left"
+            android:paddingVertical="5dp"
+            android:paddingLeft="10dp"
+            android:text="@string/action_confirm" />
+
+        <TextView
+            android:id="@+id/tv_tip"
+            style="@style/CommonTextView"
+            android:layout_centerHorizontal="true"
+            android:layout_marginTop="40dp"
+            android:text="@string/inspection_dialog_tip"
+            android:textColor="@color/black"
+            android:textStyle="bold" />
+
+        <LinearLayout
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_centerHorizontal="true"
+            android:layout_marginTop="70dp"
+            android:orientation="horizontal">
+
+            <RelativeLayout
+                android:id="@+id/rl_normal"
+                android:layout_width="70dp"
+                android:layout_height="25dp"
+                android:background="@drawable/common_btn_blue_bg"
+                android:backgroundTint="@color/common_btn_green_bg_40"
+                android:gravity="center">
+
+                <ImageView
+                    android:id="@+id/iv_ok"
+                    android:layout_width="@dimen/common_icon_size"
+                    android:layout_height="@dimen/common_icon_size"
+                    android:layout_centerVertical="true"
+                    android:src="@mipmap/ok_normal" />
+
+                <TextView
+                    style="@style/CommonTextView"
+                    android:layout_centerVertical="true"
+                    android:layout_marginLeft="@dimen/common_spacing_small"
+                    android:layout_toRightOf="@id/iv_ok"
+                    android:text="@string/normal"
+                    android:textSize="@dimen/common_text_size_small" />
+
+            </RelativeLayout>
+
+            <RelativeLayout
+                android:id="@+id/rl_expired"
+                android:layout_width="70dp"
+                android:layout_height="25dp"
+                android:layout_marginLeft="@dimen/common_spacing_small"
+                android:background="@drawable/common_btn_blue_bg"
+                android:backgroundTint="@color/common_btn_yellow_bg_40"
+                android:gravity="center">
+
+                <ImageView
+                    android:id="@+id/iv_expired"
+                    android:layout_width="@dimen/common_icon_size"
+                    android:layout_height="@dimen/common_icon_size"
+                    android:layout_centerVertical="true"
+                    android:src="@mipmap/expired_normal" />
+
+                <TextView
+                    style="@style/CommonTextView"
+                    android:layout_centerVertical="true"
+                    android:layout_marginLeft="@dimen/common_spacing_small"
+                    android:layout_toRightOf="@id/iv_expired"
+                    android:text="@string/expired"
+                    android:textSize="@dimen/common_text_size_small" />
+            </RelativeLayout>
+
+            <RelativeLayout
+                android:id="@+id/rl_damaged"
+                android:layout_width="70dp"
+                android:layout_height="25dp"
+                android:layout_marginLeft="@dimen/common_spacing_small"
+                android:background="@drawable/common_btn_blue_bg"
+                android:backgroundTint="@color/common_btn_red_bg_40"
+                android:gravity="center">
+
+                <ImageView
+                    android:id="@+id/iv_damaged"
+                    android:layout_width="@dimen/common_icon_size"
+                    android:layout_height="@dimen/common_icon_size"
+                    android:layout_centerVertical="true"
+                    android:src="@mipmap/damaged_normal" />
+
+                <TextView
+                    style="@style/CommonTextView"
+                    android:layout_centerVertical="true"
+                    android:layout_marginLeft="@dimen/common_spacing_small"
+                    android:layout_toRightOf="@id/iv_damaged"
+                    android:text="@string/damaged"
+                    android:textSize="@dimen/common_text_size_small" />
+            </RelativeLayout>
+        </LinearLayout>
+
+        <LinearLayout
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_alignParentBottom="true"
+            android:layout_centerHorizontal="true"
+            android:layout_marginBottom="@dimen/common_spacing"
+            android:orientation="horizontal">
+
+            <TextView
+                android:id="@+id/btn_confirm"
+                style="@style/CommonBtnBlue"
+                android:layout_width="80dp"
+                android:layout_height="25dp"
+                android:backgroundTint="#E600AE00"
+                android:text="@string/confirm" />
+
+            <TextView
+                android:id="@+id/btn_cancel"
+                style="@style/CommonBtnBlue"
+                android:layout_width="80dp"
+                android:layout_height="25dp"
+                android:layout_marginLeft="@dimen/common_spacing"
+                android:backgroundTint="#99FF0000"
+                android:text="@string/cancel" />
+        </LinearLayout>
+    </RelativeLayout>
+</androidx.cardview.widget.CardView>

+ 3 - 0
app/src/main/res/values/colors.xml

@@ -27,8 +27,11 @@
     <color name="dialog_card_login_bg">#990E57EA</color>
     <color name="home_menu_bg">#4D2B7AE9</color>
     <color name="common_btn_red_bg">#FF0000</color>
+    <color name="common_btn_red_bg_40">#66FF0000</color>
     <color name="common_btn_green_bg">#047b0f</color>
+    <color name="common_btn_green_bg_40">#66047b0f</color>
     <color name="common_btn_yellow_bg">#e8900d</color>
+    <color name="common_btn_yellow_bg_40">#66e8900d</color>
     <color name="lock_status_unlocked">#99008000</color>
     <color name="lock_status_locked">#CCFF0000</color>
     <color name="point_text_bg">#70b26f</color>

+ 2 - 0
app/src/main/res/values/strings.xml

@@ -44,6 +44,7 @@
     <string name="auto_replace">自动更换</string>
     <string name="manual_replace">手动更换</string>
 
+    <string name="normal">正常</string>
     <string name="expired">过期</string>
     <string name="damaged">损坏</string>
 
@@ -69,4 +70,5 @@
     <string name="rfid">RFID</string>
     <string name="method">措施</string>
     <string name="inspection_standard">检查标准</string>
+    <string name="inspection_dialog_tip">将待检查的%d件物资,全部标注为:</string>
 </resources>