@applicaster/zapp-react-native-ui-components 12.0.0-rc.112 → 12.0.0-rc.114
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/Components/MasterCell/DefaultComponents/ImageBorderContainer/index.ts +15 -2
- package/Components/Screen/__tests__/Screen.test.tsx +0 -49
- package/Components/Screen/index.tsx +1 -19
- package/Components/Screen/navigationHandler.ts +1 -3
- package/Components/Screen/orientationHandler.ts +18 -7
- package/Components/Screen/utils.ts +16 -0
- package/Components/Transitioner/Scene.tsx +9 -2
- package/Components/Transitioner/Transitioner.tsx +11 -8
- package/Components/Transitioner/__tests__/Scene.test.js +7 -0
- package/Components/Transitioner/__tests__/__snapshots__/transitioner.test.js.snap +1 -0
- package/Components/ZappFrameworkComponents/BarView/BarView.tsx +4 -3
- package/package.json +5 -5
|
@@ -15,12 +15,25 @@ export const ImageBorderContainer = ({
|
|
|
15
15
|
state: CellState;
|
|
16
16
|
imageStyles: ImageStyle;
|
|
17
17
|
}) => {
|
|
18
|
+
const imageMargins = getImageContainerMarginStyles({ value });
|
|
19
|
+
|
|
18
20
|
return {
|
|
19
21
|
type: "BorderContainerView",
|
|
20
22
|
style: {
|
|
21
|
-
...getImageContainerMarginStyles({ value }),
|
|
22
23
|
position: "absolute",
|
|
23
|
-
|
|
24
|
+
// Image border now separated from the image, so cell padding affects the border position
|
|
25
|
+
marginTop:
|
|
26
|
+
toNumberWithDefaultZero(imageMargins.marginTop) +
|
|
27
|
+
toNumberWithDefaultZero(value("cell_padding_top")),
|
|
28
|
+
marginLeft:
|
|
29
|
+
toNumberWithDefaultZero(imageMargins.marginLeft) +
|
|
30
|
+
toNumberWithDefaultZero(value("cell_padding_left")),
|
|
31
|
+
marginRight:
|
|
32
|
+
toNumberWithDefaultZero(imageMargins.marginRight) +
|
|
33
|
+
toNumberWithDefaultZero(value("cell_padding_right")),
|
|
34
|
+
marginBottom:
|
|
35
|
+
toNumberWithDefaultZero(imageMargins.marginBottom) +
|
|
36
|
+
toNumberWithDefaultZero(value("cell_padding_bottom")),
|
|
24
37
|
zIndex: 1,
|
|
25
38
|
borderWidth: value("image_border_size"),
|
|
26
39
|
borderColor: ifElseFocusedSelected(
|
|
@@ -99,14 +99,6 @@ jest.mock("@applicaster/zapp-react-native-redux/hooks", () => ({
|
|
|
99
99
|
}),
|
|
100
100
|
}));
|
|
101
101
|
|
|
102
|
-
const {
|
|
103
|
-
ORIENTATIONS,
|
|
104
|
-
} = require("@applicaster/zapp-react-native-utils/appUtils/orientationHelper");
|
|
105
|
-
|
|
106
|
-
const {
|
|
107
|
-
useCurrentScreenData,
|
|
108
|
-
} = require("@applicaster/zapp-react-native-utils/reactHooks/screen");
|
|
109
|
-
|
|
110
102
|
const {
|
|
111
103
|
allowedOrientationsForScreen,
|
|
112
104
|
getOrientation,
|
|
@@ -158,45 +150,4 @@ describe("<Screen Component />", () => {
|
|
|
158
150
|
expect(wrapper.toJSON()).toMatchSnapshot();
|
|
159
151
|
});
|
|
160
152
|
});
|
|
161
|
-
|
|
162
|
-
it("invokes the orientation hook when the route changes", () => {
|
|
163
|
-
act(() => {
|
|
164
|
-
wrapper = create(<Screen {...screenProps} />);
|
|
165
|
-
});
|
|
166
|
-
|
|
167
|
-
// @ts-ignore
|
|
168
|
-
useCurrentScreenData.mockReturnValue({
|
|
169
|
-
id: "player-testId",
|
|
170
|
-
general: { screen_orientation: ORIENTATIONS.landscapeSensor },
|
|
171
|
-
plugin_type: "player",
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
act(() => {
|
|
175
|
-
wrapper.update(
|
|
176
|
-
<Screen
|
|
177
|
-
{...screenProps}
|
|
178
|
-
pathname="/playable"
|
|
179
|
-
screenData={{
|
|
180
|
-
id: "player-testId",
|
|
181
|
-
general: { screen_orientation: ORIENTATIONS.landscapeSensor },
|
|
182
|
-
plugin_type: "player",
|
|
183
|
-
}}
|
|
184
|
-
/>
|
|
185
|
-
);
|
|
186
|
-
});
|
|
187
|
-
|
|
188
|
-
useCurrentScreenData.mockReturnValue({
|
|
189
|
-
id: "player-testId",
|
|
190
|
-
general: { screen_orientation: ORIENTATIONS.landscapeSensor },
|
|
191
|
-
});
|
|
192
|
-
|
|
193
|
-
act(() => {
|
|
194
|
-
wrapper.update(<Screen {...screenProps} />);
|
|
195
|
-
});
|
|
196
|
-
|
|
197
|
-
expect(allowedOrientationsForScreen).toHaveBeenNthCalledWith(
|
|
198
|
-
1,
|
|
199
|
-
ORIENTATIONS.landscapeSensor
|
|
200
|
-
);
|
|
201
|
-
});
|
|
202
153
|
});
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/// <reference types="@applicaster/applicaster-types" />
|
|
2
2
|
import React from "react";
|
|
3
|
-
import * as R from "ramda";
|
|
4
3
|
import { View } from "react-native";
|
|
5
4
|
import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
|
|
6
5
|
import {
|
|
@@ -27,7 +26,7 @@ import { getNavigationPluginModule } from "@applicaster/zapp-react-native-app/Ap
|
|
|
27
26
|
|
|
28
27
|
import { RouteManager } from "../RouteManager";
|
|
29
28
|
import { useScreenConfiguration } from "../River/useScreenConfiguration";
|
|
30
|
-
import {
|
|
29
|
+
import { isValidColor } from "./utils";
|
|
31
30
|
|
|
32
31
|
const screenStyles = {
|
|
33
32
|
flex: 1,
|
|
@@ -37,21 +36,6 @@ const screenStyles = {
|
|
|
37
36
|
// paddingRight: insets.right, // Should be applied directly by UI plugin
|
|
38
37
|
};
|
|
39
38
|
|
|
40
|
-
function colorIsNotTransparent(color) {
|
|
41
|
-
const layers = R.compose(
|
|
42
|
-
R.map(R.trim),
|
|
43
|
-
R.split(","),
|
|
44
|
-
R.replace(")", ""),
|
|
45
|
-
R.replace("rgba(", "")
|
|
46
|
-
)(color);
|
|
47
|
-
|
|
48
|
-
return Number(layers?.[3]) > 0;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
function isValidColor(string) {
|
|
52
|
-
return string && string !== "transparent" && colorIsNotTransparent(string);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
39
|
type Props = {
|
|
56
40
|
pathname: unknown;
|
|
57
41
|
screenData: unknown;
|
|
@@ -127,8 +111,6 @@ export function Screen(_props: Props) {
|
|
|
127
111
|
const targetScreenData =
|
|
128
112
|
currentScreenData || (screenData as any)?.targetScreen || screenData;
|
|
129
113
|
|
|
130
|
-
useScreenOrientationHandler({ screenData: targetScreenData });
|
|
131
|
-
|
|
132
114
|
const orientation = useGetScreenOrientation(targetScreenData);
|
|
133
115
|
|
|
134
116
|
// We prevent rendering of the screen until UI is actually rotated to screen desired orientation.
|
|
@@ -26,9 +26,7 @@ export function isMenuVisible(route, screenData) {
|
|
|
26
26
|
if (screenData?.hookPlugin) {
|
|
27
27
|
const hookPlugin = screenData?.hookPlugin?.module;
|
|
28
28
|
|
|
29
|
-
return
|
|
30
|
-
hookPlugin?.showNavBar || hookPlugin?.presentFullScreen !== true || false
|
|
31
|
-
);
|
|
29
|
+
return hookPlugin?.showNavBar || hookPlugin?.presentFullScreen !== true;
|
|
32
30
|
}
|
|
33
31
|
|
|
34
32
|
if (
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import React, { useLayoutEffect } from "react";
|
|
2
|
+
|
|
2
3
|
import {
|
|
3
4
|
allowedOrientationsForScreen,
|
|
4
5
|
ORIENTATIONS,
|
|
5
6
|
getOrientation,
|
|
6
7
|
useGetScreenOrientation,
|
|
7
8
|
} from "@applicaster/zapp-react-native-utils/appUtils/orientationHelper";
|
|
8
|
-
|
|
9
|
+
import { usePrevious } from "@applicaster/zapp-react-native-utils/reactHooks/utils";
|
|
9
10
|
import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
|
|
10
11
|
import { findPluginByType } from "@applicaster/zapp-react-native-utils/pluginUtils";
|
|
11
12
|
import { useIsTablet } from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
13
|
+
|
|
12
14
|
import { ZappHookModalContext } from "../../Contexts";
|
|
13
15
|
import { HookModalContextT } from "../../Contexts/ZappHookModalContext";
|
|
14
16
|
|
|
@@ -79,14 +81,23 @@ export function useNewOrientationForScreenData({
|
|
|
79
81
|
screenOrientation;
|
|
80
82
|
}
|
|
81
83
|
|
|
82
|
-
|
|
83
|
-
screenData
|
|
84
|
-
|
|
84
|
+
type Props = {
|
|
85
|
+
screenData: {
|
|
86
|
+
screen: {};
|
|
87
|
+
};
|
|
88
|
+
isActive: boolean;
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
export function useScreenOrientationHandler({ screenData, isActive }: Props) {
|
|
85
92
|
const { isHooksExecutionInProgress } = React.useContext<HookModalContextT>(
|
|
86
93
|
ZappHookModalContext.ReactContext
|
|
87
94
|
);
|
|
88
95
|
|
|
89
|
-
const
|
|
96
|
+
const prevIsActive = usePrevious(isActive);
|
|
97
|
+
|
|
98
|
+
const newOrientation = useNewOrientationForScreenData({
|
|
99
|
+
screenData: screenData.screen,
|
|
100
|
+
});
|
|
90
101
|
|
|
91
102
|
useLayoutEffect(() => {
|
|
92
103
|
// Null means screen does not have orientation preference, so we can skip rotate
|
|
@@ -100,12 +111,12 @@ export function useScreenOrientationHandler({
|
|
|
100
111
|
return;
|
|
101
112
|
}
|
|
102
113
|
|
|
103
|
-
if (newOrientation !== current) {
|
|
114
|
+
if (!prevIsActive && isActive && newOrientation !== current) {
|
|
104
115
|
current = newOrientation;
|
|
105
116
|
|
|
106
117
|
setOrientation(newOrientation);
|
|
107
118
|
}
|
|
108
|
-
}, [newOrientation, isHooksExecutionInProgress]);
|
|
119
|
+
}, [newOrientation, isHooksExecutionInProgress, prevIsActive, isActive]);
|
|
109
120
|
}
|
|
110
121
|
|
|
111
122
|
export function useOrientationHandler({ screenData }: OrientationHookArgs) {
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { map, split, replace, compose, trim } from "ramda";
|
|
2
|
+
|
|
3
|
+
function colorIsNotTransparent(color) {
|
|
4
|
+
const layers = compose(
|
|
5
|
+
map(trim),
|
|
6
|
+
split(","),
|
|
7
|
+
replace(")", ""),
|
|
8
|
+
replace("rgba(", "")
|
|
9
|
+
)(color);
|
|
10
|
+
|
|
11
|
+
return Number(layers?.[3]) > 0;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function isValidColor(string) {
|
|
15
|
+
return string && string !== "transparent" && colorIsNotTransparent(string);
|
|
16
|
+
}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { Animated, ViewProps, ViewStyle } from "react-native";
|
|
3
3
|
import { useSafeAreaFrame } from "react-native-safe-area-context";
|
|
4
|
+
|
|
5
|
+
import { useScreenOrientationHandler } from "@applicaster/zapp-react-native-ui-components/Components/Screen/orientationHandler";
|
|
6
|
+
|
|
4
7
|
import { PathnameContext } from "../../Contexts/PathnameContext";
|
|
5
8
|
import { ScreenDataContext } from "../../Contexts/ScreenDataContext";
|
|
6
9
|
import { ScreenContextProvider } from "../../Contexts/ScreenContext";
|
|
@@ -42,6 +45,11 @@ export function Scene({
|
|
|
42
45
|
}: Props) {
|
|
43
46
|
const [initialScreenData, setInitialScreenData] = React.useState(screenData);
|
|
44
47
|
|
|
48
|
+
useScreenOrientationHandler({
|
|
49
|
+
screenData,
|
|
50
|
+
isActive,
|
|
51
|
+
});
|
|
52
|
+
|
|
45
53
|
React.useLayoutEffect(() => {
|
|
46
54
|
if (isActive) {
|
|
47
55
|
setInitialScreenData(screenData);
|
|
@@ -49,13 +57,12 @@ export function Scene({
|
|
|
49
57
|
}, [screenData, isActive]);
|
|
50
58
|
|
|
51
59
|
const frame = useSafeAreaFrame();
|
|
52
|
-
|
|
53
60
|
const isAnimating = animating && overlayStyle;
|
|
54
61
|
|
|
55
62
|
const dimensions = isAnimating
|
|
56
63
|
? {
|
|
57
|
-
height: "100%",
|
|
58
64
|
width: "100%",
|
|
65
|
+
height: "100%",
|
|
59
66
|
}
|
|
60
67
|
: frame;
|
|
61
68
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { View } from "react-native";
|
|
3
|
-
import
|
|
3
|
+
import { update, compose, tail, append, take, identity } from "ramda";
|
|
4
4
|
|
|
5
5
|
import { AnimationManager } from "./AnimationManager";
|
|
6
6
|
import { Scene } from "./Scene";
|
|
@@ -46,7 +46,7 @@ function prepareScene(children) {
|
|
|
46
46
|
*/
|
|
47
47
|
function scenesForBackTransition(props: SceneProps, { scenes }) {
|
|
48
48
|
return scenes.length > 1
|
|
49
|
-
?
|
|
49
|
+
? identity(scenes)
|
|
50
50
|
: [prepareScene(props.children), scenes[0]];
|
|
51
51
|
}
|
|
52
52
|
|
|
@@ -110,7 +110,7 @@ export class TransitionerComponent extends React.PureComponent<Props, State> {
|
|
|
110
110
|
pushTransitionStart() {
|
|
111
111
|
this.setState(
|
|
112
112
|
{
|
|
113
|
-
scenes:
|
|
113
|
+
scenes: append(prepareScene(this.props.children), this.state.scenes),
|
|
114
114
|
...this.animationManager.stateForAction(this.state, NAV_ACTION_PUSH),
|
|
115
115
|
},
|
|
116
116
|
() => {
|
|
@@ -177,10 +177,10 @@ export class TransitionerComponent extends React.PureComponent<Props, State> {
|
|
|
177
177
|
to: { index: 0 },
|
|
178
178
|
};
|
|
179
179
|
} else if (isLastSceneHook || scenes.length === 1) {
|
|
180
|
-
newState = { scenes:
|
|
180
|
+
newState = { scenes: update(scenes.length - 1, newScene, scenes) };
|
|
181
181
|
} else {
|
|
182
182
|
newState = {
|
|
183
|
-
scenes:
|
|
183
|
+
scenes: compose(tail, append(newScene))(scenes),
|
|
184
184
|
};
|
|
185
185
|
}
|
|
186
186
|
|
|
@@ -225,7 +225,10 @@ export class TransitionerComponent extends React.PureComponent<Props, State> {
|
|
|
225
225
|
this.shouldSkipAnimationForRoute(previousRoute) ||
|
|
226
226
|
this.shouldSkipAnimationForRoute(currentRoute)
|
|
227
227
|
) {
|
|
228
|
-
|
|
228
|
+
// we are going back, in this case we need to have only one scene using resetState
|
|
229
|
+
const resetState = isGoingBack ? true : undefined;
|
|
230
|
+
|
|
231
|
+
return this.transitionWithoutAnimation(resetState);
|
|
229
232
|
}
|
|
230
233
|
|
|
231
234
|
switch (this.props.navigator.previousAction) {
|
|
@@ -268,7 +271,7 @@ export class TransitionerComponent extends React.PureComponent<Props, State> {
|
|
|
268
271
|
backTransitionEnd(stepsBack) {
|
|
269
272
|
this.setState({
|
|
270
273
|
animating: false,
|
|
271
|
-
scenes:
|
|
274
|
+
scenes: take(this.state.scenes.length - stepsBack, this.state.scenes),
|
|
272
275
|
});
|
|
273
276
|
}
|
|
274
277
|
|
|
@@ -284,7 +287,7 @@ export class TransitionerComponent extends React.PureComponent<Props, State> {
|
|
|
284
287
|
<View style={styles.container}>
|
|
285
288
|
{scenes[to.index] && (
|
|
286
289
|
<Scene
|
|
287
|
-
{...{ style: to
|
|
290
|
+
{...{ style: to?.style || {} }}
|
|
288
291
|
pathname={pathname}
|
|
289
292
|
isActive={pathname === this.props.navigator.currentRoute}
|
|
290
293
|
contentStyle={contentStyle}
|
|
@@ -16,6 +16,13 @@ jest.mock("react-native-safe-area-context", () => ({
|
|
|
16
16
|
})),
|
|
17
17
|
}));
|
|
18
18
|
|
|
19
|
+
jest.mock(
|
|
20
|
+
"@applicaster/zapp-react-native-ui-components/Components/Screen/orientationHandler",
|
|
21
|
+
() => ({
|
|
22
|
+
useScreenOrientationHandler: jest.fn(),
|
|
23
|
+
})
|
|
24
|
+
);
|
|
25
|
+
|
|
19
26
|
const { Scene } = require("../Scene");
|
|
20
27
|
|
|
21
28
|
const wrapper = shallow(
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { StyleSheet } from "react-native";
|
|
3
|
+
import { SafeAreaView } from "react-native-safe-area-context";
|
|
3
4
|
|
|
4
5
|
import { useIsRTL } from "@applicaster/zapp-react-native-utils/localizationUtils";
|
|
5
6
|
import CloseButton from "./Buttons/CloseButton";
|
|
@@ -44,11 +45,11 @@ const BarView = ({ screenStyles, barState = defaultState }: Props) => {
|
|
|
44
45
|
);
|
|
45
46
|
|
|
46
47
|
return (
|
|
47
|
-
<
|
|
48
|
+
<SafeAreaView style={[style.view, isRTL ? style.rtlStyle : {}]}>
|
|
48
49
|
{backButton}
|
|
49
50
|
<BarTitle title={barState.title} screenStyles={screenStyles} />
|
|
50
51
|
{closeButton}
|
|
51
|
-
</
|
|
52
|
+
</SafeAreaView>
|
|
52
53
|
);
|
|
53
54
|
};
|
|
54
55
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applicaster/zapp-react-native-ui-components",
|
|
3
|
-
"version": "12.0.0-rc.
|
|
3
|
+
"version": "12.0.0-rc.114",
|
|
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-rc.
|
|
38
|
-
"@applicaster/zapp-react-native-bridge": "12.0.0-rc.
|
|
39
|
-
"@applicaster/zapp-react-native-redux": "12.0.0-rc.
|
|
40
|
-
"@applicaster/zapp-react-native-utils": "12.0.0-rc.
|
|
37
|
+
"@applicaster/applicaster-types": "12.0.0-rc.114",
|
|
38
|
+
"@applicaster/zapp-react-native-bridge": "12.0.0-rc.114",
|
|
39
|
+
"@applicaster/zapp-react-native-redux": "12.0.0-rc.114",
|
|
40
|
+
"@applicaster/zapp-react-native-utils": "12.0.0-rc.114",
|
|
41
41
|
"promise": "^8.3.0",
|
|
42
42
|
"react-router-native": "^5.1.2",
|
|
43
43
|
"url": "^0.11.0",
|