Skip to content

Instantly share code, notes, and snippets.

@flunder
Last active September 26, 2017 16:11
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save flunder/276ea1b3b373e905a7448614df261d6b to your computer and use it in GitHub Desktop.
Save flunder/276ea1b3b373e905a7448614df261d6b to your computer and use it in GitHub Desktop.
An example gist trying to show how to implement an icon within a tcomb form in react-native
const Form = t.form.Form;
const postOptions = t.struct({
publication: t.String,
tags: t.String,
more: t.String,
facebook: t.Boolean
})
const options = {
fields: {
publication: {
placeholder: "Add to Publication",
template: template,
config: { icon: 'plus' }
},
tags: {
placeholder: "Add tags",
template: template,
config: { icon: 'tag' }
},
more: {
placeholder: "More Options",
template: template,
config: { icon: 'info' }
}
}
};
function template(locals) {
var containerStyle = { ... };
var labelStyle = { ... };
var textboxStyle = { ... };
return (
<View style={containerStyle}>
<Icon name={locals.config.icon} style={labelStyle} size={15} />
<TextInput style={textboxStyle} placeholder={locals.placeholder} />
</View>
);
}
....
<Form
ref="postOptions"
type={postOptions}
options={options}
/>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment