diff --git a/README.md b/README.md
index c906fa8..193843a 100644
--- a/README.md
+++ b/README.md
@@ -54,6 +54,17 @@ class CreateNewAppointment extends Component {
onRemoveItem={data => {
this.setState({ data })
}}
+ tagStyle={{
+ selectedTagArea: {
+ backgroundColor: 'black'
+ },
+ selectedTagText: {
+ color: 'white'
+ },
+ icon: {
+ color: 'red'
+ }
+ }}
/>
)
@@ -87,5 +98,6 @@ class CreateNewAppointment extends Component {
| **selectedTitleStyle** | _Object_ | none | Set custom style for display selected title text |
| **buttonTextStyle** | _Object_ | none | Set custom button text style |
| **buttonStyle** | _Object_ | none | Set custom button style |
+| **tagStyle** | _Object_ | none | Set custom styles for tags |
**MIT Licensed**
diff --git a/index.js b/index.js
index 5c94a58..d53c6b0 100644
--- a/index.js
+++ b/index.js
@@ -20,7 +20,13 @@ class Select2 extends Component {
colorTheme: '#16a45f',
buttonTextStyle: {},
buttonStyle: {},
- showSearchBox: true
+ showSearchBox: true,
+ tagStyle: {},
+ showLine: true,
+ popupTitleStyle: {},
+ inputStyle: {},
+ listBlockStyle: {},
+ showCheckbox: true
}
state = {
show: false,
@@ -29,7 +35,7 @@ class Select2 extends Component {
data: [],
keyword: ''
}
- animatedHeight = new Animated.Value(INIT_HEIGHT);
+ animatedHeight = new Animated.Value(this.props.windowHeight || INIT_HEIGHT);
componentDidMount() {
this.init();
@@ -81,6 +87,7 @@ class Select2 extends Component {
}
onItemSelected = (item, isSelectSingle) => {
+ let { showCheckbox, onSelect } = this.props
let selectedItem = [];
let { data } = this.state;
item.checked = !item.checked;
@@ -95,22 +102,29 @@ class Select2 extends Component {
if (item.checked) selectedItem.push(item);
})
this.setState({ data, selectedItem });
+
+ if (!showCheckbox) {
+ onSelect && onSelect([item.id], [item]);
+ this.setState({ show: false, keyword: '', preSelectedItem: this.state.selectedItem });
+ }
}
keyExtractor = (item, idx) => idx.toString();
renderItem = ({ item, idx }) => {
- let { colorTheme, isSelectSingle } = this.props;
+ let { colorTheme, isSelectSingle, showCheckbox } = this.props;
return (
this.onItemSelected(item, isSelectSingle)}
activeOpacity={0.7}
- style={styles.itemWrapper}>
-
+ style={[styles.itemWrapper, item.containerStyle]}>
+
{item.name}
-
+ }
);
}
@@ -129,7 +143,7 @@ class Select2 extends Component {
let {
style, modalStyle, title, onSelect, onRemoveItem, popupTitle, colorTheme,
isSelectSingle, cancelButtonText, selectButtonText, searchPlaceHolderText,
- selectedTitleStyle, buttonTextStyle, buttonStyle, showSearchBox
+ selectedTitleStyle, buttonTextStyle, buttonStyle, showSearchBox, tagStyle, showLine, popupTitleStyle, inputStyle, listBlockStyle, showCheckbox
} = this.props;
let { show, selectedItem, preSelectedItem } = this.state;
return (
@@ -150,44 +164,47 @@ class Select2 extends Component {
isVisible={show}>
-
+
{popupTitle || title}
-
+ { showLine && }
{
showSearchBox
? this.setState({ keyword })}
onFocus={() => {
Animated.spring(this.animatedHeight, {
toValue: INIT_HEIGHT + (Platform.OS === 'ios' ? height * 0.2 : 0),
- friction: 7
+ friction: 7,
+ useNativeDriver: false
}).start();
}}
onBlur={() => {
Animated.spring(this.animatedHeight, {
toValue: INIT_HEIGHT,
- friction: 7
+ friction: 7,
+ useNativeDriver: false
}).start();
}}
/>
: null
}
-
+ { showCheckbox &&
+
+
+ }
{
@@ -244,7 +262,8 @@ class Select2 extends Component {
this.setState({ data, preSelectedItem });
onRemoveItem && onRemoveItem(selectedIds, selectedObjectItems);
}}
- tagName={tag.name} />
+ tagName={tag.name}
+ style={tagStyle}/>
);
})
}
@@ -323,7 +342,14 @@ Select2.propTypes = {
isSelectSingle: PropTypes.bool,
showSearchBox: PropTypes.bool,
cancelButtonText: PropTypes.string,
- selectButtonText: PropTypes.string
+ selectButtonText: PropTypes.string,
+ tagStyle: PropTypes.object,
+ windowHeight: PropTypes.number,
+ showLine: PropTypes.bool,
+ popupTitleStyle: PropTypes.object,
+ inputStyle: PropTypes.object,
+ listBlockStyle: PropTypes.object,
+ showCheckbox: PropTypes.bool,
}
//make this component available to the app
diff --git a/lib/TagItem.js b/lib/TagItem.js
index c24a409..adc3a1c 100644
--- a/lib/TagItem.js
+++ b/lib/TagItem.js
@@ -1,23 +1,43 @@
import React from 'react';
-import {TouchableOpacity, Text } from 'react-native';
+import { StyleSheet, TouchableOpacity, Text } from 'react-native';
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
-const TagItem = ({ tagName, onRemoveTag }) => {
- return (
-
-
-
- {tagName}
-
-
- );
+const TagItem = ({ tagName, onRemoveTag, style={} }) => {
+ iconColor = () => {
+ return (style.icon && style.icon.color) ||
+ (style.selectedTagText && style.selectedTagText.color) ||
+ defaultStyles.selectedTagText.color
+ }
+
+ return (
+
+
+
+ {tagName}
+
+
+ );
}
-export default TagItem;
\ No newline at end of file
+
+const defaultStyles = StyleSheet.create({
+ selectedTagArea: {
+ alignItems: 'center',
+ backgroundColor: '#f5f6f5',
+ borderColor: '#e9e9e9',
+ borderRadius: 3,
+ borderWidth: 1,
+ flexDirection: 'row',
+ margin: 4,
+ paddingVertical: 4,
+ paddingHorizontal: 8,
+ },
+ selectedTagText: {
+ color: '#333',
+ fontSize: 14,
+ paddingLeft: 4
+ },
+});
+
+export default TagItem;