Hey I am trying out redwood and I am a bit confuse...
# squarelibraries
m
Hey I am trying out redwood and I am a bit confused as to how to implement widget schemas
Copy code
@Widget(2)
data class Button(
    @Property(1)
    val type: ButtonType,
    @Property(2)
    val content: ButtonScope.() -> Unit
)

object ButtonScope

enum class ButtonType {
    Primary,
    Secondary,
    Tertiary,
}
Looks like when I add the ButtonType it breaks. If I use primitives (ie: a String) everything works as expected
j
Breaks how?
m
The build itself. It starts not finding imports etc. A bit weird.
Do I need to annotate the enum somehow?
j
It needs to live in a shared module that the schema, composables, and widget interfaces can all reference
m
oh, so i should create an ie: api module
j
Yep, precisely. I think that's what we call ours.
m
okay so something like
Copy code
- schema: contains stuff annotated with @widget
- compose: build schema into composables 
- api: contains models and enums used by the above so it's imported in both
one more question that's a bit unrelated. i noticed instead of enums you ofter use value classes (with ordinal). that is required for the protocol or is there any other reason?
j
It's just for extreme efficiency on our part. We want the overhead of the library to be as small as possible. I wouldn't bother for your own stuff unless it becomes a problem later on.
m
The trick worked 😄
kind of more related to kmm than redwood, but do you know why my kotlin.native import is in red? i am only building for jvm at the moment - just testing
j
Which kotlin plugin are you using to compile the generated sources?
m
multiplatform
im using jvm for the schema, and multiplatform for api, compose and widget
j
The JVM stdlib doesn't have that annotation, but the common one does. It should still compile though, it's just the IDE that is confused
m
yeah, everything compiles it looks like
thanks for the help!