package com.bomostory.sceneeditmodule.view

import android.content.Context
import android.support.constraint.ConstraintLayout
import android.util.AttributeSet
import android.view.LayoutInflater
import android.view.View
import android.widget.CompoundButton
import com.example.tfat.myapplication.R
import kotlinx.android.synthetic.main.movie_edit_btn_panel_view.view.*

class MovieEditBtnPanelView : ConstraintLayout {

    var isMusicEmpty = true
        set(value) {
            if (value) {
                loopSwitch.visibility = View.INVISIBLE
                loopText.visibility = View.INVISIBLE
                delete.visibility = View.INVISIBLE
                edit.visibility = View.INVISIBLE
            } else {
                loopSwitch.visibility = View.VISIBLE
                loopText.visibility = View.VISIBLE
                delete.visibility = View.VISIBLE
                edit.visibility = View.VISIBLE
            }
        }

    var isEnable = true
        set(value) {
            loopSwitch.isEnabled = value
            loopText.isEnabled = value
            delete.isEnabled = value
            edit.isEnabled = value
            addMusic.isEnabled = value
            save.isEnabled = value
        }

    var onAddMusicClickListener: OnClickListener? = null
        set(value) {
            addMusic.setOnClickListener(value)
        }

    var onEditMusicClickListener: OnClickListener? = null
        set(value) {
            edit.setOnClickListener(value)
        }

    var onDeleteMusicClickListener: OnClickListener? = null
        set(value) {
            delete.setOnClickListener(value)
        }

    var onSaveMovieClickListener: OnClickListener? = null
        set(value) {
            save.setOnClickListener(value)
        }

    var onLoopSwitchChangedListener: CompoundButton.OnCheckedChangeListener? = null
        set(value) {
            loopSwitch.setOnCheckedChangeListener(value)
        }

    constructor(context: Context) : super(context) {
        initView()
    }

    constructor(context: Context, attrs: AttributeSet) : super(context, attrs) {
        initView()
    }

    constructor(context: Context, attrs: AttributeSet, defStyle: Int) : super(context, attrs, defStyle) {
        initView()
    }

    private fun initView() {
        LayoutInflater.from(context).inflate(R.layout.movie_edit_btn_panel_view, this)
    }
}