Skip to content

Instantly share code, notes, and snippets.

@cbilgili
Forked from flunder/iconExample.js
Created February 24, 2017 10:15
Show Gist options
  • Save cbilgili/ce022a574a4527172e52f8ef34b7f764 to your computer and use it in GitHub Desktop.
Save cbilgili/ce022a574a4527172e52f8ef34b7f764 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