class PageButtonWithIconVertical
@JvmOverloads constructor(context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0)
: LinearLayout(context, attrs, defStyleAttr) {
private val icon by bindView<ImageButton>(R.id.view_page_button_vertical_icon)
private val text by bindView<TextView>(R.id.view_page_button_vertical_text)
init {
View.inflate(context, R.layout.view_page_button_with_icon_vertical, this)
orientation = VERTICAL
val typedArray = context.obtainStyledAttributes(attrs, R.styleable.PageButtonWithIconVertical)
val iconResId = typedArray.getResourceId(R.styleable.PageButtonWithIconVertical_pagerIcon, -1)
icon.setImageResource(iconResId)
text.text = typedArray.getString(R.styleable.PageButtonWithIconVertical_pagerTitle)
typedArray.recycle()
}
override fun setEnabled(enabled: Boolean) {
super.setEnabled(enabled)
if (enabled) {
text.setTypeface(null, Typeface.BOLD);
text.setTextColor(ContextCompat.getColor(context, R.color.dark_blue))
icon.background.setTint(ContextCompat.getColor(context, R.color.dark_blue))
icon.imageTintList = ColorStateList.valueOf(ContextCompat.getColor(context, R.color.white))
} else {
text.setTypeface(null, Typeface.NORMAL);
text.setTextColor(ContextCompat.getColor(context, R.color.white))
icon.background.setTint(ContextCompat.getColor(context, R.color.grey_medium))
icon.imageTintList = ColorStateList.valueOf(ContextCompat.getColor(context, R.color.grey_medium))
}
}
}