-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6837 from mateusbra/rename-ExpensiPicker
Rename ExpensiPicker
- Loading branch information
Showing
19 changed files
with
162 additions
and
162 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
src/components/Picker/pickerPropTypes.js → .../Picker/BasePicker/basePickerPropTypes.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
src/components/Picker/BasePicker/basePickerStyles/index.android.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import styles from '../../../../styles/styles'; | ||
|
||
const pickerStyles = (disabled, error, focused) => ({ | ||
...styles.picker(disabled, error, focused), | ||
inputAndroid: { | ||
...styles.picker(disabled, error, focused).inputNative, | ||
paddingLeft: 12, | ||
}, | ||
}); | ||
|
||
export default pickerStyles; |
8 changes: 8 additions & 0 deletions
8
src/components/Picker/BasePicker/basePickerStyles/index.ios.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import styles from '../../../../styles/styles'; | ||
|
||
const pickerStyles = (disabled, error, focused) => ({ | ||
...styles.picker(disabled, error, focused), | ||
inputIOS: styles.picker(disabled, error, focused).inputNative, | ||
}); | ||
|
||
export default pickerStyles; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import React from 'react'; | ||
import RNPickerSelect from 'react-native-picker-select'; | ||
|
||
import styles from '../../../styles/styles'; | ||
import * as basePickerPropTypes from './basePickerPropTypes'; | ||
import basePickerStyles from './basePickerStyles'; | ||
|
||
const BasePicker = props => ( | ||
<RNPickerSelect | ||
onValueChange={props.onChange} | ||
items={props.items} | ||
style={props.size === 'normal' ? basePickerStyles(props.disabled, props.hasError, props.focused) : styles.pickerSmall} | ||
useNativeAndroidPickerStyle={false} | ||
placeholder={props.placeholder} | ||
value={props.value} | ||
Icon={() => props.icon(props.size)} | ||
disabled={props.disabled} | ||
fixAndroidTouchableBug | ||
onOpen={props.onOpen} | ||
onClose={props.onClose} | ||
pickerProps={{ | ||
onFocus: props.onOpen, | ||
onBlur: props.onClose, | ||
}} | ||
/> | ||
); | ||
|
||
|
||
BasePicker.propTypes = basePickerPropTypes.propTypes; | ||
BasePicker.defaultProps = basePickerPropTypes.defaultProps; | ||
BasePicker.displayName = 'BasePicker'; | ||
|
||
export default BasePicker; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,79 @@ | ||
import React from 'react'; | ||
import RNPickerSelect from 'react-native-picker-select'; | ||
|
||
import _ from 'underscore'; | ||
import React, {PureComponent} from 'react'; | ||
import {View} from 'react-native'; | ||
import PropTypes from 'prop-types'; | ||
import BasePicker from './BasePicker'; | ||
import Text from '../Text'; | ||
import styles from '../../styles/styles'; | ||
import * as pickerPropTypes from './pickerPropTypes'; | ||
import pickerStyles from './pickerStyles'; | ||
|
||
const Picker = props => ( | ||
<RNPickerSelect | ||
onValueChange={props.onChange} | ||
items={props.items} | ||
style={props.size === 'normal' ? pickerStyles(props.disabled, props.hasError, props.focused) : styles.pickerSmall} | ||
useNativeAndroidPickerStyle={false} | ||
placeholder={props.placeholder} | ||
value={props.value} | ||
Icon={() => props.icon(props.size)} | ||
disabled={props.disabled} | ||
fixAndroidTouchableBug | ||
onOpen={props.onOpen} | ||
onClose={props.onClose} | ||
pickerProps={{ | ||
onFocus: props.onOpen, | ||
onBlur: props.onClose, | ||
}} | ||
/> | ||
); | ||
|
||
|
||
Picker.propTypes = pickerPropTypes.propTypes; | ||
Picker.defaultProps = pickerPropTypes.defaultProps; | ||
Picker.displayName = 'Picker'; | ||
import InlineErrorText from '../InlineErrorText'; | ||
|
||
const propTypes = { | ||
/** Picker label */ | ||
label: PropTypes.string, | ||
|
||
/** Should the picker appear disabled? */ | ||
isDisabled: PropTypes.bool, | ||
|
||
/** Should the input be styled for errors */ | ||
hasError: PropTypes.bool, | ||
|
||
/** Error text to display */ | ||
errorText: PropTypes.string, | ||
|
||
/** Customize the Picker container */ | ||
containerStyles: PropTypes.arrayOf(PropTypes.object), | ||
}; | ||
|
||
const defaultProps = { | ||
label: '', | ||
isDisabled: false, | ||
hasError: false, | ||
errorText: '', | ||
containerStyles: [], | ||
}; | ||
|
||
class Picker extends PureComponent { | ||
constructor() { | ||
super(); | ||
this.state = { | ||
isOpen: false, | ||
}; | ||
} | ||
|
||
render() { | ||
const pickerProps = _.omit(this.props, _.keys(propTypes)); | ||
return ( | ||
<> | ||
<View | ||
style={[ | ||
styles.pickerContainer, | ||
this.props.isDisabled && styles.inputDisabled, | ||
]} | ||
> | ||
{this.props.label && ( | ||
<Text style={[styles.pickerLabel, styles.textLabelSupporting]}>{this.props.label}</Text> | ||
)} | ||
<BasePicker | ||
onOpen={() => this.setState({isOpen: true})} | ||
onClose={() => this.setState({isOpen: false})} | ||
disabled={this.props.isDisabled} | ||
focused={this.state.isOpen} | ||
hasError={this.props.hasError} | ||
// eslint-disable-next-line react/jsx-props-no-spreading | ||
{...pickerProps} | ||
/> | ||
</View> | ||
{!_.isEmpty(this.props.errorText) && ( | ||
<InlineErrorText> | ||
{this.props.errorText} | ||
</InlineErrorText> | ||
)} | ||
</> | ||
); | ||
} | ||
} | ||
|
||
Picker.propTypes = propTypes; | ||
Picker.defaultProps = defaultProps; | ||
|
||
export default Picker; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.