Skip to content

Commit

Permalink
FEAT: add symbol colors
Browse files Browse the repository at this point in the history
  • Loading branch information
balakz committed Feb 24, 2021
1 parent d0619f3 commit c03ff68
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 37 deletions.
Original file line number Diff line number Diff line change
@@ -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
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
/>
4 changes: 2 additions & 2 deletions formbuilderlibrary/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
<color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color>
<color name="colorAccent">#FF4081</color>
<color name="colorBackgroundPrimary">#9c9c9c</color>
<color name="colorBackgroundPrimary">#D6D6D6</color>
<color name="colorGray">#9c9c9c</color>
<color name="colorDefaultText">#000000</color>
<color name="colorBackground">#ffffff</color>
<color name="colorGreen">#2ca123</color>
<color name="colorOrange">#ffbc03</color>
<color name="colorRed">#F44336</color>



<color name="oneTextPrimary">#ffffff</color>
<color name="oneTextSecondary">#363636</color>
<color name="oneBackgroundPrimary">#FE4365</color>
Expand Down

0 comments on commit c03ff68

Please sign in to comment.