Java 类com.facebook.litho.ComponentLayout 实例源码

项目:redux-observable    文件:ProductSlideComponentSpec.java   
@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();
}
项目:litho-glide    文件:TitleComponentSpec.java   
@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();
}
项目:litho-picasso    文件:TitleComponentSpec.java   
@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();
}
项目:redux-observable    文件:HomeListComponentSpec.java   
@OnCreateLayout
static ComponentLayout onCreateLayout(ComponentContext c, @Prop RecyclerBinder binder) {
    return Recycler.create(c)
            .binder(binder)
            .withLayout().flexShrink(0)
            .testKey(MAIN_SCREEN)
            .build();
}
项目:redux-observable    文件:SingleBannerComponentSpec.java   
@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();
}
项目:litho-glide    文件:GlideSingleImageComponentSpec.java   
@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();
}
项目:litho-glide    文件:FeedItemComponentSpec.java   
@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();
}
项目:litho-glide    文件:FeedItemCardSpec.java   
@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();
}
项目:litho-glide    文件:ActionsComponentSpec.java   
@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();
}
项目:litho-glide    文件:LithographyRootComponentSpec.java   
@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();
}
项目:litho-glide    文件:DecadeSeparatorSpec.java   
@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();
}
项目:litho-glide    文件:FavouriteButtonSpec.java   
@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();
}
项目:litho-glide    文件:FooterComponentSpec.java   
@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();
}
项目:litho-glide    文件:DemoListItemComponentSpec.java   
@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();
}
项目:litho-glide    文件:DemoListComponentSpec.java   
@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();
}
项目:litho-glide    文件:PlaygroundComponentSpec.java   
@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();
}
项目:litho-picasso    文件:FeedItemComponentSpec.java   
@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();
}
项目:litho-picasso    文件:FeedItemCardSpec.java   
@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();
}
项目:litho-picasso    文件:ActionsComponentSpec.java   
@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();
}
项目:litho-picasso    文件:LithographyRootComponentSpec.java   
@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();
}
项目:litho-picasso    文件:DecadeSeparatorSpec.java   
@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();
}
项目:litho-picasso    文件:FavouriteButtonSpec.java   
@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();
}
项目:litho-picasso    文件:FooterComponentSpec.java   
@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();
}
项目:litho-picasso    文件:DemoListItemComponentSpec.java   
@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();
}
项目:litho-picasso    文件:DemoListComponentSpec.java   
@OnCreateLayout
static ComponentLayout onCreateLayout(ComponentContext c) {
  final RecyclerBinder recyclerBinder = new RecyclerBinder(
      c,
      4.0f,
      new LinearLayoutInfo(c, OrientationHelper.VERTICAL, false));

  Demos.addAllToBinder(recyclerBinder, c);

  return Recycler.create(c)
      .binder(recyclerBinder)
      .withLayout().flexShrink(0)
      .testKey(MAIN_SCREEN)
      .build();
}
项目:litho-picasso    文件:PlaygroundComponentSpec.java   
@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();
}
项目:redux-observable    文件:ProductComponentSpec.java   
@OnCreateLayout
static ComponentLayout onCreateLayout(ComponentContext c, @Prop Product product) {
    final DraweeController controller = Fresco.newDraweeControllerBuilder()
            .setUri(product.imageUrl())
            .build();
    return Column.create(c)
            .backgroundColor(Color.WHITE)
            .child(
                    FrescoImage.create(c)
                            .controller(controller)
                            .actualImageScaleType(
                                    ScalingUtils
                                            .ScaleType
                                            .CENTER_CROP
                            )
                            .withLayout()
                            .heightDip(96)
                            .widthDip(96)
                            .alignSelf(YogaAlign.CENTER)
            ).child(
                    Text.create(c)
                            .text(product.name())
                            .maxLines(2)
                            .minLines(2)
                            .ellipsize(TextUtils.TruncateAt.MIDDLE)
                            .glyphWarming(true)
                            .textAlignment(Layout.Alignment.ALIGN_CENTER)
                            .textSizeSp(14)
                            .withLayout()
                            .widthDip(128)
                            .paddingDip(TOP, 8)
            )
            .child(
                    Text.create(c)
                            .text(FormatUtil.getFormattedCurrency(product.price()))
                            .glyphWarming(true)
                            .textSizeSp(14)
                            .withLayout()
                            .paddingDip(TOP, 8)
            ).child(
                    Text.create(c)
                            .text(FormatUtil.getFormattedCurrency(product.originalPrice()))
                            .glyphWarming(true)
                            .textSizeSp(12)
                            .withLayout()
                            .paddingDip(BOTTOM, 8)
            ).clickHandler(ProductComponent.onClick(c))
            .paddingDip(ALL, 8)
            .build();
}
项目:redux-observable    文件:TripleBannersComponentSpec.java   
@OnCreateLayout
static ComponentLayout onCreateLayout(ComponentContext c, @Prop TripleBannerSection payload) {
    final DraweeController controllerBanner1 = Fresco.newDraweeControllerBuilder()
            .setUri(payload.banners().get(0).imageUrl())
            .build();
    final DraweeController controllerBanner2 = Fresco.newDraweeControllerBuilder()
            .setUri(payload.banners().get(1).imageUrl())
            .build();

    final DraweeController controllerBanner3 = Fresco.newDraweeControllerBuilder()
            .setUri(payload.banners().get(2).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(
                    Row.create(c)
                            .heightPx((int) (DisplayUtil.getScreenWidth(c) / payload.banners().get(0).ratio()))
                            .child(
                                    FrescoImage.create(c)
                                            .controller(controllerBanner1)
                                            .actualImageScaleType(ScalingUtils
                                                    .ScaleType.FIT_XY)
                                            .withLayout()
                                            .flex(1)
                                            .widthPercent(50)

                            )
                            .clickHandler(TripleBannersComponent.onClickFirstBanner(c))
                            .child(
                                    Column.create(c)
                                            .child(
                                                    FrescoImage.create(c)
                                                            .controller(controllerBanner2)
                                                            .actualImageScaleType(ScalingUtils.ScaleType.CENTER_CROP)
                                                            .withLayout()
                                                            .heightPercent(50)
                                                            .flex(1)
                                            )
                                            .clickHandler(TripleBannersComponent.onClickSecondBanner(c))
                                            .child(
                                                    FrescoImage.create(c)
                                                            .controller(controllerBanner3)
                                                            .actualImageScaleType(ScalingUtils.ScaleType.CENTER_CROP)
                                                            .withLayout()
                                                            .flex(1)
                                                            .heightPercent(50)
                                            )
                                            .widthPercent(100)
                                            .clickHandler(TripleBannersComponent.onClickThirdBanner(c)))
            )
            .build();
}
项目:litho-glide    文件:FeedItemComponentSpec.java   
private static ComponentLayout.Builder getImageComponent(ComponentContext c,
    ArtistDatum artistDatum) {
  String imageUrl = artistDatum.getImages()[0];
  return GlideSingleImageComponent.create(c).image(imageUrl).aspectRatio(2).withLayout();
}
项目:litho-glide    文件:FeedItemComponentSpec.java   
private static ComponentLayout.Builder getRecyclerComponent(ComponentContext c,
    RecyclerBinder binder) {
  return Recycler.create(c).binder(binder).withLayout().flexShrink(0).aspectRatio(2);
}
项目:litho-glide    文件:GlideImageSpec.java   
@OnMeasure
static void onMeasureLayout(ComponentContext c, ComponentLayout layout, int widthSpec,
    int heightSpec, Size size,
    @Prop(optional = true, resType = ResType.FLOAT) float imageAspectRatio) {
  MeasureUtils.measureWithAspectRatio(widthSpec, heightSpec, imageAspectRatio, size);
}
项目:litho-picasso    文件:PicassoImageSpec.java   
@OnMeasure
static void onMeasureLayout(ComponentContext c, ComponentLayout layout, int widthSpec,
    int heightSpec, Size size) {
  MeasureUtils.measureWithEqualDimens(widthSpec, heightSpec, size);
}
项目:litho-picasso    文件:FeedItemComponentSpec.java   
private static ComponentLayout.Builder getImageComponent(ComponentContext c,
    ArtistDatum artistDatum) {
  String imageUrl = artistDatum.getImages()[0];
  return PicassoSingleImageComponent.create(c).image(imageUrl).withLayout();
}
项目:litho-picasso    文件:FeedItemComponentSpec.java   
private static ComponentLayout.Builder getRecyclerComponent(ComponentContext c,
    RecyclerBinder binder) {
  return Recycler.create(c).binder(binder).withLayout().flexShrink(0).aspectRatio(2);
}
项目:litho-picasso    文件:PicassoSingleImageComponentSpec.java   
@OnCreateLayout
static ComponentLayout onCreateLayout(ComponentContext c, @Prop String image,
    @Prop(optional = true) boolean fit) {
  return PicassoImage.create(c).imageUrl(image).fit(fit).centerCrop(true).buildWithLayout();
}