Skip to content

Commit

Permalink
Merge pull request #23 from MoyeoRun/feature/default-button
Browse files Browse the repository at this point in the history
[#22] RectangleButton, RoundButton CustomView 추가
  • Loading branch information
yuni-ju authored Apr 19, 2022
2 parents 0c88fc6 + f42ba13 commit e7d35f7
Show file tree
Hide file tree
Showing 8 changed files with 101 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.moyerun.moyeorun_android.views

import android.content.Context
import android.util.AttributeSet
import android.view.ContextThemeWrapper
import androidx.appcompat.widget.AppCompatButton
import com.moyerun.moyeorun_android.R

class RectangleButton constructor(
context: Context,
attrs: AttributeSet? = null
) : AppCompatButton(ContextThemeWrapper(context, R.style.RectangleButtonTheme), attrs)
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.moyerun.moyeorun_android.views

import android.content.Context
import android.util.AttributeSet
import android.view.ContextThemeWrapper
import androidx.appcompat.widget.AppCompatButton
import com.moyerun.moyeorun_android.R

class RoundButton constructor(
context: Context,
attrs: AttributeSet? = null
) : AppCompatButton(ContextThemeWrapper(context, R.style.RoundButtonTheme), attrs)
18 changes: 18 additions & 0 deletions app/src/main/res/drawable/selector_rectangle_button.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="true" android:state_pressed="false">
<shape android:shape="rectangle" >
<solid android:color="@color/main_blue"/>
</shape>
</item>
<item android:state_enabled="true" android:state_pressed="true">
<shape android:shape="rectangle">
<solid android:color="@color/button_pressed_true"/>
</shape>
</item>
<item android:state_enabled="false">
<shape android:shape="rectangle">
<solid android:color="@color/button_enable_false"/>
</shape>
</item>
</selector>
6 changes: 6 additions & 0 deletions app/src/main/res/drawable/selector_rectangle_button_text.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:color="@color/main_white" />
<item android:state_enabled="false" android:color="@color/button_text_enable_false"/>
<item android:color="@color/main_white" />
</selector>
21 changes: 21 additions & 0 deletions app/src/main/res/drawable/selector_round_button.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="true" android:state_pressed="false">
<shape android:shape="rectangle">
<solid android:color="@color/main_blue"/>
<corners android:radius="4dp"/>
</shape>
</item>
<item android:state_enabled="true" android:state_pressed="true">
<shape android:shape="rectangle">
<solid android:color="@color/button_pressed_true"/>
<corners android:radius="4dp"/>
</shape>
</item>
<item android:state_enabled="false">
<shape android:shape="rectangle">
<solid android:color="@color/button_enable_false"/>
<corners android:radius="4dp"/>
</shape>
</item>
</selector>
6 changes: 6 additions & 0 deletions app/src/main/res/drawable/selector_round_button_text.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:color="@color/main_white" />
<item android:state_enabled="false" android:color="@color/button_text_enable_false"/>
<item android:color="@color/main_white" />
</selector>
8 changes: 5 additions & 3 deletions app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@
<color name="main_green">#00F2B8</color>
<color name="main_yellow">#FFDD64</color>
<color name="main_light_blue">#EEF4FF</color>

<!-- extra colors -->


<!-- text colors -->
<color name="text_default_black">#333333</color>
<color name="text_gray">#828282</color>
<color name="text_hint_gray">#A9A9A9</color>

<!-- button colors -->
<color name="button_pressed_true">#0047D0</color>
<color name="button_enable_false">#C4C4C4</color>
<color name="button_text_enable_false">#828282</color>
</resources>
21 changes: 21 additions & 0 deletions app/src/main/res/values/styles_button.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="RectangleButtonTheme">
<item name="buttonStyle">@style/RectangleButton</item>
</style>
<style name="RectangleButton" parent="Widget.AppCompat.Button">
<item name="android:background">@drawable/selector_rectangle_button</item>
<item name="android:textSize">21dp</item>
<item name="android:textColor">@drawable/selector_rectangle_button_text</item>
<item name="android:minHeight">88dp</item>
</style>

<style name="RoundButtonTheme">
<item name="buttonStyle">@style/RoundButton</item>
</style>
<style name="RoundButton" parent="Widget.AppCompat.Button">
<item name="android:background">@drawable/selector_round_button</item>
<item name="android:textSize">21dp</item>
<item name="android:textColor">@drawable/selector_round_button_text</item>
</style>
</resources>

0 comments on commit e7d35f7

Please sign in to comment.