Skip to content

Commit

Permalink
#6 mypage_fragment/설정 화면 : 5 회원 탈퇴 화면
Browse files Browse the repository at this point in the history
 - 회원 탈퇴 버튼을 위한 커스텀 메인 버튼 수정
 (disabled 상태 일 때 버튼 배경 수정)
  • Loading branch information
likppi10 committed Aug 23, 2022
1 parent ebf862b commit 4291920
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
13 changes: 11 additions & 2 deletions design/src/main/java/com/ftw/hometerview/design/MainButton.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import androidx.core.view.updatePadding

private const val DEFAULT_ALIGNMENT = TEXT_ALIGNMENT_CENTER
private const val DEFAULT_ELEVATION = 10.0f
private const val DEFAULT_ENABLED = true

@RequiresApi(Build.VERSION_CODES.M)
class MainButton @JvmOverloads constructor(
Expand All @@ -30,8 +31,7 @@ class MainButton @JvmOverloads constructor(
init {
inflate(context, R.layout.view_main_button, this)
titleTextView = findViewById(R.id.title_text_view)

setBackgroundResource(R.drawable.button_main_button)

val horizontalPadding = resources.getDimensionPixelSize(R.dimen.button_horizontal_padding)
val verticalPadding = resources.getDimensionPixelSize(R.dimen.main_button_vertical_padding)
updatePadding(
Expand All @@ -51,6 +51,7 @@ class MainButton @JvmOverloads constructor(
text = getString(R.styleable.MainButton_android_text)
titleTextView.textAlignment = getInt(R.styleable.MainButton_android_textAlignment, DEFAULT_ALIGNMENT)
elevation = getFloat(R.styleable.MainButton_android_elevation, DEFAULT_ELEVATION)
isEnabled = getBoolean(R.styleable.MainButton_android_enabled, DEFAULT_ENABLED)
} catch (e: Exception) {
} finally {
recycle()
Expand All @@ -68,4 +69,12 @@ class MainButton @JvmOverloads constructor(
children.forEach { it.textAlignment = textAlignment }
}

override fun setEnabled(enabled: Boolean) {
super.setEnabled(enabled)
if(enabled){
setBackgroundResource(R.drawable.button_main_button)
} else{
setBackgroundResource(R.drawable.bg_button_disabled)
}
}
}
3 changes: 1 addition & 2 deletions design/src/main/res/drawable/bg_button_disabled.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle"
>
<solid android:color="@color/gray_100" />
<stroke android:color="@color/gray_200" android:width="@dimen/button_stroke_width" />
<solid android:color="@color/gray_200" />
<corners android:radius="@dimen/button_radius" />
</shape>
1 change: 1 addition & 0 deletions design/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@
<attr name="android:text" />
<attr name="android:textAlignment" />
<attr name="android:elevation" />
<attr name="android:enabled" />
</declare-styleable>
</resources>

0 comments on commit 4291920

Please sign in to comment.