@OnCreateLayout static ComponentLayout onCreateLayout(ComponentContext c, @Prop String title, @Prop RecyclerBinder recyclerBinder) { return Column.create(c) .child( Text.create(c) .text(title) .glyphWarming(true) .textSizeSp(16) .withLayout() .paddingDip(TOP, 8) .paddingDip(BOTTOM, 4) .heightDip(44) ) .paddingDip(LEFT, 8) .paddingDip(RIGHT, 8) .child( Recycler.create(c) .hasFixedSize(true) .binder(recyclerBinder) ) .build(); }
@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(); }
public static void initialize(Context context) { final ComponentContext c = new ComponentContext(context); final RecyclerBinder glideRecyclerBinder = new RecyclerBinder( c, 4.0f, new LinearLayoutInfo(c, OrientationHelper.VERTICAL, false)); DataModel.populateBinderWithSampleDataForGlide(glideRecyclerBinder, c); demoModels = new LinkedHashMap<>(); demoModels.put( "Lithography - Picasso", LithographyRootComponent.create(c) .recyclerBinder(glideRecyclerBinder) .build()); demoModels.put("Playground", PlaygroundComponent.create(c).build()); }
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_repos); bindViews(this); componentContext = new ComponentContext(this); recyclerBinder = new RecyclerBinder( componentContext, 4.0f, new LinearLayoutInfo(this, OrientationHelper.VERTICAL, false)); sRefresh.setOnRefreshListener(() -> store.dispatch(HomeAction.REFRESH)); }
@OnEvent(ClickEvent.class) static void onClick( ComponentContext c, @FromEvent View view, @Prop final Product product) { }
@OnCreateLayout static ComponentLayout onCreateLayout(ComponentContext c, @Prop RecyclerBinder binder) { return Recycler.create(c) .binder(binder) .withLayout().flexShrink(0) .testKey(MAIN_SCREEN) .build(); }
@OnCreateLayout static ComponentLayout onCreateLayout(ComponentContext c, @Prop SingleBannerSection payload) { final DraweeController controller = Fresco.newDraweeControllerBuilder() .setUri(payload.banner().imageUrl()) .build(); return Column.create(c) .child( Text.create(c) .text(payload.title()) .glyphWarming(true) .textSizeSp(16) .withLayout() .paddingDip(TOP,8) .paddingDip(BOTTOM,4) .heightDip(44) ) .paddingDip(LEFT, 8) .paddingDip(RIGHT, 8) .child( FrescoImage.create(c) .controller(controller) .actualImageScaleType( ScalingUtils .ScaleType .CENTER_CROP ) .withLayout() .heightPx((int) (DisplayUtil.getScreenWidth(c) / payload.banner().ratio())) ) .clickHandler(SingleBannerComponent.onClick(c)) .build(); }
@OnEvent(ClickEvent.class) static void onClick( ComponentContext c, @FromEvent View view, @Prop final SingleBannerSection payload) { }
@OnEvent(ClickEvent.class) static void onClickFirstBanner( ComponentContext c, @FromEvent View view, @Prop final TripleBannerSection payload) { }
@OnEvent(ClickEvent.class) static void onClickSecondBanner( ComponentContext c, @FromEvent View view, @Prop final TripleBannerSection payload) { }
@OnEvent(ClickEvent.class) static void onClickThirdBanner( ComponentContext c, @FromEvent View view, @Prop final TripleBannerSection payload) { }
@OnCreateLayout static ComponentLayout onCreateLayout( ComponentContext c, @Prop String image, @Prop(optional = true) float imageAspectRatio) { return GlideImage.create(c) .imageUrl(image) .aspectRatio(imageAspectRatio) .centerCrop(true) .buildWithLayout(); }
@OnCreateLayout static ComponentLayout onCreateLayout(ComponentContext c, @Prop final ArtistDatum artist, @Prop final RecyclerBinder binder) { return Column.create(c) .child(Column.create(c) .child(artist.getImages().length == 1 ? getImageComponent(c, artist) : getRecyclerComponent(c, binder)) .child(TitleComponent.create(c).title(artist.getName())) .child(ActionsComponent.create(c))) .child(FooterComponent.create(c).text(artist.getBiography())) .build(); }
@OnCreateLayout static ComponentLayout onCreateLayout(ComponentContext c, @Prop final ArtistDatum artist, @Prop final RecyclerBinder binder) { return Column.create(c) .flexShrink(0) .alignContent(YogaAlign.FLEX_START) .paddingDip(VERTICAL, 8) .paddingDip(HORIZONTAL, 16) .child(Card.create(c) .content(FeedItemComponent.create(c).artist(artist).binder(binder))) .build(); }
public static void populateBinderWithSampleDataForGlide(RecyclerBinder recyclerBinder, ComponentContext c) { final Datum[] dataModels = SampleDataForGlide(); for (Datum datum : dataModels) { ComponentRenderInfo.Builder componentInfoBuilder = ComponentRenderInfo.create(); componentInfoBuilder.component(datum.createComponent(c)).isSticky(datum instanceof Decade); recyclerBinder.insertItemAt(recyclerBinder.getItemCount(), componentInfoBuilder.build()); } }
@Override public Component createComponent(ComponentContext c) { final RecyclerBinder imageRecyclerBinder = new RecyclerBinder.Builder().layoutInfo( new LinearLayoutInfo(c, OrientationHelper.HORIZONTAL, false)).build(c); for (String image : images) { ComponentRenderInfo.Builder imageComponentInfoBuilder = ComponentRenderInfo.create(); imageComponentInfoBuilder.component( GlideSingleImageComponent.create(c).image(image).aspectRatio(2).build()); imageRecyclerBinder.insertItemAt(imageRecyclerBinder.getItemCount(), imageComponentInfoBuilder.build()); } return FeedItemCard.create(c).artist(this).binder(imageRecyclerBinder).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, @State boolean favourited) { return Row.create(c) .backgroundRes(favourited ? star_on : star_off) .widthDip(32) .heightDip(32) .clickHandler(FavouriteButton.onClick(c)) .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 String name) { return Column.create(c).flexShrink(0).alignContent(YogaAlign.FLEX_START) .paddingDip(ALL, 16) .child( Text.create(c) .text(name) .textSizeSp(18) .build()) .clickHandler(DemoListItemComponent.onClick(c)) .build(); }
@OnEvent(ClickEvent.class) static void onClick( ComponentContext c, @FromEvent View view, @Prop final String name) { final Intent intent = new Intent(c, DemoActivity.class); intent.putExtra("demoName", name); c.startActivity(intent); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Demos.initialize(this); setContentView( LithoView.create( this, DemoListComponent.create(new ComponentContext(this)) .build())); }
@OnCreateLayout static ComponentLayout onCreateLayout(ComponentContext c) { final RecyclerBinder recyclerBinder = new RecyclerBinder.Builder().layoutInfo( new LinearLayoutInfo(c, OrientationHelper.VERTICAL, false)).build(c); Demos.addAllToBinder(recyclerBinder, c); return Recycler.create(c) .binder(recyclerBinder) .flexShrink(0) .testKey(MAIN_SCREEN) .buildWithLayout(); }
public static void initialize(Context context) { final ComponentContext c = new ComponentContext(context); final RecyclerBinder glideRecyclerBinder = new RecyclerBinder.Builder().layoutInfo( new LinearLayoutInfo(c, OrientationHelper.VERTICAL, false)).build(c); DataModel.populateBinderWithSampleDataForGlide(glideRecyclerBinder, c); demoModels = new LinkedHashMap<>(); demoModels.put("Lithography - Glide", LithographyRootComponent.create(c).recyclerBinder(glideRecyclerBinder).build()); demoModels.put("Playground", PlaygroundComponent.create(c).build()); }
public static void addAllToBinder(RecyclerBinder recyclerBinder, ComponentContext c) { for (String name : demoModels.keySet()) { ComponentRenderInfo.Builder componentInfoBuilder = ComponentRenderInfo.create(); componentInfoBuilder.component(DemoListItemComponent.create(c).name(name).build()); recyclerBinder.insertItemAt(recyclerBinder.getItemCount(), componentInfoBuilder.build()); } }
@OnCreateLayout static ComponentLayout onCreateLayout(ComponentContext c) { return Column.create(c).flexShrink(0).alignContent(YogaAlign.FLEX_START) .backgroundColor(Color.WHITE) .child( Text.create(c) .textSizeSp(20) .text("Playground sample")) .build(); }
public static void populateBinderWithSampleDataForGlide( RecyclerBinder recyclerBinder, ComponentContext c) { final Datum[] dataModels = SampleDataForGlide(); for (Datum datum : dataModels) { ComponentInfo.Builder componentInfoBuilder = ComponentInfo.create(); componentInfoBuilder .component(datum.createComponent(c)) .isSticky(datum instanceof Decade); recyclerBinder.insertItemAt(recyclerBinder.getItemCount(), componentInfoBuilder.build()); } }
@Override public Component createComponent(ComponentContext c) { final RecyclerBinder imageRecyclerBinder = new RecyclerBinder(c, 4.0f, new LinearLayoutInfo(c, OrientationHelper.HORIZONTAL, false)); for (String image : images) { ComponentInfo.Builder imageComponentInfoBuilder = ComponentInfo.create(); imageComponentInfoBuilder.component( PicassoSingleImageComponent.create(c).image(image).fit(true).build()); imageRecyclerBinder.insertItemAt(imageRecyclerBinder.getItemCount(), imageComponentInfoBuilder.build()); } return FeedItemCard.create(c).artist(this).binder(imageRecyclerBinder).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(); }