Created
April 30, 2017 08:52
-
-
Save tatocaster/005757e82a4561543e2dafc9cf57f785 to your computer and use it in GitHub Desktop.
ListItemSpec
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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