-
-
Save dilrajsingh1997/95f76326ad9a90f47cc8988a44c4a1c2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
composeArgumentType = when (resolvedClassDeclarationName) { | |
"Boolean" -> ComposeArgumentType.BOOLEAN | |
"String" -> ComposeArgumentType.STRING | |
"Float" -> ComposeArgumentType.FLOAT | |
"Int" -> ComposeArgumentType.INT | |
"Long" -> ComposeArgumentType.LONG | |
"IntArray" -> ComposeArgumentType.INT_ARRAY | |
"BooleanArray" -> ComposeArgumentType.BOOLEAN_ARRAY | |
"LongArray" -> ComposeArgumentType.LONG_ARRAY | |
"FloatArray" -> ComposeArgumentType.FLOAT_ARRAY | |
else -> when { | |
resolvedClassQualifiedName == "kotlin.collections.ArrayList" -> { | |
var isParcelable = false | |
var isSerializable = false | |
for (argument in typeArguments) { | |
val resolvedArgument = argument.type?.resolve() | |
if ((resolvedArgument?.declaration as? KSClassDeclaration)?.superTypes?.map { it.toString() } | |
?.contains("Parcelable") == true) { | |
isParcelable = true | |
} | |
if ((resolvedArgument?.declaration as? KSClassDeclaration)?.superTypes?.map { it.toString() } | |
?.contains("Serializable") == true) { | |
isSerializable = true | |
} | |
} | |
if (isParcelable) { | |
ComposeArgumentType.PARCELABLE_ARRAY | |
} else if (isSerializable) { | |
ComposeArgumentType.SERIALIZABLE | |
} else { | |
logger.error( | |
"invalid property type, cannot pass it in bundle", | |
property | |
) | |
return null | |
} | |
} | |
(resolvedType.declaration as KSClassDeclaration).superTypes.map { it.toString() } | |
.contains("Parcelable") -> { | |
ComposeArgumentType.PARCELABLE | |
} | |
(resolvedType.declaration as KSClassDeclaration).superTypes.map { it.toString() } | |
.contains("Serializable") -> { | |
ComposeArgumentType.SERIALIZABLE | |
} | |
else -> { | |
logger.error( | |
"invalid property type, cannot pass it in bundle", | |
property | |
) | |
return null | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment