package com.zj365.mime.weight

import android.content.Context
import android.view.Gravity
import com.xty.base.dialog.BaseDialog
import com.xty.common.bracelet.YCBOrder
import com.zj365.mime.R
import com.zj365.mime.databinding.DialogGestureBinding

class GestureDialog(context: Context, var type: (status: Int, str: String) -> Unit) :


    BaseDialog(context, R.style.CustomDialog) {
    val binding by lazy { DialogGestureBinding.inflate(layoutInflater) }


    override fun setLayout() = binding.root
    override fun initView() {
        super.initView()
        window!!.setGravity(Gravity.BOTTOM)
        window!!.setWindowAnimations(R.style.dialog_bottom)

        setCancelable(true)
        setCanceledOnTouchOutside(true)

        //手势选择
        binding.mLeft.setOnClickListener {
            it.isSelected = true
            binding.mRight.isSelected = false
            type.invoke(YCBOrder.LEFT_HAND, "左手")
            dismiss()
        }
        binding.mRight.setOnClickListener {
            it.isSelected = true
            binding.mLeft.isSelected = false
            type.invoke(YCBOrder.RIGHT_HAND, "右手")
            dismiss()
        }

    }

    fun showHand(showLoc: Int) {
        show()
        when (showLoc) {//默认为左手 0：左手 1：右手
            1 -> {
                binding.mRight.isSelected = true
                binding.mLeft.isSelected = false
            }
            else -> {
                binding.mLeft.isSelected = true
                binding.mRight.isSelected = false
            }
        }

    }


}