Skip to content

Commit

Permalink
Fix Toast component invalid value for position error from galio-org#96
Browse files Browse the repository at this point in the history
  • Loading branch information
VictorAtPL committed Aug 14, 2019
1 parent a5b21d2 commit ea42b00
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/Toast.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Toast extends Component {
static propTypes = {
children: PropTypes.node.isRequired,
isShow: PropTypes.bool.isRequired,
position: PropTypes.oneOf(['top', 'center', 'bottom']),
positionIndicator: PropTypes.oneOf(['top', 'center', 'bottom']),
positionOffset: PropTypes.number,
fadeInDuration: PropTypes.number,
fadeOutDuration: PropTypes.number,
Expand All @@ -22,18 +22,20 @@ class Toast extends Component {
round: PropTypes.bool,
style: ViewPropTypes.style,
textStyle: ViewPropTypes.style,
styles: PropTypes.any,
theme: PropTypes.any,
};

static defaultProps = {
position: 'top',
positionIndicator: 'top',
positionOffset: 120,
fadeInDuration: 300,
fadeOutDuration: 300,
color: 'primary',
round: false,
style: null,
textStyle: null,
styles: {},
theme: GalioTheme,
};

Expand Down Expand Up @@ -85,13 +87,13 @@ class Toast extends Component {
setVisibility = isShow => this.setState({ isShow });

getTopPosition = () => {
const { position, positionOffset } = this.props;
const { positionIndicator, positionOffset } = this.props;

if (position === 'top') {
if (positionIndicator === 'top') {
return positionOffset;
}

if (position === 'bottom') {
if (positionIndicator === 'bottom') {
return height - positionOffset;
}

Expand All @@ -110,7 +112,7 @@ class Toast extends Component {
};

render() {
const { theme, color, round, style, ...rest } = this.props;
const { theme, color, round, style, styles, ...rest } = this.props;
const { isShow, fadeAnim } = this.state;
const colorStyle = styles[`${color}Color`];
const toastStyles = [
Expand Down
1 change: 1 addition & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export {
Radio,
Slider,
Text,
Toast,
Switch,
Toast,
theme,
Expand Down

0 comments on commit ea42b00

Please sign in to comment.