@Override protected Component onCreateLayoutWithSizeSpec( ComponentContext c, int widthSpec, int heightSpec) { return Row.create(c) .widthDip(View.MeasureSpec.getSize(widthSpec)) .heightDip(View.MeasureSpec.getSize(heightSpec)) .build(); } };
@Override protected Component onCreateLayout(ComponentContext c) { return Row.create(c) .layoutDirection(RTL) .child( Row.create(c) .layoutDirection(LTR) .wrapInView() .child(Wrapper.create(c).delegate(child1).widthPx(10).heightPx(10)) .child(Wrapper.create(c).delegate(child2).widthPx(10).heightPx(10))) .build(); } },
@Override @OnCreateLayout protected Component onCreateLayout(ComponentContext c) { return Row.create(c) .marginPx(YogaEdge.LEFT, MARGIN_LEFT) .marginPx(YogaEdge.TOP, MARGIN_TOP) .child( TestDrawableComponent.create(c) .key(KEY_ANCHOR) .widthPx(ANCHOR_WIDTH) .heightPx(ANCHOR_HEIGHT)) .build(); } };
private static Component buildRow(ComponentContext c, int color, String key) { return Row.create(c) .child(buildCell(c, color, key + 0)) .child(buildCell(c, color, key + 1)) .child(buildCell(c, color, key + 2)) .build(); }
@Override protected Component onCreateLayout(ComponentContext c) { return Row.create(c).build(); } };
@OnCreateLayout public static Component onCreateLayout( ComponentContext c, @Prop String s, @Prop Component child, @Prop(resType = ResType.DIMEN_SIZE) float size, @Prop(optional = true) int i) { return Row.create(c).build(); } }
@Override protected Component onCreateLayout(ComponentContext c) { return Row.create(c) .child(Row.create(c).transitionKey("test").transitionKeyType(Transition.TransitionKeyType.GLOBAL)) .child(Row.create(c).transitionKey("test").transitionKeyType(Transition.TransitionKeyType.GLOBAL)) .build(); } };
@OnCreateLayout static Component onCreateLayout( ComponentContext c, @Prop(resType = ResType.DIMEN_SIZE) int radius, @Prop(resType = ResType.COLOR) int color) { final int dim = 2 * radius; return Row.create(c) .heightPx(dim) .widthPx(dim) .background(buildRoundedRect(radius, color)) .build(); }
@Override protected Component onCreateLayout(ComponentContext c) { return Row.create(c) .layoutDirection(RTL) .child(Wrapper.create(c).delegate(child1).widthPx(10).heightPx(10)) .child(Wrapper.create(c).delegate(child2).widthPx(10).heightPx(10)) .build(); } },
@Override protected Component onCreateLayout(ComponentContext c) { return Row.create(c) .layoutDirection(LTR) .child(Wrapper.create(c).delegate(child1).widthPx(10).heightPx(10)) .child(Wrapper.create(c).delegate(child2).widthPx(10).heightPx(10)) .build(); } },
@Override protected Component onCreateLayout(ComponentContext c) { return Row.create(c) .layoutDirection(LTR) .child(Wrapper.create(c).delegate(child1).widthPx(10).heightPx(10)) .child(Wrapper.create(c).delegate(child2).widthPx(10).heightPx(10)) .build(); } },
@OnCreateLayout static Component onCreateLayout(ComponentContext c) { return Row.create(c) .child( Text.create(c) .textSizeSp(20) .text("This component has all borders specified to the same color + width")) .border( Border.create(c).color(YogaEdge.ALL, NiceColor.BLUE).widthDip(YogaEdge.ALL, 5).build()) .build(); } }
@Test public void testTransitionKeyMatcher() { final ComponentContext c = mComponentsRule.getContext(); final String key = "nocolusion"; final Component component = Row.create(c).child(Card.create(c).transitionKey(key).content(Column.create(c))).build(); assertThat(c, component) .has(subComponentWith(c, TestCard.matcher(c).transitionKey(key).build())); } }
@Override protected Component onCreateLayout(ComponentContext c) { return Row.create(c) .child(Row.create(c).transitionKey("test").transitionKeyType(Transition.TransitionKeyType.GLOBAL)) .child(Row.create(c).transitionKey("test2").transitionKeyType(Transition.TransitionKeyType.GLOBAL)) .build(); } };
@Override protected Component onCreateLayout(ComponentContext c) { return Row.create(c) .layoutDirection(RTL) .child( Row.create(c) .wrapInView() .child(Wrapper.create(c).delegate(child1).widthPx(10).heightPx(10)) .child(Wrapper.create(c).delegate(child2).widthPx(10).heightPx(10))) .build(); } },
@OnCreateLayout static Component onCreateLayout(ComponentContext c, @State boolean favourited) { return Row.create(c) .backgroundRes(favourited ? star_on : star_off) .widthDip(32) .heightDip(32) .clickHandler(FavouriteButton.onClick(c)) .build(); }
@Override protected Component onCreateLayout(ComponentContext c) { return Row.create(c) .layoutDirection(RTL) .child(Wrapper.create(c).delegate(child1).widthPx(10).heightPx(10)) .child(Wrapper.create(c).delegate(child2).widthPx(10).heightPx(10)) .build(); } },
@Override protected Component onCreateLayout(ComponentContext c) { return Row.create(c) .child(Wrapper.create(c).delegate(child1).widthPx(10).heightPx(10)) .child(Wrapper.create(c).delegate(child2).widthPx(10).heightPx(10)) .build(); } });
@OnCreateLayout static Component 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(); } }
@Override protected Component onCreateLayout(ComponentContext c) { return Row.create(c) .child(Row.create(c).transitionKey("test")) .transitionKeyType(Transition.TransitionKeyType.GLOBAL) .child(Row.create(c).transitionKey("test2")) .transitionKeyType(Transition.TransitionKeyType.GLOBAL) .build(); }