Skip to content

Commit 74146b4

Browse files
committed
Add text selectors to rounded button
1 parent dde12a0 commit 74146b4

File tree

6 files changed

+23
-3
lines changed

6 files changed

+23
-3
lines changed

app/src/main/java/org/buffer/android/components/RoundedButton.kt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,18 @@ class RoundedButton @JvmOverloads constructor(context: Context,
2424
val style = ButtonStyle.fromIdentifier(getStyleIdentifierFromStyleableAttributes(attrs))
2525
when (style) {
2626
ButtonStyle.DARK -> {
27-
setTextColor(ContextCompat.getColor(context, R.color.white))
27+
setTextColor(ContextCompat.getColor(context,
28+
R.color.selector_dark_button_text))
2829
setBackgroundResource(R.drawable.button_bfr_round_dark)
2930
}
3031
ButtonStyle.LIGHT -> {
31-
setTextColor(ContextCompat.getColor(context, R.color.white))
32+
setTextColor(ContextCompat.getColorStateList(context,
33+
R.color.selector_light_button_text))
3234
setBackgroundResource(R.drawable.button_bfr_round_light)
3335
}
3436
ButtonStyle.CLEAR -> {
35-
setTextColor(ContextCompat.getColor(context, R.color.outer_space))
37+
setTextColor(ContextCompat.getColor(context,
38+
R.color.selector_clear_button_text))
3639
setBackgroundResource(R.drawable.button_bfr_round_white)
3740
}
3841
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<selector xmlns:android="http://schemas.android.com/apk/res/android">
3+
<item android:state_enabled="false" android:color="@color/disabled_text" />
4+
<item android:color="#636363"/>
5+
</selector>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<selector xmlns:android="http://schemas.android.com/apk/res/android">
3+
<item android:state_enabled="false" android:color="@color/disabled_text" />
4+
<item android:color="@color/white"/>
5+
</selector>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<selector xmlns:android="http://schemas.android.com/apk/res/android">
3+
<item android:state_enabled="false" android:color="@color/disabled_text" />
4+
<item android:color="@color/white"/>
5+
</selector>

app/src/main/res/drawable/button_bfr_round_clear_unfocused.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@
33
android:shape="rectangle">
44
<corners android:radius="@dimen/corner_radius" />
55
<solid android:color="@color/white" />
6+
<stroke android:width="1px" android:color="#B8B8B8" />
67
</shape>

app/src/main/res/values/colors.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,6 @@
2727

2828
<color name="title_text">#000000</color>
2929
<color name="content_text">#6B6B6B</color>
30+
<color name="disabled_text">#77797A</color>
3031

3132
</resources>

0 commit comments

Comments
 (0)