Untitled
unknown
plain_text
3 years ago
3.4 kB
18
Indexable
package tr.com.niximera.koopsis.koopSISComponents
import android.annotation.SuppressLint
import android.content.Context
import android.util.AttributeSet
import android.view.View
import android.widget.LinearLayout
import tr.com.niximera.koopsis.R
import kotlinx.android.synthetic.main.companent_toolbar.view.*
import tr.com.niximera.koopsis.extentions.showView
class CompanentToolBar : LinearLayout {
private var mContext: Context
private var isBackButtonVisible: Boolean = false
set(value) {
field = value
toolBack.showView(field)
}
private var isRightTextVisible: Boolean = false
set(value) {
field = value
toolRightText.showView(field)
}
private var isRightImageVisible: Boolean = false
set(value) {
field = value
toolRightImage.showView(field)
}
private var rightButtonImage: Int = R.drawable.ic_baseline_person_24
set(value) {
field = value
toolRightImage.setImageResource(field)
}
private var rightButtonTextString: String = ""
set(value) {
field = value
toolRightText.text = field
}
private var titleTextString: String = ""
set(value) {
field = value
toolTitle.text = field
}
constructor(context: Context) : super(context) {
mContext = context
init(null, 0)
}
constructor(context: Context, attrs: AttributeSet) : super(context, attrs) {
mContext = context
init(attrs, 0)
}
constructor(context: Context, attrs: AttributeSet, defStyle: Int) : super(context, attrs, defStyle) {
mContext = context
init(attrs, defStyle)
}
private fun init(attrs: AttributeSet?, defStyle: Int) {
View.inflate(mContext, R.layout.companent_toolbar, this)
val typeArray = context.obtainStyledAttributes(attrs, R.styleable.kToolBar, defStyle, 0)
typeArray.run {
isBackButtonVisible = typeArray.getBoolean(R.styleable.kToolBar_isBackButtonVisible, false)
isRightTextVisible = typeArray.getBoolean(R.styleable.kToolBar_isRightTextVisible, false)
isRightImageVisible = typeArray.getBoolean(R.styleable.kToolBar_isRightImageVisible, false)
rightButtonImage = typeArray.getResourceId(R.styleable.kToolBar_rightButtonImage, R.drawable.ic_baseline_person_24)
rightButtonTextString = typeArray.getString(R.styleable.kToolBar_rightButtonTextString).toString()
titleTextString = typeArray.getString(R.styleable.kToolBar_barTittle).toString()
}
}
fun backButtonVisibility(isVisible: Boolean) {
[email protected] = isVisible
}
fun rightTextButtonVisibility(isVisible: Boolean) {
[email protected] = isVisible
}
fun rightImageButtonVisibility(isVisible: Boolean) {
[email protected] = isVisible
}
fun rightTextButtonText(text: String) {
[email protected] = text
}
fun setTitleText(text: String) {
[email protected] = text
}
fun rightImageButtonImage(drawable: Int) {
[email protected] = drawable
}
}Editor is loading...