From 48facd92549a2c2ce8b7ce9b3e99aa1f95f1a785 Mon Sep 17 00:00:00 2001
From: Taras Smakula <tarassmakula@gmail.com>
Date: Tue, 25 Jul 2023 16:45:48 +0300
Subject: [PATCH] Create view for settings item

---
 .../futo/circles/view/SettingsMenuItemView.kt | 41 +++++++++++++++++++
 app/src/main/res/values/attrs.xml             |  5 +++
 2 files changed, 46 insertions(+)
 create mode 100644 app/src/main/java/org/futo/circles/view/SettingsMenuItemView.kt

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 000000000..78ea24df7
--- /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 ac9eed3a5..a26c8bacf 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
-- 
GitLab