-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'release' into feature/NFS-408-text-field-input
- Loading branch information
Showing
23 changed files
with
505 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Teste para adicionar o bitrise | ||
--Adicionando webhook para testes | ||
Adicionando mais linhas |
52 changes: 52 additions & 0 deletions
52
designsystem/src/main/kotlin/com/natura/android/widget/TextInputHighlight.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package com.natura.android.widget | ||
|
||
import android.content.Context | ||
import android.support.constraint.ConstraintLayout | ||
import android.util.AttributeSet | ||
import android.view.LayoutInflater | ||
import android.widget.TextView | ||
import com.natura.android.R | ||
|
||
class TextInputHighlight @JvmOverloads constructor( | ||
context: Context, | ||
attrs: AttributeSet? = null, | ||
defStyleAttr: Int = 0 | ||
) : ConstraintLayout(context, attrs, defStyleAttr) { | ||
|
||
private lateinit var descriptionLabel: TextView | ||
private lateinit var highlightInfoLabel: TextView | ||
|
||
init { | ||
LayoutInflater.from(context) | ||
.inflate(R.layout.ds_input_text_highlight_view, this, true) | ||
|
||
with(context.obtainStyledAttributes(attrs, R.styleable.ds_text_input_highlight)) { | ||
val description = this.getString(R.styleable.ds_text_input_highlight_description_label) | ||
val highlight = this.getString(R.styleable.ds_text_input_highlight_highlight_label) | ||
|
||
setupView(description, highlight) | ||
|
||
this.recycle() | ||
} | ||
} | ||
|
||
private fun setupView(description: String?, highlight: String?) { | ||
descriptionLabel = findViewById(R.id.description_label) | ||
highlightInfoLabel = findViewById(R.id.highlight_label) | ||
|
||
description?.let { descriptionLabel.text = it } | ||
highlight?.let { highlightInfoLabel.text = it } | ||
} | ||
|
||
fun setDescription(description: String) { | ||
descriptionLabel.text = description | ||
descriptionLabel.invalidate() | ||
descriptionLabel.requestLayout() | ||
} | ||
|
||
fun setHighlightedInfo(highlightStr: String) { | ||
highlightInfoLabel.text = highlightStr | ||
highlightInfoLabel.invalidate() | ||
highlightInfoLabel.requestLayout() | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
designsystem/src/main/res/color/ds_mtrl_default_btn_text_color_selector.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<selector xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<item android:color="@android:color/black" android:state_enabled="true"/> | ||
<item android:color="@color/mtrlBtnTextColorDisabled"/> | ||
</selector> |
5 changes: 5 additions & 0 deletions
5
designsystem/src/main/res/color/ds_mtrl_sec_btn_background_selector.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<selector xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<item android:color="?colorSecondary" android:state_enabled="true"/> | ||
<item android:color="@color/colorBrdBlack_12"/> | ||
</selector> |
5 changes: 5 additions & 0 deletions
5
designsystem/src/main/res/color/ds_mtrl_sec_btn_text_color_selector.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<selector xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<item android:color="@android:color/black" android:state_enabled="true"/> | ||
<item android:color="@color/mtrlBtnTextColorDisabled"/> | ||
</selector> |
5 changes: 5 additions & 0 deletions
5
designsystem/src/main/res/color/ds_mtrl_sec_colored_btn_text_color_selector.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<selector xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<item android:color="?colorSecondary" android:state_enabled="true"/> | ||
<item android:color="@color/mtrlBtnTextColorDisabled"/> | ||
</selector> |
8 changes: 8 additions & 0 deletions
8
designsystem/src/main/res/color/ds_mtrl_sec_colored_ripple_color_selector.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<selector xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<item android:alpha="0.16" android:color="?attr/colorSecondary" android:state_pressed="true"/> | ||
<item android:alpha="0.12" android:color="?attr/colorSecondary" android:state_focused="true" android:state_hovered="true"/> | ||
<item android:alpha="0.12" android:color="?attr/colorSecondary" android:state_focused="true"/> | ||
<item android:alpha="0.04" android:color="?attr/colorSecondary" android:state_hovered="true"/> | ||
<item android:alpha="0.00" android:color="?attr/colorSecondary"/> | ||
</selector> |
49 changes: 49 additions & 0 deletions
49
designsystem/src/main/res/layout/ds_input_text_highlight_view.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<merge | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
tools:parentTag="android.support.constraint.ConstraintLayout"> | ||
|
||
<View | ||
android:id="@+id/superior_divider" | ||
style="@style/Widget.Natura.Divider" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" /> | ||
|
||
<TextView | ||
android:id="@+id/description_label" | ||
style="@style/TextAppearence.Natura.Default" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginStart="@dimen/ds_spacin_tiny" | ||
android:layout_marginLeft="@dimen/ds_spacin_tiny" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toBottomOf="@id/superior_divider" | ||
tools:text="AMOUNT TO TRANSFER" /> | ||
|
||
<TextView | ||
android:id="@+id/highlight_label" | ||
style="@style/TextAppearence.Natura.Highlight" | ||
android:layout_width="0dp" | ||
android:layout_height="wrap_content" | ||
android:layout_marginEnd="@dimen/ds_spacin_tiny" | ||
android:layout_marginRight="@dimen/ds_spacin_tiny" | ||
android:gravity="end" | ||
app:layout_constraintBottom_toBottomOf="@id/description_label" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toEndOf="@id/description_label" | ||
app:layout_constraintTop_toTopOf="@id/description_label" | ||
tools:text="$ 120,75" /> | ||
|
||
<View | ||
android:id="@+id/inferior_divider" | ||
style="@style/Widget.Natura.Divider" | ||
android:layout_marginTop="@dimen/ds_spacing_standard" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toBottomOf="@id/highlight_label" /> | ||
|
||
</merge> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
|
||
<style name="Widget.Natura.Button" parent="Widget.MaterialComponents.Button"> | ||
<item name="android:textColor">@color/ds_mtrl_default_btn_text_color_selector</item> | ||
</style> | ||
|
||
<style name="Widget.Natura.Button.Secondary" parent="Widget.Natura.Button"> | ||
<item name="backgroundTint">@color/ds_mtrl_sec_btn_background_selector</item> | ||
</style> | ||
|
||
<style name="Widget.Natura.Button.Outlined" parent="Widget.MaterialComponents.Button.OutlinedButton"/> | ||
|
||
<style name="Widget.Natura.Button.Outlined.Secondary" parent="Widget.Natura.Button.Outlined"> | ||
<item name="android:textColor">@color/ds_mtrl_sec_colored_btn_text_color_selector</item> | ||
<item name="rippleColor">@color/ds_mtrl_sec_colored_ripple_color_selector</item> | ||
</style> | ||
|
||
<style name="Widget.Natura.Button.TextButton" parent="Widget.MaterialComponents.Button.TextButton"/> | ||
|
||
<style name="Widget.Natura.Button.TextButton.Secondary" parent="Widget.Natura.Button.TextButton"> | ||
<item name="android:textColor">@color/ds_mtrl_sec_colored_btn_text_color_selector</item> | ||
<item name="rippleColor">@color/ds_mtrl_sec_colored_ripple_color_selector</item> | ||
</style> | ||
|
||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
...androidTest/kotlin/com/natura/android/sample/components/TextInputHighlightActivityTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package com.natura.android.sample.components | ||
|
||
import android.view.View | ||
import androidx.test.core.app.ActivityScenario | ||
import androidx.test.espresso.Espresso.onView | ||
import androidx.test.espresso.assertion.ViewAssertions.matches | ||
import androidx.test.espresso.matcher.ViewMatchers.* | ||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
import com.natura.android.sample.R | ||
import org.hamcrest.Matcher | ||
import org.hamcrest.Matchers.allOf | ||
import org.junit.Before | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
|
||
@RunWith(AndroidJUnit4::class) | ||
class TextInputHighlightActivityTest { | ||
|
||
@Before | ||
fun setup() { | ||
ActivityScenario.launch(TextInputHighlightActivity::class.java) | ||
} | ||
|
||
@Test | ||
fun shouldDisplayInitialViewValues() { | ||
onView(matchHighlightChild( | ||
childId = R.id.description_label, | ||
parentId = R.id.highlightInitOnXml) | ||
) | ||
.check(matches(withText("Description on Xml"))) | ||
|
||
onView(matchHighlightChild( | ||
childId = R.id.highlight_label, | ||
parentId = R.id.highlightInitOnXml) | ||
) | ||
.check(matches(withText("R\$ 11,02"))) | ||
|
||
onView(matchHighlightChild( | ||
childId = R.id.highlight_label, | ||
parentId = R.id.highlightInitViaCode) | ||
) | ||
.check(matches(withText("\$ 00.00"))) | ||
|
||
onView(matchHighlightChild( | ||
childId = R.id.description_label, | ||
parentId = R.id.highlightInitViaCode) | ||
) | ||
.check(matches(withText("Add description via code"))) | ||
} | ||
|
||
private fun matchHighlightChild(childId: Int, parentId: Int): Matcher<View>? { | ||
return allOf( | ||
withId(childId), | ||
withParent(withId(parentId)) | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.