Skip to content

Instantly share code, notes, and snippets.

@tatocaster
Created April 30, 2017 08:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tatocaster/005757e82a4561543e2dafc9cf57f785 to your computer and use it in GitHub Desktop.
Save tatocaster/005757e82a4561543e2dafc9cf57f785 to your computer and use it in GitHub Desktop.
ListItemSpec
@LayoutSpec
class ListItemSpec {
@OnCreateLayout
static ComponentLayout onCreateLayout(
ComponentContext c,
@Prop(optional = true, resType = ResType.DIMEN_OFFSET) int shadowRadius,
@Prop(optional = true) int color,
@Prop String title,
@Prop String subtitle) {
return Column.create(c)
.paddingDip(ALL, 16)
.backgroundColor(color)
.child(
Text.create(c)
.text(title)
.textSizeSp(40))
.child(
Text.create(c)
.text(subtitle)
.textStyle(ITALIC)
.textSizeSp(20))
.child(EditText.create(c)
.gravity(Gravity.CENTER)
.textSizeDip(14)
.build())
.clickHandler(ListItem.onClick(c))
.build();
}
@OnEvent(ClickEvent.class)
static void onClick(ComponentContext c, @FromEvent View view, @Prop View.OnClickListener listener) {
listener.onClick(view);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment