@applicaster/zapp-react-native-ui-components 12.0.0-alpha.4223432180 → 12.0.0-alpha.4241289980
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/Cell/Cell.tsx +1 -8
- package/Components/Focusable/index.android.tsx +9 -15
- package/Components/FocusableList/FocusableChild.ts +4 -2
- package/Components/FocusableList/index.tsx +12 -11
- package/Components/FocusableScrollView/index.tsx +1 -1
- package/Components/MasterCell/DefaultComponents/FocusableView/index.tsx +3 -2
- package/Components/MasterCell/DefaultComponents/Image/Image.ios.tsx +5 -6
- package/Components/MasterCell/DefaultComponents/Image/Image.web.tsx +2 -2
- package/Components/MasterCell/DefaultComponents/__tests__/image.test.js +1 -1
- package/Components/PlayerContainer/PlayerContainer.tsx +13 -11
- package/Components/VideoLive/__tests__/__snapshots__/PlayerLiveImageComponent.test.tsx.snap +0 -5
- package/Components/VideoModal/ModalAnimation/AnimatedScrollModal.tsx +1 -2
- package/Components/VideoModal/ModalAnimation/AnimationComponent.tsx +3 -11
- package/Components/ZappFrameworkComponents/BarView/BarView.tsx +1 -4
- package/Components/ZappFrameworkComponents/BarView/Buttons/BackButton.tsx +2 -7
- package/Components/ZappFrameworkComponents/BarView/Buttons/CloseButton.tsx +2 -7
- package/Components/ZappFrameworkComponents/Buttons/ActionButton.tsx +4 -9
- package/Contexts/CachedDimensionsContext/index.ts +9 -13
- package/Contexts/ScreenContext/index.tsx +1 -6
- package/package.json +5 -5
- package/Components/Focusable/__tests__/index.android.test.tsx +0 -72
- package/Components/ZappFrameworkComponents/BarView/__tests__/BarView.test.tsx +0 -87
package/Components/Cell/Cell.tsx
CHANGED
|
@@ -276,20 +276,13 @@ export class CellComponent extends React.Component<Props, State> {
|
|
|
276
276
|
skipFocusManagerRegistration={skipFocusManagerRegistration}
|
|
277
277
|
>
|
|
278
278
|
{(focused, event) => {
|
|
279
|
-
const isFocused = this.isCellFocused(focused);
|
|
280
|
-
|
|
281
|
-
if (isFocused) {
|
|
282
|
-
const accessibilityManager = AccessibilityManager.getInstance();
|
|
283
|
-
accessibilityManager.readText({ text: item.title });
|
|
284
|
-
}
|
|
285
|
-
|
|
286
279
|
return (
|
|
287
280
|
<FocusableCell
|
|
288
281
|
{...{
|
|
289
282
|
index,
|
|
290
283
|
CellRenderer,
|
|
291
284
|
item,
|
|
292
|
-
focused:
|
|
285
|
+
focused: this.isCellFocused(focused),
|
|
293
286
|
scrollTo: this.scrollToIndex(event),
|
|
294
287
|
behavior,
|
|
295
288
|
}}
|
|
@@ -128,10 +128,7 @@ function FocusableComponent(props: Props, forwardedRef) {
|
|
|
128
128
|
|
|
129
129
|
const _onBlur = React.useCallback(
|
|
130
130
|
(ref, options = {}) => {
|
|
131
|
-
|
|
132
|
-
setFocused(false);
|
|
133
|
-
}
|
|
134
|
-
|
|
131
|
+
setFocused(false);
|
|
135
132
|
onBlur?.(ref, options);
|
|
136
133
|
},
|
|
137
134
|
[onBlur]
|
|
@@ -151,14 +148,15 @@ function FocusableComponent(props: Props, forwardedRef) {
|
|
|
151
148
|
[isRTL, nextFocusDown, nextFocusUp, nextFocusLeft, nextFocusRight]
|
|
152
149
|
);
|
|
153
150
|
|
|
154
|
-
const contextState = React.useMemo(
|
|
155
|
-
|
|
151
|
+
const contextState = React.useMemo(
|
|
152
|
+
() => ({
|
|
156
153
|
focused,
|
|
157
154
|
...parentFocus,
|
|
158
155
|
ref: touchableRef,
|
|
159
156
|
setIsFocusable,
|
|
160
|
-
}
|
|
161
|
-
|
|
157
|
+
}),
|
|
158
|
+
[parentFocus, focused]
|
|
159
|
+
);
|
|
162
160
|
|
|
163
161
|
return (
|
|
164
162
|
<Touchable
|
|
@@ -175,13 +173,9 @@ function FocusableComponent(props: Props, forwardedRef) {
|
|
|
175
173
|
{...parentFocus}
|
|
176
174
|
>
|
|
177
175
|
<FocusableContext.Provider value={contextState}>
|
|
178
|
-
{
|
|
179
|
-
()
|
|
180
|
-
|
|
181
|
-
? children(focused, parentFocus, touchableRef)
|
|
182
|
-
: children,
|
|
183
|
-
[children, focused, parentFocus]
|
|
184
|
-
)}
|
|
176
|
+
{typeof children === "function"
|
|
177
|
+
? children(focused, parentFocus, touchableRef)
|
|
178
|
+
: children}
|
|
185
179
|
</FocusableContext.Provider>
|
|
186
180
|
</Touchable>
|
|
187
181
|
);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { isEqual } from "@applicaster/zapp-react-native-utils/equalUtils";
|
|
3
3
|
import { useFocusable } from "../Focusable/index.android";
|
|
4
|
+
import { useCellState } from "./hooks/useCellState.android";
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* returns parent focus from prop or from context
|
|
@@ -29,14 +30,15 @@ const useParentFocus = (
|
|
|
29
30
|
);
|
|
30
31
|
|
|
31
32
|
function FocusableChildComponent(props) {
|
|
32
|
-
const { setIsFocusable,
|
|
33
|
-
|
|
33
|
+
const { setIsFocusable, ...focusableContext } = useFocusable();
|
|
34
34
|
const parentFocus = useParentFocus(props, focusableContext);
|
|
35
35
|
|
|
36
36
|
const onLoadFailed = React.useCallback(() => {
|
|
37
37
|
setIsFocusable(false);
|
|
38
38
|
}, []);
|
|
39
39
|
|
|
40
|
+
const focused = useCellState(props.id);
|
|
41
|
+
|
|
40
42
|
return props.renderItem({
|
|
41
43
|
...props,
|
|
42
44
|
focused,
|
|
@@ -88,7 +88,6 @@ function FocusableListComponent<ItemT>(props: Props<ItemT>, ref) {
|
|
|
88
88
|
data = [],
|
|
89
89
|
// eslint-disable-next-line unused-imports/no-unused-vars
|
|
90
90
|
onAllComponentsLoaded, // TODO: re-implement it
|
|
91
|
-
omitPropsPropagation = [],
|
|
92
91
|
} = props;
|
|
93
92
|
|
|
94
93
|
useCheckItemIdsForUnique({ componentId: props.id, items: data });
|
|
@@ -253,9 +252,9 @@ function FocusableListComponent<ItemT>(props: Props<ItemT>, ref) {
|
|
|
253
252
|
]
|
|
254
253
|
);
|
|
255
254
|
|
|
256
|
-
const
|
|
257
|
-
|
|
258
|
-
[
|
|
255
|
+
const flatListProps = React.useMemo(
|
|
256
|
+
() =>
|
|
257
|
+
R.omit([
|
|
259
258
|
"onListElementFocus",
|
|
260
259
|
"onListElementPress",
|
|
261
260
|
"onListElementPressOut",
|
|
@@ -268,17 +267,17 @@ function FocusableListComponent<ItemT>(props: Props<ItemT>, ref) {
|
|
|
268
267
|
"focusableItemProps",
|
|
269
268
|
"renderItem",
|
|
270
269
|
"extraChildrenData",
|
|
270
|
+
"extraData",
|
|
271
|
+
"keyExtractor",
|
|
271
272
|
"onAllComponentsLoaded",
|
|
272
273
|
"focused",
|
|
273
274
|
"id",
|
|
274
275
|
"initialFocusDirection",
|
|
275
276
|
"withStateMemory",
|
|
276
277
|
"useSequentialLoading",
|
|
277
|
-
...omitPropsPropagation,
|
|
278
|
-
],
|
|
279
|
-
|
|
280
|
-
),
|
|
281
|
-
[omitPropsPropagation]
|
|
278
|
+
...(props.omitPropsPropagation || []),
|
|
279
|
+
])(props),
|
|
280
|
+
[props]
|
|
282
281
|
);
|
|
283
282
|
|
|
284
283
|
const onEndReached = React.useCallback(
|
|
@@ -290,7 +289,7 @@ function FocusableListComponent<ItemT>(props: Props<ItemT>, ref) {
|
|
|
290
289
|
|
|
291
290
|
const initialNumToRender = toFiniteNumberWithDefault(
|
|
292
291
|
10,
|
|
293
|
-
|
|
292
|
+
flatListProps.initialNumToRender
|
|
294
293
|
);
|
|
295
294
|
|
|
296
295
|
return (
|
|
@@ -299,10 +298,12 @@ function FocusableListComponent<ItemT>(props: Props<ItemT>, ref) {
|
|
|
299
298
|
<FlatList
|
|
300
299
|
focusable={false}
|
|
301
300
|
scrollEnabled={false}
|
|
301
|
+
extraData={props.extraData}
|
|
302
302
|
ref={ref}
|
|
303
|
-
{...
|
|
303
|
+
{...flatListProps}
|
|
304
304
|
renderItem={renderItem}
|
|
305
305
|
onEndReached={onEndReached}
|
|
306
|
+
keyExtractor={props.keyExtractor}
|
|
306
307
|
initialNumToRender={initialNumToRender}
|
|
307
308
|
/>
|
|
308
309
|
</ChildrenFocusDeactivatorView>
|
|
@@ -47,8 +47,9 @@ export function FocusableView({ style, children, item, ...otherProps }: Props) {
|
|
|
47
47
|
|
|
48
48
|
const accessibilityManager = useAccessibilityManager({});
|
|
49
49
|
|
|
50
|
-
const { ttsLabel
|
|
51
|
-
|
|
50
|
+
const { ttsLabel } = actionContext
|
|
51
|
+
?.initialEntryState(item)
|
|
52
|
+
?.getAccessibility(item);
|
|
52
53
|
|
|
53
54
|
const onPress = (event) => {
|
|
54
55
|
event?.preventDefault?.();
|
|
@@ -38,22 +38,21 @@ function Image({
|
|
|
38
38
|
|
|
39
39
|
const shouldRenderImg = source && !error;
|
|
40
40
|
|
|
41
|
-
// Default placeholder image fallback is empty string because it won't rerender
|
|
42
|
-
// in case of undefined or {uri: undefined} source
|
|
43
|
-
// https://github.com/facebook/react-native/issues/9195
|
|
44
41
|
const defaultPlaceHolderImage = React.useMemo(
|
|
45
42
|
() => ({ uri: placeholderImage || "" }),
|
|
46
43
|
[source, error]
|
|
47
44
|
);
|
|
48
45
|
|
|
46
|
+
const _source = shouldRenderImg
|
|
47
|
+
? withDimensions(source)
|
|
48
|
+
: defaultPlaceHolderImage;
|
|
49
|
+
|
|
49
50
|
return (
|
|
50
51
|
// @ts-ignore
|
|
51
52
|
<MemoizedImage
|
|
52
53
|
style={style as ImageStyle}
|
|
53
54
|
onError={() => setErrorState(true)}
|
|
54
|
-
source={
|
|
55
|
-
shouldRenderImg ? withDimensions(source) : defaultPlaceHolderImage
|
|
56
|
-
}
|
|
55
|
+
source={_source?.uri ? _source : undefined}
|
|
57
56
|
{...R.omit(["source"], otherProps)}
|
|
58
57
|
/>
|
|
59
58
|
);
|
|
@@ -31,10 +31,10 @@ function Image({
|
|
|
31
31
|
|
|
32
32
|
return (
|
|
33
33
|
<RnImage
|
|
34
|
-
defaultSource={placeholderImage ||
|
|
34
|
+
defaultSource={placeholderImage || ""}
|
|
35
35
|
style={style}
|
|
36
36
|
source={updatedSource}
|
|
37
|
-
{...R.omit(["source"
|
|
37
|
+
{...R.omit(["source"], otherProps)}
|
|
38
38
|
/>
|
|
39
39
|
);
|
|
40
40
|
}
|
|
@@ -362,15 +362,21 @@ const PlayerContainerComponent = (props: Props) => {
|
|
|
362
362
|
const toggleFullscreen = (event) => {
|
|
363
363
|
const { fullscreen = false } = event || {};
|
|
364
364
|
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
365
|
+
if (fullscreen) {
|
|
366
|
+
// in order to avoid UI glitches with player we have to start re-render ealier and then start real rotation
|
|
367
|
+
navigator.fullscreenVideoModal();
|
|
368
|
+
|
|
369
|
+
setTimeout(() => {
|
|
368
370
|
playerEvent("onFullscreenPlayerWillPresent");
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
+
});
|
|
372
|
+
} else {
|
|
373
|
+
// in order to avoid UI glitches with player we have to start re-render ealier and then start real rotation
|
|
374
|
+
navigator.maximiseVideoModal();
|
|
375
|
+
|
|
376
|
+
setTimeout(() => {
|
|
371
377
|
playerEvent("onFullscreenPlayerWillDismiss");
|
|
372
|
-
}
|
|
373
|
-
}
|
|
378
|
+
});
|
|
379
|
+
}
|
|
374
380
|
};
|
|
375
381
|
|
|
376
382
|
const onCellTap = (entry) => {
|
|
@@ -465,10 +471,6 @@ const PlayerContainerComponent = (props: Props) => {
|
|
|
465
471
|
|
|
466
472
|
if (mode === VideoModalMode.FULLSCREEN) {
|
|
467
473
|
toggleFullscreen({ fullscreen: false });
|
|
468
|
-
|
|
469
|
-
if (!isModal) {
|
|
470
|
-
playerManager.closeNativePlayer();
|
|
471
|
-
}
|
|
472
474
|
}
|
|
473
475
|
|
|
474
476
|
return !!(
|
|
@@ -223,8 +223,7 @@ export const AnimatedScrollModalComponent = ({ children }: Props) => {
|
|
|
223
223
|
(videoModalState.mode === "MAXIMIZED" &&
|
|
224
224
|
videoModalState.previousMode === "MINIMIZED" &&
|
|
225
225
|
previousItemId === videoModalState.item?.id) ||
|
|
226
|
-
|
|
227
|
-
videoModalState.mode !== "FULLSCREEN")
|
|
226
|
+
previousItemId !== videoModalState.item?.id
|
|
228
227
|
) {
|
|
229
228
|
setPlayerAnimationState(PlayerAnimationStateEnum.maximaze);
|
|
230
229
|
setTimeout(() => resetPlayerAnimationState());
|
|
@@ -60,10 +60,7 @@ export const AnimationView = ({
|
|
|
60
60
|
const {
|
|
61
61
|
width: screenWidth,
|
|
62
62
|
deviceInfo: { isTablet, isTabletLandscape },
|
|
63
|
-
} = useDimensions("window", {
|
|
64
|
-
deviceInfo: true,
|
|
65
|
-
updateForInactiveScreens: true,
|
|
66
|
-
});
|
|
63
|
+
} = useDimensions("window", { deviceInfo: true });
|
|
67
64
|
|
|
68
65
|
const { videoModalState } = useNavigation();
|
|
69
66
|
const insets = useSafeAreaInsets();
|
|
@@ -304,18 +301,13 @@ export const AnimationView = ({
|
|
|
304
301
|
typeof additionalData.height === "number" && additionalData.height;
|
|
305
302
|
}
|
|
306
303
|
|
|
307
|
-
if (
|
|
308
|
-
videoModalState.mode === "MAXIMIZED" &&
|
|
309
|
-
defaultValue.x !== screenWidth &&
|
|
310
|
-
width &&
|
|
311
|
-
height
|
|
312
|
-
) {
|
|
304
|
+
if (defaultValue.x === 0 && width && height) {
|
|
313
305
|
const value = { x: width, y: height };
|
|
314
306
|
setDefaultValue(value);
|
|
315
307
|
animatedValue.setValue(value);
|
|
316
308
|
}
|
|
317
309
|
}
|
|
318
|
-
}, [screenWidth]);
|
|
310
|
+
}, [additionalData, screenWidth]);
|
|
319
311
|
|
|
320
312
|
React.useEffect(() => {
|
|
321
313
|
if (
|
|
@@ -45,10 +45,7 @@ const BarView = ({ screenStyles, barState = defaultState }: Props) => {
|
|
|
45
45
|
);
|
|
46
46
|
|
|
47
47
|
return (
|
|
48
|
-
<SafeAreaView
|
|
49
|
-
style={[style.view, isRTL ? style.rtlStyle : {}]}
|
|
50
|
-
testID="BarView-safeAreaView"
|
|
51
|
-
>
|
|
48
|
+
<SafeAreaView style={[style.view, isRTL ? style.rtlStyle : {}]}>
|
|
52
49
|
{backButton}
|
|
53
50
|
<BarTitle title={barState.title} screenStyles={screenStyles} />
|
|
54
51
|
{closeButton}
|
|
@@ -11,16 +11,12 @@ const renderEmptyView = () => {
|
|
|
11
11
|
return <View style={emptyViewStyle} />;
|
|
12
12
|
};
|
|
13
13
|
|
|
14
|
-
type FloatingButtonProps =
|
|
14
|
+
type FloatingButtonProps = {
|
|
15
15
|
onPress: () => void;
|
|
16
16
|
screenStyles: any;
|
|
17
17
|
};
|
|
18
18
|
|
|
19
|
-
const BackButton = ({
|
|
20
|
-
onPress,
|
|
21
|
-
screenStyles,
|
|
22
|
-
testID = "backButton",
|
|
23
|
-
}: FloatingButtonProps) => {
|
|
19
|
+
const BackButton = ({ onPress, screenStyles }: FloatingButtonProps) => {
|
|
24
20
|
const containerStyle: any = {};
|
|
25
21
|
|
|
26
22
|
if (!onPress) {
|
|
@@ -29,7 +25,6 @@ const BackButton = ({
|
|
|
29
25
|
|
|
30
26
|
return (
|
|
31
27
|
<ActionButton
|
|
32
|
-
testID={`${testID}-actionButton`}
|
|
33
28
|
onPress={onPress}
|
|
34
29
|
buttonStyles={containerStyle}
|
|
35
30
|
imageUrl={screenStyles.back_button_image}
|
|
@@ -11,16 +11,12 @@ const renderEmptyView = () => {
|
|
|
11
11
|
return <View style={emptyViewStyle} />;
|
|
12
12
|
};
|
|
13
13
|
|
|
14
|
-
type CloseButtonProps =
|
|
14
|
+
type CloseButtonProps = {
|
|
15
15
|
onPress: () => void;
|
|
16
16
|
screenStyles?: any;
|
|
17
17
|
};
|
|
18
18
|
|
|
19
|
-
const CloseButton = ({
|
|
20
|
-
onPress,
|
|
21
|
-
screenStyles,
|
|
22
|
-
testID = "closeButton",
|
|
23
|
-
}: CloseButtonProps) => {
|
|
19
|
+
const CloseButton = ({ onPress, screenStyles }: CloseButtonProps) => {
|
|
24
20
|
const containerStyle: any = {};
|
|
25
21
|
|
|
26
22
|
if (!onPress) {
|
|
@@ -29,7 +25,6 @@ const CloseButton = ({
|
|
|
29
25
|
|
|
30
26
|
return (
|
|
31
27
|
<ActionButton
|
|
32
|
-
testID={`${testID}-actionButton`}
|
|
33
28
|
onPress={onPress}
|
|
34
29
|
buttonStyles={containerStyle}
|
|
35
30
|
imageUrl={screenStyles.close_button_image}
|
|
@@ -28,7 +28,7 @@ styles: {
|
|
|
28
28
|
}
|
|
29
29
|
*/
|
|
30
30
|
|
|
31
|
-
type ActionButtonProps =
|
|
31
|
+
type ActionButtonProps = {
|
|
32
32
|
onPress: () => void;
|
|
33
33
|
buttonStyles: any;
|
|
34
34
|
imageUrl: string;
|
|
@@ -46,16 +46,11 @@ const ActionButton = ({
|
|
|
46
46
|
buttonStyles,
|
|
47
47
|
imageUrl,
|
|
48
48
|
imageStyle = closeButtonStyle,
|
|
49
|
-
testID,
|
|
50
49
|
}: ActionButtonProps) => {
|
|
51
50
|
return (
|
|
52
|
-
<View style={buttonStyles}
|
|
53
|
-
<TouchableOpacity onPress={onPress}
|
|
54
|
-
<Image
|
|
55
|
-
source={{ uri: imageUrl }}
|
|
56
|
-
style={imageStyle}
|
|
57
|
-
testID={`${testID}-image`}
|
|
58
|
-
/>
|
|
51
|
+
<View style={buttonStyles}>
|
|
52
|
+
<TouchableOpacity onPress={onPress}>
|
|
53
|
+
<Image source={{ uri: imageUrl }} style={imageStyle} />
|
|
59
54
|
</TouchableOpacity>
|
|
60
55
|
</View>
|
|
61
56
|
);
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { create, useStore } from "zustand";
|
|
2
2
|
import { produce } from "immer";
|
|
3
|
-
import { useCallback, useMemo } from "react";
|
|
4
3
|
|
|
5
4
|
type Dimensions = {
|
|
6
5
|
width: Option<number>;
|
|
@@ -32,19 +31,16 @@ export const useCachedDimensions = (id: string) => {
|
|
|
32
31
|
dimensionsStore
|
|
33
32
|
) as DimensionsState;
|
|
34
33
|
|
|
35
|
-
const getCachedDimensions =
|
|
34
|
+
const getCachedDimensions = () => {
|
|
36
35
|
return dimensions[id] || initialDimensions();
|
|
37
|
-
}
|
|
36
|
+
};
|
|
38
37
|
|
|
39
|
-
const handleSetCachedDimensions =
|
|
38
|
+
const handleSetCachedDimensions = (newDimensions) => {
|
|
40
39
|
setCachedDimensions(id, newDimensions);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}),
|
|
48
|
-
[getCachedDimensions, handleSetCachedDimensions]
|
|
49
|
-
);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
return {
|
|
43
|
+
getCachedDimensions,
|
|
44
|
+
setCachedDimensions: handleSetCachedDimensions,
|
|
45
|
+
};
|
|
50
46
|
};
|
|
@@ -177,12 +177,7 @@ export function withScreenContext(Component: React.ComponentType<any>) {
|
|
|
177
177
|
return function WithScreenContextWrapper(props) {
|
|
178
178
|
return (
|
|
179
179
|
<ScreenContext.Consumer>
|
|
180
|
-
{
|
|
181
|
-
(value) => (
|
|
182
|
-
<Component {...props} screenContext={value} />
|
|
183
|
-
),
|
|
184
|
-
[Component, props]
|
|
185
|
-
)}
|
|
180
|
+
{(value) => <Component {...props} screenContext={value} />}
|
|
186
181
|
</ScreenContext.Consumer>
|
|
187
182
|
);
|
|
188
183
|
};
|
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.
|
|
3
|
+
"version": "12.0.0-alpha.4241289980",
|
|
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.
|
|
38
|
-
"@applicaster/zapp-react-native-bridge": "12.0.0-alpha.
|
|
39
|
-
"@applicaster/zapp-react-native-redux": "12.0.0-alpha.
|
|
40
|
-
"@applicaster/zapp-react-native-utils": "12.0.0-alpha.
|
|
37
|
+
"@applicaster/applicaster-types": "12.0.0-alpha.4241289980",
|
|
38
|
+
"@applicaster/zapp-react-native-bridge": "12.0.0-alpha.4241289980",
|
|
39
|
+
"@applicaster/zapp-react-native-redux": "12.0.0-alpha.4241289980",
|
|
40
|
+
"@applicaster/zapp-react-native-utils": "12.0.0-alpha.4241289980",
|
|
41
41
|
"promise": "^8.3.0",
|
|
42
42
|
"react-router-native": "^5.1.2",
|
|
43
43
|
"url": "^0.11.0",
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { render, act } from "@testing-library/react-native";
|
|
3
|
-
import { Touchable } from "../../Touchable";
|
|
4
|
-
|
|
5
|
-
const mockUseIsRTL = jest.fn();
|
|
6
|
-
|
|
7
|
-
jest.mock("@applicaster/zapp-react-native-utils/localizationUtils", () => ({
|
|
8
|
-
useIsRTL: mockUseIsRTL,
|
|
9
|
-
}));
|
|
10
|
-
|
|
11
|
-
const mockUseFocusManager = jest.fn();
|
|
12
|
-
|
|
13
|
-
jest.mock("@applicaster/zapp-react-native-utils/focusManager", () => ({
|
|
14
|
-
useFocusManager: mockUseFocusManager,
|
|
15
|
-
}));
|
|
16
|
-
|
|
17
|
-
const mockUsePrevious = jest.fn();
|
|
18
|
-
|
|
19
|
-
jest.mock("@applicaster/zapp-react-native-utils/reactHooks/utils", () => ({
|
|
20
|
-
usePrevious: mockUsePrevious,
|
|
21
|
-
}));
|
|
22
|
-
|
|
23
|
-
const { Focusable } = require("../index.android");
|
|
24
|
-
|
|
25
|
-
describe("Focusable", () => {
|
|
26
|
-
const mockFocusManager = {
|
|
27
|
-
isFocused: jest.fn(),
|
|
28
|
-
onDisableFocusChange: jest.fn(),
|
|
29
|
-
registerFocusable: jest.fn(),
|
|
30
|
-
focusedId: "test-id",
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
beforeEach(() => {
|
|
34
|
-
jest.clearAllMocks();
|
|
35
|
-
mockUseIsRTL.mockReturnValue(false);
|
|
36
|
-
mockUseFocusManager.mockReturnValue(mockFocusManager);
|
|
37
|
-
mockUsePrevious.mockReturnValue(false);
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
it("updates disableFocus state when disableFocus prop changes", () => {
|
|
41
|
-
const { rerender } = render(
|
|
42
|
-
<Focusable id="test-id" disableFocus={false}>
|
|
43
|
-
<Touchable testID="touchable" />
|
|
44
|
-
</Focusable>
|
|
45
|
-
);
|
|
46
|
-
|
|
47
|
-
rerender(
|
|
48
|
-
<Focusable id="test-id" disableFocus={true}>
|
|
49
|
-
<Touchable testID="touchable" />
|
|
50
|
-
</Focusable>
|
|
51
|
-
);
|
|
52
|
-
|
|
53
|
-
expect(mockFocusManager.onDisableFocusChange).toHaveBeenCalledWith(
|
|
54
|
-
"test-id"
|
|
55
|
-
);
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
it("calls focusManager.registerFocusable on mount and unregisters on unmount", () => {
|
|
59
|
-
const unregister = jest.fn();
|
|
60
|
-
mockFocusManager.registerFocusable.mockReturnValue(unregister);
|
|
61
|
-
|
|
62
|
-
const { unmount } = render(
|
|
63
|
-
<Focusable id="test-id">
|
|
64
|
-
<Touchable testID="touchable" />
|
|
65
|
-
</Focusable>
|
|
66
|
-
);
|
|
67
|
-
|
|
68
|
-
expect(mockFocusManager.registerFocusable).toHaveBeenCalled();
|
|
69
|
-
act(() => unmount());
|
|
70
|
-
expect(unregister).toHaveBeenCalled();
|
|
71
|
-
});
|
|
72
|
-
});
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { renderWithProviders } from "@applicaster/zapp-react-native-utils/testUtils";
|
|
3
|
-
import { fireEvent } from "@testing-library/react-native";
|
|
4
|
-
|
|
5
|
-
const mockUseIsRTL = jest.fn(() => true);
|
|
6
|
-
|
|
7
|
-
jest.mock("@applicaster/zapp-react-native-utils/localizationUtils", () => ({
|
|
8
|
-
useIsRTL: mockUseIsRTL,
|
|
9
|
-
}));
|
|
10
|
-
|
|
11
|
-
const BarView = require("../BarView").default;
|
|
12
|
-
|
|
13
|
-
describe("BarView", () => {
|
|
14
|
-
const screenStyles = {
|
|
15
|
-
title_font_color: "#000",
|
|
16
|
-
title_font_android: "Roboto",
|
|
17
|
-
title_font_ios: "San Francisco",
|
|
18
|
-
title_font_size: "16",
|
|
19
|
-
background_color: "#fff",
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
const barState = {
|
|
23
|
-
backHandler: jest.fn(),
|
|
24
|
-
closeHandler: jest.fn(),
|
|
25
|
-
title: "Test Title",
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
beforeEach(() => {
|
|
29
|
-
jest.clearAllMocks();
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
it("renders without crashing", () => {
|
|
33
|
-
mockUseIsRTL.mockReturnValue(false);
|
|
34
|
-
|
|
35
|
-
const { getByText } = renderWithProviders(
|
|
36
|
-
<BarView screenStyles={screenStyles} barState={barState} />
|
|
37
|
-
);
|
|
38
|
-
|
|
39
|
-
expect(getByText("Test Title")).toBeTruthy();
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
it("applies RTL styles when isRTL is true", () => {
|
|
43
|
-
mockUseIsRTL.mockReturnValue(true);
|
|
44
|
-
|
|
45
|
-
const { getByTestId } = renderWithProviders(
|
|
46
|
-
<BarView screenStyles={screenStyles} barState={barState} />
|
|
47
|
-
);
|
|
48
|
-
|
|
49
|
-
expect(getByTestId("BarView-safeAreaView").props.style).toContainEqual({
|
|
50
|
-
transform: [{ scaleX: -1 }],
|
|
51
|
-
});
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
it("does not apply RTL styles when isRTL is false", () => {
|
|
55
|
-
mockUseIsRTL.mockReturnValue(false);
|
|
56
|
-
|
|
57
|
-
const { getByTestId } = renderWithProviders(
|
|
58
|
-
<BarView screenStyles={screenStyles} barState={barState} />
|
|
59
|
-
);
|
|
60
|
-
|
|
61
|
-
expect(getByTestId("BarView-safeAreaView").props.style).not.toContainEqual({
|
|
62
|
-
transform: [{ scaleX: -1 }],
|
|
63
|
-
});
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
it("calls closeHandler when CloseButton is pressed", () => {
|
|
67
|
-
mockUseIsRTL.mockReturnValue(false);
|
|
68
|
-
|
|
69
|
-
const { getByTestId } = renderWithProviders(
|
|
70
|
-
<BarView screenStyles={screenStyles} barState={barState} />
|
|
71
|
-
);
|
|
72
|
-
|
|
73
|
-
fireEvent.press(getByTestId("closeButton-actionButton-touchable"));
|
|
74
|
-
expect(barState.closeHandler).toHaveBeenCalled();
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
it("calls backHandler when BackButton is pressed", () => {
|
|
78
|
-
mockUseIsRTL.mockReturnValue(false);
|
|
79
|
-
|
|
80
|
-
const { getByTestId } = renderWithProviders(
|
|
81
|
-
<BarView screenStyles={screenStyles} barState={barState} />
|
|
82
|
-
);
|
|
83
|
-
|
|
84
|
-
fireEvent.press(getByTestId("backButton-actionButton-touchable"));
|
|
85
|
-
expect(barState.backHandler).toHaveBeenCalled();
|
|
86
|
-
});
|
|
87
|
-
});
|