package com.atmob.keyboard_android.component.base.animator

import com.atmob.keyboard_android.component.base.IUIComponent

/**
 * 组件动画执行器抽象类，具体动画实现，交给子类去实现
 */
abstract class ComponentAnimator {
    protected var mUIComponent: IUIComponent? = null

    /**
     * 设置组件实例
     */
    fun attachUIComponent(component: IUIComponent) {
        this.mUIComponent = component
        onAttachUIComponent(component)
    }

    /**
     * 获取组件实例
     */
    fun getUIComponent(): IUIComponent? {
        return mUIComponent
    }

    /**
     * 子类可重写该方法，在设置组件到动画器时，就进行一些初始化操作
     */
    open fun onAttachUIComponent(component: IUIComponent) {
    }

    /**
     * 显示组件
     */
    abstract fun show(onStart: (() -> Unit)? = null, onFinish: (() -> Unit)? = null)

    /**
     * 隐藏组件
     */
    abstract fun hide(onStart: (() -> Unit)? = null, onFinish: (() -> Unit)? = null)
}