@applicaster/quick-brick-core 15.1.5 → 15.1.6-alpha.3988508055
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/App/ActionsProvider/ActionsProvider.tsx +31 -9
- package/App/ActionsProvider/LegacyActionsRegistryAdapter.tsx +107 -0
- package/App/ModalProvider/ModalBottomSheet/ModalBottomSheetFrame.tsx +9 -1
- package/App/ModalProvider/ModalBottomSheet/hooks/__tests__/useKeyboardHeight.android.test.ts +105 -0
- package/App/ModalProvider/ModalBottomSheet/hooks/__tests__/useKeyboardHeight.test.ts +102 -0
- package/App/ModalProvider/ModalBottomSheet/hooks/index.ts +1 -0
- package/App/ModalProvider/ModalBottomSheet/hooks/useKeyboardHeight.ts +30 -0
- package/App/NotificationToastRenderer/NotificationToastManager.ts +209 -0
- package/App/NotificationToastRenderer/NotificationToastRenderer.tsx +102 -0
- package/App/NotificationToastRenderer/NotificationToastRenderer.web.tsx +61 -0
- package/App/NotificationToastRenderer/__tests__/NotificationToastManager.test.ts +237 -0
- package/App/NotificationToastRenderer/__tests__/NotificationToastRenderer.test.tsx +85 -0
- package/App/NotificationToastRenderer/__tests__/NotificationToastRenderer.web.test.tsx +90 -0
- package/App/NotificationToastRenderer/__tests__/useNotificationHeight.test.tsx +58 -0
- package/App/NotificationToastRenderer/__tests__/useNotificationToastState.test.ts +112 -0
- package/App/NotificationToastRenderer/index.tsx +5 -0
- package/App/NotificationToastRenderer/useNotificationHeight.tsx +13 -0
- package/App/NotificationToastRenderer/useNotificationToastState.tsx +12 -0
- package/package.json +8 -8
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { act, renderHook } from "@testing-library/react-native";
|
|
2
|
+
|
|
3
|
+
import { notificationToastManager } from "../NotificationToastManager";
|
|
4
|
+
import { useNotificationToastState } from "../useNotificationToastState";
|
|
5
|
+
|
|
6
|
+
jest.useFakeTimers();
|
|
7
|
+
|
|
8
|
+
describe("useNotificationToastState", () => {
|
|
9
|
+
beforeAll(() => {
|
|
10
|
+
jest.spyOn(console, "log").mockImplementation(() => {});
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
afterAll(() => {
|
|
14
|
+
(console.log as jest.Mock).mockRestore();
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
afterEach(() => {
|
|
18
|
+
// drain whatever is left showing/queued so the next test starts clean;
|
|
19
|
+
// the hook's own effect cleanup (on unmount) removes its SHOW/HIDE
|
|
20
|
+
// handlers automatically via RNTL's auto-cleanup.
|
|
21
|
+
for (let i = 0; i < 10; i++) {
|
|
22
|
+
notificationToastManager.dismiss();
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
jest.restoreAllMocks();
|
|
26
|
+
jest.spyOn(console, "log").mockImplementation(() => {});
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it("starts with no toast", () => {
|
|
30
|
+
const { result } = renderHook(() => useNotificationToastState());
|
|
31
|
+
|
|
32
|
+
expect(result.current).toBeNull();
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it("reflects the toast emitted by the manager's SHOW event", () => {
|
|
36
|
+
const { result } = renderHook(() => useNotificationToastState());
|
|
37
|
+
|
|
38
|
+
act(() => {
|
|
39
|
+
notificationToastManager.showToast({ message: "hello" });
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
expect(result.current).toEqual(
|
|
43
|
+
expect.objectContaining({ message: "hello" })
|
|
44
|
+
);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it("clears the toast when the manager emits HIDE", () => {
|
|
48
|
+
const { result } = renderHook(() => useNotificationToastState());
|
|
49
|
+
|
|
50
|
+
act(() => {
|
|
51
|
+
notificationToastManager.showToast({ message: "hello" });
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
expect(result.current).not.toBeNull();
|
|
55
|
+
|
|
56
|
+
act(() => {
|
|
57
|
+
notificationToastManager.dismiss();
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
expect(result.current).toBeNull();
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it("stops updating after unmount", () => {
|
|
64
|
+
const { result, unmount } = renderHook(() => useNotificationToastState());
|
|
65
|
+
|
|
66
|
+
unmount();
|
|
67
|
+
|
|
68
|
+
act(() => {
|
|
69
|
+
notificationToastManager.showToast({ message: "after unmount" });
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
expect(result.current).toBeNull();
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it("subscribes on mount and disposes the subscription on unmount", () => {
|
|
76
|
+
const dispose = jest.fn();
|
|
77
|
+
|
|
78
|
+
const subscribeSpy = jest
|
|
79
|
+
.spyOn(notificationToastManager, "subscribe")
|
|
80
|
+
.mockReturnValue(dispose);
|
|
81
|
+
|
|
82
|
+
const { unmount } = renderHook(() => useNotificationToastState());
|
|
83
|
+
|
|
84
|
+
expect(subscribeSpy).toHaveBeenCalledWith(expect.any(Function));
|
|
85
|
+
expect(dispose).not.toHaveBeenCalled();
|
|
86
|
+
|
|
87
|
+
unmount();
|
|
88
|
+
|
|
89
|
+
expect(dispose).toHaveBeenCalledTimes(1);
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
it("subscribe registers SHOW/HIDE handlers and its disposer removes them", () => {
|
|
93
|
+
const callback = jest.fn();
|
|
94
|
+
|
|
95
|
+
const dispose = notificationToastManager.subscribe(callback);
|
|
96
|
+
|
|
97
|
+
act(() => {
|
|
98
|
+
notificationToastManager.showToast({ message: "hello" }); // emits SHOW
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
expect(callback).toHaveBeenCalled();
|
|
102
|
+
|
|
103
|
+
callback.mockClear();
|
|
104
|
+
dispose();
|
|
105
|
+
|
|
106
|
+
act(() => {
|
|
107
|
+
notificationToastManager.showToast({ message: "again" }); // emits SHOW
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
expect(callback).not.toHaveBeenCalled();
|
|
111
|
+
});
|
|
112
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
|
2
|
+
import { getNavbarHeight } from "@applicaster/zapp-react-native-utils/reactHooks/layout";
|
|
3
|
+
|
|
4
|
+
export const useNotificationHeight = () => {
|
|
5
|
+
const insets = useSafeAreaInsets();
|
|
6
|
+
|
|
7
|
+
const navBarHeight = getNavbarHeight();
|
|
8
|
+
|
|
9
|
+
const statusHeight = insets.top;
|
|
10
|
+
const notificationHeight = statusHeight + navBarHeight;
|
|
11
|
+
|
|
12
|
+
return { statusHeight, notificationHeight };
|
|
13
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
|
|
3
|
+
import { notificationToastManager } from "./NotificationToastManager";
|
|
4
|
+
|
|
5
|
+
export const useNotificationToastState = () => {
|
|
6
|
+
const state = React.useSyncExternalStore(
|
|
7
|
+
notificationToastManager.subscribe,
|
|
8
|
+
notificationToastManager.getCurrentState
|
|
9
|
+
);
|
|
10
|
+
|
|
11
|
+
return state;
|
|
12
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applicaster/quick-brick-core",
|
|
3
|
-
"version": "15.1.
|
|
3
|
+
"version": "15.1.6-alpha.3988508055",
|
|
4
4
|
"description": "Core package for Applicaster's Quick Brick App",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -28,13 +28,13 @@
|
|
|
28
28
|
},
|
|
29
29
|
"homepage": "https://github.com/applicaster/quickbrick#readme",
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@applicaster/applicaster-types": "15.1.
|
|
32
|
-
"@applicaster/quick-brick-core-plugins": "15.1.
|
|
33
|
-
"@applicaster/zapp-pipes-v2-client": "15.1.
|
|
34
|
-
"@applicaster/zapp-react-native-bridge": "15.1.
|
|
35
|
-
"@applicaster/zapp-react-native-redux": "15.1.
|
|
36
|
-
"@applicaster/zapp-react-native-ui-components": "15.1.
|
|
37
|
-
"@applicaster/zapp-react-native-utils": "15.1.
|
|
31
|
+
"@applicaster/applicaster-types": "15.1.6-alpha.3988508055",
|
|
32
|
+
"@applicaster/quick-brick-core-plugins": "15.1.6-alpha.3988508055",
|
|
33
|
+
"@applicaster/zapp-pipes-v2-client": "15.1.6-alpha.3988508055",
|
|
34
|
+
"@applicaster/zapp-react-native-bridge": "15.1.6-alpha.3988508055",
|
|
35
|
+
"@applicaster/zapp-react-native-redux": "15.1.6-alpha.3988508055",
|
|
36
|
+
"@applicaster/zapp-react-native-ui-components": "15.1.6-alpha.3988508055",
|
|
37
|
+
"@applicaster/zapp-react-native-utils": "15.1.6-alpha.3988508055",
|
|
38
38
|
"atob": "^2.1.2",
|
|
39
39
|
"axios": "^0.28.0",
|
|
40
40
|
"btoa": "^1.2.1",
|