@OnCreateLayout static ComponentLayout onCreateLayout( ComponentContext c, @Prop(resType = STRING) String title) { return Text.create(c) .text(title) .textStyle(BOLD) .textSizeDip(24) .withLayout().flexShrink(0) .backgroundColor(0xDDFFFFFF) .positionType(YogaPositionType.ABSOLUTE) .positionDip(YogaEdge.BOTTOM, 4) .positionDip(YogaEdge.LEFT, 4) .paddingDip(YogaEdge.HORIZONTAL, 6) .build(); }
@OnCreateLayout static ComponentLayout onCreateLayout( ComponentContext c) { return Row.create(c) .backgroundColor(0xDDFFFFFF) .positionType(YogaPositionType.ABSOLUTE) .positionDip(YogaEdge.RIGHT, 4) .positionDip(YogaEdge.TOP, 4) .paddingDip(YogaEdge.ALL, 2) .child(FavouriteButton.create(c)) .build(); }
@OnCreateLayout static ComponentLayout onCreateLayout(ComponentContext c, @Prop final RecyclerBinder recyclerBinder) { return Recycler.create(c) .binder(recyclerBinder) .flexShrink(0) .paddingDip(YogaEdge.TOP, 8) .testKey(MAIN_SCREEN) .buildWithLayout(); }
@OnCreateLayout static ComponentLayout onCreateLayout( ComponentContext c, @Prop final Decade decade) { return Row.create(c) .alignItems(YogaAlign.CENTER) .paddingDip(YogaEdge.ALL, 16) .child( Row.create(c) .heightPx(1) .backgroundColor(0xFFAAAAAA) .flex(1)) .child( Text.create(c) .text(String.valueOf(decade.year)) .textSizeDip(14) .textColor(0xFFAAAAAA) .withLayout() .marginDip(YogaEdge.HORIZONTAL, 10) .flex(0)) .child( Row.create(c) .heightPx(1) .backgroundColor(0xFFAAAAAA) .flex(1)) .backgroundColor(0xFFFAFAFA) .build(); }
@OnCreateLayout static ComponentLayout onCreateLayout( ComponentContext c, @Prop(resType = STRING) String text) { return Column.create(c).flexShrink(0).alignContent(YogaAlign.FLEX_START) .paddingDip(YogaEdge.ALL, 8) .child( Text.create(c) .text(text) .textSizeDip(14) .textColor(GRAY) .textStyle(ITALIC)) .build(); }
@OnCreateLayout static ComponentLayout onCreateLayout( ComponentContext c, @Prop final RecyclerBinder recyclerBinder) { return Recycler.create(c) .binder(recyclerBinder) .withLayout().flexShrink(0) .paddingDip(YogaEdge.TOP, 8) .testKey(MAIN_SCREEN) .build(); }
private void updatePadding() { for (int spacingType = Spacing.LEFT; spacingType <= Spacing.ALL; spacingType++) { if (spacingType == Spacing.LEFT || spacingType == Spacing.RIGHT || spacingType == Spacing.START || spacingType == Spacing.END) { if (YogaConstants.isUndefined(mPadding[spacingType]) && YogaConstants.isUndefined(mPadding[Spacing.HORIZONTAL]) && YogaConstants.isUndefined(mPadding[Spacing.ALL])) { mYogaNode.setPadding(YogaEdge.fromInt(spacingType), mDefaultPadding.getRaw(spacingType)); continue; } } else if (spacingType == Spacing.TOP || spacingType == Spacing.BOTTOM) { if (YogaConstants.isUndefined(mPadding[spacingType]) && YogaConstants.isUndefined(mPadding[Spacing.VERTICAL]) && YogaConstants.isUndefined(mPadding[Spacing.ALL])) { mYogaNode.setPadding(YogaEdge.fromInt(spacingType), mDefaultPadding.getRaw(spacingType)); continue; } } else { if (YogaConstants.isUndefined(mPadding[spacingType])) { mYogaNode.setPadding(YogaEdge.fromInt(spacingType), mDefaultPadding.getRaw(spacingType)); continue; } } if (mPaddingIsPercent[spacingType]) { mYogaNode.setPaddingPercent(YogaEdge.fromInt(spacingType), mPadding[spacingType]); } else { mYogaNode.setPadding(YogaEdge.fromInt(spacingType), mPadding[spacingType]); } } }
public void setMargin(int spacingType, float margin) { mYogaNode.setMargin(YogaEdge.fromInt(spacingType), margin); }
public void setMarginPercent(int spacingType, float percent) { mYogaNode.setMarginPercent(YogaEdge.fromInt(spacingType), percent); }
public void setMarginAuto(int spacingType) { mYogaNode.setMarginAuto(YogaEdge.fromInt(spacingType)); }
public final float getPadding(int spacingType) { return mYogaNode.getLayoutPadding(YogaEdge.fromInt(spacingType)); }
public final YogaValue getStylePadding(int spacingType) { return mYogaNode.getPadding(YogaEdge.fromInt(spacingType)); }
public void setBorder(int spacingType, float borderWidth) { mYogaNode.setBorder(YogaEdge.fromInt(spacingType), borderWidth); }
public void setPosition(int spacingType, float position) { mYogaNode.setPosition(YogaEdge.fromInt(spacingType), position); }
public void setPositionPercent(int spacingType, float percent) { mYogaNode.setPositionPercent(YogaEdge.fromInt(spacingType), percent); }