Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply working code #1

Merged
merged 5 commits into from
Aug 8, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 64 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,64 @@
# react-native-taginput

## react-native-taginput

Tag input component fro React Native

## ChangeLog
- v0.1.0
- Initial working version

## Installation

1. Run `npm install react-native-taginput --save`
2. `import TagInput from 'react-native-taginput`

## Basic usage

```javascript
import TagInput from 'react-native-taginput';

class App extends Component {
render() {
return (
<View style={styles.container}>
<TagInput
ref='tagInput'
initialTags={initialTags}
suggestions={this.state.data.suggestions}
containerStyle={styles.taginput}
onChange={this._onChange.bind(this)}
onUpdateLayout={this._onUpdateLayout.bind(this)}
/>
</View>
);
}
}
```

## Examples

> Add example link

## Props

| Prop | Type | Description |
:------------ |:---------------:| :-----|
| initialTags | array | |
| suggestions | array | |
| containerStyle | style | |
| inputContainerStyle | style | |
| listStyle | style | |
| placeholder | string | |
| onUpdateTags | function | |
| onUpdateLayout | function | |


## Contribution
**Issues** and **Pull requests** are welcome. Please add a screenshot of bug and code snippet.

## About
This is inspired by [react-native-autocomplete-input](https://github.com/l-urence/react-native-autocomplete-input).

---

**MIT Licensed**
96 changes: 38 additions & 58 deletions Tag.js
Original file line number Diff line number Diff line change
@@ -1,68 +1,48 @@


import React, { Component } from 'react';
import React, { PropTypes } from 'react';
import {
StyleSheet,
View,
Text,
TouchableWithoutFeedback
TouchableHighlight,
} from 'react-native';

class Tag extends Component {

static propTypes = {
text: React.PropTypes.string.isRequired,
onPress: React.PropTypes.func,
}

static defaultProps = {
text: 'none',
onPress: () => {},
}
const Tag = ({
text,
tagContainer,
onPress,
}) => {
const styles = StyleSheet.create({
container: {
justifyContent: 'center',
backgroundColor: 'gray',
paddingHorizontal: 5,
margin: 2,
borderRadius: 3,
height:20,
},
text: {
fontSize: 10,
color: '#ffffff'
},
})

return (
<TouchableHighlight style={[styles.container, tagContainer]} onPress={onPress}>
<Text style={styles.text}>{text}</Text>
</TouchableHighlight>
);
}

render() {
return (
<View style={[styles.container, ]}>
<Text style={styles.text}>{this.props.text}</Text>
<TouchableWithoutFeedback onPress={() => this.props.onPress()}>
<View style={styles.delete}>
<Text style={styles.deleteText}>X</Text>
</View>
</TouchableWithoutFeedback>
</View>
)
}
Tag.propTypes = {
text: PropTypes.string,
tagContainer: View.propTypes.style,
onPress: PropTypes.func,
}

const styles = StyleSheet.create({
container: {
flexDirection: 'row',
backgroundColor: 'gray',
paddingHorizontal: 5,
margin: 5,
borderRadius: 5,
alignItems: 'center',
height:30,
},
text: {
fontSize: 16,
color: '#ffffff'
},
delete: {
justifyContent:'center',
alignItems: 'center',
width: 14,
height: 14,
borderColor: 'white',
borderWidth: 0.5,
borderRadius: 7,
right:0,
marginLeft:5,
},
deleteText: {
fontSize: 12,
color: '#ffffff'
}
});
Tag.defaultProps = {
text: 'none',
tagContainer: null,
onPress: () => {},
}

export default Tag;
export default Tag;
Loading