You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I see from the validator that the enclosing class must have exactly one constructor with no parameters here.
Couldn't this be relaxed to have at least one constructor with no parameters?
I mean, could that function be converted to something like this?
funvalidateEnclosingClass(enclosingClass:XTypeElement?) {
if (enclosingClass ==null) returnval hasEmptyConstructor = enclosingClass.getConstructors().any { constructor->constructor.parameters.isEmpty() }
if (!hasEmptyConstructor) {
throwShowkaseProcessorException(
"Only classes that have at least one constructor with no parameters can "+"hold a @Composable function that's annotated with the "+"@${ShowkaseComposable::class.java.simpleName}/@Preview annotation",
enclosingClass,
)
}
}
The text was updated successfully, but these errors were encountered:
francescocervone
changed the title
Impossible to use @ShowkaseColor or @ShowkaseTypography on objects' fields that have a constructor with no parameters
Impossible to use @ShowkaseColor or @ShowkaseTypography on objects' fields that have a constructor with no parameters
Feb 21, 2024
francescocervone
changed the title
Impossible to use @ShowkaseColor or @ShowkaseTypography on objects' fields that have a constructor with no parameters
Impossible to use @ShowkaseColor or @ShowkaseTypography on objects' fields that have a constructor with no parameters
Feb 21, 2024
@francescocervone Yeah I can see this being useful. I worry that it might end up impacting the preview itself but maybe that's acceptable. Can you talk a bit more about your use case. What does the enclosing class look like in your case?
Yes, we have a class for the Typography that depends on the colors, but it might have a default value which is overridden when the theme is applied.
Basically we have the colors:
interfaceTypography {
val title:TextStyleval body:TextStyle
}
classDefaultTypography(privatevalcolors:Colors = LightColors): Typography {
// we'd like to have @ShowkaseTypography here but we can'toverrideval title:TextStyle=// something// we'd like to have @ShowkaseTypography here but we can'toverrideval body:TextStyle=// something
}
Technically, Showkase would be able to instantiate DefaultTypography because it has at least one empty constructor.
I see from the validator that the enclosing class must have exactly one constructor with no parameters here.
Couldn't this be relaxed to have at least one constructor with no parameters?
I mean, could that function be converted to something like this?
The text was updated successfully, but these errors were encountered: