@applicaster/zapp-react-native-ui-components 12.0.0-alpha.5933014273 → 12.0.0-alpha.6158046395

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.
Files changed (37) hide show
  1. package/Components/Cell/Cell.tsx +8 -1
  2. package/Components/Focusable/__tests__/index.android.test.tsx +72 -0
  3. package/Components/Focusable/index.android.tsx +15 -9
  4. package/Components/FocusableList/FocusableChild.ts +2 -2
  5. package/Components/FocusableList/index.tsx +11 -12
  6. package/Components/FocusableScrollView/index.tsx +1 -1
  7. package/Components/Image/Image.android.tsx +1 -1
  8. package/Components/MasterCell/DefaultComponents/ActionButton.tsx +11 -5
  9. package/Components/MasterCell/DefaultComponents/CellBadge/index.tsx +6 -1
  10. package/Components/MasterCell/DefaultComponents/FocusableView/index.tsx +2 -3
  11. package/Components/MasterCell/DefaultComponents/Image/Image.ios.tsx +6 -5
  12. package/Components/MasterCell/DefaultComponents/Image/Image.web.tsx +2 -2
  13. package/Components/MasterCell/DefaultComponents/__tests__/image.test.js +1 -1
  14. package/Components/MasterCell/hooks/useAsyncRendering/MasterCellAsyncRenderManager.ts +2 -2
  15. package/Components/MasterCell/utils/index.ts +3 -4
  16. package/Components/PlayerContainer/PlayerContainer.tsx +14 -8
  17. package/Components/Transitioner/Transitioner.tsx +13 -3
  18. package/Components/VideoLive/__tests__/__snapshots__/PlayerLiveImageComponent.test.tsx.snap +5 -0
  19. package/Components/VideoModal/ModalAnimation/AnimatedPlayerModalWrapper.tsx +3 -9
  20. package/Components/VideoModal/ModalAnimation/AnimatedScrollModal.tsx +38 -40
  21. package/Components/VideoModal/ModalAnimation/AnimatedVideoPlayerComponent.tsx +9 -6
  22. package/Components/VideoModal/ModalAnimation/AnimationComponent.tsx +28 -26
  23. package/Components/VideoModal/PlayerDetails.tsx +16 -2
  24. package/Components/VideoModal/PlayerWrapper.tsx +40 -10
  25. package/Components/VideoModal/VideoModal.tsx +33 -27
  26. package/Components/VideoModal/__tests__/PlayerDetails.test.tsx +7 -0
  27. package/Components/VideoModal/__tests__/__snapshots__/PlayerDetails.test.tsx.snap +2 -0
  28. package/Components/VideoModal/__tests__/__snapshots__/PlayerWrapper.test.tsx.snap +56 -10
  29. package/Components/ZappFrameworkComponents/BarView/BarView.tsx +4 -1
  30. package/Components/ZappFrameworkComponents/BarView/Buttons/BackButton.tsx +7 -2
  31. package/Components/ZappFrameworkComponents/BarView/Buttons/CloseButton.tsx +7 -2
  32. package/Components/ZappFrameworkComponents/BarView/__tests__/BarView.test.tsx +87 -0
  33. package/Components/ZappFrameworkComponents/Buttons/ActionButton.tsx +9 -4
  34. package/Contexts/CachedDimensionsContext/index.ts +13 -9
  35. package/Contexts/ConfirmDialogState/index.ts +1 -1
  36. package/Contexts/ScreenContext/index.tsx +6 -1
  37. package/package.json +5 -5
@@ -0,0 +1,87 @@
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
+ });
@@ -28,7 +28,7 @@ styles: {
28
28
  }
29
29
  */
30
30
 
31
- type ActionButtonProps = {
31
+ type ActionButtonProps = Testable & {
32
32
  onPress: () => void;
33
33
  buttonStyles: any;
34
34
  imageUrl: string;
@@ -46,11 +46,16 @@ const ActionButton = ({
46
46
  buttonStyles,
47
47
  imageUrl,
48
48
  imageStyle = closeButtonStyle,
49
+ testID,
49
50
  }: ActionButtonProps) => {
50
51
  return (
51
- <View style={buttonStyles}>
52
- <TouchableOpacity onPress={onPress}>
53
- <Image source={{ uri: imageUrl }} style={imageStyle} />
52
+ <View style={buttonStyles} testID={testID}>
53
+ <TouchableOpacity onPress={onPress} testID={`${testID}-touchable`}>
54
+ <Image
55
+ source={{ uri: imageUrl }}
56
+ style={imageStyle}
57
+ testID={`${testID}-image`}
58
+ />
54
59
  </TouchableOpacity>
55
60
  </View>
56
61
  );
@@ -1,5 +1,6 @@
1
1
  import { create, useStore } from "zustand";
2
2
  import { produce } from "immer";
3
+ import { useCallback, useMemo } from "react";
3
4
 
4
5
  type Dimensions = {
5
6
  width: Option<number>;
@@ -31,16 +32,19 @@ export const useCachedDimensions = (id: string) => {
31
32
  dimensionsStore
32
33
  ) as DimensionsState;
33
34
 
34
- const getCachedDimensions = () => {
35
+ const getCachedDimensions = useCallback(() => {
35
36
  return dimensions[id] || initialDimensions();
36
- };
37
+ }, [dimensions?.[id], id]);
37
38
 
38
- const handleSetCachedDimensions = (newDimensions) => {
39
+ const handleSetCachedDimensions = useCallback((newDimensions) => {
39
40
  setCachedDimensions(id, newDimensions);
40
- };
41
-
42
- return {
43
- getCachedDimensions,
44
- setCachedDimensions: handleSetCachedDimensions,
45
- };
41
+ }, []);
42
+
43
+ return useMemo(
44
+ () => ({
45
+ getCachedDimensions,
46
+ setCachedDimensions: handleSetCachedDimensions,
47
+ }),
48
+ [getCachedDimensions, handleSetCachedDimensions]
49
+ );
46
50
  };
@@ -2,7 +2,7 @@ import { createStore } from "zustand/vanilla";
2
2
  import { useStore } from "zustand";
3
3
  import { noop } from "@applicaster/zapp-react-native-utils/functionUtils";
4
4
 
5
- interface ConfirmationDialogState {
5
+ export interface ConfirmationDialogState {
6
6
  isDialogVisible: boolean;
7
7
  messages: string;
8
8
  confirmAction: () => void;
@@ -177,7 +177,12 @@ export function withScreenContext(Component: React.ComponentType<any>) {
177
177
  return function WithScreenContextWrapper(props) {
178
178
  return (
179
179
  <ScreenContext.Consumer>
180
- {(value) => <Component {...props} screenContext={value} />}
180
+ {useCallback(
181
+ (value) => (
182
+ <Component {...props} screenContext={value} />
183
+ ),
184
+ [Component, props]
185
+ )}
181
186
  </ScreenContext.Consumer>
182
187
  );
183
188
  };
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.5933014273",
3
+ "version": "12.0.0-alpha.6158046395",
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.5933014273",
38
- "@applicaster/zapp-react-native-bridge": "12.0.0-alpha.5933014273",
39
- "@applicaster/zapp-react-native-redux": "12.0.0-alpha.5933014273",
40
- "@applicaster/zapp-react-native-utils": "12.0.0-alpha.5933014273",
37
+ "@applicaster/applicaster-types": "12.0.0-alpha.6158046395",
38
+ "@applicaster/zapp-react-native-bridge": "12.0.0-alpha.6158046395",
39
+ "@applicaster/zapp-react-native-redux": "12.0.0-alpha.6158046395",
40
+ "@applicaster/zapp-react-native-utils": "12.0.0-alpha.6158046395",
41
41
  "promise": "^8.3.0",
42
42
  "react-router-native": "^5.1.2",
43
43
  "url": "^0.11.0",