@shoutem/ui 5.3.0 → 5.5.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.
package/README.md CHANGED
@@ -20,84 +20,6 @@ All the documentation is available on the [Developer portal](http://shoutem.gith
20
20
 
21
21
  Join [our community](https://www.facebook.com/groups/shoutem.community/) on Facebook. Also, feel free to ask a question on Stack Overflow using ["shoutem" tag](http://stackoverflow.com/tags/shoutem).
22
22
 
23
- ## Examples
24
-
25
- To see how Shoutem UI works, you can:
26
-
27
- - include the `Examples` component into your React Native app or
28
- - run `Restaurants` app in `examples` folder.
29
-
30
- ### Examples component
31
-
32
- **If you are using Expo, see [this
33
- project](https://github.com/shoutem/ui/blob/develop/examples/create-react-native-app/App.js)
34
- for example usage. Otherwise, follow the steps below.**
35
-
36
- Create new React Native project and locate to it:
37
-
38
- ```bash
39
- $ react-native init HelloWorld && cd HelloWorld
40
- ```
41
-
42
- Install `@shoutem/ui` in your project:
43
-
44
- ```bash
45
- $ npm install --save @shoutem/ui
46
- ```
47
-
48
- Now, simply copy the following to your `App.js` files of the React Native project:
49
-
50
- ```JavaScript
51
- import React, { PureComponent } from 'react';
52
- import { Examples } from '@shoutem/ui';
53
-
54
- export default class App extends PureComponent {
55
- render() {
56
- return (
57
- <Examples />
58
- );
59
- }
60
- }
61
- ```
62
-
63
- Finally, run the app!
64
-
65
- ```bash
66
- $ react-native run-ios
67
- ```
68
-
69
- To see other components, just import them from `@shoutem/ui` and render them.
70
-
71
- You can also use standard React Native components in your layouts anywhere you want, but they will not inherit either the theme or the parent styles, so you will need to style them manually.
72
-
73
- ### Restaurants app
74
-
75
- Clone the [Shoutem UI](https://github.com/shoutem/ui) repository:
76
-
77
- ```bash
78
- git clone https://github.com/shoutem/ui.git
79
- ```
80
-
81
- Locate to `RestaurantsApp` folder:
82
-
83
- ```bash
84
- cd ui/examples/RestaurantsApp
85
- ```
86
-
87
- Install and link dependencies:
88
-
89
- ```bash
90
- npm install
91
- react-native link
92
- ```
93
-
94
- Finally, run the app!
95
-
96
- ```bash
97
- react-native run-ios
98
- react-native run-android
99
- ```
100
-
101
23
  ## UI Toolkit
102
24
 
103
25
  Shoutem UI is a part of the [Shoutem UI Toolkit](https://shoutem.github.io/ui/) that enables you to build professional looking React Native apps with ease.
@@ -54,7 +54,7 @@ class DropDownMenu extends PureComponent {
54
54
  <View style={style.horizontalContainer}>
55
55
  <Button onPress={this.collapse} style={style.selectedOption}>
56
56
  {showSelectedOption && <Text>{selectedOption[titleProperty]}</Text>}
57
- <Icon name={iconName} />
57
+ <Icon name={iconName} style={style.icon} />
58
58
  </Button>
59
59
  </View>
60
60
  ) : null;
@@ -52,7 +52,6 @@ class EmptyListImage extends PureComponent {
52
52
  }
53
53
 
54
54
  EmptyListImage.propTypes = {
55
- ...EmptyListImage.propTypes,
56
55
  image: PropTypes.func,
57
56
  imageStyle: PropTypes.object,
58
57
  message: PropTypes.string,
@@ -1,5 +1,5 @@
1
1
  import React, { Children, PureComponent } from 'react';
2
- import { View as RNView, ViewPropTypes } from 'react-native';
2
+ import { View as RNView } from 'react-native';
3
3
  import _ from 'lodash';
4
4
  import PropTypes from 'prop-types';
5
5
  import { connectAnimation } from '@shoutem/animation';
@@ -35,7 +35,7 @@ class GridRow extends PureComponent {
35
35
  }
36
36
 
37
37
  GridRow.propTypes = {
38
- ...ViewPropTypes,
38
+ ...View.propTypes,
39
39
  columns: PropTypes.number.isRequired,
40
40
  };
41
41
 
@@ -1,6 +1,7 @@
1
1
  import React, { PureComponent } from 'react';
2
2
  import { Image as RNImage, Platform } from 'react-native';
3
3
  import autoBindReact from 'auto-bind/react';
4
+ import { ImagePropTypes } from 'deprecated-react-native-prop-types';
4
5
  import _ from 'lodash';
5
6
  import { connectAnimation } from '@shoutem/animation';
6
7
  import { connectStyle } from '@shoutem/theme';
@@ -82,7 +83,7 @@ class Image extends PureComponent {
82
83
  }
83
84
 
84
85
  Image.propTypes = {
85
- ...RNImage.propTypes,
86
+ ...ImagePropTypes,
86
87
  };
87
88
 
88
89
  const AnimatedImage = connectAnimation(Image);
@@ -65,11 +65,11 @@ class NumberInput extends PureComponent {
65
65
  return (
66
66
  <View style={style.container} styleName="horizontal">
67
67
  <Button
68
- style={style.button}
68
+ style={[style.button, style.buttonLeft]}
69
69
  styleName="secondary"
70
70
  onPress={this.decreaseValue}
71
71
  >
72
- <Icon name="minus-button" style={style.icon} />
72
+ <Icon name="minus-button" style={[style.icon, style.iconLeft]} />
73
73
  </Button>
74
74
  <View style={style.inputContainer} styleName="horizontal">
75
75
  <TextInput
@@ -80,11 +80,11 @@ class NumberInput extends PureComponent {
80
80
  />
81
81
  </View>
82
82
  <Button
83
- style={style.button}
83
+ style={[style.button, style.buttonRight]}
84
84
  styleName="secondary"
85
85
  onPress={this.increaseValue}
86
86
  >
87
- <Icon name="plus-button" style={style.icon} />
87
+ <Icon name="plus-button" style={[style.icon, style.iconRight]} />
88
88
  </Button>
89
89
  </View>
90
90
  );
@@ -24,7 +24,7 @@ class ShareButton extends PureComponent {
24
24
  onShare() {
25
25
  const { title, message, url } = this.props;
26
26
 
27
- Share.share({
27
+ return Share.share({
28
28
  title,
29
29
  // URL property isn't supported on Android, so we are
30
30
  // including it as the message for now.
@@ -34,7 +34,11 @@ class ShareButton extends PureComponent {
34
34
  }
35
35
 
36
36
  render() {
37
- const { animationName, iconProps, ...otherProps } = this.props;
37
+ const { animationName, iconProps, url, ...otherProps } = this.props;
38
+
39
+ if (!url) {
40
+ return null;
41
+ }
38
42
 
39
43
  return (
40
44
  <Button onPress={this.onShare} {...otherProps}>
@@ -1,5 +1,6 @@
1
1
  import React, { PureComponent } from 'react';
2
2
  import { Text as RNText } from 'react-native';
3
+ import { TextPropTypes } from 'deprecated-react-native-prop-types';
3
4
  import { connectAnimation } from '@shoutem/animation';
4
5
  import { connectStyle } from '@shoutem/theme';
5
6
 
@@ -10,7 +11,7 @@ class Text extends PureComponent {
10
11
  }
11
12
 
12
13
  Text.propTypes = {
13
- ...RNText.propTypes,
14
+ ...TextPropTypes,
14
15
  };
15
16
 
16
17
  const AnimatedText = connectAnimation(Text);
@@ -1,6 +1,7 @@
1
1
  import React, { PureComponent } from 'react';
2
2
  import { TextInput as RNTextInput } from 'react-native';
3
3
  import autoBindReact from 'auto-bind/react';
4
+ import { TextInputPropTypes } from 'deprecated-react-native-prop-types';
4
5
  import PropTypes from 'prop-types';
5
6
  import { connectAnimation, Wiggle } from '@shoutem/animation';
6
7
  import { connectStyle } from '@shoutem/theme';
@@ -91,7 +92,7 @@ class TextInput extends PureComponent {
91
92
  }
92
93
 
93
94
  TextInput.propTypes = {
94
- ...RNTextInput.propTypes,
95
+ ...TextInputPropTypes,
95
96
  style: PropTypes.object.isRequired,
96
97
  animate: PropTypes.bool,
97
98
  errorMessage: PropTypes.string,
@@ -1,5 +1,6 @@
1
1
  import React, { PureComponent } from 'react';
2
- import { View as RNView, ViewPropTypes } from 'react-native';
2
+ import { View as RNView } from 'react-native';
3
+ import { ViewPropTypes } from 'deprecated-react-native-prop-types';
3
4
  import PropTypes from 'prop-types';
4
5
  import { connectAnimation } from '@shoutem/animation';
5
6
  import { connectStyle } from '@shoutem/theme';
package/index.js CHANGED
@@ -11,6 +11,8 @@ export {
11
11
  resolveFontFamily,
12
12
  resolveFontStyle,
13
13
  resolveFontWeight,
14
+ responsiveHeight,
15
+ responsiveWidth,
14
16
  } from './theme';
15
17
 
16
18
  // Services
@@ -70,9 +72,6 @@ export { Video } from './components/Video';
70
72
  export { View } from './components/View';
71
73
  export { YearRangePicker } from './components/YearRangePicker';
72
74
 
73
- // Examples
74
- export { Examples } from './examples/components';
75
-
76
75
  // Helpers
77
76
  export { calculateKeyboardOffset, Device, Keyboard } from './helpers';
78
77
 
@@ -87,7 +86,6 @@ export {
87
86
  IPHONE_X_NOTCH_PADDING,
88
87
  IPHONE_XR_LONG_SIDE,
89
88
  IPHONE_XR_NOTCH_PADDING,
90
- nativeDependencies,
91
89
  NAVIGATION_BAR_HEIGHT,
92
90
  NAVIGATION_HEADER_HEIGHT,
93
91
  STATUS_BAR_OFFSET,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shoutem/ui",
3
- "version": "5.3.0",
3
+ "version": "5.5.0",
4
4
  "description": "Styleable set of components for React Native applications",
5
5
  "scripts": {
6
6
  "lint": "eslint .",
@@ -16,25 +16,27 @@
16
16
  "auto-bind": "4.0.0",
17
17
  "babel-plugin-transform-decorators-legacy": "1.3.5",
18
18
  "buffer": "5.6.0",
19
+ "deprecated-react-native-prop-types": "2.3.0",
19
20
  "events": "1.1.0",
20
21
  "fs-extra": "7.0.1",
21
22
  "html-entities": "1.3.1",
22
23
  "htmlparser2": "3.10.1",
23
24
  "lodash": "4.17.21",
24
- "lottie-react-native": "5.1.3",
25
+ "lottie-ios": "3.4.0",
26
+ "lottie-react-native": "5.1.4",
25
27
  "prop-types": "15.8.1",
26
28
  "qs": "6.9.3",
27
29
  "react-native-device-info": "9.0.2",
28
30
  "react-native-lightbox": "github:shoutem/react-native-lightbox#v0.7.2",
29
31
  "react-native-linear-gradient": "2.6.2",
30
32
  "react-native-modal": "11.7.0",
31
- "react-native-photo-view": "github:shoutem/react-native-photo-view#8f88667",
33
+ "react-native-photo-view": "github:shoutem/react-native-photo-view#a296aa2",
32
34
  "react-native-render-html": "4.2.5",
33
35
  "react-native-render-html-table-bridge": "0.6.0",
34
36
  "react-native-svg": "12.3.0",
35
37
  "react-native-svg-transformer": "1.0.0",
36
38
  "react-native-transformable-image": "github:shoutem/react-native-transformable-image#v0.0.20",
37
- "react-native-webview": "11.22.7",
39
+ "react-native-webview": "11.23.0",
38
40
  "react-native-youtube-iframe": "2.2.2",
39
41
  "stream": "0.0.2",
40
42
  "tinycolor2": "1.4.1"
@@ -67,6 +69,7 @@
67
69
  },
68
70
  "nativeDependencies": [
69
71
  "@react-native-community/datetimepicker",
72
+ "lottie-ios",
70
73
  "lottie-react-native",
71
74
  "react-native-device-info",
72
75
  "react-native-linear-gradient",
@@ -118,8 +121,7 @@
118
121
  "jest": {
119
122
  "preset": "react-native",
120
123
  "testPathIgnorePatterns": [
121
- "/node_modules/",
122
- "examples/"
124
+ "/node_modules/"
123
125
  ],
124
126
  "transformIgnorePatterns": [
125
127
  "!/node_modules/@shoutem"
package/theme.js CHANGED
@@ -48,9 +48,23 @@ export function dimensionRelativeToIphone(
48
48
  actualRefVal = window.width,
49
49
  ) {
50
50
  // 375 is iPhone width
51
+ // eslint-disable-next-line no-console
52
+ console.warn(
53
+ 'dimensionRelativeToIphone is depreacted and will be removed in next major release. Use responsiveWidth instead.',
54
+ );
51
55
  return getSizeRelativeToReference(dimension, 375, actualRefVal);
52
56
  }
53
57
 
58
+ export function responsiveWidth(dimension, actualRefVal = window.width) {
59
+ // 375 is iPhone width
60
+ return getSizeRelativeToReference(dimension, 375, actualRefVal);
61
+ }
62
+
63
+ export function responsiveHeight(dimension, actualRefVal = window.height) {
64
+ // 812 is iPhone height
65
+ return getSizeRelativeToReference(dimension, 812, actualRefVal);
66
+ }
67
+
54
68
  // 'fontWeight' and 'fontStyle' aren't always supplied for every component, so we're setting default
55
69
  // values of 'normal'.
56
70
  export function resolveFontFamily(
@@ -584,65 +598,65 @@ export default () => {
584
598
  imageSizes: {
585
599
  // NOTE: '-avatar' styles do not work with ImageBackground
586
600
  '.small-avatar': {
587
- width: dimensionRelativeToIphone(25),
588
- height: dimensionRelativeToIphone(25),
601
+ width: responsiveWidth(25),
602
+ height: responsiveWidth(25),
589
603
  borderRadius: 12.5,
590
604
  borderWidth: 0,
591
605
  },
592
606
 
593
607
  '.small': {
594
- width: dimensionRelativeToIphone(65),
595
- height: dimensionRelativeToIphone(65),
608
+ width: responsiveWidth(65),
609
+ height: responsiveWidth(65),
596
610
  },
597
611
 
598
612
  '.medium-avatar': {
599
- width: dimensionRelativeToIphone(145),
600
- height: dimensionRelativeToIphone(145),
601
- borderRadius: dimensionRelativeToIphone(72.5),
613
+ width: responsiveWidth(145),
614
+ height: responsiveWidth(145),
615
+ borderRadius: responsiveWidth(72.5),
602
616
  borderWidth: 0,
603
617
  },
604
618
 
605
619
  '.medium': {
606
- width: dimensionRelativeToIphone(145),
607
- height: dimensionRelativeToIphone(92),
620
+ width: responsiveWidth(145),
621
+ height: responsiveWidth(92),
608
622
  },
609
623
 
610
624
  '.medium-wide': {
611
- width: dimensionRelativeToIphone(180),
612
- height: dimensionRelativeToIphone(85),
625
+ width: responsiveWidth(180),
626
+ height: responsiveWidth(85),
613
627
  },
614
628
 
615
629
  '.medium-portrait': {
616
- width: dimensionRelativeToIphone(209),
617
- height: dimensionRelativeToIphone(139),
630
+ width: responsiveWidth(209),
631
+ height: responsiveWidth(139),
618
632
  },
619
633
 
620
634
  '.medium-square': {
621
- width: dimensionRelativeToIphone(145),
622
- height: dimensionRelativeToIphone(145),
635
+ width: responsiveWidth(145),
636
+ height: responsiveWidth(145),
623
637
  },
624
638
 
625
639
  // NOTE: Image resizing doesn't work correctly if both
626
640
  // dimensions are not explicitly defined, so we can't
627
641
  // use flex: 1, or alignSelf: 'stretch' here...
628
642
  '.featured': {
629
- width: dimensionRelativeToIphone(365),
630
- height: dimensionRelativeToIphone(345),
643
+ width: responsiveWidth(365),
644
+ height: responsiveWidth(345),
631
645
  },
632
646
 
633
647
  '.large': {
634
648
  width: window.width,
635
- height: dimensionRelativeToIphone(280),
649
+ height: responsiveWidth(280),
636
650
  },
637
651
 
638
652
  '.large-portrait': {
639
653
  width: window.width,
640
- height: dimensionRelativeToIphone(518),
654
+ height: responsiveWidth(518),
641
655
  },
642
656
 
643
657
  '.large-banner': {
644
658
  width: window.width,
645
- height: dimensionRelativeToIphone(200),
659
+ height: responsiveWidth(200),
646
660
  },
647
661
 
648
662
  '.large-square': {
@@ -652,12 +666,12 @@ export default () => {
652
666
 
653
667
  '.large-wide': {
654
668
  width: window.width,
655
- height: dimensionRelativeToIphone(238),
669
+ height: responsiveWidth(238),
656
670
  },
657
671
 
658
672
  '.large-ultra-wide': {
659
673
  width: window.width,
660
- height: dimensionRelativeToIphone(130),
674
+ height: responsiveWidth(130),
661
675
  },
662
676
  },
663
677
  'shoutem.ui.Image': {
@@ -1123,7 +1137,7 @@ export default () => {
1123
1137
  backgroundColor: resolveVariable('paperColor'),
1124
1138
  },
1125
1139
 
1126
- width: dimensionRelativeToIphone(180),
1140
+ width: responsiveWidth(180),
1127
1141
  flexDirection: 'column',
1128
1142
  justifyContent: 'center',
1129
1143
  alignItems: 'flex-start',
@@ -1137,7 +1151,7 @@ export default () => {
1137
1151
  'shoutem.ui.View': {
1138
1152
  '.pull-left': {
1139
1153
  marginVertical: resolveVariable('mediumGutter'),
1140
- marginLeft: -dimensionRelativeToIphone(72),
1154
+ marginLeft: -responsiveWidth(72),
1141
1155
  },
1142
1156
  },
1143
1157
 
@@ -1340,7 +1354,7 @@ export default () => {
1340
1354
  fontFamily: 'Rubik-Medium',
1341
1355
  },
1342
1356
 
1343
- width: dimensionRelativeToIphone(120),
1357
+ width: responsiveWidth(120),
1344
1358
  height: 82,
1345
1359
  flexDirection: 'column',
1346
1360
  },
@@ -2287,8 +2301,8 @@ export default () => {
2287
2301
  },
2288
2302
  video: {
2289
2303
  // 16:9 ratio covers majority of YouTube videos
2290
- width: dimensionRelativeToIphone(345),
2291
- height: dimensionRelativeToIphone(194),
2304
+ width: responsiveWidth(345),
2305
+ height: responsiveWidth(194),
2292
2306
  paddingBottom: resolveVariable('smallGutter'),
2293
2307
  },
2294
2308
  fallback: {
@@ -2565,30 +2579,30 @@ export default () => {
2565
2579
  'shoutem.ui.InlineGallery': {
2566
2580
  '.large-ultra-wide': {
2567
2581
  container: {
2568
- height: dimensionRelativeToIphone(130),
2582
+ height: responsiveWidth(130),
2569
2583
  },
2570
2584
  },
2571
2585
 
2572
2586
  '.large-banner': {
2573
2587
  container: {
2574
- height: dimensionRelativeToIphone(200),
2588
+ height: responsiveWidth(200),
2575
2589
  },
2576
2590
  },
2577
2591
 
2578
2592
  '.large-wide': {
2579
2593
  container: {
2580
- height: dimensionRelativeToIphone(238),
2594
+ height: responsiveWidth(238),
2581
2595
  },
2582
2596
  },
2583
2597
 
2584
2598
  '.large-square': {
2585
2599
  container: {
2586
- height: dimensionRelativeToIphone(375),
2600
+ height: responsiveWidth(375),
2587
2601
  },
2588
2602
  },
2589
2603
 
2590
2604
  container: {
2591
- height: dimensionRelativeToIphone(345),
2605
+ height: responsiveWidth(345),
2592
2606
  },
2593
2607
 
2594
2608
  imageContainer: {},
@@ -1,95 +0,0 @@
1
- import React from 'react';
2
- import { Button } from '../../components/Button';
3
- import { Icon } from '../../components/Icon';
4
- import { Text } from '../../components/Text';
5
- import { View } from '../../components/View';
6
- import { Stage } from './Stage';
7
-
8
- export function Buttons() {
9
- return (
10
- <View styleName="vertical collapsed">
11
- <Stage title="Button / Text only / Light">
12
- <Button>
13
- <Text>CHECK IN HERE</Text>
14
- </Button>
15
- </Stage>
16
-
17
- <Stage title="Button / Text only / Dark">
18
- <Button styleName="secondary">
19
- <Text>CHECK IN HERE</Text>
20
- </Button>
21
- </Stage>
22
-
23
- <Stage title="Button / Icon + Text / Light">
24
- <Button>
25
- <Icon name="add-event" />
26
- <Text>ADD TO CALENDAR</Text>
27
- </Button>
28
- </Stage>
29
-
30
- <Stage title="Button / Icon + Text / Dark">
31
- <Button styleName="secondary">
32
- <Icon name="add-event" />
33
- <Text>ADD TO CALENDAR</Text>
34
- </Button>
35
- </Stage>
36
-
37
- <Stage title="Button / Fixed size">
38
- <View styleName="horizontal flexible">
39
- <Button styleName="confirmation">
40
- <Text>REMOVE</Text>
41
- </Button>
42
-
43
- <Button styleName="confirmation secondary">
44
- <Text>UPDATE</Text>
45
- </Button>
46
- </View>
47
- </Stage>
48
-
49
- <Stage title="Button / Full width">
50
- <Button styleName="full-width">
51
- <Text>SEE ALL COMMENTS</Text>
52
- </Button>
53
- </Stage>
54
-
55
- <Stage title="Button / Navbar">
56
- <Button styleName="textual">
57
- <Icon name="add-to-favorites-on" />
58
- </Button>
59
- </Stage>
60
-
61
- <Stage title="Button / Vertical / Icon + Text">
62
- <Button styleName="stacked textual">
63
- <Icon name="tweet" />
64
- <Text>Text description</Text>
65
- </Button>
66
- </Stage>
67
-
68
- <Stage title="Button / Full width - Muted">
69
- <View styleName="horizontal flexible">
70
- <Button styleName="full-width muted">
71
- <Icon name="add-to-favorites-on" />
72
- <Text>LIKE</Text>
73
- </Button>
74
- <Button styleName="full-width muted">
75
- <Icon name="comment" />
76
- <Text>COMMENT</Text>
77
- </Button>
78
- </View>
79
- </Stage>
80
-
81
- <Stage title="Button / Full width - Active">
82
- <View styleName="horizontal flexible">
83
- <Button styleName="full-width">
84
- <Icon name="add-to-favorites-on" />
85
- <Text>LIKE</Text>
86
- </Button>
87
- <Button styleName="full-width">
88
- <Icon name="comment" />
89
- <Text>COMMENT</Text>
90
- </Button>
91
- </View>
92
- </Stage>
93
- </View>
94
- );
95
- }