Browse Source

临时提交

Frankensteinly 1 year ago
parent
commit
f387d58c9b

+ 3 - 0
app/src/main/AndroidManifest.xml

@@ -21,6 +21,9 @@
         android:supportsRtl="true"
         android:theme="@style/Theme.ISCS"
         tools:targetApi="31">
+        <activity
+            android:name=".activity.SopActivity"
+            android:exported="false" />
         <activity
             android:name=".activity.WelcomeActivity"
             android:exported="false" />

+ 4 - 0
app/src/main/java/com/grkj/iscs/activity/MainActivity.kt

@@ -33,5 +33,9 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
         mBinding?.home?.setOnClickListener {
             startActivity(Intent(this, WelcomeActivity::class.java))
         }
+
+        mBinding?.sop?.setOnClickListener {
+            startActivity(Intent(this, SopActivity::class.java))
+        }
     }
 }

+ 20 - 0
app/src/main/java/com/grkj/iscs/activity/SopActivity.kt

@@ -0,0 +1,20 @@
+package com.grkj.iscs.activity
+
+import com.grkj.iscs.base.BaseMvpActivity
+import com.grkj.iscs.databinding.ActivitySopBinding
+import com.grkj.iscs.iview.ISopView
+import com.grkj.iscs.presenter.SopPresenter
+
+class SopActivity : BaseMvpActivity<ISopView, SopPresenter, ActivitySopBinding>() {
+
+    override val viewBinding: ActivitySopBinding
+        get() = ActivitySopBinding.inflate(layoutInflater)
+
+    override fun initView() {
+
+    }
+
+    override fun initPresenter(): SopPresenter {
+        return SopPresenter()
+    }
+}

+ 5 - 0
app/src/main/java/com/grkj/iscs/iview/ISopView.kt

@@ -0,0 +1,5 @@
+package com.grkj.iscs.iview
+
+import com.grkj.iscs.base.IView
+
+interface ISopView : IView {}

+ 6 - 0
app/src/main/java/com/grkj/iscs/presenter/SopPresenter.kt

@@ -0,0 +1,6 @@
+package com.grkj.iscs.presenter
+
+import com.grkj.iscs.base.BasePresenter
+import com.grkj.iscs.iview.ISopView
+
+class SopPresenter : BasePresenter<ISopView>() {}

+ 60 - 0
app/src/main/java/com/grkj/iscs/widget/SelectableInput.kt

@@ -0,0 +1,60 @@
+package com.grkj.iscs.widget
+
+import android.content.Context
+import android.util.AttributeSet
+import android.view.View
+import android.view.inputmethod.InputMethodManager
+import android.widget.LinearLayout
+import com.grkj.iscs.R
+import com.grkj.iscs.databinding.LayoutSelectableInputBinding
+
+class SelectableInput(ctx: Context, attrs: AttributeSet) : LinearLayout(ctx, attrs) {
+
+    companion object {
+        const val MODE_INPUT = 0
+        const val MODE_SELECT = 1
+    }
+
+    private var mBinding: LayoutSelectableInputBinding
+
+    init {
+        val root = View.inflate(ctx, R.layout.layout_selectable_input, this)
+        mBinding = LayoutSelectableInputBinding.bind(root)
+
+        val attrSet = ctx.obtainStyledAttributes(attrs, R.styleable.SelectableInput)
+
+        val mode = attrSet.getInt(R.styleable.SelectableInput_mode, 0)
+        setMode(mode)
+
+        val isRequired = attrSet.getBoolean(R.styleable.SelectableInput_required, false)
+        mBinding.tvPrefix.visibility = if (isRequired) View.VISIBLE else View.GONE
+
+        mBinding.tvName.text = attrSet.getString(R.styleable.SelectableInput_name)
+        mBinding.et.hint = attrSet.getString(R.styleable.SelectableInput_edittext_hint)
+
+        attrSet.recycle()
+    }
+
+    private fun setMode(mode: Int) {
+        if (mode == MODE_SELECT) {
+            mBinding.et.isEnabled = false
+            mBinding.spinner.visibility = View.VISIBLE
+            mBinding.et.visibility = View.GONE
+//            btnDropdown.visibility = View.VISIBLE
+//            if (!options.isNullOrEmpty()) {
+//                btnDropdown.setOnClickListener(onBtnDropdownClickListener)
+//            }
+        } else {
+            mBinding.et.isEnabled = true
+            mBinding.spinner.visibility = View.GONE
+            mBinding.et.visibility = View.VISIBLE
+//            btnDropdown.visibility = View.GONE
+//            btnDropdown.setOnClickListener(null)
+//            clContainer.setOnClickListener {
+//                editText.requestFocus()
+//                val imm = context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
+//                imm.showSoftInput(editText, 0)
+//            }
+        }
+    }
+}

+ 18 - 0
app/src/main/res/drawable/selectable_input_spinner_bg.xml

@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="utf-8"?>
+<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
+    <item>
+        <shape android:shape="rectangle">
+            <solid android:color="@color/white" />
+            <corners android:radius="@dimen/selectable_input_radius" />
+            <stroke
+                android:width="@dimen/selectable_input_stroke"
+                android:color="@color/main_color" />
+        </shape>
+    </item>
+    <item
+        android:width="@dimen/selectable_input_spinner_arrow_size"
+        android:height="@dimen/selectable_input_spinner_arrow_size"
+        android:drawable="@mipmap/ic_dropdown"
+        android:gravity="end|center_vertical"
+        android:right="@dimen/selectable_input_spinner_arrow_margin" />
+</layer-list>

+ 10 - 0
app/src/main/res/layout/activity_main.xml

@@ -68,4 +68,14 @@
         android:text="HomePage"
         android:textSize="10sp"
         android:layout_margin="5dp"/>
+
+    <Button
+        android:id="@+id/sop"
+        android:layout_width="80dp"
+        android:layout_height="50dp"
+        android:minWidth="0dp"
+        android:minHeight="0dp"
+        android:text="SOP"
+        android:textSize="10sp"
+        android:layout_margin="5dp"/>
 </LinearLayout>

+ 16 - 0
app/src/main/res/layout/activity_sop.xml

@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    tools:context=".activity.SopActivity">
+
+    <com.grkj.iscs.widget.SelectableInput
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_marginRight="100dp"
+        app:mode="select"
+        app:required="true"
+        app:name="test" />
+</RelativeLayout>

+ 37 - 0
app/src/main/res/layout/layout_selectable_input.xml

@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    android:gravity="top"
+    android:orientation="horizontal">
+
+    <TextView
+        android:id="@+id/tv_prefix"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:text="@string/selectable_input_prefix"
+        android:textColor="@color/selectable_input_prefix" />
+
+    <TextView
+        android:id="@+id/tv_name"
+        android:layout_width="@dimen/selectable_input_width"
+        android:layout_height="wrap_content"
+        android:textColor="@color/main_color" />
+
+    <EditText
+        android:id="@+id/et"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:textColor="@color/black"
+        android:visibility="gone" />
+
+    <Spinner
+        android:id="@+id/spinner"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_gravity="center_vertical"
+        android:background="@drawable/selectable_input_spinner_bg"
+        android:minHeight="@dimen/selectable_input_min_height"
+        android:spinnerMode="dropdown"
+        android:visibility="gone" />
+</LinearLayout>

BIN
app/src/main/res/mipmap/ic_dropdown.png


BIN
app/src/main/res/mipmap/icon_back.png


+ 11 - 0
app/src/main/res/values/attrs.xml

@@ -3,4 +3,15 @@
     <declare-styleable name="TitleBar">
         <attr name="title" format="string" />
     </declare-styleable>
+
+    <declare-styleable name="SelectableInput">
+        <attr name="mode">
+            <flag name="input" value="0x00000000" />
+            <flag name="select" value="0x00000001" />
+        </attr>
+        <attr name="required" default="false" format="boolean" />
+        <attr name="name" format="string" />
+        <attr name="spinner_hint" format="string" />
+        <attr name="edittext_hint" format="string" />
+    </declare-styleable>
 </resources>

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

@@ -5,4 +5,5 @@
     <color name="aquamarine">#7FFFD4</color>
 
     <color name="main_color">#644bd8</color>
+    <color name="selectable_input_prefix">#bd3124</color>
 </resources>

+ 7 - 0
app/src/main/res/values/dimens.xml

@@ -10,4 +10,11 @@
     
     <dimen name="home_navi_height">600px</dimen>
     <dimen name="home_navi_width">400px</dimen>
+
+    <dimen name="selectable_input_width">150px</dimen>
+    <dimen name="selectable_input_radius">6px</dimen>
+    <dimen name="selectable_input_stroke">2px</dimen>
+    <dimen name="selectable_input_min_height">70px</dimen>
+    <dimen name="selectable_input_spinner_arrow_size">30px</dimen>
+    <dimen name="selectable_input_spinner_arrow_margin">10px</dimen>
 </resources>

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

@@ -13,4 +13,6 @@
     <string name="swipe_card_on_machine">请在机器上刷卡</string>
     <string name="auth_success">认证通过!</string>
     <string name="auth_fail">认证失败,请重试!</string>
+
+    <string name="selectable_input_prefix">*</string>
 </resources>