@shoutem/ui 6.3.0 → 6.4.1-rc.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.
@@ -171,7 +171,6 @@ export const defaultConfig = [
171
171
  { name: 'forward', icon: forward },
172
172
  { name: 'gallery', icon: gallery },
173
173
  { name: 'friends', icon: friends },
174
- { name: 'gallery', icon: gallery },
175
174
  { name: 'garbage-can', icon: garbageCan },
176
175
  { name: 'gift', icon: gift },
177
176
  { name: 'github', icon: github },
@@ -1,87 +1,32 @@
1
- import React, { PureComponent } from 'react';
2
- import { TouchableWithoutFeedback } from 'react-native';
3
- import autoBindReact from 'auto-bind/react';
1
+ import React from 'react';
2
+ import { Switch as RNSwitch } from 'react-native';
4
3
  import PropTypes from 'prop-types';
5
- import { connectAnimation, TimingDriver } from '@shoutem/animation';
6
4
  import { connectStyle } from '@shoutem/theme';
7
5
  import { View } from './View';
8
6
 
9
- class Switch extends PureComponent {
10
- constructor(props) {
11
- super(props);
12
-
13
- autoBindReact(this);
14
-
15
- this.timingDriver = new TimingDriver();
16
-
17
- this.setValue(props.value);
18
- }
19
-
20
- componentDidUpdate(prevProps) {
21
- const { value: currentValue } = this.props;
22
-
23
- if (prevProps.value !== currentValue) {
24
- this.setValue(currentValue);
25
- }
26
- }
27
-
28
- onSwitchPressed() {
29
- const { value, onValueChange } = this.props;
30
-
31
- onValueChange(!value);
32
- }
33
-
34
- setValue(value) {
35
- this.timingDriver.toValue(value ? 1 : 0);
36
- }
37
-
38
- render() {
39
- const { style } = this.props;
40
-
41
- return (
42
- <TouchableWithoutFeedback
43
- onPress={this.onSwitchPressed}
44
- styleName="clear"
45
- >
46
- <View>
47
- <View
48
- animationName="mute"
49
- driver={this.timingDriver}
50
- style={style.container}
51
- >
52
- <View
53
- animationName="turn"
54
- animationOptions={{ containerWidth: style.container.width }}
55
- driver={this.timingDriver}
56
- style={style.thumb}
57
- />
58
- </View>
59
- </View>
60
- </TouchableWithoutFeedback>
61
- );
62
- }
63
- }
7
+ const Switch = ({ value, onValueChange, style }) => (
8
+ <View style={style.container}>
9
+ <RNSwitch
10
+ trackColor={style.track}
11
+ thumbColor={style.thumb}
12
+ ios_backgroundColor={style.track?.false}
13
+ onValueChange={onValueChange}
14
+ value={value}
15
+ />
16
+ </View>
17
+ );
64
18
 
65
19
  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
20
+ onValueChange: PropTypes.func.isRequired,
21
+ style: PropTypes.object,
74
22
  value: PropTypes.bool,
75
- // Called when switch is toggled on and off
76
- onValueChange: PropTypes.func,
77
23
  };
78
24
 
79
25
  Switch.defaultProps = {
80
26
  value: false,
81
- onValueChange: undefined,
27
+ style: {},
82
28
  };
83
29
 
84
- const AnimatedSwitch = connectAnimation(Switch);
85
- const StyledSwitch = connectStyle('shoutem.ui.Switch')(AnimatedSwitch);
30
+ const StyledSwitch = connectStyle('shoutem.ui.Switch')(Switch);
86
31
 
87
32
  export { StyledSwitch as Switch };
@@ -1,5 +1,5 @@
1
1
  import { Dimensions, Platform, StatusBar } from 'react-native';
2
- import { hasNotch } from 'react-native-device-info';
2
+ import DeviceInfo from 'react-native-device-info';
3
3
  import _ from 'lodash';
4
4
 
5
5
  const { OS, isPad, isTVOS } = Platform;
@@ -37,7 +37,7 @@ const isIphoneXR =
37
37
  !isTVOS &&
38
38
  (xrDimensionsMatch || twelveDimensionsMatch || twelveMaxDimensionsMatch);
39
39
 
40
- const isNotchedAndroid = OS === 'android' && hasNotch();
40
+ const isNotchedAndroid = OS === 'android' && DeviceInfo.hasNotch();
41
41
 
42
42
  /**
43
43
  * Receives settings for different devices
@@ -71,6 +71,51 @@ export const NAVIGATION_BAR_HEIGHT = select({
71
71
  default: NAVIGATION_HEADER_HEIGHT,
72
72
  });
73
73
 
74
+ export const getHomeIndicatorPadding = () => {
75
+ if (Platform.OS === 'android') {
76
+ return 0;
77
+ }
78
+
79
+ // Apple identifier
80
+ const deviceId = DeviceInfo.getDeviceId();
81
+
82
+ // Extract the numbers from the deviceId string using a regular expression
83
+ const versions = deviceId.match(/(\d+),(\d+)/);
84
+
85
+ // Only checks if regex found X,Y, it does not resolve any of device ID-padding logic.
86
+ // If version is present, e.g. in iPhone 9,1, it'll always return array of length 3.
87
+ if (!versions && versions.length < 3) {
88
+ return 0;
89
+ }
90
+
91
+ // Extracted numbers as strings
92
+ const majorVersion = versions[1];
93
+ const minorVersion = versions[2];
94
+
95
+ const numericVersion = parseFloat(`${majorVersion}.${minorVersion}`);
96
+
97
+ const excludedIphones = {
98
+ iPhone8: 10.4,
99
+ iPhone8plus: 10.5,
100
+ iPhoneSeGen2: 12.8,
101
+ iPhoneSeGen3: 14.6,
102
+ };
103
+
104
+ // Home indicator is present since iPhone X series with id of iPhone10,3.
105
+ // There are few newer models that do not have home indicator.
106
+ // They're included in excludedIphones object above.
107
+ if (
108
+ numericVersion >= 10.3 &&
109
+ !Object.values(excludedIphones).includes(numericVersion)
110
+ ) {
111
+ // Devices with home indicator
112
+ return 34;
113
+ }
114
+
115
+ // Devices without home indicator
116
+ return 0;
117
+ };
118
+
74
119
  export const Device = {
75
120
  isIphoneX,
76
121
  isIphoneXR,
@@ -1,4 +1,5 @@
1
1
  import React from 'react';
2
+ import { Vimeo } from 'react-native-vimeo-iframe';
2
3
  import YoutubePlayer from 'react-native-youtube-iframe';
3
4
  import iframe from '@native-html/iframe-plugin';
4
5
  import PropTypes from 'prop-types';
@@ -41,6 +42,19 @@ const IframeRenderer = props => {
41
42
  );
42
43
  }
43
44
 
45
+ if (url && url.includes('vimeo')) {
46
+ const vimeoIdRegEx = /(?:www\.|player\.)?vimeo.com\/(?:channels\/(?:\w+\/)?|groups\/(?:[^\/]*)\/videos\/|album\/(?:\d+)\/video\/|video\/|)(\d+)(?:[a-zA-Z0-9_\-]+)?/i;
47
+ const regExMatches = url.match(vimeoIdRegEx);
48
+ const vimeoId = regExMatches[1];
49
+
50
+ return (
51
+ <Vimeo
52
+ videoId={vimeoId}
53
+ style={{ height: shoutemStyle.vimeoVideo.height }}
54
+ />
55
+ );
56
+ }
57
+
44
58
  return iframe(props);
45
59
  };
46
60
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shoutem/ui",
3
- "version": "6.3.0",
3
+ "version": "6.4.1-rc.0",
4
4
  "description": "Styleable set of components for React Native applications",
5
5
  "scripts": {
6
6
  "lint": "eslint .",
@@ -41,6 +41,7 @@
41
41
  "react-native-toast-message": "2.1.5",
42
42
  "react-native-webview": "11.23.0",
43
43
  "react-native-youtube-iframe": "2.2.2",
44
+ "react-native-vimeo-iframe": "1.2.1",
44
45
  "stream": "0.0.2",
45
46
  "tinycolor2": "1.4.1"
46
47
  },
@@ -135,4 +136,4 @@
135
136
  "!/node_modules/@shoutem"
136
137
  ]
137
138
  }
138
- }
139
+ }
package/theme.js CHANGED
@@ -7,8 +7,8 @@ import {
7
7
  INCLUDE,
8
8
  inverseColorBrightnessForAmount,
9
9
  } from '@shoutem/theme';
10
+ import { getHomeIndicatorPadding } from './helpers/device-selector';
10
11
  import {
11
- IPHONE_X_HOME_INDICATOR_PADDING,
12
12
  IPHONE_X_NOTCH_PADDING,
13
13
  IPHONE_XR_NOTCH_PADDING,
14
14
  NAVIGATION_BAR_HEIGHT,
@@ -856,6 +856,10 @@ export default () => {
856
856
  'shoutem.ui.View': {
857
857
  [INCLUDE]: ['commonVariants', 'guttersPadding'],
858
858
 
859
+ '.with-home-indicator-padding': {
860
+ paddingBottom: getHomeIndicatorPadding(),
861
+ },
862
+
859
863
  '.horizontal': {
860
864
  [INCLUDE]: ['horizontalFlexAlignment'],
861
865
  flexDirection: 'row',
@@ -955,21 +959,19 @@ export default () => {
955
959
  backgroundColor: resolveVariable('paperColor'),
956
960
  },
957
961
 
962
+ // This was created with home indicator padding in mind. Use with-home-indicator-padding
963
+ // if you need bottom padding. For actual notch - top of the screen padding, use SafeAreaView component instead.
958
964
  '.with-notch-padding': {
959
- paddingBottom: Device.select({
960
- iPhoneX: IPHONE_X_HOME_INDICATOR_PADDING,
961
- iPhoneXR: IPHONE_X_HOME_INDICATOR_PADDING,
962
- default: 0,
963
- }),
965
+ paddingBottom: getHomeIndicatorPadding(),
966
+ },
967
+
968
+ '.with-home-indicator-padding': {
969
+ paddingBottom: getHomeIndicatorPadding(),
964
970
  },
965
971
 
966
972
  'shoutem.ui.ListView': {
967
973
  listContent: {
968
- paddingBottom: Device.select({
969
- iPhoneX: IPHONE_X_HOME_INDICATOR_PADDING,
970
- iPhoneXR: IPHONE_X_HOME_INDICATOR_PADDING,
971
- default: 0,
972
- }),
974
+ paddingBottom: getHomeIndicatorPadding(),
973
975
  },
974
976
  },
975
977
 
@@ -2060,56 +2062,11 @@ export default () => {
2060
2062
  },
2061
2063
 
2062
2064
  'shoutem.ui.Switch': {
2063
- container: {
2064
- borderRadius: 15,
2065
- height: 18,
2066
- marginVertical: 7,
2067
- paddingHorizontal: 2,
2068
- paddingVertical: 2,
2069
- width: 32,
2070
-
2071
- muteAnimation(driver) {
2072
- return {
2073
- backgroundColor: driver.interpolate({
2074
- inputRange: [0, 1],
2075
- outputRange: [
2076
- inverseColorBrightnessForAmount(
2077
- resolveVariable('paperColor'),
2078
- 15,
2079
- ),
2080
- changeColorAlpha(
2081
- resolveVariable('secondaryButtonBackgroundColor'),
2082
- 1,
2083
- ),
2084
- ],
2085
- }),
2086
- };
2087
- },
2088
- },
2089
-
2090
- thumb: {
2091
- backgroundColor: resolveVariable('paperColor'),
2092
- borderRadius: 7,
2093
- height: 14,
2094
- width: 14,
2095
-
2096
- turnAnimation(driver, { layout, animationOptions }) {
2097
- const { x, width } = layout;
2098
- return {
2099
- transform: [
2100
- {
2101
- translateX: driver.interpolate({
2102
- inputRange: [0, 1],
2103
- outputRange: [
2104
- 0,
2105
- animationOptions.containerWidth - width - 2 * x,
2106
- ],
2107
- }),
2108
- },
2109
- ],
2110
- };
2111
- },
2065
+ track: {
2066
+ false: resolveVariable('backgroundColor'),
2067
+ true: resolveVariable('featuredColor'),
2112
2068
  },
2069
+ thumb: resolveVariable('paperColor'),
2113
2070
  },
2114
2071
 
2115
2072
  'shoutem.ui.DropDownMenu': {
@@ -2327,6 +2284,10 @@ export default () => {
2327
2284
  height: responsiveWidth(194),
2328
2285
  paddingBottom: resolveVariable('smallGutter'),
2329
2286
  },
2287
+ // Just enough to display portrait mode Vimeo videos and all Vimeo player controls
2288
+ vimeoVideo: {
2289
+ height: responsiveWidth(220),
2290
+ },
2330
2291
  fallback: {
2331
2292
  width: window.width,
2332
2293
  height: 40,