@applicaster/quick-brick-core 16.0.0-rc.53 → 16.0.0-rc.55
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/NotificationToastRenderer/NotificationToastManager.ts +13 -2
- package/App/NotificationToastRenderer/NotificationToastRenderer.tsx +56 -24
- package/App/NotificationToastRenderer/__tests__/NotificationToastManager.test.ts +24 -0
- package/App/NotificationToastRenderer/__tests__/NotificationToastRenderer.test.tsx +151 -3
- package/App/NotificationToastRenderer/__tests__/resolveConfirmationToastStyle.test.ts +118 -0
- package/App/NotificationToastRenderer/index.tsx +6 -0
- package/App/NotificationToastRenderer/resolveConfirmationToastStyle.ts +33 -0
- package/package.json +8 -8
|
@@ -24,12 +24,19 @@ export interface ToastStyle {
|
|
|
24
24
|
letterSpacing?: number;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
+
export const DEFAULT_TOAST_TIMEOUT = 4000;
|
|
28
|
+
|
|
29
|
+
export const CONFIRMATION_TOAST_SOURCE = "confirmation";
|
|
30
|
+
|
|
27
31
|
export interface ToastPayload {
|
|
28
32
|
id?: string;
|
|
29
33
|
message: string;
|
|
30
34
|
extraMessage?: string; // secondary line; TV renderers show it as a subtitle, mobile ignores it
|
|
31
|
-
timeout?: number; // ms;
|
|
35
|
+
timeout?: number; // ms; defaults to DEFAULT_TOAST_TIMEOUT (4000) if omitted
|
|
32
36
|
style?: ToastStyle;
|
|
37
|
+
// stamped by the showToast action; Theme confirmation styles apply when
|
|
38
|
+
// source === CONFIRMATION_TOAST_SOURCE ("confirmation")
|
|
39
|
+
source?: string;
|
|
33
40
|
[key: string]: unknown;
|
|
34
41
|
}
|
|
35
42
|
|
|
@@ -122,7 +129,11 @@ class NotificationToastManager {
|
|
|
122
129
|
};
|
|
123
130
|
|
|
124
131
|
private handleShowToast = (payload: ToastPayload) => {
|
|
125
|
-
const item = {
|
|
132
|
+
const item = {
|
|
133
|
+
...payload,
|
|
134
|
+
id: payload.id ?? String(this.nextId++),
|
|
135
|
+
timeout: payload.timeout ?? DEFAULT_TOAST_TIMEOUT,
|
|
136
|
+
};
|
|
126
137
|
|
|
127
138
|
const queuedIndex = this.queue.findIndex((queued) => queued.id === item.id);
|
|
128
139
|
|
|
@@ -1,16 +1,22 @@
|
|
|
1
|
-
import React, { useEffect, useRef, useState } from "react";
|
|
1
|
+
import React, { useEffect, useMemo, useRef, useState } from "react";
|
|
2
|
+
import { View, Text, Animated, StyleSheet, ViewStyle } from "react-native";
|
|
2
3
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
4
|
+
Directions,
|
|
5
|
+
Gesture,
|
|
6
|
+
GestureDetector,
|
|
7
|
+
} from "react-native-gesture-handler";
|
|
8
|
+
import { useTheme } from "@applicaster/zapp-react-native-utils/theme";
|
|
9
|
+
|
|
10
|
+
import {
|
|
11
|
+
CONFIRMATION_TOAST_SOURCE,
|
|
12
|
+
notificationToastManager,
|
|
13
|
+
} from "./NotificationToastManager";
|
|
12
14
|
import { useNotificationToastState } from "./useNotificationToastState";
|
|
13
15
|
import { useNotificationHeight } from "./useNotificationHeight";
|
|
16
|
+
import { resolveConfirmationToastStyle } from "./resolveConfirmationToastStyle";
|
|
17
|
+
|
|
18
|
+
const DEFAULT_TOAST_BACKGROUND_COLOR = "#000";
|
|
19
|
+
const DEFAULT_TOAST_MESSAGE_COLOR = "#fff";
|
|
14
20
|
|
|
15
21
|
const styles = StyleSheet.create({
|
|
16
22
|
notificationView: {
|
|
@@ -28,6 +34,7 @@ type NumberBoolean = 0 | 1;
|
|
|
28
34
|
|
|
29
35
|
export const NotificationToastRenderer = ({ children }) => {
|
|
30
36
|
const { statusHeight, notificationHeight } = useNotificationHeight();
|
|
37
|
+
const theme = useTheme<BaseThemePropertiesMobile>();
|
|
31
38
|
|
|
32
39
|
const toast = useNotificationToastState();
|
|
33
40
|
|
|
@@ -36,15 +43,22 @@ export const NotificationToastRenderer = ({ children }) => {
|
|
|
36
43
|
|
|
37
44
|
const yPosition = useRef(new Animated.Value(0)).current;
|
|
38
45
|
|
|
39
|
-
const
|
|
40
|
-
|
|
46
|
+
const resolvedStyle =
|
|
47
|
+
toast?.source === CONFIRMATION_TOAST_SOURCE
|
|
48
|
+
? resolveConfirmationToastStyle(theme, toast.style)
|
|
49
|
+
: toast?.style;
|
|
50
|
+
|
|
51
|
+
const backgroundColor =
|
|
52
|
+
resolvedStyle?.backgroundColor ?? DEFAULT_TOAST_BACKGROUND_COLOR;
|
|
53
|
+
|
|
54
|
+
const color = resolvedStyle?.color ?? DEFAULT_TOAST_MESSAGE_COLOR;
|
|
41
55
|
|
|
42
56
|
const textStyles = {
|
|
43
57
|
color,
|
|
44
|
-
fontFamily:
|
|
45
|
-
fontSize:
|
|
46
|
-
lineHeight:
|
|
47
|
-
letterSpacing:
|
|
58
|
+
fontFamily: resolvedStyle?.fontFamily,
|
|
59
|
+
fontSize: resolvedStyle?.fontSize,
|
|
60
|
+
lineHeight: resolvedStyle?.lineHeight,
|
|
61
|
+
letterSpacing: resolvedStyle?.letterSpacing,
|
|
48
62
|
};
|
|
49
63
|
|
|
50
64
|
const animatedViewStyles: ViewStyle = {
|
|
@@ -64,6 +78,20 @@ export const NotificationToastRenderer = ({ children }) => {
|
|
|
64
78
|
backgroundColor,
|
|
65
79
|
};
|
|
66
80
|
|
|
81
|
+
const flingGesture = useMemo(
|
|
82
|
+
() =>
|
|
83
|
+
Gesture.Fling()
|
|
84
|
+
.direction(Directions.UP)
|
|
85
|
+
.enabled(!!toast)
|
|
86
|
+
.runOnJS(true)
|
|
87
|
+
.onEnd((_event, success) => {
|
|
88
|
+
if (success) {
|
|
89
|
+
notificationToastManager.dismiss();
|
|
90
|
+
}
|
|
91
|
+
}),
|
|
92
|
+
[toast]
|
|
93
|
+
);
|
|
94
|
+
|
|
67
95
|
useEffect(() => {
|
|
68
96
|
if (toast) {
|
|
69
97
|
setNotificationOpacity(1);
|
|
@@ -83,20 +111,24 @@ export const NotificationToastRenderer = ({ children }) => {
|
|
|
83
111
|
}, [toast]);
|
|
84
112
|
|
|
85
113
|
return (
|
|
86
|
-
<View
|
|
114
|
+
<View
|
|
115
|
+
testID="NotificationToastRenderer"
|
|
116
|
+
style={StyleSheet.absoluteFill}
|
|
117
|
+
pointerEvents="box-none"
|
|
118
|
+
>
|
|
87
119
|
{children}
|
|
88
|
-
<
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
120
|
+
<GestureDetector gesture={flingGesture}>
|
|
121
|
+
<Animated.View
|
|
122
|
+
testID="NotificationToastRenderer-fling"
|
|
123
|
+
pointerEvents={toast ? "auto" : "none"}
|
|
124
|
+
style={animatedViewStyles}
|
|
125
|
+
>
|
|
94
126
|
<View style={{ height: statusHeight, backgroundColor }} />
|
|
95
127
|
<Text testID="NotificationToastRenderer-message" style={textStyles}>
|
|
96
128
|
{toast?.message}
|
|
97
129
|
</Text>
|
|
98
130
|
</Animated.View>
|
|
99
|
-
</
|
|
131
|
+
</GestureDetector>
|
|
100
132
|
</View>
|
|
101
133
|
);
|
|
102
134
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
notificationToastManager,
|
|
3
3
|
NOTIFICATION_TOAST_EVENTS,
|
|
4
|
+
DEFAULT_TOAST_TIMEOUT,
|
|
4
5
|
} from "../NotificationToastManager";
|
|
5
6
|
import { postEvent } from "@applicaster/zapp-react-native-utils/reactHooks/useSubscriberFor";
|
|
6
7
|
|
|
@@ -210,4 +211,27 @@ describe("NotificationToastManager", () => {
|
|
|
210
211
|
|
|
211
212
|
expect(onShow).not.toHaveBeenCalled();
|
|
212
213
|
});
|
|
214
|
+
|
|
215
|
+
it("defaults timeout to DEFAULT_TOAST_TIMEOUT (4000ms) when omitted and auto-hides", () => {
|
|
216
|
+
const onShow = jest.fn();
|
|
217
|
+
const onHide = jest.fn();
|
|
218
|
+
on(NOTIFICATION_TOAST_EVENTS.SHOW, onShow);
|
|
219
|
+
on(NOTIFICATION_TOAST_EVENTS.HIDE, onHide);
|
|
220
|
+
|
|
221
|
+
notificationToastManager.showToast({
|
|
222
|
+
message: "Added to queue",
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
expect(onShow).toHaveBeenCalledWith(
|
|
226
|
+
expect.objectContaining({
|
|
227
|
+
message: "Added to queue",
|
|
228
|
+
timeout: DEFAULT_TOAST_TIMEOUT,
|
|
229
|
+
}),
|
|
230
|
+
expect.any(Function)
|
|
231
|
+
);
|
|
232
|
+
|
|
233
|
+
jest.advanceTimersByTime(DEFAULT_TOAST_TIMEOUT);
|
|
234
|
+
|
|
235
|
+
expect(onHide).toHaveBeenCalledTimes(1);
|
|
236
|
+
});
|
|
213
237
|
});
|
|
@@ -1,14 +1,68 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { Text } from "react-native";
|
|
3
3
|
import { act, fireEvent, render } from "@testing-library/react-native";
|
|
4
|
+
import { useTheme } from "@applicaster/zapp-react-native-utils/theme";
|
|
4
5
|
|
|
5
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
CONFIRMATION_TOAST_SOURCE,
|
|
8
|
+
notificationToastManager,
|
|
9
|
+
} from "../NotificationToastManager";
|
|
6
10
|
import { NotificationToastRenderer } from "../NotificationToastRenderer";
|
|
7
11
|
|
|
8
12
|
jest.mock("react-native-safe-area-context", () => ({
|
|
9
13
|
useSafeAreaInsets: () => ({ top: 44 }),
|
|
10
14
|
}));
|
|
11
15
|
|
|
16
|
+
jest.mock("@applicaster/zapp-react-native-utils/theme", () => ({
|
|
17
|
+
useTheme: jest.fn(),
|
|
18
|
+
}));
|
|
19
|
+
|
|
20
|
+
jest.mock("react-native-gesture-handler", () => {
|
|
21
|
+
const RN = require("react-native");
|
|
22
|
+
const ReactActual = require("react");
|
|
23
|
+
const actual = jest.requireActual("react-native-gesture-handler");
|
|
24
|
+
|
|
25
|
+
const GestureDetector = ReactActual.forwardRef(
|
|
26
|
+
({ gesture, children }: any, ref: any) => {
|
|
27
|
+
const onEnd = gesture?.handlers?.onEnd;
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<RN.View
|
|
31
|
+
ref={ref}
|
|
32
|
+
testID="NotificationToastRenderer-fling-handler"
|
|
33
|
+
accessibilityState={{ disabled: gesture?.config?.enabled === false }}
|
|
34
|
+
// drive Gesture.Fling().onEnd via a test-only event
|
|
35
|
+
onEnd={() => onEnd?.({}, true)}
|
|
36
|
+
onEndFailed={() => onEnd?.({}, false)}
|
|
37
|
+
>
|
|
38
|
+
{children}
|
|
39
|
+
</RN.View>
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
return {
|
|
45
|
+
__esModule: true,
|
|
46
|
+
...actual,
|
|
47
|
+
GestureDetector,
|
|
48
|
+
};
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
const mockedUseTheme = useTheme as jest.MockedFunction<typeof useTheme>;
|
|
52
|
+
|
|
53
|
+
const confirmationTheme: Partial<BaseThemePropertiesMobile> = {
|
|
54
|
+
confirmation_toast_style_background_color: "#0188FF",
|
|
55
|
+
confirmation_toast_style_color: "#EFEFEF",
|
|
56
|
+
confirmation_toast_style_ios_font_family: "SFProText-Semibold",
|
|
57
|
+
confirmation_toast_style_android_font_family: "Roboto-Medium",
|
|
58
|
+
confirmation_toast_style_ios_font_size: 14,
|
|
59
|
+
confirmation_toast_style_android_font_size: 14,
|
|
60
|
+
confirmation_toast_style_ios_line_height: 44,
|
|
61
|
+
confirmation_toast_style_android_line_height: 44,
|
|
62
|
+
confirmation_toast_style_ios_letter_spacing: -1.4,
|
|
63
|
+
confirmation_toast_style_android_letter_spacing: -1.4,
|
|
64
|
+
};
|
|
65
|
+
|
|
12
66
|
describe("NotificationToastRenderer", () => {
|
|
13
67
|
beforeAll(() => {
|
|
14
68
|
jest.spyOn(console, "log").mockImplementation(() => {});
|
|
@@ -18,6 +72,12 @@ describe("NotificationToastRenderer", () => {
|
|
|
18
72
|
(console.log as jest.Mock).mockRestore();
|
|
19
73
|
});
|
|
20
74
|
|
|
75
|
+
beforeEach(() => {
|
|
76
|
+
mockedUseTheme.mockReturnValue(
|
|
77
|
+
confirmationTheme as BaseThemePropertiesMobile
|
|
78
|
+
);
|
|
79
|
+
});
|
|
80
|
+
|
|
21
81
|
afterEach(() => {
|
|
22
82
|
// drain whatever is left showing/queued so the next test starts clean
|
|
23
83
|
for (let i = 0; i < 10; i++) {
|
|
@@ -73,13 +133,101 @@ describe("NotificationToastRenderer", () => {
|
|
|
73
133
|
).toEqual(expect.objectContaining({ color: "#123456", fontSize: 20 }));
|
|
74
134
|
});
|
|
75
135
|
|
|
76
|
-
it("
|
|
136
|
+
it("applies Theme confirmation styles when source is confirmation", () => {
|
|
137
|
+
const { getByTestId } = render(<NotificationToastRenderer />);
|
|
138
|
+
|
|
139
|
+
act(() => {
|
|
140
|
+
notificationToastManager.showToast({
|
|
141
|
+
message: "Added to queue",
|
|
142
|
+
source: CONFIRMATION_TOAST_SOURCE,
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
expect(
|
|
147
|
+
getByTestId("NotificationToastRenderer-message").props.style
|
|
148
|
+
).toEqual(
|
|
149
|
+
expect.objectContaining({
|
|
150
|
+
color: "#EFEFEF",
|
|
151
|
+
fontSize: 14,
|
|
152
|
+
lineHeight: 44,
|
|
153
|
+
letterSpacing: -1.4,
|
|
154
|
+
})
|
|
155
|
+
);
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
it("shallow-merges style overrides onto Theme confirmation defaults", () => {
|
|
159
|
+
const { getByTestId } = render(<NotificationToastRenderer />);
|
|
160
|
+
|
|
161
|
+
act(() => {
|
|
162
|
+
notificationToastManager.showToast({
|
|
163
|
+
message: "Playlist created",
|
|
164
|
+
source: CONFIRMATION_TOAST_SOURCE,
|
|
165
|
+
style: { backgroundColor: "#00FF00", fontSize: 20 },
|
|
166
|
+
});
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
expect(
|
|
170
|
+
getByTestId("NotificationToastRenderer-message").props.style
|
|
171
|
+
).toEqual(
|
|
172
|
+
expect.objectContaining({
|
|
173
|
+
color: "#EFEFEF",
|
|
174
|
+
fontSize: 20,
|
|
175
|
+
lineHeight: 44,
|
|
176
|
+
})
|
|
177
|
+
);
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
it("does not apply Theme confirmation styles for non-confirmation toasts", () => {
|
|
181
|
+
const { getByTestId } = render(<NotificationToastRenderer />);
|
|
182
|
+
|
|
183
|
+
act(() => {
|
|
184
|
+
notificationToastManager.showToast({
|
|
185
|
+
message: "You are offline",
|
|
186
|
+
style: { color: "#abcdef" },
|
|
187
|
+
});
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
expect(
|
|
191
|
+
getByTestId("NotificationToastRenderer-message").props.style
|
|
192
|
+
).toEqual(
|
|
193
|
+
expect.objectContaining({
|
|
194
|
+
color: "#abcdef",
|
|
195
|
+
})
|
|
196
|
+
);
|
|
197
|
+
|
|
198
|
+
expect(
|
|
199
|
+
getByTestId("NotificationToastRenderer-message").props.style.fontSize
|
|
200
|
+
).toBeUndefined();
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
it("dismisses the toast on a successful upward fling", () => {
|
|
77
204
|
const dismissSpy = jest.spyOn(notificationToastManager, "dismiss");
|
|
78
205
|
|
|
79
206
|
const { getByTestId } = render(<NotificationToastRenderer />);
|
|
80
207
|
|
|
81
|
-
|
|
208
|
+
act(() => {
|
|
209
|
+
notificationToastManager.showToast({ message: "Added to queue" });
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
fireEvent(getByTestId("NotificationToastRenderer-fling-handler"), "end");
|
|
82
213
|
|
|
83
214
|
expect(dismissSpy).toHaveBeenCalled();
|
|
84
215
|
});
|
|
216
|
+
|
|
217
|
+
it("does not dismiss when the fling ends unsuccessfully", () => {
|
|
218
|
+
const dismissSpy = jest.spyOn(notificationToastManager, "dismiss");
|
|
219
|
+
|
|
220
|
+
const { getByTestId } = render(<NotificationToastRenderer />);
|
|
221
|
+
|
|
222
|
+
act(() => {
|
|
223
|
+
notificationToastManager.showToast({ message: "Added to queue" });
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
fireEvent(
|
|
227
|
+
getByTestId("NotificationToastRenderer-fling-handler"),
|
|
228
|
+
"endFailed"
|
|
229
|
+
);
|
|
230
|
+
|
|
231
|
+
expect(dismissSpy).not.toHaveBeenCalled();
|
|
232
|
+
});
|
|
85
233
|
});
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { resolveConfirmationToastStyle } from "../resolveConfirmationToastStyle";
|
|
2
|
+
|
|
3
|
+
jest.mock("@applicaster/zapp-react-native-utils/reactUtils", () => ({
|
|
4
|
+
// manifestKeyParser captures currentPlatform at module load from this map
|
|
5
|
+
platformSelect: jest.fn((platforms) => {
|
|
6
|
+
if (platforms?.ios === "ios" && platforms?.android === "android") {
|
|
7
|
+
return "ios";
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
return platforms?.default;
|
|
11
|
+
}),
|
|
12
|
+
}));
|
|
13
|
+
|
|
14
|
+
describe("resolveConfirmationToastStyle", () => {
|
|
15
|
+
const theme = {
|
|
16
|
+
confirmation_toast_style_background_color: "#0188FF",
|
|
17
|
+
confirmation_toast_style_color: "#EFEFEF",
|
|
18
|
+
confirmation_toast_style_ios_font_family: "SFProText-Semibold",
|
|
19
|
+
confirmation_toast_style_android_font_family: "Roboto-Medium",
|
|
20
|
+
confirmation_toast_style_ios_font_size: 14,
|
|
21
|
+
confirmation_toast_style_android_font_size: 16,
|
|
22
|
+
confirmation_toast_style_ios_line_height: 44,
|
|
23
|
+
confirmation_toast_style_android_line_height: 40,
|
|
24
|
+
confirmation_toast_style_ios_letter_spacing: -1.4,
|
|
25
|
+
confirmation_toast_style_android_letter_spacing: -0.5,
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
it("maps Theme confirmation_toast_style_* keys via getAllSpecificStyles (iOS platform)", () => {
|
|
29
|
+
expect(resolveConfirmationToastStyle(theme)).toEqual({
|
|
30
|
+
backgroundColor: "#0188FF",
|
|
31
|
+
color: "#EFEFEF",
|
|
32
|
+
fontFamily: "SFProText-Semibold",
|
|
33
|
+
fontSize: 14,
|
|
34
|
+
lineHeight: 44,
|
|
35
|
+
letterSpacing: -1.4,
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it("ignores other-platform keys for the current platform", () => {
|
|
40
|
+
const result = resolveConfirmationToastStyle(theme);
|
|
41
|
+
|
|
42
|
+
expect(result.fontFamily).toBe("SFProText-Semibold");
|
|
43
|
+
expect(result.fontSize).toBe(14);
|
|
44
|
+
|
|
45
|
+
expect(result).not.toEqual(
|
|
46
|
+
expect.objectContaining({
|
|
47
|
+
fontFamily: "Roboto-Medium",
|
|
48
|
+
fontSize: 16,
|
|
49
|
+
})
|
|
50
|
+
);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it("shallow-merges override style on top of Theme defaults", () => {
|
|
54
|
+
expect(
|
|
55
|
+
resolveConfirmationToastStyle(theme, {
|
|
56
|
+
backgroundColor: "#00FF00",
|
|
57
|
+
fontSize: 20,
|
|
58
|
+
})
|
|
59
|
+
).toEqual({
|
|
60
|
+
backgroundColor: "#00FF00",
|
|
61
|
+
color: "#EFEFEF",
|
|
62
|
+
fontFamily: "SFProText-Semibold",
|
|
63
|
+
fontSize: 20,
|
|
64
|
+
lineHeight: 44,
|
|
65
|
+
letterSpacing: -1.4,
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it("returns override fields when Theme is missing", () => {
|
|
70
|
+
expect(resolveConfirmationToastStyle(undefined, { color: "#fff" })).toEqual(
|
|
71
|
+
{
|
|
72
|
+
color: "#fff",
|
|
73
|
+
}
|
|
74
|
+
);
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
describe("resolveConfirmationToastStyle (android platform)", () => {
|
|
79
|
+
it("maps android platform Theme keys", () => {
|
|
80
|
+
jest.resetModules();
|
|
81
|
+
|
|
82
|
+
jest.doMock("@applicaster/zapp-react-native-utils/reactUtils", () => ({
|
|
83
|
+
platformSelect: jest.fn((platforms) => {
|
|
84
|
+
if (platforms?.ios === "ios" && platforms?.android === "android") {
|
|
85
|
+
return "android";
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return platforms?.default;
|
|
89
|
+
}),
|
|
90
|
+
}));
|
|
91
|
+
|
|
92
|
+
const {
|
|
93
|
+
resolveConfirmationToastStyle: resolveAndroid,
|
|
94
|
+
} = require("../resolveConfirmationToastStyle");
|
|
95
|
+
|
|
96
|
+
const theme = {
|
|
97
|
+
confirmation_toast_style_background_color: "#0188FF",
|
|
98
|
+
confirmation_toast_style_color: "#EFEFEF",
|
|
99
|
+
confirmation_toast_style_ios_font_family: "SFProText-Semibold",
|
|
100
|
+
confirmation_toast_style_android_font_family: "Roboto-Medium",
|
|
101
|
+
confirmation_toast_style_ios_font_size: 14,
|
|
102
|
+
confirmation_toast_style_android_font_size: 16,
|
|
103
|
+
confirmation_toast_style_ios_line_height: 44,
|
|
104
|
+
confirmation_toast_style_android_line_height: 40,
|
|
105
|
+
confirmation_toast_style_ios_letter_spacing: -1.4,
|
|
106
|
+
confirmation_toast_style_android_letter_spacing: -0.5,
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
expect(resolveAndroid(theme)).toEqual({
|
|
110
|
+
backgroundColor: "#0188FF",
|
|
111
|
+
color: "#EFEFEF",
|
|
112
|
+
fontFamily: "Roboto-Medium",
|
|
113
|
+
fontSize: 16,
|
|
114
|
+
lineHeight: 40,
|
|
115
|
+
letterSpacing: -0.5,
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
});
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
export { notificationToastManager } from "./NotificationToastManager";
|
|
2
2
|
|
|
3
|
+
export type { ToastPayload, ToastStyle } from "./NotificationToastManager";
|
|
4
|
+
|
|
5
|
+
export { CONFIRMATION_TOAST_SOURCE } from "./NotificationToastManager";
|
|
6
|
+
|
|
3
7
|
export { NotificationToastRenderer } from "./NotificationToastRenderer";
|
|
4
8
|
|
|
5
9
|
export { useNotificationHeight } from "./useNotificationHeight";
|
|
10
|
+
|
|
11
|
+
export { resolveConfirmationToastStyle } from "./resolveConfirmationToastStyle";
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { getAllSpecificStyles } from "@applicaster/zapp-react-native-utils/configurationUtils/manifestKeyParser";
|
|
2
|
+
|
|
3
|
+
import { ToastStyle } from "./NotificationToastManager";
|
|
4
|
+
|
|
5
|
+
const CONFIRMATION_TOAST_STYLE_COMPONENT = "confirmation_toast";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Builds confirmation-toast style from Theme defaults via getAllSpecificStyles,
|
|
9
|
+
* then shallow-merges any caller override on top.
|
|
10
|
+
*
|
|
11
|
+
* Expected Theme keys follow:
|
|
12
|
+
* `confirmation_toast_style_[platform_]<style_name>`
|
|
13
|
+
* e.g. confirmation_toast_style_background_color,
|
|
14
|
+
* confirmation_toast_style_ios_font_family
|
|
15
|
+
*/
|
|
16
|
+
export function resolveConfirmationToastStyle(
|
|
17
|
+
theme: Partial<BaseThemePropertiesMobile> | null | undefined,
|
|
18
|
+
overrideStyle?: ToastStyle | null
|
|
19
|
+
): ToastStyle {
|
|
20
|
+
const outStyles: Record<string, ToastStyle> = {};
|
|
21
|
+
|
|
22
|
+
getAllSpecificStyles({
|
|
23
|
+
configuration: { ...(theme ?? {}) },
|
|
24
|
+
componentName: CONFIRMATION_TOAST_STYLE_COMPONENT,
|
|
25
|
+
subComponentName: "",
|
|
26
|
+
outStyles,
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
return {
|
|
30
|
+
...outStyles.default,
|
|
31
|
+
...overrideStyle,
|
|
32
|
+
};
|
|
33
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applicaster/quick-brick-core",
|
|
3
|
-
"version": "16.0.0-rc.
|
|
3
|
+
"version": "16.0.0-rc.55",
|
|
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": "16.0.0-rc.
|
|
32
|
-
"@applicaster/quick-brick-core-plugins": "16.0.0-rc.
|
|
33
|
-
"@applicaster/zapp-pipes-v2-client": "16.0.0-rc.
|
|
34
|
-
"@applicaster/zapp-react-native-bridge": "16.0.0-rc.
|
|
35
|
-
"@applicaster/zapp-react-native-redux": "16.0.0-rc.
|
|
36
|
-
"@applicaster/zapp-react-native-ui-components": "16.0.0-rc.
|
|
37
|
-
"@applicaster/zapp-react-native-utils": "16.0.0-rc.
|
|
31
|
+
"@applicaster/applicaster-types": "16.0.0-rc.55",
|
|
32
|
+
"@applicaster/quick-brick-core-plugins": "16.0.0-rc.55",
|
|
33
|
+
"@applicaster/zapp-pipes-v2-client": "16.0.0-rc.55",
|
|
34
|
+
"@applicaster/zapp-react-native-bridge": "16.0.0-rc.55",
|
|
35
|
+
"@applicaster/zapp-react-native-redux": "16.0.0-rc.55",
|
|
36
|
+
"@applicaster/zapp-react-native-ui-components": "16.0.0-rc.55",
|
|
37
|
+
"@applicaster/zapp-react-native-utils": "16.0.0-rc.55",
|
|
38
38
|
"atob": "^2.1.2",
|
|
39
39
|
"axios": "^0.28.0",
|
|
40
40
|
"btoa": "^1.2.1",
|