@shoutem/ui 5.1.0 → 5.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/components/ActionSheet/ActionSheet.js +15 -8
  2. package/components/ActionSheet/ActionSheetOption.js +7 -2
  3. package/components/Button.js +5 -9
  4. package/components/CategoryPicker/Category.js +45 -0
  5. package/components/CategoryPicker/CategoryPicker.js +62 -0
  6. package/components/CategoryPicker/index.js +1 -0
  7. package/components/CategoryPicker/shapes.js +7 -0
  8. package/components/DateTimePicker.js +4 -1
  9. package/components/DropDownMenu/DropDownMenu.js +20 -23
  10. package/components/DropDownMenu/DropDownModal.js +56 -54
  11. package/components/EmptyStateView.js +16 -12
  12. package/components/FormGroup.js +7 -1
  13. package/components/GridRow.js +1 -1
  14. package/components/HorizontalPager/HorizontalPager.js +61 -52
  15. package/components/HorizontalPager/Page.js +12 -7
  16. package/components/Icon/Icon.js +1 -1
  17. package/components/Image.js +4 -4
  18. package/components/ImageBackground.js +4 -4
  19. package/components/ImageGallery/ImageGallery.android.js +8 -0
  20. package/components/ImageGallery/ImageGallery.ios.js +8 -0
  21. package/components/ImageGallery/ImageGalleryBase.js +65 -48
  22. package/components/ImageGalleryOverlay.js +12 -7
  23. package/components/ImagePreview.js +19 -14
  24. package/components/InlineDropDownMenu/InlineDropDownMenu.js +27 -18
  25. package/components/InlineDropDownMenu/InlineDropDownMenuItem.js +17 -9
  26. package/components/InlineGallery.js +42 -35
  27. package/components/LinearGradient.js +15 -5
  28. package/components/ListView.js +1 -2
  29. package/components/LoadingContainer.js +1 -2
  30. package/components/NavigationBar/NavigationBar.js +18 -13
  31. package/components/NumberInput.js +32 -24
  32. package/components/PageIndicators.js +19 -17
  33. package/components/ScrollView/ScrollDriverProvider.js +20 -10
  34. package/components/ScrollView/ScrollView.js +15 -13
  35. package/components/SearchField.js +24 -18
  36. package/components/ShareButton.js +21 -11
  37. package/components/Spinner.js +1 -1
  38. package/components/Switch.js +19 -14
  39. package/components/TabMenu/TabMenu.js +12 -7
  40. package/components/TabMenu/TabMenuItem.js +13 -7
  41. package/components/TextInput.js +3 -1
  42. package/components/Touchable.js +19 -23
  43. package/components/TouchableNativeFeedback.js +15 -21
  44. package/components/TouchableOpacity.js +6 -12
  45. package/components/Video/Video.js +21 -25
  46. package/components/View.js +7 -9
  47. package/components/YearRangePicker/YearRangePicker.js +22 -17
  48. package/components/YearRangePicker/YearRangePickerButton.js +13 -7
  49. package/components/YearRangePicker/YearRangePickerModal.js +23 -16
  50. package/examples/components/NavigationBars.js +4 -0
  51. package/examples/components/Stage.js +6 -1
  52. package/html/Html.js +14 -8
  53. package/html/components/Gallery.js +9 -5
  54. package/html/components/Image.js +16 -16
  55. package/html/components/SimpleHtml.js +19 -10
  56. package/html/elements/A.js +11 -6
  57. package/html/elements/Inline.js +13 -14
  58. package/html/elements/Text.js +6 -0
  59. package/html/elements/Video.js +3 -1
  60. package/html/elements/list/Li.js +0 -2
  61. package/html/elements/list/Ol.js +4 -0
  62. package/html/elements/list/Ul.js +4 -0
  63. package/html/elements/list/prefix/Bullet.js +4 -0
  64. package/html/elements/list/prefix/Number.js +6 -1
  65. package/index.js +42 -54
  66. package/package.json +1 -1
  67. package/theme.js +51 -0
@@ -20,19 +20,6 @@ function getBackgroundColor(style) {
20
20
 
21
21
  // eslint-disable-next-line react/prefer-stateless-function
22
22
  class NavigationBar extends PureComponent {
23
- static propTypes = {
24
- leftComponent: PropTypes.node,
25
- centerComponent: PropTypes.node,
26
- rightComponent: PropTypes.node,
27
- style: PropTypes.object,
28
- id: PropTypes.string,
29
- statusBarColor: PropTypes.string,
30
- };
31
-
32
- static defaultProps = {
33
- id: 'default',
34
- };
35
-
36
23
  setStatusBarStyle(backgroundColor) {
37
24
  function chooseBarStyle(bgColor) {
38
25
  return color(bgColor).isDark() ? 'light-content' : 'default';
@@ -100,6 +87,24 @@ class NavigationBar extends PureComponent {
100
87
  }
101
88
  }
102
89
 
90
+ NavigationBar.propTypes = {
91
+ style: PropTypes.object.isRequired,
92
+ centerComponent: PropTypes.node,
93
+ id: PropTypes.string,
94
+ leftComponent: PropTypes.node,
95
+ rightComponent: PropTypes.node,
96
+ // eslint-disable-next-line react/no-unused-prop-types
97
+ statusBarColor: PropTypes.string,
98
+ };
99
+
100
+ NavigationBar.defaultProps = {
101
+ id: 'default',
102
+ leftComponent: undefined,
103
+ centerComponent: undefined,
104
+ rightComponent: undefined,
105
+ statusBarColor: undefined,
106
+ };
107
+
103
108
  const AnimatedNavigationBar = connectAnimation(composeChildren(NavigationBar));
104
109
  const StyledNavigationBar = connectStyle('shoutem.ui.NavigationBar')(
105
110
  AnimatedNavigationBar,
@@ -22,28 +22,6 @@ import { View } from './View';
22
22
  * focus and blur events.
23
23
  */
24
24
  class NumberInput extends PureComponent {
25
- static propTypes = {
26
- ...TextInput.propTypes,
27
- // Maximum allowed value
28
- max: PropTypes.number,
29
- // Minimum allowed value
30
- min: PropTypes.number,
31
- // Called when the user changes the value by inputting it directly or with buttons
32
- onChange: PropTypes.func.isRequired,
33
- // Step used to increase or decrease value with corresponding buttons
34
- step: PropTypes.number,
35
- // Styles for component parts
36
- style: PropTypes.shape({
37
- button: PropTypes.object,
38
- container: PropTypes.object,
39
- icon: PropTypes.object,
40
- input: PropTypes.object,
41
- inputContainer: PropTypes.object,
42
- }),
43
- // Value of the input - can be empty
44
- value: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
45
- };
46
-
47
25
  constructor(props) {
48
26
  super(props);
49
27
 
@@ -57,13 +35,13 @@ class NumberInput extends PureComponent {
57
35
  }
58
36
 
59
37
  decreaseValue() {
60
- const { step = 1, value = 0 } = this.props;
38
+ const { step, value } = this.props;
61
39
 
62
40
  this.updateValue(value - step);
63
41
  }
64
42
 
65
43
  increaseValue() {
66
- const { step = 1, value = 0 } = this.props;
44
+ const { step, value } = this.props;
67
45
 
68
46
  this.updateValue(value + step);
69
47
  }
@@ -113,6 +91,36 @@ class NumberInput extends PureComponent {
113
91
  }
114
92
  }
115
93
 
94
+ NumberInput.propTypes = {
95
+ ...TextInput.propTypes,
96
+ // Styles for component parts
97
+ style: PropTypes.shape({
98
+ button: PropTypes.object,
99
+ container: PropTypes.object,
100
+ icon: PropTypes.object,
101
+ input: PropTypes.object,
102
+ inputContainer: PropTypes.object,
103
+ }).isRequired,
104
+ // Called when the user changes the value by inputting it directly or with buttons
105
+ onChange: PropTypes.func.isRequired,
106
+ // Maximum allowed value
107
+ max: PropTypes.number,
108
+ // Minimum allowed value
109
+ min: PropTypes.number,
110
+ // Step used to increase or decrease value with corresponding buttons
111
+ step: PropTypes.number,
112
+ // Value of the input - can be empty
113
+ value: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
114
+ };
115
+
116
+ NumberInput.defaultProps = {
117
+ ...TextInput.defaultProps,
118
+ max: undefined,
119
+ min: undefined,
120
+ step: 1,
121
+ value: 0,
122
+ };
123
+
116
124
  const AnimatedNumberInput = connectAnimation(NumberInput);
117
125
  const StyledNumberInput = connectStyle('shoutem.ui.NumberInput')(
118
126
  AnimatedNumberInput,
@@ -8,23 +8,6 @@ import { View } from './View';
8
8
  * Renders Page indicators (dots)
9
9
  */
10
10
  class PageIndicators extends PureComponent {
11
- static propTypes = {
12
- // ActiveIndex: number defining which page indicator will be rendered as active (selected)
13
- activeIndex: PropTypes.number,
14
- // Count: number defining how many page indicators will be rendered
15
- count: PropTypes.number,
16
- // maxCount defining highest number of page indicators that can be rendered
17
- // If `count` is higher than `maxCount`, then `maxCount` number of indicators
18
- // will be rendered. Defaults to 10
19
- maxCount: PropTypes.number,
20
- // Style prop used to override default (theme) styling
21
- style: PropTypes.object,
22
- };
23
-
24
- static defaultProps = {
25
- maxCount: 10,
26
- };
27
-
28
11
  constructor(props) {
29
12
  super(props);
30
13
 
@@ -73,6 +56,25 @@ class PageIndicators extends PureComponent {
73
56
  }
74
57
  }
75
58
 
59
+ PageIndicators.propTypes = {
60
+ // Style prop used to override default (theme) styling
61
+ style: PropTypes.object.isRequired,
62
+ // ActiveIndex: number defining which page indicator will be rendered as active (selected)
63
+ activeIndex: PropTypes.number,
64
+ // Count: number defining how many page indicators will be rendered
65
+ count: PropTypes.number,
66
+ // maxCount defining highest number of page indicators that can be rendered
67
+ // If `count` is higher than `maxCount`, then `maxCount` number of indicators
68
+ // will be rendered. Defaults to 10
69
+ maxCount: PropTypes.number,
70
+ };
71
+
72
+ PageIndicators.defaultProps = {
73
+ activeIndex: undefined,
74
+ count: undefined,
75
+ maxCount: 10,
76
+ };
77
+
76
78
  const StyledPageIndicators = connectStyle('shoutem.ui.PageIndicators')(
77
79
  PageIndicators,
78
80
  );
@@ -19,16 +19,6 @@ export class ScrollDriverProvider extends PureComponent {
19
19
  animationDriver: DriverShape,
20
20
  };
21
21
 
22
- static propTypes = {
23
- children: PropTypes.node,
24
- driver: DriverShape,
25
- // Used to propagate animation driver changes to components who aren't
26
- // children of ScrollDriver, recieves driver as argument.
27
- // TODO: Rewrite for new context API.
28
- onAnimationDriverChange: PropTypes.func,
29
- onScroll: PropTypes.func,
30
- };
31
-
32
22
  constructor(props, context) {
33
23
  super(props, context);
34
24
 
@@ -87,3 +77,23 @@ export class ScrollDriverProvider extends PureComponent {
87
77
  return children && Children.only(children);
88
78
  }
89
79
  }
80
+
81
+ // We disable this eslint rule because the props are being utilized indirectly
82
+ // through componentDidUpdate's usage of setupAnimationDriver
83
+ /* eslint-disable react/no-unused-prop-types */
84
+ ScrollDriverProvider.propTypes = {
85
+ children: PropTypes.node,
86
+ driver: DriverShape,
87
+ // Used to propagate animation driver changes to components that aren't
88
+ // children of ScrollDriver, recieves driver as argument.
89
+ // TODO: Rewrite for new context API.
90
+ onAnimationDriverChange: PropTypes.func,
91
+ onScroll: PropTypes.func,
92
+ };
93
+
94
+ ScrollDriverProvider.defaultProps = {
95
+ children: undefined,
96
+ driver: undefined,
97
+ onAnimationDriverChange: undefined,
98
+ onScroll: undefined,
99
+ };
@@ -12,11 +12,6 @@ const isTabBarOnScreen = true;
12
12
  const IPHONE_X_HOME_INDICATOR_PADDING = isTabBarOnScreen ? 0 : 34;
13
13
 
14
14
  class ScrollView extends PureComponent {
15
- static propTypes = {
16
- ...Animated.ScrollView.propTypes,
17
- primary: PropTypes.bool,
18
- };
19
-
20
15
  static contextTypes = {
21
16
  animationDriver: DriverShape,
22
17
  driverProvider: PropTypes.object,
@@ -82,24 +77,31 @@ class ScrollView extends PureComponent {
82
77
  }
83
78
 
84
79
  render() {
85
- const { props, animationDriver } = this;
86
- const { style = {} } = props;
87
- const contentContainerStyle = {
88
- ...style.contentContainerStyle,
89
- };
90
- delete style.contentContainerStyle;
80
+ const { style, ...otherProps } = this.props;
81
+ const { scrollViewProps } = this.animationDriver;
82
+ const { contentContainerStyle, ...otherStyle } = style;
91
83
 
92
84
  return (
93
85
  <Animated.ScrollView
94
86
  ref={this.setWrappedInstance}
95
87
  contentContainerStyle={this.addIphoneXPadding(contentContainerStyle)}
96
- {...animationDriver.scrollViewProps}
97
- {..._.omit(props, 'onScroll')}
88
+ {...scrollViewProps}
89
+ {..._.omit(otherProps, 'onScroll')}
90
+ style={otherStyle}
98
91
  />
99
92
  );
100
93
  }
101
94
  }
102
95
 
96
+ ScrollView.propTypes = {
97
+ ...Animated.ScrollView.propTypes,
98
+ primary: PropTypes.bool,
99
+ };
100
+
101
+ ScrollView.defaultProps = {
102
+ primary: false,
103
+ };
104
+
103
105
  const StyledScrollView = connectStyle('shoutem.ui.ScrollView')(ScrollView);
104
106
 
105
107
  function getRNScrollViewComponent(context) {
@@ -14,8 +14,8 @@ const ClearButton = ({ style, onPress }) => (
14
14
  );
15
15
 
16
16
  ClearButton.propTypes = {
17
- style: PropTypes.object,
18
- onPress: PropTypes.func,
17
+ style: PropTypes.object.isRequired,
18
+ onPress: PropTypes.func.isRequired,
19
19
  };
20
20
 
21
21
  /**
@@ -24,22 +24,6 @@ ClearButton.propTypes = {
24
24
  *
25
25
  */
26
26
  class SearchField extends PureComponent {
27
- static propTypes = {
28
- // A placeholder for input when no value is entered
29
- placeholder: PropTypes.string,
30
- // Called with the new value on text change
31
- onChangeText: PropTypes.func,
32
- // Styles for container and search icon
33
- style: PropTypes.shape({
34
- clearIcon: PropTypes.object,
35
- container: PropTypes.object,
36
- input: PropTypes.object,
37
- searchIcon: PropTypes.object,
38
- }),
39
- // Value to render as text in search input
40
- value: PropTypes.string,
41
- };
42
-
43
27
  render() {
44
28
  const {
45
29
  onChangeText,
@@ -72,6 +56,28 @@ class SearchField extends PureComponent {
72
56
  }
73
57
  }
74
58
 
59
+ SearchField.propTypes = {
60
+ // Styles for container and search icon
61
+ style: PropTypes.shape({
62
+ clearIcon: PropTypes.object,
63
+ container: PropTypes.object,
64
+ input: PropTypes.object,
65
+ searchIcon: PropTypes.object,
66
+ }).isRequired,
67
+ // A placeholder for input when no value is entered
68
+ placeholder: PropTypes.string,
69
+ // Value to render as text in search input
70
+ value: PropTypes.string,
71
+ // Called with the new value on text change
72
+ onChangeText: PropTypes.func,
73
+ };
74
+
75
+ SearchField.defaultProps = {
76
+ placeholder: undefined,
77
+ value: undefined,
78
+ onChangeText: undefined,
79
+ };
80
+
75
81
  const AnimatedSearchField = connectAnimation(SearchField);
76
82
  const StyledSearchField = connectStyle('shoutem.ui.SearchField')(
77
83
  AnimatedSearchField,
@@ -15,17 +15,6 @@ import { Icon } from './Icon';
15
15
  * or animation.
16
16
  */
17
17
  class ShareButton extends PureComponent {
18
- static propTypes = {
19
- // Animation name for share icon
20
- animationName: PropTypes.string,
21
- // Message to share
22
- message: PropTypes.string,
23
- // Title
24
- title: PropTypes.string,
25
- // Url to share
26
- url: PropTypes.string,
27
- };
28
-
29
18
  constructor(props) {
30
19
  super(props);
31
20
 
@@ -59,6 +48,27 @@ class ShareButton extends PureComponent {
59
48
  }
60
49
  }
61
50
 
51
+ ShareButton.propTypes = {
52
+ // Animation name for share icon
53
+ animationName: PropTypes.string,
54
+ // Additional props for Icon component
55
+ iconProps: PropTypes.object,
56
+ // Message to share
57
+ message: PropTypes.string,
58
+ // Title
59
+ title: PropTypes.string,
60
+ // Url to share
61
+ url: PropTypes.string,
62
+ };
63
+
64
+ ShareButton.defaultProps = {
65
+ animationName: undefined,
66
+ iconProps: undefined,
67
+ message: undefined,
68
+ title: undefined,
69
+ url: undefined,
70
+ };
71
+
62
72
  const StyledShareButton = connectStyle(
63
73
  'shoutem.ui.ShareButton',
64
74
  undefined,
@@ -20,7 +20,7 @@ class Spinner extends PureComponent {
20
20
  }
21
21
 
22
22
  Spinner.propTypes = {
23
- style: PropTypes.object,
23
+ style: PropTypes.object.isRequired,
24
24
  };
25
25
 
26
26
  const StyledSpinner = connectStyle('shoutem.ui.Spinner', {
@@ -7,20 +7,6 @@ import { connectStyle } from '@shoutem/theme';
7
7
  import { View } from './View';
8
8
 
9
9
  class Switch extends PureComponent {
10
- static propTypes = {
11
- // True when switch is on, false otherwise
12
- value: PropTypes.bool,
13
- // Called when switch is toggled on and off
14
- onValueChange: PropTypes.func,
15
- // Styles for the container and underlying thumb
16
- style: PropTypes.shape({
17
- // Container style
18
- container: PropTypes.object,
19
- // Thumb style
20
- thumb: PropTypes.object,
21
- }),
22
- };
23
-
24
10
  constructor(props) {
25
11
  super(props);
26
12
 
@@ -76,6 +62,25 @@ class Switch extends PureComponent {
76
62
  }
77
63
  }
78
64
 
65
+ Switch.propTypes = {
66
+ // Styles for the container and underlying thumb
67
+ style: PropTypes.shape({
68
+ // Container style
69
+ container: PropTypes.object,
70
+ // Thumb style
71
+ thumb: PropTypes.object,
72
+ }).isRequired,
73
+ // True when switch is on, false otherwise
74
+ value: PropTypes.bool,
75
+ // Called when switch is toggled on and off
76
+ onValueChange: PropTypes.func,
77
+ };
78
+
79
+ Switch.defaultProps = {
80
+ value: false,
81
+ onValueChange: undefined,
82
+ };
83
+
79
84
  const AnimatedSwitch = connectAnimation(Switch);
80
85
  const StyledSwitch = connectStyle('shoutem.ui.Switch')(AnimatedSwitch);
81
86
 
@@ -8,13 +8,6 @@ import { optionShape } from './const';
8
8
  import { TabMenuItem } from './TabMenuItem';
9
9
 
10
10
  class TabMenu extends PureComponent {
11
- static propTypes = {
12
- options: PropTypes.arrayOf(optionShape).isRequired,
13
- onOptionSelected: PropTypes.func,
14
- selectedOption: optionShape,
15
- style: PropTypes.object,
16
- };
17
-
18
11
  constructor(props) {
19
12
  super(props);
20
13
 
@@ -59,6 +52,18 @@ class TabMenu extends PureComponent {
59
52
  }
60
53
  }
61
54
 
55
+ TabMenu.propTypes = {
56
+ options: PropTypes.arrayOf(optionShape).isRequired,
57
+ style: PropTypes.object.isRequired,
58
+ selectedOption: optionShape,
59
+ onOptionSelected: PropTypes.func,
60
+ };
61
+
62
+ TabMenu.defaultProps = {
63
+ selectedOption: undefined,
64
+ onOptionSelected: undefined,
65
+ };
66
+
62
67
  const StyledTabMenu = connectStyle('shoutem.ui.TabMenu')(TabMenu);
63
68
 
64
69
  export { StyledTabMenu as TabMenu };
@@ -10,13 +10,6 @@ import { View } from '../View';
10
10
  import { optionShape } from './const';
11
11
 
12
12
  class TabMenuItem extends PureComponent {
13
- static propTypes = {
14
- item: optionShape,
15
- onItemPressed: PropTypes.any,
16
- isSelected: PropTypes.bool,
17
- style: PropTypes.object,
18
- };
19
-
20
13
  constructor(props) {
21
14
  super(props);
22
15
 
@@ -63,6 +56,19 @@ class TabMenuItem extends PureComponent {
63
56
  }
64
57
  }
65
58
 
59
+ TabMenuItem.propTypes = {
60
+ style: PropTypes.object.isRequired,
61
+ isSelected: PropTypes.bool,
62
+ item: optionShape,
63
+ onItemPressed: PropTypes.func,
64
+ };
65
+
66
+ TabMenuItem.defaultProps = {
67
+ isSelected: false,
68
+ item: undefined,
69
+ onItemPressed: undefined,
70
+ };
71
+
66
72
  const StyledTabMenuItem = connectStyle('shoutem.ui.TabMenuItem')(TabMenuItem);
67
73
 
68
74
  export { StyledTabMenuItem as TabMenuItem };
@@ -90,12 +90,14 @@ class TextInput extends PureComponent {
90
90
 
91
91
  TextInput.propTypes = {
92
92
  ...RNTextInput.propTypes,
93
+ style: PropTypes.object.isRequired,
93
94
  animate: PropTypes.bool,
94
- style: PropTypes.object,
95
+ errorMessage: PropTypes.string,
95
96
  };
96
97
 
97
98
  TextInput.defaultProps = {
98
99
  animate: true,
100
+ errorMessage: undefined,
99
101
  };
100
102
 
101
103
  const AnimatedTextInput = connectAnimation(TextInput);
@@ -7,33 +7,23 @@ import { TouchableOpacity } from './TouchableOpacity';
7
7
  import { View } from './View';
8
8
 
9
9
  /**
10
- * A universal touchable component with a
11
- * platform specific feedback. This
12
- * component displays a TouchableOpacity on
13
- * iOS, and a TouchableNativeFeedback on
14
- * Android.
10
+ * A universal touchable component with a platform specific feedback. This
11
+ * component displays a TouchableOpacity on iOS, and a TouchableNativeFeedback
12
+ * on Android.
15
13
  */
16
14
  class Touchable extends PureComponent {
17
- static propTypes = {
18
- ...TouchableOpacity.propTypes,
19
- ...TouchableNativeFeedback.propTypes,
20
- style: PropTypes.object,
21
- };
22
-
23
15
  render() {
24
- const { props } = this;
25
- const style = { ...props.style };
26
- delete style.touchableOpacity;
27
- delete style.touchableNativeFeedback;
16
+ const { children, style, styleName, ...otherProps } = this.props;
17
+ const { touchableNativeFeedback, touchableOpacity, ...otherStyle } = style;
28
18
 
29
19
  if (Platform.OS === 'android') {
30
20
  return (
31
21
  <TouchableNativeFeedback
32
- {...props}
33
- style={props.style.touchableNativeFeedback}
22
+ {...otherProps}
23
+ style={touchableNativeFeedback}
34
24
  >
35
- <View virtual style={style} styleName={props.styleName}>
36
- {props.children}
25
+ <View virtual style={otherStyle} styleName={styleName}>
26
+ {children}
37
27
  </View>
38
28
  </TouchableNativeFeedback>
39
29
  );
@@ -41,18 +31,24 @@ class Touchable extends PureComponent {
41
31
 
42
32
  return (
43
33
  <TouchableOpacity
44
- {...props}
34
+ {...otherProps}
45
35
  style={{
46
- ...style,
47
- ...props.style.touchableOpacity,
36
+ ...otherStyle,
37
+ ...touchableOpacity,
48
38
  }}
49
39
  >
50
- {props.children}
40
+ {children}
51
41
  </TouchableOpacity>
52
42
  );
53
43
  }
54
44
  }
55
45
 
46
+ Touchable.propTypes = {
47
+ ...TouchableOpacity.propTypes,
48
+ ...TouchableNativeFeedback.propTypes,
49
+ style: PropTypes.object.isRequired,
50
+ };
51
+
56
52
  const StyledTouchable = connectStyle('shoutem.ui.Touchable', {
57
53
  touchableNativeFeedback: {},
58
54
  touchableOpacity: {},
@@ -4,37 +4,31 @@ import PropTypes from 'prop-types';
4
4
  import { connectStyle } from '@shoutem/theme';
5
5
 
6
6
  class TouchableNativeFeedback extends PureComponent {
7
- static propTypes = {
8
- ...RNTouchableNativeFeedback.propTypes,
9
- style: PropTypes.shape({
10
- background: PropTypes.object,
11
- useForeground: PropTypes.bool,
12
- }),
13
- };
14
-
15
7
  render() {
16
- const { props } = this;
17
- // Remove the props that are not valid
18
- // style keys.
19
- const style = {
20
- ...props.style,
21
- };
22
- delete style.background;
23
- delete style.useForeground;
8
+ const { children, style, ...otherProps } = this.props;
9
+ const { background, useForeground, ...otherStyle } = style;
24
10
 
25
11
  return (
26
12
  <RNTouchableNativeFeedback
27
- {...props}
28
- style={style}
29
- background={props.style.background}
30
- useForeground={props.style.useForeground}
13
+ {...otherProps}
14
+ style={otherStyle}
15
+ background={background}
16
+ useForeground={useForeground}
31
17
  >
32
- {props.children}
18
+ {children}
33
19
  </RNTouchableNativeFeedback>
34
20
  );
35
21
  }
36
22
  }
37
23
 
24
+ TouchableNativeFeedback.propTypes = {
25
+ ...RNTouchableNativeFeedback.propTypes,
26
+ style: PropTypes.shape({
27
+ background: PropTypes.object,
28
+ useForeground: PropTypes.bool,
29
+ }).isRequired,
30
+ };
31
+
38
32
  const StyledTouchableNativeFeedback = connectStyle(
39
33
  'shoutem.ui.TouchableNativeFeedback',
40
34
  )(TouchableNativeFeedback);
@@ -4,22 +4,16 @@ import { connectStyle } from '@shoutem/theme';
4
4
 
5
5
  class TouchableOpacity extends PureComponent {
6
6
  render() {
7
- const { props } = this;
8
-
9
- // The activeOpacity is not a valid RN style
10
- // property, so we have to unset it here.
11
- const style = {
12
- ...props.style,
13
- };
14
- delete style.activeOpacity;
7
+ const { children, style, ...otherProps } = this.props;
8
+ const { activeOpacity, ...otherStyle } = style;
15
9
 
16
10
  return (
17
11
  <RNTouchableOpacity
18
- {...props}
19
- style={style}
20
- activeOpacity={props.style.activeOpacity}
12
+ {...otherProps}
13
+ style={otherStyle}
14
+ activeOpacity={activeOpacity}
21
15
  >
22
- {props.children}
16
+ {children}
23
17
  </RNTouchableOpacity>
24
18
  );
25
19
  }