diff --git a/components/ModalDropdown.js b/components/ModalDropdown.js index ace1472..89d2cb3 100644 --- a/components/ModalDropdown.js +++ b/components/ModalDropdown.js @@ -1,5 +1,6 @@ /** * Created by sohobloo on 16/9/13. + * Updated by TheFabiCraft */ 'use strict'; @@ -9,6 +10,7 @@ import React, { } from 'react'; import { + FlatList, StyleSheet, Dimensions, View, @@ -21,7 +23,7 @@ import { ActivityIndicator, } from 'react-native'; -import ListView from "deprecated-react-native-listview"; +// import ListView from "deprecated-react-native-listview"; import PropTypes from 'prop-types'; const TOUCHABLE_ELEMENTS = [ @@ -88,7 +90,7 @@ export default class ModalDropdown extends Component { }; } - componentWillReceiveProps(nextProps) { + UNSAFE_componentWillReceiveProps(nextProps) { let {buttonText, selectedIndex} = this.state; const {defaultIndex, defaultValue, options} = nextProps; buttonText = this._nextValue == null ? buttonText : this._nextValue; @@ -109,7 +111,7 @@ export default class ModalDropdown extends Component { }); } - render() { + render () { return ( {this._renderButton()} @@ -168,16 +170,16 @@ export default class ModalDropdown extends Component { return ( this._button = button} - disabled={disabled} - accessible={accessible} - onPress={this._onButtonPress} + disabled={disabled} + accessible={accessible} + onPress={this._onButtonPress} > { children || ( {buttonText} @@ -203,15 +205,16 @@ export default class ModalDropdown extends Component { const frameStyle = this._calcPosition(); const animationType = animated ? 'fade' : 'none'; return ( - @@ -281,29 +284,35 @@ export default class ModalDropdown extends Component { } _renderDropdown() { - const {scrollEnabled, renderSeparator, showsVerticalScrollIndicator, keyboardShouldPersistTaps} = this.props; + const {scrollEnabled, showsVerticalScrollIndicator, keyboardShouldPersistTaps, options} = this.props; + const Separator = return ( - ); } - get _dataSource() { - const {options} = this.props; - const ds = new ListView.DataSource({ - rowHasChanged: (r1, r2) => r1 !== r2 - }); - return ds.cloneWithRows(options); - } + _keyExtractor = (item, index) => `${index}` + + // get _dataSource() { + // const {options} = this.props; + // const ds = new ListView.DataSource({ + // rowHasChanged: (r1, r2) => r1 !== r2 + // }); + // return ds.cloneWithRows(options); + // } - _renderRow = (rowData, sectionID, rowID, highlightRow) => { + _renderRow = ({item: rowData, index: rowID, separators}) => { const {renderRow, dropdownTextStyle, dropdownTextHighlightStyle, accessible} = this.props; const {selectedIndex} = this.state; const key = `row_${rowID}`; @@ -322,7 +331,7 @@ export default class ModalDropdown extends Component { const preservedProps = { key, accessible, - onPress: () => this._onRowPress(rowData, sectionID, rowID, highlightRow), + onPress: () => this._onRowPress(rowData, rowID), }; if (TOUCHABLE_ELEMENTS.find(name => name == row.type.displayName)) { const props = {...row.props}; @@ -369,10 +378,10 @@ export default class ModalDropdown extends Component { ); }; - _onRowPress(rowData, sectionID, rowID, highlightRow) { + _onRowPress(rowData, rowID) { const {onSelect, renderButtonText, onDropdownWillHide} = this.props; if (!onSelect || onSelect(rowID, rowData) !== false) { - highlightRow(sectionID, rowID); + // highlightRow(sectionID, rowID); const value = renderButtonText && renderButtonText(rowData) || rowData.toString(); this._nextValue = value; this._nextIndex = rowID; @@ -388,13 +397,8 @@ export default class ModalDropdown extends Component { } } - _renderSeparator = (sectionID, rowID, adjacentRowHighlighted) => { - const key = `spr_${rowID}`; - return ( - - ); + _renderSeparator = () => { + return }; } diff --git a/package.json b/package.json index db7820b..d8e25a6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-modal-dropdown", - "version": "0.7.0", + "version": "0.7.1", "description": "A react-native dropdown component for both iOS and Android.", "keywords": [ "react",