Skip to content
This repository has been archived by the owner on Nov 5, 2024. It is now read-only.

Commit

Permalink
Add Vue icons
Browse files Browse the repository at this point in the history
  • Loading branch information
ILIYANGERMANOV committed May 1, 2022
1 parent f1d8b32 commit d8066c4
Show file tree
Hide file tree
Showing 3 changed files with 402 additions and 108 deletions.
33 changes: 21 additions & 12 deletions app/src/main/java/com/ivy/wallet/ui/theme/components/ItemIcon.kt
Original file line number Diff line number Diff line change
Expand Up @@ -237,17 +237,17 @@ fun getCustomIconId(
style = iconStyle,
newFormat = false
)
}
} ?: fallbackToNewIconFormat(
context = context,
iconName = iconName,
iconStyle = iconStyle
)
} catch (e: Exception) {
fallbackToNewIconFormat(
context = context, iconName = iconName
)?.let { nonNullId ->
IconInfo(
iconId = nonNullId,
style = iconStyle,
newFormat = true
)
}
context = context,
iconName = iconName,
iconStyle = iconStyle
)
}
}
}
Expand All @@ -263,22 +263,31 @@ enum class IconStyle {
L, M, S, UNKNOWN
}

@DrawableRes
fun fallbackToNewIconFormat(
iconStyle: IconStyle,
context: Context,
iconName: String?,
): Int? {
): IconInfo? {
return iconName?.let {
try {
val iconNameNormalized = iconName
.replace(" ", "")
.trim()
.toLowerCaseLocal()
context.resources.getIdentifier(

val iconId = context.resources.getIdentifier(
iconNameNormalized,
"drawable",
context.packageName
).takeIf { it != 0 }

iconId?.let { nonNullId ->
IconInfo(
iconId = nonNullId,
style = iconStyle,
newFormat = true
)
}
} catch (e: Exception) {
null
}
Expand Down
Loading

0 comments on commit d8066c4

Please sign in to comment.