-
Notifications
You must be signed in to change notification settings - Fork 105
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Impossible to use @ShowkaseColor
or @ShowkaseTypography
on objects' fields that have a constructor with no parameters
#375
Comments
@ShowkaseTypography
on objects' fields that have a constructor with no parameters
@ShowkaseTypography
on objects' fields that have a constructor with no parameters@ShowkaseColor
or @ShowkaseTypography
on objects' fields that have a constructor with no parameters
@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. interface Colors {
val content: Color
val background: Color
}
class LightColors: Colors {
@ShowkaseColor
override val content: Color = // something
@ShowkaseColor
override val background: Color = // something
}
class DarkColors: Colors {
@ShowkaseColor
override val content: Color = // something
@ShowkaseColor
override val background: Color = // something
} Then we have the typography: interface Typography {
val title: TextStyle
val body: TextStyle
}
class DefaultTypography(private val colors: Colors = LightColors): Typography {
// we'd like to have @ShowkaseTypography here but we can't
override val title: TextStyle = // something
// we'd like to have @ShowkaseTypography here but we can't
override val body: TextStyle = // something
} Technically, Showkase would be able to instantiate |
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: