Skip to content

Commit

Permalink
[NFS-408] correct filled status and rename class (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
pmunizferreira authored Mar 18, 2020
1 parent 089daba commit 7fd025c
Show file tree
Hide file tree
Showing 4 changed files with 147 additions and 98 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import com.natura.android.R
import com.natura.android.icon.FontIcon

@SuppressLint("CustomViewStyleable")
class TextFieldInput @JvmOverloads constructor(
class TextField @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
Expand All @@ -28,7 +28,8 @@ class TextFieldInput @JvmOverloads constructor(
}

enum class LayoutState(val borderWidth: Int, val borderColor: Int, val labelColor: Int, val textColor: Int, val footerColor: Int) {
DEFAULT(R.dimen.ds_border_tiny, R.color.colorHighEmphasis, R.color.colorMediumEmphasis, R.color.colorHighEmphasis, R.color.colorMediumEmphasis),
DEFAULT(R.dimen.ds_border_tiny, R.color.colorLowEmphasis, R.color.colorMediumEmphasis, R.color.colorMediumEmphasis, R.color.colorMediumEmphasis),
FILLED(R.dimen.ds_border_tiny, R.color.colorHighEmphasis, R.color.colorMediumEmphasis, R.color.colorHighEmphasis, R.color.colorMediumEmphasis),
DISABLED(R.dimen.ds_border_tiny, R.color.colorLowEmphasis, R.color.colorLowEmphasis, R.color.colorLowEmphasis, R.color.colorLowEmphasis),
FOCUSED(R.dimen.ds_border_emphasis, R.color.colorBrdNatYellow, R.color.colorMediumEmphasis, R.color.colorHighEmphasis, R.color.colorMediumEmphasis),
ERROR(R.dimen.ds_border_emphasis, R.color.colorBrdNatRed, R.color.colorBrdNatRed, R.color.colorHighEmphasis, R.color.colorBrdNatRed),
Expand All @@ -55,6 +56,11 @@ class TextFieldInput @JvmOverloads constructor(
resetLayoutState()
}

val editTextView: EditText
get() {
return inputValue
}

var inputType: Int = EditorInfo.TYPE_CLASS_TEXT
set(value) {
field = value
Expand Down Expand Up @@ -93,6 +99,7 @@ class TextFieldInput @JvmOverloads constructor(
set(value) {
field = value
inputValue.setText(value)
resetLayoutState()
}
get() {
return inputValue.text.toString()
Expand Down Expand Up @@ -165,6 +172,7 @@ class TextFieldInput @JvmOverloads constructor(
else -> {
if (!isEnabled) LayoutState.DISABLED
else if (inputValue.isFocused) LayoutState.FOCUSED
else if (inputValue.text.isNotEmpty()) LayoutState.FILLED
else LayoutState.DEFAULT
}
}
Expand Down
Loading

0 comments on commit 7fd025c

Please sign in to comment.