Skip to content

Commit

Permalink
Add the 'text_color' attribute (#28) (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
cortinico authored Oct 29, 2018
1 parent d14304f commit de2c4b9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
17 changes: 14 additions & 3 deletions slidetoact/src/main/java/com/ncorti/slidetoact/SlideToActView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,13 @@ class SlideToActView @JvmOverloads constructor (
var innerColor: Int = 0
set(value) {
field = value
mInnerPaint.color = value
mTextPaint.color = value
invalidate()
}

var textColor: Int = 0
set(value) {
field = value
mTextPaint.color = value
invalidate()
}
Expand Down Expand Up @@ -179,6 +185,7 @@ class SlideToActView @JvmOverloads constructor (
init {
val actualOuterColor : Int
val actualInnerColor : Int
val actualTextColor : Int

val layoutAttrs: TypedArray = context.theme.obtainStyledAttributes(attrs,
R.styleable.SlideToActView, defStyleAttr, R.style.SlideToActView)
Expand All @@ -190,9 +197,12 @@ class SlideToActView @JvmOverloads constructor (
mBorderRadius = layoutAttrs.getDimensionPixelSize(R.styleable.SlideToActView_border_radius, -1)

val defaultOuter = ContextCompat.getColor(this.context, R.color.defaultAccent)
val defaultInner = ContextCompat.getColor(this.context, R.color.white)
val defaultWhite = ContextCompat.getColor(this.context, R.color.white)

actualOuterColor = layoutAttrs.getColor(R.styleable.SlideToActView_outer_color, defaultOuter)
actualInnerColor = layoutAttrs.getColor(R.styleable.SlideToActView_inner_color, defaultInner)
actualInnerColor = layoutAttrs.getColor(R.styleable.SlideToActView_inner_color, defaultWhite)
actualTextColor = layoutAttrs.getColor(R.styleable.SlideToActView_text_color, defaultWhite)

text = layoutAttrs.getString(R.styleable.SlideToActView_text)
typeFace = layoutAttrs.getInt(R.styleable.SlideToActView_text_style, 0)

Expand Down Expand Up @@ -228,6 +238,7 @@ class SlideToActView @JvmOverloads constructor (

outerColor = actualOuterColor
innerColor = actualInnerColor
textColor = actualTextColor

mIconMargin = context.resources.getDimensionPixelSize(R.dimen.default_icon_margin)
mArrowMargin = mIconMargin
Expand Down
1 change: 1 addition & 0 deletions slidetoact/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<attr name="area_margin" format="dimension" />
<attr name="inner_color" format="color" />
<attr name="outer_color" format="color" />
<attr name="text_color" format="color" />
<attr name="border_radius" format="dimension" />
<attr name="slider_height" format="dimension" />
<attr name="slider_locked" format="boolean" />
Expand Down

0 comments on commit de2c4b9

Please sign in to comment.