PropDefault

annotation class PropDefault

PropDefault can be used for setting the default value of an optional Prop in a LayoutSpec or MountSpec. The field must be a constant (i.e. static final) with the same name and type as the Prop.

For example:

@LayoutSpec
class SomeSpec {

 @PropDefault
  static final String name = "John Doe";  // default value for name

 @OnCreateLayout
  static Component onCreateLayout(
    ComponentContext c,
   @Prop(optional = true) String name) {

    return Text.create(c)
      .text(title.getTitle())
      .textSizeSp(16)
      .marginDip(YogaEdge.BOTTOM, 4)
      .build();
  }
}

Functions

Link copied to clipboard
abstract fun annotationType(): Class<out Annotation>
Link copied to clipboard
abstract fun equals(p: Any): Boolean
Link copied to clipboard
abstract fun hashCode(): Int
Link copied to clipboard
abstract fun resId(): Int
Sets an Android resource as the default value of the Prop.
Link copied to clipboard
abstract fun resType(): ResType
Declares that the default value must be a resource of the specified ResType.
Link copied to clipboard
abstract fun toString(): String