Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions lib/components/RowItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class RowItem extends Component {
) {
return true
}

}

if (this.props.searchTerm !== nextProps.searchTerm) {
Expand All @@ -82,6 +82,11 @@ class RowItem extends Component {
if (this.props.mergedStyles !== nextProps.mergedStyles) {
return true
}

if (this.props.costumeSubItemContentRender !== nextProps.costumeSubItemContentRender) {
return true
}

return false
}

Expand Down Expand Up @@ -179,12 +184,12 @@ class RowItem extends Component {
<Icon
name="check"
style={{
fontSize: 16,
color: mergedColors.success,
paddingLeft: 10,
}}
fontSize: 16,
color: mergedColors.success,
paddingLeft: 10,
}}
/>
)
)
: callIfFunction(unselectedIconComponent) || null
}

Expand Down
86 changes: 57 additions & 29 deletions lib/components/RowSubItem.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { Component } from 'react'
import React, { Component, Fragment } from 'react';
import PropTypes from 'prop-types'
import { View, TouchableOpacity, Text, Image } from 'react-native'
import Icon from 'react-native-vector-icons/MaterialIcons'
Expand Down Expand Up @@ -32,6 +32,9 @@ class RowSubItem extends Component {
if (this.props.mergedStyles !== nextProps.mergedStyles) {
return true
}
if (this.props.customSubItemContentRenderer !== nextProps.customSubItemContentRenderer) {
return true
}
return false
}

Expand Down Expand Up @@ -77,24 +80,70 @@ class RowSubItem extends Component {
) : null
}

render() {
_renderDefaultContent = () => {
const {
mergedStyles,
mergedColors,
subItem,
selectChildren,
selectedIconOnLeft,
iconKey,
uniqueKey,
displayKey,
itemNumberOfLines,
subItemFontFamily,
highlightedChildren,
} = this.props;

const itemSelected = this._itemSelected();
const highlightChild = !selectChildren && highlightedChildren.includes(subItem[uniqueKey])

return (
<Fragment>
{selectedIconOnLeft && this._renderSelectedIcon()}

{iconKey && subItem[iconKey] && (
<ItemIcon
iconKey={iconKey}
icon={subItem[iconKey]}
style={mergedStyles.itemIconStyle}
/>
)}
<Text
numberOfLines={itemNumberOfLines}
style={[
{
flex: 1,
color: subItem.disabled ? mergedColors.disabled : mergedColors.subText,
},
subItemFontFamily,
mergedStyles.subItemText,
(itemSelected || highlightChild) && mergedStyles.selectedSubItemText,
]}
>
{subItem[displayKey]}
</Text>
{!selectedIconOnLeft && this._renderSelectedIcon()}
</Fragment>
)
}

render() {
const {
mergedStyles,
mergedColors,
subItem,
uniqueKey,
selectChildren,
selectedIconOnLeft,
highlightedChildren,
itemNumberOfLines,
displayKey,
iconKey,
customSubItemContentRenderer: CustomSubItemContentRenderer
} = this.props

const highlightChild = !selectChildren && highlightedChildren.includes(subItem[uniqueKey])
const itemSelected = this._itemSelected()

const shouldUseCostumeRender = CustomSubItemContentRenderer ? true : false;

return (
<View
key={subItem[uniqueKey]}
Expand All @@ -120,30 +169,9 @@ class RowSubItem extends Component {
(itemSelected || highlightChild) && mergedStyles.selectedSubItem,
]}
>
{selectedIconOnLeft && this._renderSelectedIcon()}
{!shouldUseCostumeRender && this._renderDefaultContent()}

{iconKey && subItem[iconKey] && (
<ItemIcon
iconKey={iconKey}
icon={subItem[iconKey]}
style={mergedStyles.itemIconStyle}
/>
)}
<Text
numberOfLines={itemNumberOfLines}
style={[
{
flex: 1,
color: subItem.disabled ? mergedColors.disabled : mergedColors.subText,
},
subItemFontFamily,
mergedStyles.subItemText,
(itemSelected || highlightChild) && mergedStyles.selectedSubItemText,
]}
>
{subItem[displayKey]}
</Text>
{!selectedIconOnLeft && this._renderSelectedIcon()}
{shouldUseCostumeRender && <CustomSubItemContentRenderer subItem={subItem} isItemSelected={itemSelected}/> }
</TouchableOpacity>
</View>
)
Expand Down
25 changes: 18 additions & 7 deletions lib/sectioned-multi-select.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ class SectionedMultiSelect extends PureComponent {
dropDownToggleIconUpComponent: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
dropDownToggleIconDownComponent: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
chipRemoveIconComponent: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
customSubItemContentRenderer: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
selectChildren: PropTypes.bool,
highlightChildren: PropTypes.bool,
onSelectedItemObjectsChange: PropTypes.func,
Expand Down Expand Up @@ -485,6 +486,16 @@ class SectionedMultiSelect extends PureComponent {
})
onToggleSelector && onToggleSelector(false)
}

_openSelector = () => {
const { onToggleSelector } = this.props
this.setState({
selector: true,
searchTerm: '',
})
onToggleSelector && onToggleSelector(true)
}

_submitSelection = () => {
const { onConfirm } = this.props
this._toggleSelector()
Expand Down Expand Up @@ -951,13 +962,13 @@ class SectionedMultiSelect extends PureComponent {
onRequestClose={this._closeSelector}
>
<this.BackdropView
style={[{
flex: 1,
width: '100%',
height: '100%',
position: 'absolute',
style={[{
flex: 1,
width: '100%',
height: '100%',
position: 'absolute',
backgroundColor: 'rgba(0,0,0,0.5)',
zIndex: 0
zIndex: 0
}, styles.backdrop]}
/>
<View
Expand Down Expand Up @@ -1117,7 +1128,7 @@ class SectionedMultiSelect extends PureComponent {
styles.selectToggle,
]}
>
{this._getSelectLabel()}
{this._getSelectLabel()}
{callIfFunction(selectToggleIconComponent) || (
<Icon
size={24}
Expand Down