Forráskód Böngészése

[feat]键盘插件,优化键盘动画

hezihao 8 hónapja
szülő
commit
3d3c204c12

+ 7 - 0
plugins/keyboard_android/android/src/main/kotlin/com/atmob/keyboard_android/component/base/animator/ComponentAnimator.kt

@@ -13,6 +13,7 @@ abstract class ComponentAnimator {
      */
     fun attachUIComponent(component: IUIComponent) {
         this.mUIComponent = component
+        onAttachUIComponent(component)
     }
 
     /**
@@ -23,6 +24,12 @@ abstract class ComponentAnimator {
     }
 
     /**
+     * 子类可重写该方法,在设置组件到动画器时,就进行一些初始化操作
+     */
+    open fun onAttachUIComponent(component: IUIComponent) {
+    }
+
+    /**
      * 显示组件
      */
     abstract fun show(onStart: (() -> Unit)? = null, onFinish: (() -> Unit)? = null)

+ 10 - 0
plugins/keyboard_android/android/src/main/kotlin/com/atmob/keyboard_android/component/base/animator/impl/TransitionAnimator.kt

@@ -5,6 +5,7 @@ import android.animation.AnimatorListenerAdapter
 import android.animation.ValueAnimator
 import android.view.View
 import android.view.animation.AccelerateInterpolator
+import com.atmob.keyboard_android.component.base.IUIComponent
 import com.atmob.keyboard_android.component.base.animator.ComponentAnimator
 import com.atmob.keyboard_android.ext.measureView
 
@@ -25,6 +26,15 @@ class TransitionAnimator : ComponentAnimator() {
      */
     private var mComponentSize: Pair<Int, Int>? = null
 
+    override fun onAttachUIComponent(component: IUIComponent) {
+        super.onAttachUIComponent(component)
+        component.asView().let { rootView ->
+            rootView.post {
+                ensureInitComponentSize(rootView)
+            }
+        }
+    }
+
     override fun show(onStart: (() -> Unit)?, onFinish: (() -> Unit)?) {
         if (isShow) {
             return