From c03ff689a44d298110aa5ef7a72c1e5baba35be5 Mon Sep 17 00:00:00 2001 From: balakz Date: Wed, 24 Feb 2021 02:25:37 +0100 Subject: [PATCH] FEAT: add symbol colors --- .../formbuilderlibrary/FormStyleBundle.kt | 55 ++++++++++--------- .../element/LabelSwitchElement.kt | 16 +++--- .../element/NavigationWithErrorElement.kt | 2 + .../src/main/res/layout/form_error_symbol.xml | 1 - .../src/main/res/values/colors.xml | 4 +- 5 files changed, 41 insertions(+), 37 deletions(-) diff --git a/formbuilderlibrary/src/main/java/cz/qase/android/formbuilderlibrary/FormStyleBundle.kt b/formbuilderlibrary/src/main/java/cz/qase/android/formbuilderlibrary/FormStyleBundle.kt index bcf1f17..1d081d9 100644 --- a/formbuilderlibrary/src/main/java/cz/qase/android/formbuilderlibrary/FormStyleBundle.kt +++ b/formbuilderlibrary/src/main/java/cz/qase/android/formbuilderlibrary/FormStyleBundle.kt @@ -1,44 +1,49 @@ package cz.qase.android.formbuilderlibrary -class FormStyleBundle(val primaryTextColor: Int = R.color.colorPrimary, - val secondaryTextColor: Int = R.color.colorDefaultText, - val primaryBackgroundColor: Int = R.color.colorBackgroundPrimary, - val secondaryBackgroundColor: Int = R.color.colorBackground, - val dividerColor: Int = R.color.colorGreen) { +class FormStyleBundle( + val primaryTextColor: Int = R.color.colorPrimary, + val secondaryTextColor: Int = R.color.colorDefaultText, + val primaryBackgroundColor: Int = R.color.colorBackgroundPrimary, + val secondaryBackgroundColor: Int = R.color.colorBackground, + val dividerColor: Int = R.color.colorGray, + val neutralSymbolColor: Int = R.color.colorGray, + val dangerousSymbolColor: Int = R.color.colorRed +) { companion object { fun colorBundleOne() = FormStyleBundle( - R.color.oneTextPrimary, - R.color.oneTextSecondary, - R.color.oneBackgroundPrimary, - R.color.oneBackgroundSecondary, - R.color.oneDivider + R.color.oneTextPrimary, + R.color.oneTextSecondary, + R.color.oneBackgroundPrimary, + R.color.oneBackgroundSecondary, + R.color.oneDivider ) fun colorBundleTwo() = FormStyleBundle( - R.color.twoTextPrimary, - R.color.twoTextSecondary, - R.color.twoBackgroundPrimary, - R.color.twoBackgroundSecondary, - R.color.twoDivider + R.color.twoTextPrimary, + R.color.twoTextSecondary, + R.color.twoBackgroundPrimary, + R.color.twoBackgroundSecondary, + R.color.twoDivider ) fun colorBundleThree() = FormStyleBundle( - R.color.threeTextPrimary, - R.color.threeTextSecondary, - R.color.threeBackgroundPrimary, - R.color.threeBackgroundSecondary, - R.color.threeDivider + R.color.threeTextPrimary, + R.color.threeTextSecondary, + R.color.threeBackgroundPrimary, + R.color.threeBackgroundSecondary, + R.color.threeDivider, + R.color.threeDivider ) fun colorBundleFour() = FormStyleBundle( - R.color.fourTextPrimary, - R.color.fourTextSecondary, - R.color.fourBackgroundPrimary, - R.color.fourBackgroundSecondary, - R.color.fourDivider + R.color.fourTextPrimary, + R.color.fourTextSecondary, + R.color.fourBackgroundPrimary, + R.color.fourBackgroundSecondary, + R.color.fourDivider ) } } diff --git a/formbuilderlibrary/src/main/java/cz/qase/android/formbuilderlibrary/element/LabelSwitchElement.kt b/formbuilderlibrary/src/main/java/cz/qase/android/formbuilderlibrary/element/LabelSwitchElement.kt index b6aead6..3d32c3c 100644 --- a/formbuilderlibrary/src/main/java/cz/qase/android/formbuilderlibrary/element/LabelSwitchElement.kt +++ b/formbuilderlibrary/src/main/java/cz/qase/android/formbuilderlibrary/element/LabelSwitchElement.kt @@ -65,24 +65,22 @@ class LabelSwitchElement( noteCallback?.let { actionCallback -> val noteView = inflater.inflate(noteSymbolComponent, groupEnd, false) as ImageView groupEnd.addView(noteView) - val color = ContextCompat.getColor(context, formStyleBundle.dividerColor) - noteView.setColorFilter(color) + val neutralColor = ContextCompat.getColor(context, formStyleBundle.neutralSymbolColor) + val primaryColor = ContextCompat.getColor(context, formStyleBundle.primaryTextColor) + noteView.setColorFilter(neutralColor) noteView.setOnClickListener { actionCallback.callback() } noteView.setOnTouchListener { _, event -> when (event.action) { MotionEvent.ACTION_UP -> { - val color = ContextCompat.getColor(context, formStyleBundle.dividerColor) - noteView.setColorFilter(color) + noteView.setColorFilter(neutralColor) noteView.performClick() } MotionEvent.ACTION_CANCEL -> { - val color = ContextCompat.getColor(context, formStyleBundle.dividerColor) - noteView.setColorFilter(color) + noteView.setColorFilter(neutralColor) } MotionEvent.ACTION_DOWN -> { - val color = - ContextCompat.getColor(context, formStyleBundle.primaryTextColor) - noteView.setColorFilter(color) + + noteView.setColorFilter(primaryColor) } } true diff --git a/formbuilderlibrary/src/main/java/cz/qase/android/formbuilderlibrary/element/NavigationWithErrorElement.kt b/formbuilderlibrary/src/main/java/cz/qase/android/formbuilderlibrary/element/NavigationWithErrorElement.kt index e65fc75..ca4c022 100644 --- a/formbuilderlibrary/src/main/java/cz/qase/android/formbuilderlibrary/element/NavigationWithErrorElement.kt +++ b/formbuilderlibrary/src/main/java/cz/qase/android/formbuilderlibrary/element/NavigationWithErrorElement.kt @@ -45,6 +45,8 @@ open class NavigationWithErrorElement( ?: formStyleBundle, view ) val errorView = inflater.inflate(warningSymbolComponent, viewEnd, false) as ImageView + val dangerousColor = ContextCompat.getColor(context, formStyleBundle.dangerousSymbolColor) + errorView.setColorFilter(dangerousColor) val symbolView = prepareSymbol( inflater, context, this.formStyleBundle ?: formStyleBundle, viewEnd diff --git a/formbuilderlibrary/src/main/res/layout/form_error_symbol.xml b/formbuilderlibrary/src/main/res/layout/form_error_symbol.xml index 79a2062..4345f8d 100644 --- a/formbuilderlibrary/src/main/res/layout/form_error_symbol.xml +++ b/formbuilderlibrary/src/main/res/layout/form_error_symbol.xml @@ -3,7 +3,6 @@ android:id="@+id/errorSymbol" android:layout_width="30dp" android:layout_height="30dp" - android:tint="@color/colorRed" android:contentDescription="@string/navigation" android:src="@drawable/ic_error" /> diff --git a/formbuilderlibrary/src/main/res/values/colors.xml b/formbuilderlibrary/src/main/res/values/colors.xml index b9ce9ea..e57c8f9 100644 --- a/formbuilderlibrary/src/main/res/values/colors.xml +++ b/formbuilderlibrary/src/main/res/values/colors.xml @@ -3,7 +3,8 @@ #3F51B5 #303F9F #FF4081 - #9c9c9c + #D6D6D6 + #9c9c9c #000000 #ffffff #2ca123 @@ -11,7 +12,6 @@ #F44336 - #ffffff #363636 #FE4365