package com.remax.visualnovel.widget.ui.chips

import android.content.Context
import android.util.AttributeSet
import com.remax.visualnovel.R
import com.remax.visualnovel.widget.ui.IconFontTextView
import com.remax.visualnovel.widget.uitoken.changeBackground
import com.remax.visualnovel.widget.uitoken.changeTextColor
import com.remax.visualnovel.widget.uitoken.changeTextFont
import com.scwang.smart.refresh.layout.util.SmartUtil

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


    init {
        //初始化固定token
        customViewToken.run {
            textUITextToken = context.getString(R.string.txt_label_m)
            textUIDisabledColorToken = context.getString(R.string.color_txt_disabled)
            backgroundUIPressedColorToken = context.getString(R.string.color_surface_element_press)
            radiusToken = context.getString(R.string.radius_round)
        }
        changeTextFont(customViewToken)
        setInActive()
        setPaddingRelative(SmartUtil.dp2px(16f), SmartUtil.dp2px(6f), SmartUtil.dp2px(8f), SmartUtil.dp2px(6f))
    }

    /**
     * 筛选状态
     */
    fun setActive() {
        customViewToken.run {
            //normal
            textUIColorToken = context.getString(R.string.color_primary_variant_normal)
            //press
            textUIPressedColorToken = context.getString(R.string.color_primary_variant_normal)
            setIconFontDrawable(endIconFont = context.getString(R.string.icon_arrow_down_fill), iconPadding = 4, iconSize = 12)
            changeTextColor(customViewToken)
            changeBackground(customViewToken)
        }
    }

    /**
     * 无筛选状态
     */
    fun setInActive() {
        customViewToken.run {
            //normal
            textUIColorToken = context.getString(R.string.color_txt_primary_normal)
            //press
            textUIPressedColorToken = context.getString(R.string.color_txt_primary_normal)
            setIconFontDrawable(endIconFont = context.getString(R.string.icon_arrow_down_fill), iconPadding = 4, iconSize = 12)
            changeTextColor(customViewToken)
            changeBackground(customViewToken)
        }
    }
}