package com.atmob.keyboard_android.component.child.impl

import android.content.Context
import android.util.AttributeSet
import android.view.View
import android.widget.TextView
import com.atmob.keyboard_android.R
import com.atmob.keyboard_android.component.base.BaseUIComponent
import com.atmob.keyboard_android.component.child.IPermissionTipComponent
import com.atmob.keyboard_android.ext.click

/**
 * 权限提示条
 */
class PermissionTipComponent @JvmOverloads constructor(
    context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
) : BaseUIComponent<IPermissionTipComponent>(context, attrs, defStyleAttr),
    IPermissionTipComponent {
    private lateinit var vTip: TextView
    private lateinit var vCloseBtn: View

    override fun onInflateViewId(): Int {
        return R.layout.component_permission_tip
    }

    override fun findView(view: View) {
        vTip = view.findViewById(R.id.tip)
        vCloseBtn = view.findViewById(R.id.close_btn)
    }

    override fun bindView(view: View) {
        // 提示文案
        vTip.text = context.resources.getString(R.string.paste_permission_tip)
        vCloseBtn.click {
            // 关闭提示条
            hide()
        }
    }

    override fun getComponentInterfaceClazz(): Class<IPermissionTipComponent> {
        return IPermissionTipComponent::class.java
    }
}