@Override protected ComponentLayout resolve(ComponentContext c) { if (delegate == null) { return ComponentContext.NULL_LAYOUT; } return c.newLayoutBuilder(delegate, 0, 0); }
@Override protected ComponentLayout resolve(ComponentContext c) { return c.newLayoutBuilder(0, 0); }
/** * Create a {@link InternalNode} from an existing {@link Component}. * * @param c The context to create the layout within * @param component The component to render within this layout * @param defStyleAttr The id of the attribute to use for default style attributes * @param defStyleRes The id of the style to use for layout attributes * @return A layout builder */ static InternalNode create( ComponentContext c, Component component, @AttrRes int defStyleAttr, @StyleRes int defStyleRes) { if (component == null) { return ComponentContext.NULL_LAYOUT; } return c.newLayoutBuilder(component, defStyleAttr, defStyleRes); }
@Override public InternalNode newLayoutBuilder( Component component, @AttrRes int defStyleAttr, @StyleRes int defStyleRes) { if (component.canResolve()) { return super.newLayoutBuilder(component, defStyleAttr, defStyleRes); } final InternalNode node = ComponentsPools.acquireInternalNode(this); component.updateInternalChildState(this); node.appendComponent(new TestComponent(component)); return node; }
@Override protected ComponentLayout resolve(ComponentContext c) { InternalNode node = c.newLayoutBuilder(0, 0) .flexDirection(reverse ? YogaFlexDirection.COLUMN_REVERSE : YogaFlexDirection.COLUMN); if (alignItems != null) { node.alignItems(alignItems); } if (alignContent != null) { node.alignContent(alignContent); } if (justifyContent != null) { node.justifyContent(justifyContent); } if (wrap != null) { node.wrap(wrap); } if (children != null) { boolean splitLayout = false; if (SplitBackgroundLayoutConfiguration.isSplitLayoutEnabled(this)) { splitLayout = SplitLayoutResolver.resolveLayouts(c, children, node); } if (!splitLayout) { for (Component child : children) { node.child(child); } } } return node; }
@Override protected ComponentLayout resolve(ComponentContext c) { InternalNode node = c.newLayoutBuilder(0, 0) .flexDirection(reverse ? YogaFlexDirection.ROW_REVERSE : YogaFlexDirection.ROW); if (alignItems != null) { node.alignItems(alignItems); } if (alignContent != null) { node.alignContent(alignContent); } if (justifyContent != null) { node.justifyContent(justifyContent); } if (wrap != null) { node.wrap(wrap); } if (children != null) { boolean splitLayout = false; if (SplitBackgroundLayoutConfiguration.isSplitLayoutEnabled(this)) { splitLayout = SplitLayoutResolver.resolveLayouts(c, children, node); } if (!splitLayout) { for (Component child : children) { node.child(child); } } } return node; }
@Test public void testNewLayoutBuilderUsesWillRenderResult() { ComponentContext c = new ComponentContext(application); final Component component = TestLayoutComponent.create(c, 0, 0, true, true, true, false).build(); Component.willRender(c, component); final InternalNode cachedLayout = component.getLayoutCreatedInWillRenderForTesting(); assertThat(cachedLayout).isNotNull(); InternalNode result = c.newLayoutBuilder(component, 0, 0); assertThat(result).isEqualTo(cachedLayout); assertThat(component.getLayoutCreatedInWillRenderForTesting()).isNull(); }