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

Added new selectedText Prop and has changes some ui problems in my ios simulators. #125

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
@@ -1,3 +1,4 @@

# react-native-multiple-select

[![npm](https://img.shields.io/npm/v/react-native-multiple-select.svg)](https://www.npmjs.com/package/react-native-multiple-select) [![Downloads](https://img.shields.io/npm/dt/react-native-multiple-select.svg)](https://www.npmjs.com/package/react-native-multiple-select) [![Licence](https://img.shields.io/npm/l/react-native-multiple-select.svg)](https://www.npmjs.com/package/react-native-multiple-select)
Expand Down Expand Up @@ -145,6 +146,7 @@ The component takes 3 compulsory props - `items`, `uniqueKey` and `onSelectedIte
| searchInputPlaceholderText | No | (String) Placeholder text displayed in multi-select filter input |
| searchInputStyle | No | (Object) Style object for multi-select input element |
| selectText | No | (String) Text displayed in main component |
| selectedText | No | (String) Text displayed when choosed one or one more records selected for example "2 records selected" < you are setting "selected" text when enter this prop. |
| selectedItemFontFamily | No | (String) Font family for each selected item in multi-select drop-down |
| selectedItemIconColor | No | (String) Color for `selected` check icon for each selected item in multi-select drop-down |
| selectedItemTextColor | No | (String) Text color for each selected item in multi-select drop-down |
Expand Down
1 change: 1 addition & 0 deletions index.d.ts
Expand Up @@ -23,6 +23,7 @@ export interface MultiSelectProps {
searchInputPlaceholderText?: string;
searchInputStyle?: StyleProp<TextStyle>;
selectText?: string;
selectedText?: string;
styleDropdownMenu?: StyleProp<ViewStyle>;
styleDropdownMenuSubsection?: StyleProp<ViewStyle>;
styleInputGroup?: StyleProp<ViewStyle>;
Expand Down
28 changes: 15 additions & 13 deletions lib/react-native-multi-select.js
@@ -1,22 +1,22 @@
import React, { Component } from 'react';
import {
FlatList,
Text,
View,
TextInput,
TouchableWithoutFeedback,
TouchableOpacity,
FlatList,
TouchableWithoutFeedback,
UIManager,
View,
ViewPropTypes
} from 'react-native';
import React, { Component } from 'react';
import styles, { colorPack } from './styles';

import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
import PropTypes from 'prop-types';
import reject from 'lodash/reject';
import find from 'lodash/find';
import get from 'lodash/get';
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';

import styles, { colorPack } from './styles';
import nodeTypes from './helpers/nodeTypes';
import reject from 'lodash/reject';

// set UIManager LayoutAnimationEnabledExperimental
if (UIManager.setLayoutAnimationEnabledExperimental) {
Expand All @@ -34,6 +34,7 @@ const defaultSearchIcon = (

export default class MultiSelect extends Component {
static propTypes = {
selectedText: PropTypes.string,
single: PropTypes.bool,
selectedItems: PropTypes.array,
items: PropTypes.array.isRequired,
Expand Down Expand Up @@ -117,7 +118,8 @@ export default class MultiSelect extends Component {
onAddItem: () => {},
onClearSelector: () => {},
onToggleList: () => {},
removeSelected: false
removeSelected: false,
selectedText: 'selected'
};

constructor(props) {
Expand Down Expand Up @@ -153,7 +155,7 @@ export default class MultiSelect extends Component {
};

_getSelectLabel = () => {
const { selectText, single, selectedItems, displayKey } = this.props;
const { selectText, single, selectedItems, displayKey, selectedText } = this.props;
if (!selectedItems || selectedItems.length === 0) {
return selectText;
}
Expand All @@ -162,7 +164,7 @@ export default class MultiSelect extends Component {
const foundItem = this._findItem(item);
return get(foundItem, displayKey) || selectText;
}
return `${selectText} (${selectedItems.length} selected)`;
return `${selectText} (${selectedItems.length} ${selectedText})`;
};

_findItem = itemKey => {
Expand Down Expand Up @@ -615,7 +617,7 @@ export default class MultiSelect extends Component {
size={20}
onPress={this._clearSelectorCallback}
color={colorPack.placeholderTextColor}
style={{ marginLeft: 5 }}
style={{ marginLeft: 5, marginRight: 10}}
/>
)}
</View>
Expand Down Expand Up @@ -705,7 +707,7 @@ export default class MultiSelect extends Component {
</Text>
<Icon
name={hideSubmitButton ? 'menu-right' : 'menu-down'}
style={styles.indicator}
style={[styles.indicator, { right: -20, height: '100%' }]}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this can be bad for other users of the library.
I think better to you create another props

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you are right but some devices has redundant indicator right margin.

/>
</View>
</TouchableWithoutFeedback>
Expand Down