package com.bomostory.sceneeditmodule.utils

import android.view.View
import android.view.animation.AccelerateInterpolator
import android.view.animation.Animation
import android.view.animation.TranslateAnimation

object AnimationUtils {

    fun expand(view: View, duration: Long, animationListener: Animation.AnimationListener) {
        val translateAnimation = TranslateAnimation(0f, 0f, (-view.height).toFloat(), 0f)

        translateAnimation.setAnimationListener(animationListener)
        translateAnimation.duration = duration
        translateAnimation.interpolator = AccelerateInterpolator(0.5f)
        view.startAnimation(translateAnimation)
    }

    fun collapse(view: View, duration: Long, animationListener: Animation.AnimationListener) {
        val translateAnimation = TranslateAnimation(0f, 0f, 0f, (-view.height).toFloat())

        translateAnimation.setAnimationListener(animationListener)
        translateAnimation.duration = duration
        translateAnimation.interpolator = AccelerateInterpolator(0.5f)
        view.startAnimation(translateAnimation)
    }
}