Fix Icons not displayed in catalog app as their accessor changed from field to method

This commit is contained in:
Wolf-Martell Montwé 2023-11-07 18:08:55 +01:00
parent 19a14fe9d7
commit 7dcf1fb321
No known key found for this signature in database
GPG key ID: 6D45B21512ACBF72

View file

@ -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(