@Retention(value=CLASS) public @interface 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();
}
}
public abstract ResType resType
ResType
.
For example:
@LayoutSpec
class SomeSpec {
@PropDefault(resType = ResType.STRING, resId = R.string.default_name)
static final String name = null;
}
public abstract int resId
Prop
.