Fix Icons not displayed in catalog app as their accessor changed from field to method
This commit is contained in:
parent
19a14fe9d7
commit
7dcf1fb321
1 changed files with 13 additions and 9 deletions
|
@ -24,19 +24,23 @@ fun LazyGridScope.iconItems() {
|
|||
}
|
||||
|
||||
private inline fun <reified T> LazyGridScope.getIconsFor(icons: T) {
|
||||
for (field in T::class.java.declaredFields) {
|
||||
if (field.name in exclusions) continue
|
||||
item {
|
||||
field.isAccessible = true
|
||||
IconItem(
|
||||
name = field.name.replaceFirstChar { it.uppercase() },
|
||||
imageVector = field.get(icons) as ImageVector,
|
||||
)
|
||||
for (method in T::class.java.methods) {
|
||||
if (exclusions.contains(method.name)) {
|
||||
continue
|
||||
} else if (method.name.startsWith("get")) {
|
||||
item {
|
||||
method.isAccessible = true
|
||||
val imageVector = method.invoke(icons) as ImageVector
|
||||
IconItem(
|
||||
name = method.name.replaceFirst("get", ""),
|
||||
imageVector = imageVector,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private val exclusions = listOf("\$stable", "INSTANCE")
|
||||
private val exclusions = listOf("getClass")
|
||||
|
||||
@Composable
|
||||
private fun IconItem(
|
||||
|
|
Loading…
Reference in a new issue