@applicaster/zapp-react-native-ui-components 12.0.0-alpha.3849101242 → 12.0.0-alpha.3893335783

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.
@@ -7,24 +7,50 @@ type BorderPosition = "inside" | "outside" | "center";
7
7
  interface Props {
8
8
  style: ImageStyle | ViewStyle;
9
9
  borderPosition: BorderPosition;
10
- borderPaddingTop: number;
11
- borderPaddingRight: number;
12
- borderPaddingBottom: number;
13
- borderPaddingLeft: number;
14
10
  children: React.ReactNode;
15
11
  }
16
12
 
17
- const COLOR_TRANSPARENT = "transparent";
13
+ const MARGINS = [
14
+ "marginTop",
15
+ "marginBottom",
16
+ "marginLeft",
17
+ "marginRight",
18
+ ] as const;
18
19
 
19
- const styles = StyleSheet.create({
20
- container: {
21
- overflow: "visible",
22
- borderWidth: 0,
23
- borderColor: COLOR_TRANSPARENT,
24
- },
25
- });
20
+ const PADDINGS = [
21
+ "paddingTop",
22
+ "paddingBottom",
23
+ "paddingLeft",
24
+ "paddingRight",
25
+ ] as const;
26
26
 
27
- const getBorderPadding = (borderPosition: BorderPosition, borderWidth) => {
27
+ const isPercentageValue = (value: number | string) => {
28
+ if (typeof value === "string" && value.endsWith("%")) {
29
+ return true;
30
+ }
31
+
32
+ return false;
33
+ };
34
+
35
+ const calculateContainerSpacing = ({
36
+ spacingKey,
37
+ style,
38
+ additionalSpacing,
39
+ }: {
40
+ spacingKey: typeof MARGINS[number] | typeof PADDINGS[number];
41
+ style: ImageStyle | ViewStyle;
42
+ additionalSpacing: number;
43
+ }) => {
44
+ return {
45
+ [spacingKey]:
46
+ toNumberWithDefaultZero(style[spacingKey]) + additionalSpacing,
47
+ };
48
+ };
49
+
50
+ const getContainerBorderWidth = (
51
+ borderPosition: BorderPosition,
52
+ borderWidth
53
+ ) => {
28
54
  switch (borderPosition) {
29
55
  case "inside":
30
56
  return 0;
@@ -37,101 +63,104 @@ const getBorderPadding = (borderPosition: BorderPosition, borderWidth) => {
37
63
  }
38
64
  };
39
65
 
40
- const Border = ({
66
+ const getContainerPadding = (borderPosition: BorderPosition, borderWidth) => {
67
+ switch (borderPosition) {
68
+ case "inside":
69
+ return borderWidth;
70
+ case "center":
71
+ return borderWidth / 2;
72
+ case "outside":
73
+ return 0;
74
+ default:
75
+ return 0;
76
+ }
77
+ };
78
+
79
+ const InsideBorder = ({
41
80
  style,
42
- padding,
43
81
  borderPosition,
44
82
  }: {
45
83
  style: ViewStyle;
46
- padding: ViewStyle;
47
84
  borderPosition: BorderPosition;
48
85
  }) => {
49
- if (!borderPosition) {
86
+ if (borderPosition === "outside") {
50
87
  return null;
51
88
  }
52
89
 
53
- const borderWidth = toNumberWithDefaultZero(style.borderWidth);
54
- const containerPadding = getBorderPadding(borderPosition, borderWidth);
55
-
56
- const initialBorderRadius = toNumberWithDefaultZero(style.borderRadius);
57
- const paddingTop = toNumberWithDefaultZero(padding.paddingTop);
58
- const paddingRight = toNumberWithDefaultZero(padding.paddingRight);
59
- const paddingBottom = toNumberWithDefaultZero(padding.paddingBottom);
60
- const paddingLeft = toNumberWithDefaultZero(padding.paddingLeft);
61
-
62
- const borderRadiusStyle = initialBorderRadius
63
- ? {
64
- borderTopLeftRadius:
65
- initialBorderRadius +
66
- containerPadding +
67
- Math.min(paddingTop, paddingLeft),
68
- borderTopRightRadius:
69
- initialBorderRadius +
70
- containerPadding +
71
- Math.min(paddingTop, paddingRight),
72
- borderBottomLeftRadius:
73
- initialBorderRadius +
74
- containerPadding +
75
- Math.min(paddingBottom, paddingLeft),
76
- borderBottomRightRadius:
77
- initialBorderRadius +
78
- containerPadding +
79
- Math.min(paddingBottom, paddingRight),
80
- }
81
- : {
82
- borderTopLeftRadius: 0,
83
- borderTopRightRadius: 0,
84
- borderBottomLeftRadius: 0,
85
- borderBottomRightRadius: 0,
86
- };
90
+ const insideBorderWidth =
91
+ borderPosition === "center" ? style.borderWidth / 2 : style.borderWidth;
87
92
 
88
93
  return (
89
94
  <View
90
95
  style={{
91
96
  ...StyleSheet.absoluteFillObject,
92
- right: -containerPadding - paddingRight,
93
- bottom: -containerPadding - paddingBottom,
94
- left: -containerPadding - paddingLeft,
95
- top: -containerPadding - paddingTop,
96
- borderWidth,
97
+ borderWidth: insideBorderWidth,
97
98
  borderColor: style.borderColor,
98
- ...borderRadiusStyle,
99
+ borderRadius: style.borderRadius,
99
100
  }}
100
101
  />
101
102
  );
102
103
  };
103
104
 
104
105
  export const BorderContainerView = (props: Props) => {
105
- const {
106
- borderPosition,
107
- borderPaddingTop,
108
- borderPaddingRight,
109
- borderPaddingBottom,
110
- borderPaddingLeft,
111
- style,
112
- children,
113
- } = props;
106
+ const { style, children } = props;
107
+ // Return border position prop after re-implementing
108
+ const borderPosition = "outside";
109
+
110
+ const borderWidth = toNumberWithDefaultZero(style.borderWidth);
111
+ const spacing = getContainerPadding(borderPosition, borderWidth);
114
112
 
115
113
  const borderStyleForMissingBorder =
116
114
  style?.borderWidth === 0 || !style?.borderColor ? { borderRadius: 0 } : {};
117
115
 
118
- const padding =
119
- borderPosition === "outside"
120
- ? {
121
- paddingTop: borderPaddingTop,
122
- paddingRight: borderPaddingRight,
123
- paddingBottom: borderPaddingBottom,
124
- paddingLeft: borderPaddingLeft,
125
- }
126
- : {};
116
+ const updatedMargins = MARGINS.reduce((acc, margin) => {
117
+ const marginValue = calculateContainerSpacing({
118
+ spacingKey: margin,
119
+ style,
120
+ additionalSpacing: spacing,
121
+ });
122
+
123
+ return { ...acc, ...marginValue };
124
+ }, {});
125
+
126
+ const updatedPaddings = PADDINGS.reduce((acc, padding) => {
127
+ const paddingValue = calculateContainerSpacing({
128
+ spacingKey: padding,
129
+ style,
130
+ additionalSpacing: spacing,
131
+ });
132
+
133
+ return { ...acc, ...paddingValue };
134
+ }, {});
135
+
136
+ const updatedWidth = style.width
137
+ ? isPercentageValue(style.width)
138
+ ? style.width
139
+ : toNumberWithDefaultZero(style.width) - spacing * 2
140
+ : undefined;
141
+
142
+ const updatedHeight = style.height
143
+ ? isPercentageValue(style.height)
144
+ ? style.height
145
+ : toNumberWithDefaultZero(style.height) - spacing * 2
146
+ : undefined;
147
+
148
+ const containerStyle = {
149
+ borderWidth: getContainerBorderWidth(borderPosition, borderWidth),
150
+ padding: spacing,
151
+ ...updatedMargins,
152
+ ...updatedPaddings,
153
+ width: updatedWidth,
154
+ height: updatedHeight,
155
+ };
127
156
 
128
157
  return (
129
- <View
130
- {...props}
131
- style={[style, styles.container, borderStyleForMissingBorder]}
132
- >
158
+ <View {...props} style={[style, containerStyle]}>
133
159
  {children}
134
- <Border style={style} padding={padding} borderPosition={borderPosition} />
160
+ <InsideBorder
161
+ style={{ ...style, ...borderStyleForMissingBorder }}
162
+ borderPosition={borderPosition}
163
+ />
135
164
  </View>
136
165
  );
137
166
  };
@@ -42,12 +42,12 @@ export const PlayerDetails = ({
42
42
  : {};
43
43
 
44
44
  // Animation setup
45
- const translateY = useRef(new Animated.Value(50)).current;
45
+ const translateY = useRef(new Animated.Value(100)).current;
46
46
  const opacity = useRef(new Animated.Value(0)).current;
47
47
 
48
48
  const runAnimation = () => {
49
49
  Animated.timing(translateY, {
50
- toValue: -30,
50
+ toValue: 0,
51
51
  duration: 500,
52
52
  easing: Easing.inOut(Easing.ease),
53
53
  useNativeDriver: true,
@@ -63,7 +63,7 @@ export const PlayerDetails = ({
63
63
 
64
64
  useEffect(() => {
65
65
  if (isAudioPlayer) {
66
- setTimeout(() => runAnimation(), 1500);
66
+ setTimeout(() => runAnimation(), 1000);
67
67
  }
68
68
  }, [isAudioPlayer]);
69
69
 
@@ -181,6 +181,17 @@ export const PlayerWrapper = (props: Props) => {
181
181
  [containerDimensions, playerDimesionsHack]
182
182
  );
183
183
 
184
+ const playerPositionStyle = React.useMemo(() => {
185
+ if (isModal) {
186
+ return {};
187
+ }
188
+
189
+ return {
190
+ left: 0,
191
+ width: "100%",
192
+ };
193
+ }, [isModal]);
194
+
184
195
  const pathname = `${ROUTE_TYPES.VIDEO_MODAL}/${entry?.id}`;
185
196
 
186
197
  return (
@@ -191,6 +202,7 @@ export const PlayerWrapper = (props: Props) => {
191
202
  style={[
192
203
  safeAreaStyles(configuration, isTablet),
193
204
  style,
205
+ playerPositionStyle,
194
206
  playerDimesionsHack,
195
207
  ]}
196
208
  >
@@ -31,6 +31,7 @@ exports[`PlayerWrapper renders inline 1`] = `
31
31
  "width": 300,
32
32
  },
33
33
  Object {},
34
+ Object {},
34
35
  ]
35
36
  }
36
37
  >
@@ -109,6 +110,7 @@ exports[`PlayerWrapper renders inline and docked 1`] = `
109
110
  "width": 300,
110
111
  },
111
112
  Object {},
113
+ Object {},
112
114
  ]
113
115
  }
114
116
  >
@@ -187,6 +189,7 @@ exports[`PlayerWrapper renders inline on tablet in landscape orientation 1`] = `
187
189
  "width": 300,
188
190
  },
189
191
  Object {},
192
+ Object {},
190
193
  ]
191
194
  }
192
195
  >
@@ -280,6 +283,10 @@ exports[`PlayerWrapper renders properly 1`] = `
280
283
  "height": 800,
281
284
  "width": 300,
282
285
  },
286
+ Object {
287
+ "left": 0,
288
+ "width": "100%",
289
+ },
283
290
  Object {},
284
291
  ]
285
292
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applicaster/zapp-react-native-ui-components",
3
- "version": "12.0.0-alpha.3849101242",
3
+ "version": "12.0.0-alpha.3893335783",
4
4
  "description": "Applicaster Zapp React Native ui components for the Quick Brick App",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -34,10 +34,10 @@
34
34
  "redux-mock-store": "^1.5.3"
35
35
  },
36
36
  "dependencies": {
37
- "@applicaster/applicaster-types": "12.0.0-alpha.3849101242",
38
- "@applicaster/zapp-react-native-bridge": "12.0.0-alpha.3849101242",
39
- "@applicaster/zapp-react-native-redux": "12.0.0-alpha.3849101242",
40
- "@applicaster/zapp-react-native-utils": "12.0.0-alpha.3849101242",
37
+ "@applicaster/applicaster-types": "12.0.0-alpha.3893335783",
38
+ "@applicaster/zapp-react-native-bridge": "12.0.0-alpha.3893335783",
39
+ "@applicaster/zapp-react-native-redux": "12.0.0-alpha.3893335783",
40
+ "@applicaster/zapp-react-native-utils": "12.0.0-alpha.3893335783",
41
41
  "promise": "^8.3.0",
42
42
  "react-router-native": "^5.1.2",
43
43
  "url": "^0.11.0",