Skip to content
Snippets Groups Projects
Commit 48facd92 authored by Taras's avatar Taras
Browse files

Create view for settings item

parent d53960c3
No related branches found
No related tags found
No related merge requests found
package org.futo.circles.view
import android.content.Context
import android.util.AttributeSet
import android.view.LayoutInflater
import android.widget.LinearLayout
import org.futo.circles.R
import org.futo.circles.core.extensions.getAttributes
import org.futo.circles.databinding.ViewSettingsMenuItemBinding
class SettingsMenuItemView(
context: Context,
attrs: AttributeSet? = null,
) : LinearLayout(context, attrs) {
init {
orientation = VERTICAL
}
private val binding =
ViewSettingsMenuItemBinding.inflate(LayoutInflater.from(context), this)
init {
getAttributes(attrs, R.styleable.SettingsMenuItemView) {
binding.tvOptionName.apply {
text = getString(R.styleable.SettingsMenuItemView_optionName)
?.replace(' ', Typography.nbsp)
setCompoundDrawablesWithIntrinsicBounds(
getDrawable(R.styleable.SettingsMenuItemView_optionIcon), null, null, null
)
}
}
}
fun setText(text: String) {
binding.tvOptionName.text = text
}
}
\ No newline at end of file
...@@ -13,4 +13,9 @@ ...@@ -13,4 +13,9 @@
<attr name="readMoreTextViewStyle" format="reference" /> <attr name="readMoreTextViewStyle" format="reference" />
<declare-styleable name="SettingsMenuItemView">
<attr name="optionName" format="string" />
<attr name="optionIcon" format="reference" />
</declare-styleable>
</resources> </resources>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment