@applicaster/zapp-react-native-ui-components 13.0.0-alpha.8532113155 → 13.0.0-alpha.9103242840
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/BaseFocusable/index.ios.ts +1 -1
- package/Components/BaseFocusable/index.tsx +1 -1
- package/Components/Cell/Cell.tsx +4 -7
- package/Components/Cell/CellWithFocusable.tsx +59 -43
- package/Components/Cell/TvOSCellComponent.tsx +20 -22
- package/Components/Cell/__tests__/CellWIthFocusable.test.js +6 -13
- package/Components/Cell/index.js +3 -1
- package/Components/Focusable/FocusableTvOS.tsx +5 -1
- package/Components/Focusable/Touchable.tsx +20 -19
- package/Components/FocusableList/index.tsx +26 -9
- package/Components/FocusableScrollView/index.tsx +39 -12
- package/Components/Layout/TV/NavBarContainer.tsx +8 -7
- package/Components/Layout/TV/__tests__/__snapshots__/NavBarContainer.test.tsx.snap +1 -1
- package/Components/Layout/TV/__tests__/__snapshots__/ScreenContainer.test.tsx.snap +1 -1
- package/Components/MasterCell/DefaultComponents/BorderContainerView/index.tsx +1 -4
- package/Components/MasterCell/DefaultComponents/Image/Image.ios.tsx +11 -5
- package/Components/MasterCell/DefaultComponents/SecondaryImage/utils.ts +1 -1
- package/Components/MasterCell/DefaultComponents/__tests__/image.test.js +1 -1
- package/Components/MasterCell/hooks/useAsyncRendering/MasterCellAsyncRenderManager.ts +2 -2
- package/Components/MasterCell/utils/index.ts +1 -1
- package/Components/ModalComponent/Header/index.tsx +3 -3
- package/Components/River/ComponentsMap/ComponentsMap.tsx +65 -39
- package/Components/River/ComponentsMap/hooks/useLoadingState.ts +51 -78
- package/Components/River/RiverFooter.tsx +9 -39
- package/Components/River/RiverItem.tsx +2 -37
- package/Components/River/TV/index.tsx +6 -1
- package/Components/River/__tests__/__snapshots__/componentsMap.test.js.snap +31 -100
- package/Components/River/__tests__/componentsMap.test.js +5 -17
- package/Components/Screen/index.tsx +39 -13
- package/Components/Tabs/Tab.tsx +6 -6
- package/Components/TextInputTv/index.tsx +2 -2
- package/Components/Transitioner/AnimationManager.js +8 -8
- package/Components/Transitioner/Scene.tsx +23 -52
- package/Components/Transitioner/__tests__/__snapshots__/Scene.test.js.snap +43 -59
- package/Components/Transitioner/__tests__/__snapshots__/transitioner.test.js.snap +2 -2
- package/Components/Transitioner/index.js +4 -8
- package/Components/VideoLive/LiveImageManager.ts +1 -27
- package/Components/VideoLive/PlayerLiveImageComponent.tsx +21 -29
- package/Components/VideoLive/__tests__/PlayerLiveImageComponent.test.tsx +1 -51
- package/Components/VideoLive/__tests__/__snapshots__/PlayerLiveImageComponent.test.tsx.snap +5 -0
- package/Components/VideoModal/ModalAnimation/AnimationComponent.tsx +6 -7
- package/Components/VideoModal/ModalAnimation/ModalAnimationContext.tsx +3 -2
- package/Components/VideoModal/ModalAnimation/utils.ts +2 -2
- package/Components/VideoModal/PlayerWrapper.tsx +35 -16
- package/Components/VideoModal/VideoModal.tsx +23 -14
- package/Components/VideoModal/__tests__/PlayerWrapper.test.tsx +1 -1
- package/Components/VideoModal/__tests__/__snapshots__/PlayerWrapper.test.tsx.snap +90 -0
- package/Components/VideoModal/hooks/utils/index.ts +0 -33
- package/Components/VideoModal/utils.ts +1 -1
- package/Contexts/ComponentsMapOffsetContext/index.tsx +46 -0
- package/Contexts/ScreenContext/index.tsx +2 -3
- package/Decorators/ZappPipesDataConnector/__tests__/Hero.js +1 -1
- package/Decorators/ZappPipesDataConnector/index.tsx +1 -31
- package/package.json +5 -5
- package/Components/Cell/CellWithFocusable.ios.tsx +0 -126
- package/Components/MasterCell/DefaultComponents/BorderContainerView/__tests__/index.test.tsx +0 -66
- package/Components/MasterCell/DefaultComponents/ImageBorderContainer/__tests__/index.test.ts +0 -93
- package/Components/Screen/hooks.ts +0 -56
- package/Components/VideoModal/OpaqueLayer.tsx +0 -33
- package/Components/VideoModal/hooks/__tests__/useDelayedPlayerDetails.test.ts +0 -89
- package/Components/VideoModal/hooks/index.ts +0 -7
- package/Components/VideoModal/hooks/useDelayedPlayerDetails.ts +0 -49
- package/Components/VideoModal/hooks/utils/__tests__/showDetails.test.ts +0 -91
|
@@ -17,90 +17,7 @@ exports[`componentsMap renders renders components map correctly 1`] = `
|
|
|
17
17
|
}
|
|
18
18
|
>
|
|
19
19
|
<RCTScrollView
|
|
20
|
-
ListFooterComponent={
|
|
21
|
-
<Memo(RiverFooterComponent)
|
|
22
|
-
flatListHeight={null}
|
|
23
|
-
loadingState={
|
|
24
|
-
BehaviorSubject {
|
|
25
|
-
"_value": {
|
|
26
|
-
"done": false,
|
|
27
|
-
"index": -1,
|
|
28
|
-
"waitForAllComponents": false,
|
|
29
|
-
},
|
|
30
|
-
"closed": false,
|
|
31
|
-
"currentObservers": null,
|
|
32
|
-
"hasError": false,
|
|
33
|
-
"isStopped": false,
|
|
34
|
-
"observers": [
|
|
35
|
-
SafeSubscriber {
|
|
36
|
-
"_finalizers": [
|
|
37
|
-
Subscription {
|
|
38
|
-
"_finalizers": null,
|
|
39
|
-
"_parentage": [Circular],
|
|
40
|
-
"closed": false,
|
|
41
|
-
"initialTeardown": [Function],
|
|
42
|
-
},
|
|
43
|
-
],
|
|
44
|
-
"_parentage": null,
|
|
45
|
-
"closed": false,
|
|
46
|
-
"destination": ConsumerObserver {
|
|
47
|
-
"partialObserver": {
|
|
48
|
-
"complete": undefined,
|
|
49
|
-
"error": undefined,
|
|
50
|
-
"next": [Function],
|
|
51
|
-
},
|
|
52
|
-
},
|
|
53
|
-
"initialTeardown": undefined,
|
|
54
|
-
"isStopped": false,
|
|
55
|
-
},
|
|
56
|
-
SafeSubscriber {
|
|
57
|
-
"_finalizers": [
|
|
58
|
-
Subscription {
|
|
59
|
-
"_finalizers": null,
|
|
60
|
-
"_parentage": [Circular],
|
|
61
|
-
"closed": false,
|
|
62
|
-
"initialTeardown": [Function],
|
|
63
|
-
},
|
|
64
|
-
],
|
|
65
|
-
"_parentage": null,
|
|
66
|
-
"closed": false,
|
|
67
|
-
"destination": ConsumerObserver {
|
|
68
|
-
"partialObserver": {
|
|
69
|
-
"complete": undefined,
|
|
70
|
-
"error": undefined,
|
|
71
|
-
"next": [Function],
|
|
72
|
-
},
|
|
73
|
-
},
|
|
74
|
-
"initialTeardown": undefined,
|
|
75
|
-
"isStopped": false,
|
|
76
|
-
},
|
|
77
|
-
SafeSubscriber {
|
|
78
|
-
"_finalizers": [
|
|
79
|
-
Subscription {
|
|
80
|
-
"_finalizers": null,
|
|
81
|
-
"_parentage": [Circular],
|
|
82
|
-
"closed": false,
|
|
83
|
-
"initialTeardown": [Function],
|
|
84
|
-
},
|
|
85
|
-
],
|
|
86
|
-
"_parentage": null,
|
|
87
|
-
"closed": false,
|
|
88
|
-
"destination": ConsumerObserver {
|
|
89
|
-
"partialObserver": {
|
|
90
|
-
"complete": undefined,
|
|
91
|
-
"error": undefined,
|
|
92
|
-
"next": [Function],
|
|
93
|
-
},
|
|
94
|
-
},
|
|
95
|
-
"initialTeardown": undefined,
|
|
96
|
-
"isStopped": false,
|
|
97
|
-
},
|
|
98
|
-
],
|
|
99
|
-
"thrownError": null,
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
/>
|
|
103
|
-
}
|
|
20
|
+
ListFooterComponent={[Function]}
|
|
104
21
|
contentContainerStyle={
|
|
105
22
|
{
|
|
106
23
|
"paddingBottom": undefined,
|
|
@@ -163,14 +80,22 @@ exports[`componentsMap renders renders components map correctly 1`] = `
|
|
|
163
80
|
style={null}
|
|
164
81
|
>
|
|
165
82
|
<View
|
|
166
|
-
onLayout={[Function]}
|
|
167
83
|
style={
|
|
168
84
|
{
|
|
169
|
-
"
|
|
85
|
+
"display": "flex",
|
|
170
86
|
}
|
|
171
87
|
}
|
|
172
88
|
>
|
|
173
|
-
<View
|
|
89
|
+
<View
|
|
90
|
+
onLayout={[Function]}
|
|
91
|
+
style={
|
|
92
|
+
{
|
|
93
|
+
"flex": 1,
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
>
|
|
97
|
+
<View />
|
|
98
|
+
</View>
|
|
174
99
|
</View>
|
|
175
100
|
</View>
|
|
176
101
|
<View
|
|
@@ -178,13 +103,23 @@ exports[`componentsMap renders renders components map correctly 1`] = `
|
|
|
178
103
|
style={null}
|
|
179
104
|
>
|
|
180
105
|
<View
|
|
181
|
-
onLayout={[Function]}
|
|
182
106
|
style={
|
|
183
107
|
{
|
|
184
|
-
"
|
|
108
|
+
"display": "none",
|
|
185
109
|
}
|
|
186
110
|
}
|
|
187
|
-
|
|
111
|
+
>
|
|
112
|
+
<View
|
|
113
|
+
onLayout={[Function]}
|
|
114
|
+
style={
|
|
115
|
+
{
|
|
116
|
+
"flex": 1,
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
>
|
|
120
|
+
<View />
|
|
121
|
+
</View>
|
|
122
|
+
</View>
|
|
188
123
|
</View>
|
|
189
124
|
<View
|
|
190
125
|
onLayout={[Function]}
|
|
@@ -192,16 +127,12 @@ exports[`componentsMap renders renders components map correctly 1`] = `
|
|
|
192
127
|
<View
|
|
193
128
|
renderToHardwareTextureAndroid={true}
|
|
194
129
|
style={
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
{
|
|
202
|
-
"height": null,
|
|
203
|
-
},
|
|
204
|
-
]
|
|
130
|
+
{
|
|
131
|
+
"alignItems": "center",
|
|
132
|
+
"height": null,
|
|
133
|
+
"justifyContent": "center",
|
|
134
|
+
"width": "100%",
|
|
135
|
+
}
|
|
205
136
|
}
|
|
206
137
|
>
|
|
207
138
|
<ActivityIndicator
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import
|
|
2
|
+
import TestRenderer from "react-test-renderer";
|
|
3
|
+
import { cleanup } from "@testing-library/react-native";
|
|
3
4
|
import { Provider } from "react-redux";
|
|
4
5
|
import configureStore from "redux-mock-store";
|
|
5
6
|
|
|
@@ -80,13 +81,6 @@ const mockScreenData = {
|
|
|
80
81
|
id: "A1234",
|
|
81
82
|
};
|
|
82
83
|
|
|
83
|
-
jest.mock("@applicaster/zapp-react-native-redux/AppStore", () => ({
|
|
84
|
-
appStore: {
|
|
85
|
-
get: jest.fn((prop) => mockStore[prop]),
|
|
86
|
-
getState: jest.fn(),
|
|
87
|
-
},
|
|
88
|
-
}));
|
|
89
|
-
|
|
90
84
|
jest.mock("@applicaster/zapp-react-native-utils/localizationUtils", () => ({
|
|
91
85
|
useIsRTL: jest.fn(() => mock_rtl_flag),
|
|
92
86
|
}));
|
|
@@ -159,13 +153,7 @@ const plugins = [];
|
|
|
159
153
|
const navigation = {};
|
|
160
154
|
|
|
161
155
|
const props = { components, cellStyles, riverComponents, navigation };
|
|
162
|
-
|
|
163
|
-
const store = mockStore({
|
|
164
|
-
components,
|
|
165
|
-
cellStyles,
|
|
166
|
-
plugins,
|
|
167
|
-
getState: jest.fn(),
|
|
168
|
-
});
|
|
156
|
+
const store = mockStore({ components, cellStyles, plugins });
|
|
169
157
|
|
|
170
158
|
jest.useFakeTimers();
|
|
171
159
|
|
|
@@ -182,12 +170,12 @@ describe("componentsMap", () => {
|
|
|
182
170
|
.spyOn(themeUtils, "useTheme")
|
|
183
171
|
.mockImplementation(() => () => theme);
|
|
184
172
|
|
|
185
|
-
const
|
|
173
|
+
const wrapper = TestRenderer.create(
|
|
186
174
|
<Provider store={store}>
|
|
187
175
|
<ComponentsMap {...props} />
|
|
188
176
|
</Provider>
|
|
189
177
|
);
|
|
190
178
|
|
|
191
|
-
expect(toJSON()).toMatchSnapshot();
|
|
179
|
+
expect(wrapper.toJSON()).toMatchSnapshot();
|
|
192
180
|
});
|
|
193
181
|
});
|
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
import React from "react";
|
|
3
3
|
import { View } from "react-native";
|
|
4
4
|
import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
|
|
5
|
+
import {
|
|
6
|
+
isOrientationCompatible,
|
|
7
|
+
useGetScreenOrientation,
|
|
8
|
+
} from "@applicaster/zapp-react-native-utils/appUtils/orientationHelper";
|
|
5
9
|
|
|
6
10
|
import { useTheme } from "@applicaster/zapp-react-native-utils/theme";
|
|
7
11
|
import { getComponentModule } from "@applicaster/zapp-react-native-utils/pluginUtils";
|
|
@@ -11,6 +15,7 @@ import {
|
|
|
11
15
|
getScreenId,
|
|
12
16
|
} from "@applicaster/zapp-react-native-utils/navigationUtils";
|
|
13
17
|
import {
|
|
18
|
+
useDimensions,
|
|
14
19
|
useRoute,
|
|
15
20
|
useCurrentScreenData,
|
|
16
21
|
useNavbarState,
|
|
@@ -22,7 +27,6 @@ import { getNavigationPluginModule } from "@applicaster/zapp-react-native-app/Ap
|
|
|
22
27
|
import { RouteManager } from "../RouteManager";
|
|
23
28
|
import { useScreenConfiguration } from "../River/useScreenConfiguration";
|
|
24
29
|
import { isValidColor } from "./utils";
|
|
25
|
-
import { useWaitForValidOrientation } from "./hooks";
|
|
26
30
|
|
|
27
31
|
const screenStyles = {
|
|
28
32
|
flex: 1,
|
|
@@ -46,6 +50,14 @@ export function Screen(_props: Props) {
|
|
|
46
50
|
const currentScreenData = useCurrentScreenData();
|
|
47
51
|
const { backgroundColor } = useScreenConfiguration(currentScreenData.id);
|
|
48
52
|
|
|
53
|
+
const {
|
|
54
|
+
width: screenWidth,
|
|
55
|
+
height,
|
|
56
|
+
deviceInfo,
|
|
57
|
+
} = useDimensions("screen", {
|
|
58
|
+
fullDimensions: true,
|
|
59
|
+
});
|
|
60
|
+
|
|
49
61
|
const { screenData, pathname } = useRoute();
|
|
50
62
|
|
|
51
63
|
const currentRiver = useScreenData(
|
|
@@ -54,6 +66,13 @@ export function Screen(_props: Props) {
|
|
|
54
66
|
|
|
55
67
|
const { title } = useNavbarState();
|
|
56
68
|
|
|
69
|
+
const isTablet = deviceInfo?.isTablet;
|
|
70
|
+
|
|
71
|
+
const { appData } = usePickFromState(["appData"]);
|
|
72
|
+
const isTabletPortrait = appData?.isTabletPortrait;
|
|
73
|
+
|
|
74
|
+
const layoutData = { isTablet, isTabletPortrait, width: screenWidth, height };
|
|
75
|
+
|
|
57
76
|
const hasMenu = shouldNavBarDisplayMenu(currentRiver, plugins);
|
|
58
77
|
|
|
59
78
|
const navBarProps = React.useMemo<MobileNavBarPluginProps | null>(
|
|
@@ -89,23 +108,30 @@ export function Screen(_props: Props) {
|
|
|
89
108
|
[theme.app_background_color, backgroundColor]
|
|
90
109
|
);
|
|
91
110
|
|
|
92
|
-
|
|
93
|
-
|
|
111
|
+
const targetScreenData =
|
|
112
|
+
currentScreenData || (screenData as any)?.targetScreen || screenData;
|
|
113
|
+
|
|
114
|
+
const orientation = useGetScreenOrientation(targetScreenData);
|
|
94
115
|
|
|
95
116
|
// We prevent rendering of the screen until UI is actually rotated to screen desired orientation.
|
|
96
117
|
// This saves unnecessary re-renders and user will not see distorted aspect screen.
|
|
118
|
+
if (
|
|
119
|
+
!isOrientationCompatible({
|
|
120
|
+
orientation,
|
|
121
|
+
layoutData,
|
|
122
|
+
})
|
|
123
|
+
) {
|
|
124
|
+
return <View style={style} />;
|
|
125
|
+
}
|
|
126
|
+
|
|
97
127
|
return (
|
|
98
128
|
<View style={style}>
|
|
99
|
-
{
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
<RouteManager pathname={pathname} screenData={screenData} />
|
|
106
|
-
</OfflineFallbackScreen>
|
|
107
|
-
</>
|
|
108
|
-
) : null}
|
|
129
|
+
{navBarProps && <NavBar {...navBarProps} hasMenu={hasMenu} />}
|
|
130
|
+
|
|
131
|
+
<OfflineFallbackScreen>
|
|
132
|
+
{/* @TODO RouteManager doesn't use props, can they be removed ? */}
|
|
133
|
+
<RouteManager pathname={pathname} screenData={screenData} />
|
|
134
|
+
</OfflineFallbackScreen>
|
|
109
135
|
</View>
|
|
110
136
|
);
|
|
111
137
|
}
|
package/Components/Tabs/Tab.tsx
CHANGED
|
@@ -69,8 +69,8 @@ const getStyles = (configuration, selected, focused) => {
|
|
|
69
69
|
? tab_cell_background_color_selected_active
|
|
70
70
|
: tab_cell_background_color_selected_default
|
|
71
71
|
: focused
|
|
72
|
-
|
|
73
|
-
|
|
72
|
+
? tab_cell_background_color_active
|
|
73
|
+
: tab_cell_background_color_default,
|
|
74
74
|
justifyContent: "center",
|
|
75
75
|
alignItems: "center",
|
|
76
76
|
position: "relative",
|
|
@@ -85,8 +85,8 @@ const getStyles = (configuration, selected, focused) => {
|
|
|
85
85
|
? tab_cell_border_color_active_focused
|
|
86
86
|
: tab_cell_border_color_active
|
|
87
87
|
: focused
|
|
88
|
-
|
|
89
|
-
|
|
88
|
+
? tab_cell_border_color_default_focused
|
|
89
|
+
: tab_cell_border_color_default,
|
|
90
90
|
},
|
|
91
91
|
label: {
|
|
92
92
|
fontFamily: text_label_font_family,
|
|
@@ -98,8 +98,8 @@ const getStyles = (configuration, selected, focused) => {
|
|
|
98
98
|
? text_label_selected_active_font_color
|
|
99
99
|
: text_label_selected_default_font_color
|
|
100
100
|
: focused
|
|
101
|
-
|
|
102
|
-
|
|
101
|
+
? text_label_active_font_color
|
|
102
|
+
: text_label_default_font_color,
|
|
103
103
|
},
|
|
104
104
|
underline: {
|
|
105
105
|
position: "absolute",
|
|
@@ -3,19 +3,19 @@ import { Animated } from "react-native";
|
|
|
3
3
|
import { NAV_ACTION_PUSH, NAV_ACTION_BACK } from "./Transitioner";
|
|
4
4
|
|
|
5
5
|
type TransitionConfig = {
|
|
6
|
-
duration: number
|
|
7
|
-
easing: any
|
|
6
|
+
duration: number,
|
|
7
|
+
easing: any,
|
|
8
8
|
from: {
|
|
9
|
-
style: any
|
|
10
|
-
}
|
|
9
|
+
style: any,
|
|
10
|
+
},
|
|
11
11
|
to: {
|
|
12
|
-
style: any
|
|
13
|
-
}
|
|
12
|
+
style: any,
|
|
13
|
+
},
|
|
14
14
|
};
|
|
15
15
|
|
|
16
16
|
type Props = {
|
|
17
|
-
transitionConfig: TransitionConfig
|
|
18
|
-
contentStyle: { [string]: any }
|
|
17
|
+
transitionConfig: TransitionConfig,
|
|
18
|
+
contentStyle: { [string]: any },
|
|
19
19
|
};
|
|
20
20
|
|
|
21
21
|
/**
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { equals } from "ramda";
|
|
3
2
|
import { Animated, ViewProps, ViewStyle } from "react-native";
|
|
4
3
|
import { useSafeAreaFrame } from "react-native-safe-area-context";
|
|
5
4
|
|
|
@@ -9,11 +8,6 @@ import { PathnameContext } from "../../Contexts/PathnameContext";
|
|
|
9
8
|
import { ScreenDataContext } from "../../Contexts/ScreenDataContext";
|
|
10
9
|
import { ScreenContextProvider } from "../../Contexts/ScreenContext";
|
|
11
10
|
|
|
12
|
-
const fullWidthDimensions = {
|
|
13
|
-
height: "100%",
|
|
14
|
-
width: "100%",
|
|
15
|
-
};
|
|
16
|
-
|
|
17
11
|
type Props = {
|
|
18
12
|
children: any;
|
|
19
13
|
style: any;
|
|
@@ -26,47 +20,6 @@ type Props = {
|
|
|
26
20
|
screenData: NavigationScreenData;
|
|
27
21
|
};
|
|
28
22
|
|
|
29
|
-
export function CurrentScreenContextProvider({
|
|
30
|
-
children,
|
|
31
|
-
...props
|
|
32
|
-
}: {
|
|
33
|
-
children: any;
|
|
34
|
-
pathname: string;
|
|
35
|
-
isActive: boolean;
|
|
36
|
-
screenData: NavigationScreenData;
|
|
37
|
-
}) {
|
|
38
|
-
const { pathname, isActive = false, screenData } = props;
|
|
39
|
-
|
|
40
|
-
const [initialScreenData, setInitialScreenData] = React.useState(screenData);
|
|
41
|
-
|
|
42
|
-
React.useLayoutEffect(() => {
|
|
43
|
-
const screenDataChanged = !equals(initialScreenData, screenData);
|
|
44
|
-
|
|
45
|
-
if (isActive && screenDataChanged) {
|
|
46
|
-
setInitialScreenData(screenData);
|
|
47
|
-
}
|
|
48
|
-
}, [initialScreenData, screenData, isActive]);
|
|
49
|
-
|
|
50
|
-
return (
|
|
51
|
-
<ScreenDataContext.Provider value={initialScreenData}>
|
|
52
|
-
<PathnameContext.Provider value={pathname}>
|
|
53
|
-
<ScreenContextProvider pathname={pathname}>
|
|
54
|
-
{children}
|
|
55
|
-
</ScreenContextProvider>
|
|
56
|
-
</PathnameContext.Provider>
|
|
57
|
-
</ScreenDataContext.Provider>
|
|
58
|
-
);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
const withCurrentScreenContext = (Component) =>
|
|
62
|
-
function SceneComponent(props: Props) {
|
|
63
|
-
return (
|
|
64
|
-
<CurrentScreenContextProvider {...props}>
|
|
65
|
-
<Component {...props} />
|
|
66
|
-
</CurrentScreenContextProvider>
|
|
67
|
-
);
|
|
68
|
-
};
|
|
69
|
-
|
|
70
23
|
/**
|
|
71
24
|
* Animated View container for any purpose.
|
|
72
25
|
* Renders given children with given style object.
|
|
@@ -79,35 +32,53 @@ const withCurrentScreenContext = (Component) =>
|
|
|
79
32
|
* @param contentStyle
|
|
80
33
|
* @param screenUniqueId
|
|
81
34
|
*/
|
|
82
|
-
function
|
|
35
|
+
export function Scene({
|
|
83
36
|
children,
|
|
84
37
|
style,
|
|
85
38
|
pointerEvents = "auto",
|
|
86
39
|
overlayStyle,
|
|
87
40
|
animating,
|
|
88
41
|
contentStyle,
|
|
42
|
+
pathname,
|
|
89
43
|
isActive = false,
|
|
90
44
|
screenData,
|
|
91
45
|
}: Props) {
|
|
46
|
+
const [initialScreenData, setInitialScreenData] = React.useState(screenData);
|
|
47
|
+
|
|
92
48
|
useScreenOrientationHandler({
|
|
93
49
|
screenData,
|
|
94
50
|
isActive,
|
|
95
51
|
});
|
|
96
52
|
|
|
53
|
+
React.useLayoutEffect(() => {
|
|
54
|
+
if (isActive) {
|
|
55
|
+
setInitialScreenData(screenData);
|
|
56
|
+
}
|
|
57
|
+
}, [screenData, isActive]);
|
|
58
|
+
|
|
97
59
|
const frame = useSafeAreaFrame();
|
|
98
60
|
const isAnimating = animating && overlayStyle;
|
|
99
61
|
|
|
100
|
-
const dimensions = isAnimating
|
|
62
|
+
const dimensions = isAnimating
|
|
63
|
+
? {
|
|
64
|
+
width: "100%",
|
|
65
|
+
height: "100%",
|
|
66
|
+
}
|
|
67
|
+
: frame;
|
|
101
68
|
|
|
102
69
|
return (
|
|
103
70
|
<Animated.View
|
|
104
71
|
pointerEvents={pointerEvents}
|
|
105
72
|
style={[style, contentStyle, dimensions]}
|
|
106
73
|
>
|
|
107
|
-
{
|
|
74
|
+
<ScreenDataContext.Provider value={initialScreenData}>
|
|
75
|
+
<PathnameContext.Provider value={pathname}>
|
|
76
|
+
<ScreenContextProvider pathname={pathname}>
|
|
77
|
+
{children}
|
|
78
|
+
</ScreenContextProvider>
|
|
79
|
+
</PathnameContext.Provider>
|
|
80
|
+
</ScreenDataContext.Provider>
|
|
108
81
|
{isAnimating && <Animated.View style={overlayStyle} />}
|
|
109
82
|
</Animated.View>
|
|
110
83
|
);
|
|
111
84
|
}
|
|
112
|
-
|
|
113
|
-
export const Scene = withCurrentScreenContext(SceneComponent);
|
|
@@ -1,79 +1,63 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
3
|
exports[`<Scene /> renders correctly 1`] = `
|
|
4
|
-
<
|
|
5
|
-
|
|
6
|
-
{
|
|
7
|
-
"paddingBottom": 49,
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
overlayStyle={
|
|
11
|
-
{
|
|
12
|
-
"opacity": 1,
|
|
13
|
-
}
|
|
14
|
-
}
|
|
4
|
+
<ForwardRef(AnimatedComponentWrapper)
|
|
5
|
+
pointerEvents="auto"
|
|
15
6
|
style={
|
|
16
|
-
|
|
17
|
-
"flex": 1,
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
>
|
|
21
|
-
<SceneComponent
|
|
22
|
-
contentStyle={
|
|
7
|
+
[
|
|
23
8
|
{
|
|
24
|
-
"
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
overlayStyle={
|
|
9
|
+
"flex": 1,
|
|
10
|
+
},
|
|
28
11
|
{
|
|
29
|
-
"
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
style={
|
|
12
|
+
"paddingBottom": 49,
|
|
13
|
+
},
|
|
33
14
|
{
|
|
34
|
-
"
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
15
|
+
"fontScale": 2,
|
|
16
|
+
"height": 1334,
|
|
17
|
+
"scale": 2,
|
|
18
|
+
"statusBarHeight": null,
|
|
19
|
+
"width": 750,
|
|
20
|
+
},
|
|
21
|
+
]
|
|
22
|
+
}
|
|
23
|
+
>
|
|
24
|
+
<ContextProvider>
|
|
25
|
+
<ContextProvider>
|
|
26
|
+
<ScreenContextProvider />
|
|
27
|
+
</ContextProvider>
|
|
28
|
+
</ContextProvider>
|
|
29
|
+
</ForwardRef(AnimatedComponentWrapper)>
|
|
39
30
|
`;
|
|
40
31
|
|
|
41
32
|
exports[`<Scene /> renders the overlay while animating 1`] = `
|
|
42
|
-
<
|
|
43
|
-
|
|
44
|
-
contentStyle={
|
|
45
|
-
{
|
|
46
|
-
"paddingBottom": 49,
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
overlayStyle={
|
|
50
|
-
{
|
|
51
|
-
"opacity": 1,
|
|
52
|
-
}
|
|
53
|
-
}
|
|
33
|
+
<ForwardRef(AnimatedComponentWrapper)
|
|
34
|
+
pointerEvents="auto"
|
|
54
35
|
style={
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
>
|
|
60
|
-
<SceneComponent
|
|
61
|
-
animating={true}
|
|
62
|
-
contentStyle={
|
|
36
|
+
[
|
|
37
|
+
{
|
|
38
|
+
"flex": 1,
|
|
39
|
+
},
|
|
63
40
|
{
|
|
64
41
|
"paddingBottom": 49,
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
overlayStyle={
|
|
42
|
+
},
|
|
68
43
|
{
|
|
69
|
-
"
|
|
70
|
-
|
|
71
|
-
|
|
44
|
+
"height": "100%",
|
|
45
|
+
"width": "100%",
|
|
46
|
+
},
|
|
47
|
+
]
|
|
48
|
+
}
|
|
49
|
+
>
|
|
50
|
+
<ContextProvider>
|
|
51
|
+
<ContextProvider>
|
|
52
|
+
<ScreenContextProvider />
|
|
53
|
+
</ContextProvider>
|
|
54
|
+
</ContextProvider>
|
|
55
|
+
<ForwardRef(AnimatedComponentWrapper)
|
|
72
56
|
style={
|
|
73
57
|
{
|
|
74
|
-
"
|
|
58
|
+
"opacity": 1,
|
|
75
59
|
}
|
|
76
60
|
}
|
|
77
61
|
/>
|
|
78
|
-
</
|
|
62
|
+
</ForwardRef(AnimatedComponentWrapper)>
|
|
79
63
|
`;
|
|
@@ -9,7 +9,7 @@ exports[`<TransitionerComponent /> renders correctly 1`] = `
|
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
11
|
>
|
|
12
|
-
<
|
|
12
|
+
<Scene
|
|
13
13
|
isActive={true}
|
|
14
14
|
screenUniqueId="mocked-uuid"
|
|
15
15
|
style={{}}
|
|
@@ -23,6 +23,6 @@ exports[`<TransitionerComponent /> renders correctly 1`] = `
|
|
|
23
23
|
children
|
|
24
24
|
</Text>
|
|
25
25
|
</View>
|
|
26
|
-
</
|
|
26
|
+
</Scene>
|
|
27
27
|
</View>
|
|
28
28
|
`;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
+
import { useWindowDimensions } from "react-native";
|
|
2
3
|
import { useNavigation } from "@applicaster/zapp-react-native-utils/reactHooks/navigation";
|
|
3
4
|
import { useDimensions } from "@applicaster/zapp-react-native-utils/reactHooks/layout";
|
|
4
5
|
import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
|
|
@@ -6,15 +7,10 @@ import { TransitionerComponent } from "./Transitioner";
|
|
|
6
7
|
|
|
7
8
|
export const Transitioner = (props) => {
|
|
8
9
|
const navigator = useNavigation();
|
|
10
|
+
const { height, width } = useWindowDimensions();
|
|
9
11
|
|
|
10
|
-
const {
|
|
11
|
-
|
|
12
|
-
height,
|
|
13
|
-
deviceInfo: { isTablet },
|
|
14
|
-
} = useDimensions("window", {
|
|
15
|
-
updateForInactiveScreens: false,
|
|
16
|
-
deviceInfo: true,
|
|
17
|
-
});
|
|
12
|
+
const dimensions = useDimensions("window", { deviceInfo: true });
|
|
13
|
+
const isTablet = dimensions?.deviceInfo?.isTablet;
|
|
18
14
|
|
|
19
15
|
const { appData } = usePickFromState(["appData"]);
|
|
20
16
|
const isTabletPortrait = appData?.isTabletPortrait;
|