| 15 | const window = Dimensions.get('window'); |
| 16 | |
| 17 | class DropDownModal extends PureComponent { |
| 18 | static DEFAULT_VISIBLE_OPTIONS = 8; |
| 19 | |
| 20 | constructor(props) { |
| 21 | super(props); |
| 22 | |
| 23 | autoBindReact(this); |
| 24 | |
| 25 | this.state = { optionHeight: 0 }; |
| 26 | } |
| 27 | |
| 28 | onOptionLayout(event) { |
| 29 | const { height } = event.nativeEvent.layout; |
| 30 | const { optionHeight } = this.state; |
| 31 | |
| 32 | if (height !== optionHeight) { |
| 33 | this.setState({ |
| 34 | optionHeight: height, |
| 35 | listStyle: this.resolveListViewStyle(height), |
| 36 | }); |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | getVisibleOptions() { |
| 41 | const { |
| 42 | visibleOptions, |
| 43 | style: { visibleOptions: styleVisibleOptions }, |
| 44 | } = this.props; |
| 45 | const defaultOptions = DropDownModal.DEFAULT_VISIBLE_OPTIONS; |
| 46 | |
| 47 | return visibleOptions || styleVisibleOptions || defaultOptions; |
| 48 | } |
| 49 | |
| 50 | selectOption(option) { |
| 51 | const { selectedOption } = this.props; |
| 52 | |
| 53 | this.close(); |
| 54 | |
| 55 | if (option !== selectedOption) { |
| 56 | this.emitOnOptionSelectedEvent(option); |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | close() { |
| 61 | const { onClose } = this.props; |
| 62 | |
| 63 | if (_.isFunction(onClose)) { |
| 64 | onClose(); |
| 65 | } |
| 66 | } |
| 67 | |
| 68 | emitOnOptionSelectedEvent(option) { |
| 69 | const { onOptionSelected } = this.props; |
| 70 | |
| 71 | if (_.isFunction(onOptionSelected)) { |
| 72 | onOptionSelected(option); |
| 73 | } |
| 74 | } |
nothing calls this directly
no outgoing calls
no test coverage detected