-
-
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
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
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