From 0805b6ed92f05f938f0b4baf996902076e72a0fd Mon Sep 17 00:00:00 2001 From: Louis CAD Date: Fri, 6 Aug 2021 11:11:11 +0200 Subject: [PATCH] Simplify styledColor --- .../kotlin/splitties/resources/ColorResources.kt | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/modules/resources/src/androidMain/kotlin/splitties/resources/ColorResources.kt b/modules/resources/src/androidMain/kotlin/splitties/resources/ColorResources.kt index d4ddb401..67cade89 100644 --- a/modules/resources/src/androidMain/kotlin/splitties/resources/ColorResources.kt +++ b/modules/resources/src/androidMain/kotlin/splitties/resources/ColorResources.kt @@ -69,12 +69,9 @@ inline fun appColorSL(@ColorRes colorRes: Int) = appCtx.colorSL(colorRes) @ColorInt fun Context.styledColor(@AttrRes attr: Int): Int = withResolvedThemeAttribute(attr) { - when (type) { - in TypedValue.TYPE_FIRST_COLOR_INT..TypedValue.TYPE_LAST_COLOR_INT -> data - TypedValue.TYPE_STRING -> { - if (string.startsWith("res/color/")) color(resourceId) - else illegalArg(unexpectedThemeAttributeTypeErrorMessage(expectedKind = "color")) - } + when { + type in TypedValue.TYPE_FIRST_COLOR_INT..TypedValue.TYPE_LAST_COLOR_INT -> data + type == TypedValue.TYPE_STRING && string.startsWith("res/color/") -> color(resourceId) else -> illegalArg(unexpectedThemeAttributeTypeErrorMessage(expectedKind = "color")) } }