diff --git a/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/views/FormLabelledValue.kt b/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/views/FormLabelledValue.kt new file mode 100644 index 00000000..602ed227 --- /dev/null +++ b/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/views/FormLabelledValue.kt @@ -0,0 +1,65 @@ +package net.dankito.banking.ui.android.views + +import android.content.Context +import android.util.AttributeSet +import android.view.LayoutInflater +import android.view.View +import android.widget.LinearLayout +import kotlinx.android.synthetic.main.view_form_labelled_value.view.* +import net.dankito.banking.ui.android.R + + +open class FormLabelledValue @JvmOverloads constructor( + context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0 +) : LinearLayout(context, attrs, defStyleAttr) { + + + init { + setupUi(context, attrs) + } + + private fun setupUi(context: Context, attrs: AttributeSet?) { + val inflater = context.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater + val rootView = inflater.inflate(R.layout.view_form_labelled_value, this, true) + + rootView.apply { + + context.theme.obtainStyledAttributes( + attrs, + R.styleable.FormLabelledValue, + 0, 0).apply { + + try { + txtLabel.text = getString(R.styleable.FormLabelledValue_android_label) + txtValue.text = getString(R.styleable.FormLabelledValue_android_value) + } finally { + recycle() + } + } + } + } + + + open var label: CharSequence + get() = txtLabel.text + set(value) { + txtLabel.text = value + } + + open var value: CharSequence + get() = txtValue.text + set(value) { + txtValue.text = value + } + + open fun setValueAndVisibilityIfValueIsSet(value: CharSequence?) { + if (value != null) { + this.value = value + this.visibility = View.VISIBLE + } + else { + this.visibility = View.GONE + } + } + +} \ No newline at end of file diff --git a/ui/BankingAndroidApp/src/main/res/layout/view_form_labelled_value.xml b/ui/BankingAndroidApp/src/main/res/layout/view_form_labelled_value.xml new file mode 100644 index 00000000..c44c79f1 --- /dev/null +++ b/ui/BankingAndroidApp/src/main/res/layout/view_form_labelled_value.xml @@ -0,0 +1,30 @@ + + + + + + + + \ No newline at end of file diff --git a/ui/BankingAndroidApp/src/main/res/values/attrs.xml b/ui/BankingAndroidApp/src/main/res/values/attrs.xml index 3c037cdc..9c43076b 100644 --- a/ui/BankingAndroidApp/src/main/res/values/attrs.xml +++ b/ui/BankingAndroidApp/src/main/res/values/attrs.xml @@ -26,4 +26,12 @@ + + + + + + + + \ No newline at end of file diff --git a/ui/BankingAndroidApp/src/main/res/values/colors.xml b/ui/BankingAndroidApp/src/main/res/values/colors.xml index 5e6f99b0..8d577545 100644 --- a/ui/BankingAndroidApp/src/main/res/values/colors.xml +++ b/ui/BankingAndroidApp/src/main/res/values/colors.xml @@ -16,6 +16,9 @@ #8a8a8e #737373 + + #494949 + #999999 @color/primaryTextColor_Dark diff --git a/ui/BankingAndroidApp/src/main/res/values/dimens.xml b/ui/BankingAndroidApp/src/main/res/values/dimens.xml index b3547390..ef4437d3 100644 --- a/ui/BankingAndroidApp/src/main/res/values/dimens.xml +++ b/ui/BankingAndroidApp/src/main/res/values/dimens.xml @@ -22,7 +22,13 @@ 6dp 15sp 18dp - 8dp + 8dp + + 15sp + 12dp + 2dp + 15sp + 4dp 4dp 24dp