@Test public void testRootHostClickableUnmount() { final LithoView lithoView = mountComponent( mContext, Column.create(mContext) .clickHandler(mContext.newEventHandler(1)) .longClickHandler(mContext.newEventHandler(2)) .child(TestDrawableComponent.create(mContext)) .build(), true); assertThat(lithoView.isClickable()).isTrue(); assertThat(lithoView.isLongClickable()).isTrue(); lithoView.unmountAllItems(); assertThat(lithoView.isClickable()).isFalse(); assertThat(lithoView.isLongClickable()).isFalse(); } }
@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(); }
@Override protected Component onCreateLayout(final ComponentContext c) { return create(c) .child(TestDrawableComponent.create(c)) .clickHandler(c.newEventHandler(1)) .viewTags(new SparseArray<>()) .build(); } };
@Override protected Component onCreateLayout(ComponentContext c) { return create(c) .duplicateParentState(true) .clickHandler(c.newEventHandler(1)) .child( create(c) .duplicateParentState(false) .child(TestDrawableComponent.create(c).duplicateParentState(true))) .child( create(c) .duplicateParentState(true) .child(TestDrawableComponent.create(c).duplicateParentState(true))) .child( create(c) .clickHandler(c.newEventHandler(2)) .child(TestDrawableComponent.create(c).duplicateParentState(true))) .child( create(c) .clickHandler(c.newEventHandler(3)) .child(TestDrawableComponent.create(c).duplicateParentState(false))) .child( create(c) .clickHandler(c.newEventHandler(3)) .backgroundColor(RED) .foregroundColor(RED)) .child(create(c).backgroundColor(BLUE).foregroundColor(BLUE)) .build(); } };
@OnCreateLayout static Component onCreateLayout( ComponentContext c, @Prop String messageText, @Prop String timestamp, @Prop(optional = true) boolean seen, @State Boolean expanded) { final boolean isExpanded = expanded == null ? false : expanded; return Column.create(c) .paddingDip(YogaEdge.TOP, 8) .transitionKey(TRANSITION_MSG_PARENT) .transitionKeyType(Transition.TransitionKeyType.GLOBAL) .clickHandler(ExpandableElementMe.onClick(c)) .child(ExpandableElementUtil.maybeCreateTopDetailComponent(c, isExpanded, timestamp)) .child( Column.create(c) .transitionKey(ExpandableElementUtil.TRANSITION_TEXT_MESSAGE_WITH_BOTTOM) .transitionKeyType(Transition.TransitionKeyType.GLOBAL) .child( Row.create(c) .justifyContent(YogaJustify.FLEX_END) .paddingDip(YogaEdge.START, 75) .paddingDip(YogaEdge.END, 5) .child(createMessageContent(c, messageText))) .child(ExpandableElementUtil.maybeCreateBottomDetailComponent(c, isExpanded, seen))) .build(); }
@OnCreateLayout public static Component onCreateLayout( ComponentContext c, @Prop String message, @Prop Throwable throwable) { Log.e(TAG, message, throwable); return Column.create(c) .backgroundColor(DARK_RED_FRAME) .paddingDip(YogaEdge.ALL, 1f) .child( Text.create(c) .backgroundColor(LIGHT_RED_BACKGROUND) .paddingDip(YogaEdge.ALL, 4f) .textSizeDip(16f) .text(message)) .child( Text.create(c) .backgroundColor(LIGHT_RED_BACKGROUND) .paddingDip(YogaEdge.ALL, 4f) .textSizeDip(12f) .textColor(LIGHT_GRAY_TEXT) .typeface(Typeface.MONOSPACE) .text(StacktraceHelper.formatStacktrace(throwable))) .clickHandler(DebugErrorComponent.onClick(c)) .build(); }
@Override protected Component onCreateLayout(final ComponentContext c) { return Column.create(c) .child( Column.create(c) .child( TestSizeDependentComponent.create(c) .clickHandler(clickHandler1) .longClickHandler(longClickHandler1) .touchHandler(touchHandler1) .interceptTouchHandler(interceptTouchHandler1) .focusChangeHandler(focusChangedHandler1)) .clickHandler(clickHandler2) .longClickHandler(longClickHandler2) .touchHandler(touchHandler2) .interceptTouchHandler(interceptTouchHandler2) .focusChangeHandler(focusChangedHandler2)) .clickHandler(clickHandler3) .longClickHandler(longClickHandler3) .touchHandler(touchHandler3) .interceptTouchHandler(interceptTouchHandler3) .focusChangeHandler(focusChangedHandler3) .build(); } };
@Override protected Component onCreateLayout(final ComponentContext c) { return Column.create(c) .child( Column.create(c) .child( TestDrawableComponent.create(c) .clickHandler(clickHandler1) .longClickHandler(longClickHandler1) .touchHandler(touchHandler1) .interceptTouchHandler(interceptTouchHandler1) .focusChangeHandler(focusChangedHandler1)) .clickHandler(clickHandler2) .longClickHandler(longClickHandler2) .touchHandler(touchHandler2) .interceptTouchHandler(interceptTouchHandler2) .focusChangeHandler(focusChangedHandler2)) .clickHandler(clickHandler3) .longClickHandler(longClickHandler3) .touchHandler(touchHandler3) .interceptTouchHandler(interceptTouchHandler3) .focusChangeHandler(focusChangedHandler3) .build(); } };
@OnCreateLayout static Component onCreateLayout( ComponentContext c, @Prop String messageText, @Prop String timestamp, @Prop(optional = true) boolean seen, @State Boolean expanded) { final boolean isExpanded = expanded == null ? false : expanded; return Column.create(c) .paddingDip(YogaEdge.TOP, 8) .transitionKey(ExpandableElementUtil.TRANSITION_MSG_PARENT) .transitionKeyType(Transition.TransitionKeyType.GLOBAL) .clickHandler(ExpandableElementOther.onClick(c)) .child(ExpandableElementUtil.maybeCreateTopDetailComponent(c, isExpanded, timestamp)) .child( Column.create(c) .transitionKey(ExpandableElementUtil.TRANSITION_TEXT_MESSAGE_WITH_BOTTOM) .transitionKeyType(Transition.TransitionKeyType.GLOBAL) .child( Row.create(c) .paddingDip(YogaEdge.END, 5) .child(createSenderTile(c)) .child(createMessageContent(c, messageText))) .child(ExpandableElementUtil.maybeCreateBottomDetailComponent(c, isExpanded, seen))) .build(); }
@Override protected Component onCreateLayout(final ComponentContext c) { return create(c) .child(TestDrawableComponent.create(c).widthPx(100).heightPx(10)) .child( Row.create(c) .viewTag(new Object()) .child(TestDrawableComponent.create(c).widthPx(20).heightPx(90)) .child( create(c) .child(TestDrawableComponent.create(c)) .clickHandler(c.newEventHandler(1)) .widthPx(50) .heightPx(50) .touchExpansionPx(YogaEdge.ALL, 5))) .build(); } };
@Override protected Component onCreateLayout(final ComponentContext c) { return create(c) .child( create(c) .child(TestDrawableComponent.create(c)) .clickHandler(c.newEventHandler(1))) .build(); } };
@OnCreateLayout static Component onCreateLayout(ComponentContext c, @State boolean state) { final int color = state ? Color.RED : Color.LTGRAY; final String key = state ? "red" : "gray"; return Column.create(c) .child(buildRow(c, color, key + 0)) .child(buildRow(c, color, key + 1)) .paddingDip(YogaEdge.ALL, 8) .clickHandler(RTAnimationComponent.onClick(c)) .build(); }
@OnCreateLayout static Component onCreateLayout(ComponentContext c, @State int state) { final boolean expanded1 = state == 1 || state == 2; final boolean expanded2 = state == 2 || state == 3; return Column.create(c) .paddingDip(YogaEdge.ALL, 8) .child(Row.create(c).marginDip(YogaEdge.TOP, 8).child(buildComment1(c, expanded1))) .child(Row.create(c).marginDip(YogaEdge.TOP, 16).child(buildComment2(c, expanded2))) .clickHandler(AnimatedBadge.onClick(c)) .build(); }
@Override protected Component onCreateLayout(ComponentContext c) { return create(c) .clickHandler(c.newEventHandler(1)) .child(TestDrawableComponent.create(c)) .child(TestDrawableComponent.create(c)) .build(); } });
@Override protected Component onCreateLayout(ComponentContext c) { return create(c) .clickHandler(c.newEventHandler(1)) .child(TestDrawableComponent.create(c)) .child(TestDrawableComponent.create(c)) .build(); } });
@Override protected Component onCreateLayout(ComponentContext c) { return create(c) .clickHandler(c.newEventHandler(1)) .child(TestDrawableComponent.create(c)) .build(); } });
@Override protected Component onCreateLayout(ComponentContext c) { return create(c) .child( create(c) .clickHandler(c.newEventHandler(1)) .child(TestViewComponent.create(c))) .build(); } });
@Override protected Component onCreateLayout(ComponentContext c) { return create(c) .clickHandler(c.newEventHandler(1)) .child(TestDrawableComponent.create(c)) .child(TestDrawableComponent.create(c)) .build(); } });
@Override protected Component onCreateLayout(ComponentContext c) { return create(c) .clickHandler(c.newEventHandler(1)) .child(TestDrawableComponent.create(c)) .child(TestDrawableComponent.create(c)) .build(); } });
@OnCreateLayout static Component onCreateLayout( ComponentContext c, @Prop final DemoListActivity.DemoListDataModel model) { return Column.create(c) .paddingDip(ALL, 16) .child(Text.create(c).text(model.name).textSizeSp(18).build()) .clickHandler(DemoListItemComponent.onClick(c)) .build(); }