Selaa lähdekoodia

[feat]键盘插件,实现键盘顶部的工具栏布局

hezihao 8 kuukautta sitten
vanhempi
commit
2488812518
20 muutettua tiedostoa jossa 261 lisäystä ja 1 poistoa
  1. 2 0
      plugins/keyboard_android/android/build.gradle
  2. 24 0
      plugins/keyboard_android/android/src/main/kotlin/com/atmob/keyboard_android/component/KeyBoardContainerComponent.kt
  3. 24 0
      plugins/keyboard_android/android/src/main/kotlin/com/atmob/keyboard_android/component/QuickSwitchComponent.kt
  4. 24 0
      plugins/keyboard_android/android/src/main/kotlin/com/atmob/keyboard_android/component/ToolBarComponent.kt
  5. 7 0
      plugins/keyboard_android/android/src/main/res/drawable/bg_quick_switch_white.xml
  6. 5 0
      plugins/keyboard_android/android/src/main/res/drawable/ic_quick_switch_checked.xml
  7. 5 0
      plugins/keyboard_android/android/src/main/res/drawable/ic_quick_switch_normal.xml
  8. 16 0
      plugins/keyboard_android/android/src/main/res/layout/component_key_board_container.xml
  9. 77 0
      plugins/keyboard_android/android/src/main/res/layout/component_tool_bar.xml
  10. 10 1
      plugins/keyboard_android/android/src/main/res/layout/keyboard_layout.xml
  11. 62 0
      plugins/keyboard_android/android/src/main/res/layout/quick_switch_component.xml
  12. BIN
      plugins/keyboard_android/android/src/main/res/mipmap-xxxhdpi/bg_love.png
  13. BIN
      plugins/keyboard_android/android/src/main/res/mipmap-xxxhdpi/ic_arrow_btn.png
  14. BIN
      plugins/keyboard_android/android/src/main/res/mipmap-xxxhdpi/ic_keyboard.png
  15. BIN
      plugins/keyboard_android/android/src/main/res/mipmap-xxxhdpi/ic_keyboard_icon.png
  16. BIN
      plugins/keyboard_android/android/src/main/res/mipmap-xxxhdpi/ic_quick_switch_checked.png
  17. BIN
      plugins/keyboard_android/android/src/main/res/mipmap-xxxhdpi/ic_quick_switch_normal.png
  18. BIN
      plugins/keyboard_android/android/src/main/res/mipmap-xxxhdpi/ic_switch.png
  19. 2 0
      plugins/keyboard_android/android/src/main/res/values/colors.xml
  20. 3 0
      plugins/keyboard_android/android/src/main/res/values/string.xml

+ 2 - 0
plugins/keyboard_android/android/build.gradle

@@ -71,6 +71,8 @@ android {
         implementation "androidx.constraintlayout:constraintlayout:2.1.4"
         // Gson
         implementation "com.google.code.gson:gson:2.10"
+        // CircleImageView
+        implementation 'de.hdodenhof:circleimageview:3.1.0'
     }
 
     testOptions {

+ 24 - 0
plugins/keyboard_android/android/src/main/kotlin/com/atmob/keyboard_android/component/KeyBoardContainerComponent.kt

@@ -0,0 +1,24 @@
+package com.atmob.keyboard_android.component
+
+import android.content.Context
+import android.util.AttributeSet
+import android.view.View
+import com.atmob.keyboard_android.R
+import com.atmob.keyboard_android.component.base.BaseUIComponent
+
+/**
+ * 键盘容器组件,包含多个键盘,例如拼音键盘和AI键盘,顶部是工具栏组件
+ */
+class KeyBoardContainerComponent @JvmOverloads constructor(
+    context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
+) : BaseUIComponent(context, attrs, defStyleAttr) {
+    override fun onInflateViewId(): Int {
+        return R.layout.component_key_board_container
+    }
+
+    override fun findView(view: View) {
+    }
+
+    override fun bindView(view: View) {
+    }
+}

+ 24 - 0
plugins/keyboard_android/android/src/main/kotlin/com/atmob/keyboard_android/component/QuickSwitchComponent.kt

@@ -0,0 +1,24 @@
+package com.atmob.keyboard_android.component
+
+import android.content.Context
+import android.util.AttributeSet
+import android.view.View
+import com.atmob.keyboard_android.R
+import com.atmob.keyboard_android.component.base.BaseUIComponent
+
+/**
+ * 快速切换组件
+ */
+class QuickSwitchComponent @JvmOverloads constructor(
+    context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
+) : BaseUIComponent(context, attrs, defStyleAttr) {
+    override fun onInflateViewId(): Int {
+        return R.layout.quick_switch_component
+    }
+
+    override fun findView(view: View) {
+    }
+
+    override fun bindView(view: View) {
+    }
+}

+ 24 - 0
plugins/keyboard_android/android/src/main/kotlin/com/atmob/keyboard_android/component/ToolBarComponent.kt

@@ -0,0 +1,24 @@
+package com.atmob.keyboard_android.component
+
+import android.content.Context
+import android.util.AttributeSet
+import android.view.View
+import com.atmob.keyboard_android.R
+import com.atmob.keyboard_android.component.base.BaseUIComponent
+
+/**
+ * 工具类组件
+ */
+class ToolBarComponent @JvmOverloads constructor(
+    context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
+) : BaseUIComponent(context, attrs, defStyleAttr) {
+    override fun onInflateViewId(): Int {
+        return R.layout.component_tool_bar
+    }
+
+    override fun findView(view: View) {
+    }
+
+    override fun bindView(view: View) {
+    }
+}

+ 7 - 0
plugins/keyboard_android/android/src/main/res/drawable/bg_quick_switch_white.xml

@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8"?>
+<shape xmlns:android="http://schemas.android.com/apk/res/android"
+    android:shape="rectangle">
+
+    <solid android:color="@color/text_color_white" />
+    <corners android:radius="17dp" />
+</shape>

+ 5 - 0
plugins/keyboard_android/android/src/main/res/drawable/ic_quick_switch_checked.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<shape xmlns:android="http://schemas.android.com/apk/res/android">
+    <solid android:color="@color/bg_quick_switch_checked" />
+    <corners android:radius="16dp" />
+</shape>

+ 5 - 0
plugins/keyboard_android/android/src/main/res/drawable/ic_quick_switch_normal.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<shape xmlns:android="http://schemas.android.com/apk/res/android">
+    <solid android:color="@color/bg_quick_switch_normal" />
+    <corners android:radius="16dp" />
+</shape>

+ 16 - 0
plugins/keyboard_android/android/src/main/res/layout/component_key_board_container.xml

@@ -0,0 +1,16 @@
+<?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">
+
+    <!-- 工具栏 -->
+    <com.atmob.keyboard_android.component.ToolBarComponent
+        android:id="@+id/tool_bar"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_marginTop="16dp" />
+
+    <!-- 拼音键盘 -->
+
+    <!-- AI键盘 -->
+</LinearLayout>

+ 77 - 0
plugins/keyboard_android/android/src/main/res/layout/component_tool_bar.xml

@@ -0,0 +1,77 @@
+<?xml version="1.0" encoding="utf-8"?>
+<androidx.constraintlayout.widget.ConstraintLayout 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="wrap_content"
+    android:gravity="center_vertical"
+    android:orientation="horizontal"
+    tools:background="@android:color/background_dark"
+    tools:paddingBottom="16dp"
+    tools:paddingTop="16dp">
+
+    <de.hdodenhof.circleimageview.CircleImageView
+        android:id="@+id/icon"
+        android:layout_width="34dp"
+        android:layout_height="34dp"
+        android:layout_marginStart="13dp"
+        android:src="@mipmap/ic_keyboard_icon"
+        app:civ_border_color="@color/text_color_white"
+        app:civ_border_width="1dp"
+        app:layout_constraintBottom_toBottomOf="parent"
+        app:layout_constraintStart_toStartOf="parent"
+        app:layout_constraintTop_toTopOf="parent" />
+
+    <!-- 快速切换组件 -->
+    <com.atmob.keyboard_android.component.QuickSwitchComponent
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_marginStart="12dp"
+        app:layout_constraintBottom_toBottomOf="@+id/icon"
+        app:layout_constraintStart_toEndOf="@+id/icon"
+        app:layout_constraintTop_toTopOf="@+id/icon" />
+
+    <LinearLayout
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_gravity="end"
+        android:layout_marginEnd="10dp"
+        android:gravity="center_vertical"
+        android:orientation="horizontal"
+        app:layout_constraintBottom_toBottomOf="parent"
+        app:layout_constraintEnd_toEndOf="parent"
+        app:layout_constraintTop_toTopOf="parent">
+
+        <ImageView
+            android:layout_width="34dp"
+            android:layout_height="34dp"
+            android:src="@mipmap/ic_pinyin_btn" />
+
+        <ImageView
+            android:layout_width="34dp"
+            android:layout_height="34dp"
+            android:layout_marginStart="10dp"
+            android:layout_marginEnd="10dp"
+            android:src="@mipmap/ic_keyboard" />
+
+        <FrameLayout
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content">
+
+            <ImageView
+                android:layout_width="35dp"
+                android:layout_height="30dp"
+                android:src="@mipmap/bg_love" />
+
+            <TextView
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_gravity="center_horizontal"
+                android:layout_marginTop="7dp"
+                android:text="30%"
+                android:textColor="@color/text_color_white"
+                android:textSize="10sp"
+                android:textStyle="bold" />
+        </FrameLayout>
+    </LinearLayout>
+</androidx.constraintlayout.widget.ConstraintLayout>

+ 10 - 1
plugins/keyboard_android/android/src/main/res/layout/keyboard_layout.xml

@@ -4,23 +4,32 @@
     android:layout_height="@dimen/keyboard_height"
     android:background="@mipmap/bg_keyboard">
 
+    <!-- 登录组件 -->
     <com.atmob.keyboard_android.component.LoginComponent
         android:layout_width="match_parent"
         android:layout_height="wrap_content" />
 
+    <!-- VIP组件 -->
     <com.atmob.keyboard_android.component.VipComponent
         android:layout_width="match_parent"
         android:layout_height="wrap_content" />
 
+    <!-- 设置组件 -->
     <com.atmob.keyboard_android.component.SettingComponent
         android:layout_width="match_parent"
         android:layout_height="wrap_content" />
 
+    <!-- 键盘组件 -->
+    <com.atmob.keyboard_android.component.KeyBoardContainerComponent
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content" />
+
     <LinearLayout
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:orientation="vertical"
-        android:padding="5dp">
+        android:padding="5dp"
+        android:visibility="visible">
 
         <!-- 输入框 -->
         <EditText

+ 62 - 0
plugins/keyboard_android/android/src/main/res/layout/quick_switch_component.xml

@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="utf-8"?>
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="wrap_content"
+    android:layout_height="wrap_content"
+    tools:background="@mipmap/bg_keyboard">
+
+    <LinearLayout
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:background="@drawable/bg_quick_switch_white"
+        android:gravity="center_vertical"
+        android:orientation="horizontal">
+
+        <LinearLayout
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_marginStart="1dp"
+            android:layout_marginTop="1dp"
+            android:layout_marginBottom="1dp"
+            android:background="@mipmap/ic_quick_switch_checked"
+            android:gravity="center_vertical">
+
+            <TextView
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_gravity="center_vertical"
+                android:layout_marginStart="12dp"
+                android:text="@string/mode_teach_you_say"
+                android:textColor="@color/text_color_primary"
+                android:textSize="12sp"
+                android:textStyle="bold" />
+
+            <ImageView
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_gravity="center_vertical"
+                android:layout_marginStart="14dp"
+                android:layout_marginTop="6dp"
+                android:layout_marginEnd="5dp"
+                android:layout_marginBottom="6dp"
+                android:src="@mipmap/ic_arrow_btn" />
+        </LinearLayout>
+
+        <TextView
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_gravity="center_vertical"
+            android:layout_marginStart="9dp"
+            android:textColor="@color/text_color_primary"
+            android:textSize="12sp"
+            android:text="小蕊" />
+
+        <ImageView
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_gravity="center_vertical"
+            android:layout_marginStart="4dp"
+            android:layout_marginEnd="8dp"
+            android:src="@mipmap/ic_switch" />
+    </LinearLayout>
+</FrameLayout>

BIN
plugins/keyboard_android/android/src/main/res/mipmap-xxxhdpi/bg_love.png


BIN
plugins/keyboard_android/android/src/main/res/mipmap-xxxhdpi/ic_arrow_btn.png


BIN
plugins/keyboard_android/android/src/main/res/mipmap-xxxhdpi/ic_keyboard.png


BIN
plugins/keyboard_android/android/src/main/res/mipmap-xxxhdpi/ic_keyboard_icon.png


BIN
plugins/keyboard_android/android/src/main/res/mipmap-xxxhdpi/ic_quick_switch_checked.png


BIN
plugins/keyboard_android/android/src/main/res/mipmap-xxxhdpi/ic_quick_switch_normal.png


BIN
plugins/keyboard_android/android/src/main/res/mipmap-xxxhdpi/ic_switch.png


+ 2 - 0
plugins/keyboard_android/android/src/main/res/values/colors.xml

@@ -20,4 +20,6 @@
     <color name="text_color_auxiliary2">#F95FAC</color>
     <color name="text_color_auxiliary3">#FD5E4D</color>
     <color name="text_color_auxiliary4">#FB8A3C</color>
+    <color name="bg_quick_switch_checked">#DDCFFD</color>
+    <color name="bg_quick_switch_normal">#FFFFFF</color>
 </resources>

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

@@ -7,4 +7,7 @@
     <string name="setting_custom_person">定制人设</string>
     <string name="setting_market">人设市场</string>
     <string name="setting_unlock_vip">解锁会员</string>
+    <string name="mode_help_chat">帮聊</string>
+    <string name="mode_teach_you_say">教你说</string>
+    <string name="mode_open_remarks">开场白</string>
 </resources>