package com.remax.visualnovel.ui.chat.ui

import android.content.Context
import android.util.AttributeSet
import android.view.LayoutInflater
import android.widget.LinearLayout
import com.remax.visualnovel.databinding.LayoutMaxNumViewBinding

class MaxNumView @JvmOverloads constructor(
    context: Context,
    attrs: AttributeSet? = null,
    defStyleAttr: Int = 0
) : LinearLayout(context, attrs, defStyleAttr) {

    companion object {
        private var GAP = 100
    }

    private var mBinding: LayoutMaxNumViewBinding

    private var mCurNum = 2500

    init {
        mBinding = LayoutMaxNumViewBinding.inflate(LayoutInflater.from(context), this, true)
        setupClickListeners()
    }




    private fun setupClickListeners() {
        with (mBinding) {
            ivLeftIcon.setOnClickListener {
                mCurNum -= GAP
                tvCenter.text = mCurNum.toString()
            }

            ivRightIcon.setOnClickListener {
                mCurNum += GAP
                tvCenter.text = mCurNum.toString()
            }

        }
    }



    /*override fun onTouchEvent(event: MotionEvent): Boolean {
        when (event.action) {
            MotionEvent.ACTION_DOWN -> {
                val x = event.x
                val y = event.y

                if (mBinding..contains(x, y)) {
                    isLeftPressed = true
                    startLongPress(false) // 减小
                    return true
                } else if (rightArrowRect.contains(x, y)) {
                    isRightPressed = true
                    startLongPress(true) // 增大
                    return true
                }
            }

            MotionEvent.ACTION_UP, MotionEvent.ACTION_CANCEL -> {
                stopLongPress()
            }

            MotionEvent.ACTION_MOVE -> {
                val x = event.x
                val y = event.y

                // 如果手指移出按钮区域，停止长按
                if (!leftArrowRect.contains(x, y) && isLeftPressed) {
                    stopLongPress()
                }
                if (!rightArrowRect.contains(x, y) && isRightPressed) {
                    stopLongPress()
                }
            }
        }

        invalidate()
        return super.onTouchEvent(event)
    }*/


}