diff --git a/README.md b/README.md index ff2aa7d83..8ddf04d5f 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,11 @@ In construction You can contribute submitting [pull requests](https://github.com/natura-cosmeticos/natds-android/pulls). +### How to add resource icons +It is preferable that the icon resources are saved as vectors (XML format). The nomenclature of drawables must be `ds_ic___`. + +For instance: `ds_ic_outlined_navigation_arrowbottom.xml` + ### How to create a new version In the file **publish.gradle** update field in the method **getVersionName** with the new version number. Example, for the version 1.0.1: diff --git a/designsystem/src/main/kotlin/com/natura/android/button/DsPrimaryButton.kt b/designsystem/src/main/kotlin/com/natura/android/button/DsPrimaryButton.kt index 0843b9536..833fb9bd1 100644 --- a/designsystem/src/main/kotlin/com/natura/android/button/DsPrimaryButton.kt +++ b/designsystem/src/main/kotlin/com/natura/android/button/DsPrimaryButton.kt @@ -17,6 +17,7 @@ class DsPrimaryButton @JvmOverloads constructor( defStyleAttr: Int = 0 ) : ConstraintLayout(context, attrs, defStyleAttr) { + // TODO remover esta classe pois android.support.design.button.MaterialButton ja atende private val buttonLabel by lazy { findViewById(R.id.button_primary_text) } private val buttonIconLeft by lazy { findViewById(R.id.button_primary_icon_left) } private val buttonIconRight by lazy { findViewById(R.id.button_primary_icon_right) } diff --git a/designsystem/src/main/kotlin/com/natura/android/error/DsErrorDefault.kt b/designsystem/src/main/kotlin/com/natura/android/error/DsErrorDefault.kt index bf75ddc5f..ca404beef 100644 --- a/designsystem/src/main/kotlin/com/natura/android/error/DsErrorDefault.kt +++ b/designsystem/src/main/kotlin/com/natura/android/error/DsErrorDefault.kt @@ -17,6 +17,7 @@ class DsErrorDefault @JvmOverloads constructor( defStyleAttr: Int = 0 ) : ConstraintLayout(context, attrs, defStyleAttr) { + // TODO mover esta classe para com.natura.android.pattern private val erroIcon by lazy { findViewById(R.id.ds_default_error_icon) } private val errorLabel by lazy { findViewById(R.id.ds_default_error_label) } private val errorButton by lazy { findViewById(R.id.ds_default_error_button) } diff --git a/designsystem/src/main/kotlin/com/natura/android/icon/FontIcon.kt b/designsystem/src/main/kotlin/com/natura/android/icon/FontIcon.kt index 1914531a2..b607b7995 100644 --- a/designsystem/src/main/kotlin/com/natura/android/icon/FontIcon.kt +++ b/designsystem/src/main/kotlin/com/natura/android/icon/FontIcon.kt @@ -11,6 +11,7 @@ class FontIcon @JvmOverloads constructor( defStyleAttr: Int = 0 ) : AppCompatTextView(context, attrs, defStyleAttr) { + // TODO considerar usar esta classe como inner class de MenuView private val natDsFontPath = "fonts/natds_icons.ttf" init { diff --git a/designsystem/src/main/kotlin/com/natura/android/textfield/TextFieldInput.kt b/designsystem/src/main/kotlin/com/natura/android/textfield/TextField.kt similarity index 90% rename from designsystem/src/main/kotlin/com/natura/android/textfield/TextFieldInput.kt rename to designsystem/src/main/kotlin/com/natura/android/textfield/TextField.kt index 1adf57b6f..7e1f091b9 100644 --- a/designsystem/src/main/kotlin/com/natura/android/textfield/TextFieldInput.kt +++ b/designsystem/src/main/kotlin/com/natura/android/textfield/TextField.kt @@ -12,24 +12,24 @@ import android.view.inputmethod.EditorInfo import android.widget.EditText import android.widget.LinearLayout import android.widget.TextView -import android.widget.Toast import com.natura.android.R import com.natura.android.icon.FontIcon - @SuppressLint("CustomViewStyleable") -class TextFieldInput @JvmOverloads constructor( +class TextField @JvmOverloads constructor( context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0 ) : ConstraintLayout(context, attrs, defStyleAttr) { + // TODO trocar FontIcon por AppCompatImageView enum class State { NONE, ERROR, SUCCESS } enum class LayoutState(val borderWidth: Int, val borderColor: Int, val labelColor: Int, val textColor: Int, val footerColor: Int) { - DEFAULT(R.dimen.ds_border_tiny, R.color.colorHighEmphasis, R.color.colorMediumEmphasis, R.color.colorHighEmphasis, R.color.colorMediumEmphasis), + DEFAULT(R.dimen.ds_border_tiny, R.color.colorLowEmphasis, R.color.colorMediumEmphasis, R.color.colorMediumEmphasis, R.color.colorMediumEmphasis), + FILLED(R.dimen.ds_border_tiny, R.color.colorHighEmphasis, R.color.colorMediumEmphasis, R.color.colorHighEmphasis, R.color.colorMediumEmphasis), DISABLED(R.dimen.ds_border_tiny, R.color.colorLowEmphasis, R.color.colorLowEmphasis, R.color.colorLowEmphasis, R.color.colorLowEmphasis), FOCUSED(R.dimen.ds_border_emphasis, R.color.colorBrdNatYellow, R.color.colorMediumEmphasis, R.color.colorHighEmphasis, R.color.colorMediumEmphasis), ERROR(R.dimen.ds_border_emphasis, R.color.colorBrdNatRed, R.color.colorBrdNatRed, R.color.colorHighEmphasis, R.color.colorBrdNatRed), @@ -56,6 +56,11 @@ class TextFieldInput @JvmOverloads constructor( resetLayoutState() } + val editTextView: EditText + get() { + return inputValue + } + var inputType: Int = EditorInfo.TYPE_CLASS_TEXT set(value) { field = value @@ -94,6 +99,10 @@ class TextFieldInput @JvmOverloads constructor( set(value) { field = value inputValue.setText(value) + resetLayoutState() + } + get() { + return inputValue.text.toString() } var icon: String? = null @@ -149,10 +158,10 @@ class TextFieldInput @JvmOverloads constructor( set(value) { field = value footer = value - if (value != null) { - state = State.ERROR + state = if (value != null) { + State.ERROR } else { - state = State.NONE + State.NONE } } @@ -163,6 +172,7 @@ class TextFieldInput @JvmOverloads constructor( else -> { if (!isEnabled) LayoutState.DISABLED else if (inputValue.isFocused) LayoutState.FOCUSED + else if (inputValue.text.isNotEmpty()) LayoutState.FILLED else LayoutState.DEFAULT } } @@ -178,7 +188,7 @@ class TextFieldInput @JvmOverloads constructor( else view.visibility = View.VISIBLE } - private fun intToState(vstate: Int)= when(vstate) { + private fun intToState(vstate: Int) = when (vstate) { 1 -> State.SUCCESS 2 -> State.ERROR else -> State.NONE @@ -200,7 +210,7 @@ class TextFieldInput @JvmOverloads constructor( val vtext = typedArray.getString(R.styleable.ds_text_field_input_text_field_text) val vicon = typedArray.getString(R.styleable.ds_text_field_input_text_field_icon) val vfooter = typedArray.getString(R.styleable.ds_text_field_input_text_field_footer) - var vstate = typedArray.getInt(R.styleable.ds_text_field_input_text_field_state, 0) + val vstate = typedArray.getInt(R.styleable.ds_text_field_input_text_field_state, 0) typedArray.recycle() diff --git a/designsystem/src/main/kotlin/com/natura/android/widget/ValueTextHighlight.kt b/designsystem/src/main/kotlin/com/natura/android/widget/ValueTextHighlight.kt index 6853a3cab..56d67215d 100644 --- a/designsystem/src/main/kotlin/com/natura/android/widget/ValueTextHighlight.kt +++ b/designsystem/src/main/kotlin/com/natura/android/widget/ValueTextHighlight.kt @@ -49,4 +49,4 @@ class ValueTextHighlight @JvmOverloads constructor( highlightInfoLabel.invalidate() highlightInfoLabel.requestLayout() } -} \ No newline at end of file +} diff --git a/designsystem/src/main/res/drawable/ds_ic_arrow_down.xml b/designsystem/src/main/res/drawable/ds_ic_arrow_down.xml deleted file mode 100644 index 1989b419b..000000000 --- a/designsystem/src/main/res/drawable/ds_ic_arrow_down.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - diff --git a/designsystem/src/main/res/drawable/ds_ic_filled_action_cancel.xml b/designsystem/src/main/res/drawable/ds_ic_filled_action_cancel.xml new file mode 100644 index 000000000..0086e9d9f --- /dev/null +++ b/designsystem/src/main/res/drawable/ds_ic_filled_action_cancel.xml @@ -0,0 +1,9 @@ + + + diff --git a/designsystem/src/main/res/drawable/ds_ic_filled_action_check.xml b/designsystem/src/main/res/drawable/ds_ic_filled_action_check.xml new file mode 100644 index 000000000..42dc440d4 --- /dev/null +++ b/designsystem/src/main/res/drawable/ds_ic_filled_action_check.xml @@ -0,0 +1,9 @@ + + + diff --git a/designsystem/src/main/res/drawable/ds_ic_outlined_action_cancel.xml b/designsystem/src/main/res/drawable/ds_ic_outlined_action_cancel.xml new file mode 100644 index 000000000..02a92701a --- /dev/null +++ b/designsystem/src/main/res/drawable/ds_ic_outlined_action_cancel.xml @@ -0,0 +1,9 @@ + + + diff --git a/designsystem/src/main/res/drawable/ds_ic_outlined_action_mic.xml b/designsystem/src/main/res/drawable/ds_ic_outlined_action_mic.xml new file mode 100644 index 000000000..c1b48af6c --- /dev/null +++ b/designsystem/src/main/res/drawable/ds_ic_outlined_action_mic.xml @@ -0,0 +1,9 @@ + + + diff --git a/designsystem/src/main/res/drawable/ds_ic_outlined_action_search.xml b/designsystem/src/main/res/drawable/ds_ic_outlined_action_search.xml new file mode 100644 index 000000000..d83d18720 --- /dev/null +++ b/designsystem/src/main/res/drawable/ds_ic_outlined_action_search.xml @@ -0,0 +1,9 @@ + + + diff --git a/designsystem/src/main/res/drawable/ds_ic_outlined_finance_transfermoney.xml b/designsystem/src/main/res/drawable/ds_ic_outlined_finance_transfermoney.xml new file mode 100644 index 000000000..5d8a12ba1 --- /dev/null +++ b/designsystem/src/main/res/drawable/ds_ic_outlined_finance_transfermoney.xml @@ -0,0 +1,9 @@ + + + diff --git a/designsystem/src/main/res/drawable/ds_ic_outlined_navigation_arrowbottom.xml b/designsystem/src/main/res/drawable/ds_ic_outlined_navigation_arrowbottom.xml new file mode 100644 index 000000000..1f31cbfcf --- /dev/null +++ b/designsystem/src/main/res/drawable/ds_ic_outlined_navigation_arrowbottom.xml @@ -0,0 +1,9 @@ + + + diff --git a/designsystem/src/main/res/drawable/ds_ic_outlined_navigation_arrowleft.xml b/designsystem/src/main/res/drawable/ds_ic_outlined_navigation_arrowleft.xml new file mode 100644 index 000000000..ce516e0d0 --- /dev/null +++ b/designsystem/src/main/res/drawable/ds_ic_outlined_navigation_arrowleft.xml @@ -0,0 +1,9 @@ + + + diff --git a/designsystem/src/main/res/drawable/ds_ic_outlined_navigation_arrowright.xml b/designsystem/src/main/res/drawable/ds_ic_outlined_navigation_arrowright.xml new file mode 100644 index 000000000..d225af02b --- /dev/null +++ b/designsystem/src/main/res/drawable/ds_ic_outlined_navigation_arrowright.xml @@ -0,0 +1,9 @@ + + + diff --git a/designsystem/src/main/res/drawable/ds_ic_outlined_navigation_arrowtop.xml b/designsystem/src/main/res/drawable/ds_ic_outlined_navigation_arrowtop.xml new file mode 100644 index 000000000..e2cd132d7 --- /dev/null +++ b/designsystem/src/main/res/drawable/ds_ic_outlined_navigation_arrowtop.xml @@ -0,0 +1,9 @@ + + + diff --git a/designsystem/src/main/res/drawable/ds_ic_outlined_navigation_close.xml b/designsystem/src/main/res/drawable/ds_ic_outlined_navigation_close.xml new file mode 100644 index 000000000..45cb0e1b7 --- /dev/null +++ b/designsystem/src/main/res/drawable/ds_ic_outlined_navigation_close.xml @@ -0,0 +1,9 @@ + + + diff --git a/designsystem/src/main/res/drawable/ds_ic_outlined_navigation_directionright.xml b/designsystem/src/main/res/drawable/ds_ic_outlined_navigation_directionright.xml new file mode 100644 index 000000000..9767a92e7 --- /dev/null +++ b/designsystem/src/main/res/drawable/ds_ic_outlined_navigation_directionright.xml @@ -0,0 +1,9 @@ + + + diff --git a/designsystem/src/main/res/layout/ds_menu_view.xml b/designsystem/src/main/res/layout/ds_menu_view.xml index 95e94936e..0cd0e8761 100644 --- a/designsystem/src/main/res/layout/ds_menu_view.xml +++ b/designsystem/src/main/res/layout/ds_menu_view.xml @@ -85,6 +85,7 @@ app:layout_constraintBottom_toBottomOf="@id/ds_menu_label" app:layout_constraintEnd_toEndOf="@+id/ds_menu_view_background" app:layout_constraintTop_toTopOf="@id/ds_menu_label" - app:srcCompat="@drawable/ds_ic_arrow_down" + app:srcCompat="@drawable/ds_ic_outlined_navigation_arrowbottom" app:tint="@color/colorBrdNatGray" /> + diff --git a/designsystem/src/main/res/values/themes.xml b/designsystem/src/main/res/values/themes.xml index faf9ec0f2..55fc368ed 100644 --- a/designsystem/src/main/res/values/themes.xml +++ b/designsystem/src/main/res/values/themes.xml @@ -24,6 +24,11 @@ @style/Widget.Natura.Button.TextButton.DarkText + +