extend text input layout theming

Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
This commit is contained in:
Andy Scherzinger 2022-07-27 00:31:25 +02:00
parent 907386e9b7
commit 28aae00641
No known key found for this signature in database
GPG Key ID: 6CADC7E3523C308B

View File

@ -119,7 +119,8 @@ class ViewThemeUtils @Inject constructor(private val theme: ServerTheme) {
val colorStateList = ColorStateList( val colorStateList = ColorStateList(
arrayOf( arrayOf(
intArrayOf(android.R.attr.state_enabled), intArrayOf(android.R.attr.state_enabled),
intArrayOf(-android.R.attr.state_enabled)), intArrayOf(-android.R.attr.state_enabled)
),
intArrayOf(color, disabledColor) intArrayOf(color, disabledColor)
) )
button.setTextColor(colorStateList) button.setTextColor(colorStateList)
@ -212,8 +213,55 @@ class ViewThemeUtils @Inject constructor(private val theme: ServerTheme) {
fun colorTextInputLayout(textInputLayout: TextInputLayout) { fun colorTextInputLayout(textInputLayout: TextInputLayout) {
withElementColor(textInputLayout) { color -> withElementColor(textInputLayout) { color ->
textInputLayout.hintTextColor = ColorStateList.valueOf(color) // TODO calculate error color based on primary color, dark/light aware
val errorColor = Color.GRAY
textInputLayout.boxStrokeColor = color textInputLayout.boxStrokeColor = color
textInputLayout.setErrorIconTintList(
ColorStateList(
arrayOf(
intArrayOf(-android.R.attr.state_focused),
intArrayOf(android.R.attr.state_focused)
),
intArrayOf(
errorColor,
errorColor
)
)
)
textInputLayout.setErrorTextColor(
ColorStateList(
arrayOf(
intArrayOf(-android.R.attr.state_focused),
intArrayOf(android.R.attr.state_focused)
),
intArrayOf(
errorColor,
errorColor
)
)
)
textInputLayout.boxStrokeErrorColor =
ColorStateList(
arrayOf(
intArrayOf(-android.R.attr.state_focused),
intArrayOf(android.R.attr.state_focused)
),
intArrayOf(
errorColor,
errorColor
)
)
textInputLayout.defaultHintTextColor =
ColorStateList(
arrayOf(
intArrayOf(-android.R.attr.state_focused),
intArrayOf(android.R.attr.state_focused)
),
intArrayOf(
Color.GRAY,
color
)
)
} }
} }