diff --git a/app/src/main/java/org/futo/circles/view/SettingsMenuItemView.kt b/app/src/main/java/org/futo/circles/view/SettingsMenuItemView.kt new file mode 100644 index 0000000000000000000000000000000000000000..78ea24df705b3f566e3d7dd51676f388546089aa --- /dev/null +++ b/app/src/main/java/org/futo/circles/view/SettingsMenuItemView.kt @@ -0,0 +1,41 @@ +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 diff --git a/app/src/main/res/values/attrs.xml b/app/src/main/res/values/attrs.xml index ac9eed3a50e31cf0d63f6b3e43237019b581fe79..a26c8bacfb7dd1cede93883606a86678e7bd334e 100644 --- a/app/src/main/res/values/attrs.xml +++ b/app/src/main/res/values/attrs.xml @@ -13,4 +13,9 @@ <attr name="readMoreTextViewStyle" format="reference" /> + <declare-styleable name="SettingsMenuItemView"> + <attr name="optionName" format="string" /> + <attr name="optionIcon" format="reference" /> + </declare-styleable> + </resources> \ No newline at end of file