Bladeren bron

[feat]键盘插件,完善键盘选择页UI

hezihao 8 maanden geleden
bovenliggende
commit
8f1ec92799

+ 24 - 17
plugins/keyboard_android/android/src/main/kotlin/com/atmob/keyboard_android/component/KeyboardSelectComponent.kt

@@ -27,6 +27,7 @@ class KeyboardSelectComponent @JvmOverloads constructor(
 ) : BaseUIComponent(context, attrs, defStyleAttr) {
     private lateinit var vBackBtn: View
     private lateinit var vList: RecyclerView
+    private lateinit var vSaveBtn: View
 
     private lateinit var mListItems: Items
     private lateinit var mListAdapter: MultiTypeAdapter
@@ -38,6 +39,7 @@ class KeyboardSelectComponent @JvmOverloads constructor(
     override fun findView(view: View) {
         vBackBtn = view.findViewById(R.id.back_btn)
         vList = view.findViewById(R.id.list)
+        vSaveBtn = view.findViewById(R.id.save_btn)
     }
 
     @SuppressLint("NotifyDataSetChanged")
@@ -45,25 +47,30 @@ class KeyboardSelectComponent @JvmOverloads constructor(
         vBackBtn.click {
             // 关闭选择页
         }
-        mListItems = Items()
-        mListAdapter = MultiTypeAdapter(mListItems).apply {
-            // 空占位条目
-            register(EmptyPlaceholderModel::class.java, EmptyPlaceholderViewBinder())
-            // 键盘条目
-            register(KeyboardSelectModel::class.java, KeyboardSelectViewBinder { item ->
-                // 先全部取消选中,再选中当前设置的键盘
-                mListItems.forEachIndexed { index, item ->
-                    if (item is KeyboardSelectModel) {
-                        item.isSelected = false
-                    }
-                }
-                val targetPosition = mListItems.indexOf(item)
-                val targetItem = mListItems[targetPosition] as KeyboardSelectModel
-                targetItem.isSelected = true
-                notifyDataSetChanged()
-            })
+        vSaveBtn.click {
+            // 保存设置
         }
+
+        // 配置列表
         vList.apply {
+            mListItems = Items()
+            mListAdapter = MultiTypeAdapter(mListItems).apply {
+                // 空占位条目
+                register(EmptyPlaceholderModel::class.java, EmptyPlaceholderViewBinder())
+                // 键盘条目
+                register(KeyboardSelectModel::class.java, KeyboardSelectViewBinder { item ->
+                    // 先全部取消选中,再选中当前设置的键盘
+                    mListItems.forEachIndexed { index, item ->
+                        if (item is KeyboardSelectModel) {
+                            item.isSelected = false
+                        }
+                    }
+                    val targetPosition = mListItems.indexOf(item)
+                    val targetItem = mListItems[targetPosition] as KeyboardSelectModel
+                    targetItem.isSelected = true
+                    notifyDataSetChanged()
+                })
+            }
             layoutManager = GridLayoutManager(context, Constants.KEYBOARD_SELECT_SPAN_COUNT)
             adapter = mListAdapter
             addItemDecoration(

+ 18 - 0
plugins/keyboard_android/android/src/main/res/layout/component_keyboard_select.xml

@@ -24,4 +24,22 @@
         android:src="@mipmap/ic_back_btn"
         app:layout_constraintStart_toStartOf="parent"
         app:layout_constraintTop_toTopOf="parent" />
+
+    <TextView
+        android:id="@+id/save_btn"
+        android:layout_width="0dp"
+        android:layout_height="wrap_content"
+        android:layout_marginStart="70dp"
+        android:layout_marginEnd="70dp"
+        android:layout_marginBottom="16dp"
+        android:background="@drawable/bg_gradient"
+        android:gravity="center"
+        android:paddingTop="12dp"
+        android:paddingBottom="12dp"
+        android:text="@string/save"
+        android:textColor="@color/text_color_white"
+        android:textSize="14sp"
+        app:layout_constraintBottom_toBottomOf="parent"
+        app:layout_constraintEnd_toEndOf="parent"
+        app:layout_constraintStart_toStartOf="parent" />
 </androidx.constraintlayout.widget.ConstraintLayout>

+ 1 - 0
plugins/keyboard_android/android/src/main/res/values/string.xml

@@ -11,4 +11,5 @@
     <string name="mode_teach_you_say">教你说</string>
     <string name="mode_open_remarks">开场白</string>
     <string name="common_keyboard">通用键盘</string>
+    <string name="save">保存</string>
 </resources>