@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(); } };
@OnCreateLayout static Component onCreateLayout(ComponentContext c, @State boolean left) { return Column.create(c) .alignItems(left ? YogaAlign.FLEX_START : YogaAlign.FLEX_END) .child( Row.create(c) .heightDip(40) .widthDip(40) .backgroundColor(Color.parseColor("#ee1111")) .transitionKey("red") .build()) .child( Row.create(c) .heightDip(40) .widthDip(40) .backgroundColor(Color.parseColor("#1111ee")) .transitionKey("blue") .build()) .child( Row.create(c) .heightDip(40) .widthDip(40) .backgroundColor(Color.parseColor("#11ee11")) .transitionKey("green") .build()) .clickHandler(LeftRightBlocksSequenceComponent.onClick(c)) .build(); }
Row.create(c) .heightDip(40) .widthDip(40) .backgroundColor(Color.parseColor("#ee1111")) .transitionKey("red") Row.create(c) .heightDip(40) .widthDip(40) .backgroundColor(Color.parseColor("#1111ee")) .transitionKey("blue") Row.create(c) .heightDip(40) .widthDip(40) .backgroundColor(Color.parseColor("#11ee11")) .transitionKey("green") Row.create(c) .heightDip(40) .widthDip(40) .backgroundColor(Color.BLACK) .transitionKey("black")
Row.create(c) .heightDip(40) .widthDip(40) .backgroundColor(Color.parseColor("#ee1111")) .transitionKey(TRANSITION_KEY_RED) Row.create(c) .heightDip(40) .widthDip(40) .backgroundColor(Color.parseColor("#1111ee")) .transitionKey(TRANSITION_KEY_BLUE) Row.create(c) .heightDip(40) .widthDip(40) .backgroundColor(Color.parseColor("#11ee11")) .transitionKey(TRANSITION_KEY_GREEN)
.child( Row.create(c) .widthDip(expanded ? 48 : 24) .marginDip(YogaEdge.LEFT, 8) .paddingDip(YogaEdge.ALL, 3)
private static Component affectedChildren(ComponentContext c, boolean flag1) { return Row.create(c) .transitionKey(TRANSITION_KEY_CONTAINER_1) .transitionKeyType(Transition.TransitionKeyType.GLOBAL) .heightDip(60 + 2 * 8) .widthDip((3 * 60) * (flag1 ? 0.5f : 1) + 4 * 8) .paddingDip(YogaEdge.ALL, 8) .backgroundColor(Color.YELLOW) .child( Column.create(c) .transitionKey(TRANSITION_KEY_CHILD_1_1) .transitionKeyType(Transition.TransitionKeyType.GLOBAL) .flex(1) .backgroundColor(Color.RED)) .child( Column.create(c) .transitionKey(TRANSITION_KEY_CHILD_1_2) .transitionKeyType(Transition.TransitionKeyType.GLOBAL) .flex(1) .backgroundColor(Color.RED) .marginDip(YogaEdge.HORIZONTAL, 8)) .child( Column.create(c) .flex(1) .transitionKey(TRANSITION_KEY_CHILD_1_3) .transitionKeyType(Transition.TransitionKeyType.GLOBAL) .backgroundColor(Color.RED)) .clickHandler(BoundsAnimationComponent.onFirstComponentClick(c)) .build(); }
private static Component affectedSiblings(ComponentContext c, boolean flag2) { return Row.create(c) .transitionKey(TRANSITION_KEY_CONTAINER_2) .transitionKeyType(Transition.TransitionKeyType.GLOBAL) .heightDip(60 + 2 * 8) .widthDip(3 * 60 + 3 * 8) .paddingDip(YogaEdge.ALL, 8) .backgroundColor(Color.LTGRAY) .child( Column.create(c) .transitionKey(TRANSITION_KEY_CHILD_2_1) .transitionKeyType(Transition.TransitionKeyType.GLOBAL) .flex(1) .backgroundColor(Color.RED)) .child( Column.create(c) .transitionKey(TRANSITION_KEY_CHILD_2_2) .transitionKeyType(Transition.TransitionKeyType.GLOBAL) .flex(flag2 ? 1 : 2) .backgroundColor(Color.YELLOW) .marginDip(YogaEdge.LEFT, 8)) .clickHandler(BoundsAnimationComponent.onSecondComponentClick(c)) .build(); }
@OnEvent(RenderEvent.class) static RenderInfo onRender(ComponentContext c, @FromEvent Object model, @FromEvent int index) { return ComponentRenderInfo.create() .component( Row.create(c) .justifyContent(YogaJustify.CENTER) .widthDip(120) .heightDip(120) .backgroundColor((int) model) .child( Text.create(c) .textSizeSp(20) .textColor(Color.LTGRAY) .text(Integer.toString(index)) .verticalGravity(VerticalGravity.CENTER))) .build(); }
static Component.Builder createSenderTile(ComponentContext c) { return Row.create(c) .marginDip(YogaEdge.ALL, 5) .alignSelf(YogaAlign.CENTER) .widthDip(55) .heightDip(55) .flexShrink(0) .background(getCircle(c)); }
@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(); }