Skip to content

Commit

Permalink
remove dependency on ViewPropTypes
Browse files Browse the repository at this point in the history
  • Loading branch information
calintamas committed Feb 14, 2021
1 parent fe374ee commit 896e678
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 13 deletions.
19 changes: 10 additions & 9 deletions src/components/base/index.js
@@ -1,9 +1,10 @@
import React from 'react';
import { View, TouchableOpacity, Text, ViewPropTypes } from 'react-native';
import { View, TouchableOpacity, Text } from 'react-native';
import PropTypes from 'prop-types';

import Icon from '../icon';
import { icons } from '../../assets';
import { stylePropType } from '../../utils/prop-types';
import styles, { HEIGHT } from './styles';

function BaseToast({
Expand Down Expand Up @@ -96,14 +97,14 @@ BaseToast.propTypes = {
onPress: PropTypes.func,
onTrailingIconPress: PropTypes.func,
onLeadingIconPress: PropTypes.func,
style: ViewPropTypes.style,
leadingIconContainerStyle: ViewPropTypes.style,
trailingIconContainerStyle: ViewPropTypes.style,
leadingIconStyle: ViewPropTypes.style,
trailingIconStyle: ViewPropTypes.style,
contentContainerStyle: ViewPropTypes.style,
text1Style: Text.propTypes.style,
text2Style: Text.propTypes.style,
style: stylePropType,
leadingIconContainerStyle: stylePropType,
trailingIconContainerStyle: stylePropType,
leadingIconStyle: stylePropType,
trailingIconStyle: stylePropType,
contentContainerStyle: stylePropType,
text1Style: stylePropType,
text2Style: stylePropType,
activeOpacity: PropTypes.number,
text1NumberOfLines: PropTypes.number,
text2NumberOfLines: PropTypes.number
Expand Down
5 changes: 3 additions & 2 deletions src/components/icon/index.js
@@ -1,7 +1,8 @@
import React from 'react';
import { Image, ViewPropTypes } from 'react-native';
import { Image } from 'react-native';
import PropTypes from 'prop-types';

import { stylePropType } from '../../utils/prop-types';
import styles from './styles';

function Icon({ source, style }) {
Expand All @@ -28,7 +29,7 @@ const imageSourcePropType = PropTypes.oneOfType([

Icon.propTypes = {
source: imageSourcePropType,
style: ViewPropTypes.style
style: stylePropType
};

Icon.defaultProps = {
Expand Down
5 changes: 3 additions & 2 deletions src/index.js
@@ -1,12 +1,13 @@
import React, { Component } from 'react';
import { Animated, PanResponder, ViewPropTypes, Keyboard } from 'react-native';
import { Animated, PanResponder, Keyboard } from 'react-native';
import PropTypes from 'prop-types';

import SuccessToast from './components/success';
import ErrorToast from './components/error';
import InfoToast from './components/info';
import { complement } from './utils/arr';
import { includeKeys } from './utils/obj';
import { stylePropType } from './utils/prop-types';
import styles from './styles';

const FRICTION = 8;
Expand Down Expand Up @@ -390,7 +391,7 @@ class Toast extends Component {

Toast.propTypes = {
config: PropTypes.objectOf(PropTypes.func),
style: ViewPropTypes.style,
style: stylePropType,
topOffset: PropTypes.number,
bottomOffset: PropTypes.number,
keyboardOffset: PropTypes.number,
Expand Down
5 changes: 5 additions & 0 deletions src/utils/prop-types.js
@@ -0,0 +1,5 @@
import PropTypes from 'prop-types';

const stylePropType = PropTypes.oneOfType([PropTypes.object, PropTypes.number]);

export { stylePropType };

0 comments on commit 896e678

Please sign in to comment.