@applicaster/zapp-react-native-ui-components 15.0.0-rc.14 → 15.0.0-rc.140
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/AnimatedInOut/index.tsx +69 -26
- package/Components/BaseFocusable/index.ios.ts +12 -2
- package/Components/Cell/Cell.tsx +14 -3
- package/Components/Cell/CellWithFocusable.tsx +9 -0
- package/Components/Cell/FocusableWrapper.tsx +3 -0
- package/Components/Cell/TvOSCellComponent.tsx +25 -6
- package/Components/Focusable/Focusable.tsx +4 -2
- package/Components/Focusable/FocusableTvOS.tsx +18 -1
- package/Components/Focusable/__tests__/__snapshots__/FocusableTvOS.test.tsx.snap +1 -0
- package/Components/FocusableGroup/FocusableTvOS.tsx +32 -1
- package/Components/GeneralContentScreen/GeneralContentScreen.tsx +39 -28
- package/Components/GeneralContentScreen/__tests__/GeneralContentScreen.test.tsx +104 -0
- package/Components/GeneralContentScreen/utils/__tests__/getScreenDataSource.test.ts +19 -0
- package/Components/GeneralContentScreen/utils/__tests__/useCurationAPI.test.js +1 -1
- package/Components/GeneralContentScreen/utils/getScreenDataSource.ts +9 -0
- package/Components/GeneralContentScreen/utils/useCurationAPI.ts +22 -6
- package/Components/HandlePlayable/HandlePlayable.tsx +33 -94
- package/Components/HandlePlayable/const.ts +3 -0
- package/Components/HandlePlayable/utils.ts +105 -0
- package/Components/HookRenderer/HookRenderer.tsx +40 -10
- package/Components/HookRenderer/__tests__/HookRenderer.test.tsx +60 -0
- package/Components/Layout/TV/LayoutBackground.tsx +5 -2
- package/Components/Layout/TV/NavBarContainer.tsx +1 -10
- package/Components/Layout/TV/ScreenContainer.tsx +2 -6
- package/Components/Layout/TV/__tests__/__snapshots__/NavBarContainer.test.tsx.snap +7 -12
- package/Components/Layout/TV/__tests__/__snapshots__/ScreenContainer.test.tsx.snap +7 -12
- package/Components/Layout/TV/index.tsx +3 -4
- package/Components/Layout/TV/index.web.tsx +3 -4
- package/Components/LinkHandler/LinkHandler.tsx +2 -2
- package/Components/MasterCell/DefaultComponents/ActionButtonsCore/__tests__/model.test.ts +80 -0
- package/Components/MasterCell/DefaultComponents/ActionButtonsCore/__tests__/placement.test.ts +187 -0
- package/Components/MasterCell/DefaultComponents/ActionButtonsCore/__tests__/selectors.test.ts +45 -0
- package/Components/MasterCell/DefaultComponents/ActionButtonsCore/__tests__/style.test.ts +49 -0
- package/Components/MasterCell/DefaultComponents/ActionButtonsCore/model.ts +47 -0
- package/Components/MasterCell/DefaultComponents/ActionButtonsCore/placement.ts +170 -0
- package/Components/MasterCell/DefaultComponents/ActionButtonsCore/selectors.ts +26 -0
- package/Components/MasterCell/DefaultComponents/ActionButtonsCore/style.ts +29 -0
- package/Components/MasterCell/DefaultComponents/ActionButtonsCore/types.ts +37 -0
- package/Components/MasterCell/DefaultComponents/BorderContainerView/__tests__/index.test.tsx +16 -1
- package/Components/MasterCell/DefaultComponents/BorderContainerView/index.tsx +30 -2
- package/Components/MasterCell/DefaultComponents/Button.tsx +0 -15
- package/Components/MasterCell/DefaultComponents/Image/Image.android.tsx +5 -1
- package/Components/MasterCell/DefaultComponents/Image/Image.ios.tsx +11 -3
- package/Components/MasterCell/DefaultComponents/Image/Image.web.tsx +9 -1
- package/Components/MasterCell/DefaultComponents/Image/hooks/useImage.ts +15 -14
- package/Components/MasterCell/DefaultComponents/LiveImage/__tests__/prepareEntry.test.ts +352 -0
- package/Components/MasterCell/DefaultComponents/LiveImage/executePreloadHooks.ts +136 -0
- package/Components/MasterCell/DefaultComponents/LiveImage/index.tsx +43 -22
- package/Components/MasterCell/DefaultComponents/PressableView.tsx +261 -0
- package/Components/MasterCell/DefaultComponents/SecondaryImage/Image.tsx +40 -39
- package/Components/MasterCell/DefaultComponents/SecondaryImage/__tests__/Image.test.tsx +95 -0
- package/Components/MasterCell/DefaultComponents/SecondaryImage/__tests__/__snapshots__/Image.test.tsx.snap +86 -0
- package/Components/MasterCell/DefaultComponents/SecondaryImage/__tests__/index.test.ts +141 -0
- package/Components/MasterCell/DefaultComponents/SecondaryImage/hooks/__tests__/useGetImageDimensions.test.ts +7 -6
- package/Components/MasterCell/DefaultComponents/SecondaryImage/index.ts +1 -1
- package/Components/MasterCell/DefaultComponents/Text/index.tsx +10 -14
- package/Components/MasterCell/DefaultComponents/index.ts +2 -0
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/Asset.ts +42 -0
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/Button.ts +127 -0
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/ButtonContainerView.ts +23 -0
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/Spacer.ts +16 -0
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/TextLabel.ts +67 -0
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/TextLabelsContainer.ts +32 -0
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/__tests__/PressableView.test.tsx +195 -0
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/__tests__/builders.test.ts +140 -0
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/__tests__/index.test.ts +222 -0
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/helpers.ts +105 -0
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/index.ts +104 -0
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/utils/__tests__/insertButtons.test.ts +118 -0
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/utils/index.ts +73 -0
- package/Components/MasterCell/DefaultComponents/tv/TvActionButtons/__tests__/index.test.ts +86 -0
- package/Components/MasterCell/DefaultComponents/tv/TvActionButtons/index.ts +35 -48
- package/Components/MasterCell/DefaultComponents/tv/TvActionButtons/utils/__tests__/getPluginIdentifier.test.ts +115 -29
- package/Components/MasterCell/DefaultComponents/tv/TvActionButtons/utils/index.ts +39 -144
- package/Components/MasterCell/elementMapper.tsx +1 -0
- package/Components/MasterCell/hoc/__tests__/withAsyncRender.test.tsx +219 -0
- package/Components/MasterCell/hoc/withAsyncRender.tsx +9 -7
- package/Components/MasterCell/index.tsx +2 -0
- package/Components/MasterCell/utils/__tests__/resolveColor.test.js +82 -3
- package/Components/MasterCell/utils/index.ts +61 -31
- package/Components/MeasurmentsPortal/MeasurementsPortal.tsx +102 -87
- package/Components/MeasurmentsPortal/__tests__/MeasurementsPortal.test.tsx +355 -0
- package/Components/OfflineHandler/NotificationView/NotificationView.lg.tsx +17 -9
- package/Components/OfflineHandler/NotificationView/NotificationView.samsung.tsx +16 -8
- package/Components/OfflineHandler/NotificationView/NotificationView.tsx +2 -2
- package/Components/OfflineHandler/NotificationView/__tests__/index.test.tsx +17 -18
- package/Components/OfflineHandler/NotificationView/utils.ts +34 -0
- package/Components/OfflineHandler/__tests__/index.test.tsx +27 -18
- package/Components/PlayerContainer/PlayerContainer.tsx +43 -64
- package/Components/PlayerImageBackground/index.tsx +3 -22
- package/Components/PreloaderWrapper/__tests__/index.test.tsx +26 -0
- package/Components/PreloaderWrapper/index.tsx +15 -0
- package/Components/River/ComponentsMap/ComponentsMap.tsx +18 -16
- package/Components/River/ComponentsMap/hooks/__tests__/useLoadingState.test.ts +1 -1
- package/Components/River/RefreshControl.tsx +19 -82
- package/Components/River/River.tsx +9 -82
- package/Components/River/RiverItem.tsx +26 -20
- package/Components/River/TV/River.tsx +31 -14
- package/Components/River/TV/index.tsx +8 -4
- package/Components/River/TV/utils/__tests__/toStringOrEmpty.test.ts +30 -0
- package/Components/River/TV/utils/index.ts +4 -0
- package/Components/River/TV/withFocusableGroupForContent.tsx +71 -0
- package/Components/River/__tests__/__snapshots__/componentsMap.test.js.snap +2 -0
- package/Components/River/__tests__/componentsMap.test.js +38 -0
- package/Components/River/hooks/__tests__/usePullToRefresh.test.ts +132 -0
- package/Components/River/hooks/index.ts +1 -0
- package/Components/River/hooks/usePullToRefresh.ts +51 -0
- package/Components/Screen/TV/index.web.tsx +4 -2
- package/Components/Screen/__tests__/Screen.test.tsx +66 -42
- package/Components/Screen/__tests__/__snapshots__/Screen.test.tsx.snap +68 -44
- package/Components/Screen/hooks.ts +75 -6
- package/Components/Screen/index.tsx +9 -4
- package/Components/Screen/navigationHandler.ts +49 -24
- package/Components/Screen/orientationHandler.ts +10 -13
- package/Components/ScreenFeedLoader/ScreenFeedLoader.tsx +46 -0
- package/Components/ScreenFeedLoader/__tests__/ScreenFeedLoader.test.tsx +94 -0
- package/Components/ScreenFeedLoader/index.ts +1 -0
- package/Components/ScreenResolver/__tests__/screenResolver.test.js +24 -0
- package/Components/ScreenResolver/hooks/index.ts +3 -0
- package/Components/ScreenResolver/hooks/useGetComponent.ts +15 -0
- package/Components/ScreenResolver/hooks/useScreenComponentResolver.tsx +90 -0
- package/Components/ScreenResolver/index.tsx +15 -111
- package/Components/ScreenResolver/utils/__tests__/getScreenTypeProps.test.ts +45 -0
- package/Components/ScreenResolver/utils/getScreenTypeProps.ts +43 -0
- package/Components/ScreenResolver/utils/index.ts +1 -0
- package/Components/ScreenResolver/withDefaultScreenContext.tsx +16 -0
- package/Components/ScreenResolverFeedProvider/ScreenResolverFeedProvider.tsx +25 -0
- package/Components/ScreenResolverFeedProvider/__tests__/ScreenResolverFeedProvider.test.tsx +44 -0
- package/Components/ScreenResolverFeedProvider/index.ts +1 -0
- package/Components/ScreenRevealManager/ScreenRevealManager.ts +40 -8
- package/Components/ScreenRevealManager/__tests__/ScreenRevealManager.test.ts +86 -69
- package/Components/ScreenRevealManager/withScreenRevealManager.tsx +44 -26
- package/Components/Tabs/TV/Tabs.tsx +20 -3
- package/Components/Tabs/TabContent.tsx +7 -4
- package/Components/TopCutoffOverlay/hooks/__tests__/useMarginTop.test.ts +130 -0
- package/Components/TopCutoffOverlay/hooks/index.ts +1 -0
- package/Components/TopCutoffOverlay/hooks/useMarginTop.ts +59 -0
- package/Components/TopCutoffOverlay/index.tsx +55 -0
- package/Components/Transitioner/Scene.tsx +10 -3
- package/Components/Transitioner/index.js +3 -3
- package/Components/VideoLive/LiveImageManager.ts +199 -54
- package/Components/VideoLive/PlayerLiveImageComponent.tsx +31 -33
- package/Components/VideoLive/__tests__/PlayerLiveImageComponent.test.tsx +2 -17
- package/Components/VideoLive/__tests__/__snapshots__/PlayerLiveImageComponent.test.tsx.snap +1 -0
- package/Components/VideoModal/ModalAnimation/ModalAnimationContext.tsx +118 -171
- package/Components/VideoModal/ModalAnimation/index.ts +2 -13
- package/Components/VideoModal/ModalAnimation/utils.ts +1 -327
- package/Components/VideoModal/PlayerWrapper.tsx +14 -88
- package/Components/VideoModal/VideoModal.tsx +1 -5
- package/Components/VideoModal/__tests__/PlayerWrapper.test.tsx +1 -0
- package/Components/VideoModal/hooks/__tests__/useDelayedPlayerDetails.test.ts +15 -7
- package/Components/VideoModal/hooks/useModalSize.ts +10 -5
- package/Components/VideoModal/playerWrapperStyle.ts +70 -0
- package/Components/VideoModal/playerWrapperUtils.ts +91 -0
- package/Components/VideoModal/utils.ts +19 -9
- package/Components/Viewport/ViewportAware/__tests__/viewportAware.test.js +0 -2
- package/Components/Viewport/ViewportAware/index.tsx +16 -7
- package/Components/Viewport/ViewportEvents/__tests__/viewportEvents.test.js +1 -1
- package/Components/ZappUIComponent/index.tsx +12 -6
- package/Components/default-cell-renderer/viewTrees/mobile/index.ts +0 -3
- package/Components/index.js +1 -1
- package/Contexts/ScreenContext/__tests__/index.test.tsx +57 -0
- package/Contexts/ScreenContext/index.tsx +71 -19
- package/Contexts/ScreenTrackedViewPositionsContext/__tests__/index.test.tsx +1 -1
- package/Contexts/ZappHookModalContext/index.tsx +37 -61
- package/Contexts/ZappPipesContext/ZappPipesContextFactory.tsx +18 -7
- package/Contexts/index.ts +0 -2
- package/Decorators/Analytics/index.tsx +6 -5
- package/Decorators/ConfigurationWrapper/__tests__/__snapshots__/withConfigurationProvider.test.tsx.snap +1 -0
- package/Decorators/ConfigurationWrapper/const.ts +1 -0
- package/Decorators/ZappPipesDataConnector/ResolverSelector.tsx +25 -7
- package/Decorators/ZappPipesDataConnector/__tests__/ResolverSelector.test.tsx +212 -5
- package/Decorators/ZappPipesDataConnector/__tests__/UrlFeedResolver.test.tsx +39 -21
- package/Decorators/ZappPipesDataConnector/__tests__/zappPipesDataConnector.test.js +1 -1
- package/Decorators/ZappPipesDataConnector/index.tsx +2 -2
- package/Decorators/ZappPipesDataConnector/resolvers/StaticFeedResolver.tsx +1 -1
- package/Decorators/ZappPipesDataConnector/resolvers/UrlFeedResolver.tsx +18 -7
- package/Helpers/DataSourceHelper/__tests__/itemLimitForData.test.ts +80 -0
- package/Helpers/DataSourceHelper/index.ts +19 -0
- package/events/index.ts +3 -0
- package/events/scrollEndReached.ts +15 -0
- package/index.d.ts +7 -0
- package/package.json +6 -5
- package/Components/MasterCell/DefaultComponents/Text/utils/__tests__/withAdjustedLineHeight.test.ts +0 -46
- package/Components/MasterCell/DefaultComponents/Text/utils/index.ts +0 -21
- package/Components/PlayerContainer/ErrorDisplay/ErrorDisplay.tsx +0 -57
- package/Components/PlayerContainer/ErrorDisplay/index.ts +0 -9
- package/Components/River/TV/withTVEventHandler.tsx +0 -27
- package/Components/VideoModal/ModalAnimation/AnimatedPlayerModalWrapper.tsx +0 -60
- package/Components/VideoModal/ModalAnimation/AnimatedScrollModal.tsx +0 -417
- package/Components/VideoModal/ModalAnimation/AnimatedScrollModal.web.tsx +0 -294
- package/Components/VideoModal/ModalAnimation/AnimatedVideoPlayerComponent.tsx +0 -176
- package/Components/VideoModal/ModalAnimation/AnimatedVideoPlayerComponent.web.tsx +0 -93
- package/Components/VideoModal/ModalAnimation/AnimationComponent.tsx +0 -500
- package/Components/VideoModal/ModalAnimation/__tests__/getMoveUpValue.test.ts +0 -108
- package/Helpers/DataSourceHelper/index.js +0 -19
- /package/Components/HookRenderer/{index.tsx → index.ts} +0 -0
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { render, fireEvent } from "@testing-library/react-native";
|
|
3
|
+
import { useActions } from "@applicaster/zapp-react-native-utils/reactHooks/actions";
|
|
4
|
+
|
|
5
|
+
import { elementMapper } from "../../../../elementMapper";
|
|
6
|
+
import { defaultComponents } from "../../../index";
|
|
7
|
+
|
|
8
|
+
jest.mock("@applicaster/zapp-react-native-utils/reactHooks/actions", () => ({
|
|
9
|
+
useActions: jest.fn(),
|
|
10
|
+
}));
|
|
11
|
+
|
|
12
|
+
jest.mock("@applicaster/zapp-react-native-utils/theme", () => ({
|
|
13
|
+
useTheme: () => ({}),
|
|
14
|
+
}));
|
|
15
|
+
|
|
16
|
+
jest.mock("@applicaster/zapp-react-native-utils/localizationUtils", () => ({
|
|
17
|
+
useIsRTL: jest.fn(() => false),
|
|
18
|
+
}));
|
|
19
|
+
|
|
20
|
+
jest.mock(
|
|
21
|
+
"@applicaster/zapp-react-native-utils/reactHooks/navigation/useNavigation",
|
|
22
|
+
() => ({
|
|
23
|
+
useNavigation: jest.fn(() => ({
|
|
24
|
+
currentRoute: "home",
|
|
25
|
+
videoModalState: {
|
|
26
|
+
visible: false,
|
|
27
|
+
},
|
|
28
|
+
})),
|
|
29
|
+
})
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
jest.mock(
|
|
33
|
+
"@applicaster/zapp-react-native-utils/reactHooks/navigation/usePathname",
|
|
34
|
+
() => ({
|
|
35
|
+
usePathname: jest.fn(() => "home"),
|
|
36
|
+
})
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
jest.mock(
|
|
40
|
+
"@applicaster/zapp-react-native-utils/appUtils/accessibilityManager/hooks",
|
|
41
|
+
() => ({
|
|
42
|
+
useAccessibilityManager: jest.fn(() => ({
|
|
43
|
+
addHeading: jest.fn(),
|
|
44
|
+
})),
|
|
45
|
+
})
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
const mockUseActions = useActions as jest.Mock;
|
|
49
|
+
|
|
50
|
+
const item = {
|
|
51
|
+
id: "entry-1",
|
|
52
|
+
} as ZappEntry;
|
|
53
|
+
|
|
54
|
+
const buildActionContext = (entryState = {}) => ({
|
|
55
|
+
initialEntryState: jest.fn(() => ({
|
|
56
|
+
asset: {
|
|
57
|
+
inactive: "https://example.com/image-inactive.png",
|
|
58
|
+
active: "https://example.com/image-active.png",
|
|
59
|
+
},
|
|
60
|
+
mobileButtonAssets: [
|
|
61
|
+
"https://example.com/image-inactive.png",
|
|
62
|
+
"https://example.com/image-active.png",
|
|
63
|
+
],
|
|
64
|
+
label: {
|
|
65
|
+
label_1: "Play",
|
|
66
|
+
},
|
|
67
|
+
...entryState,
|
|
68
|
+
})),
|
|
69
|
+
invokeAction: jest.fn(),
|
|
70
|
+
addListener: jest.fn(() => jest.fn()),
|
|
71
|
+
isActionAvailable: jest.fn(() => true),
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
const baseNode = {
|
|
75
|
+
type: "PressableView",
|
|
76
|
+
style: {
|
|
77
|
+
backgroundColor: "rgba(1,1,1,1)",
|
|
78
|
+
borderColor: "rgba(2,2,2,1)",
|
|
79
|
+
borderWidth: 1,
|
|
80
|
+
},
|
|
81
|
+
props: {
|
|
82
|
+
item,
|
|
83
|
+
action: {
|
|
84
|
+
identifier: "navigation_action",
|
|
85
|
+
},
|
|
86
|
+
focusedStyles: {
|
|
87
|
+
backgroundColor: "rgba(3,3,3,1)",
|
|
88
|
+
borderColor: "rgba(4,4,4,1)",
|
|
89
|
+
},
|
|
90
|
+
testID: "mobile-action-button",
|
|
91
|
+
},
|
|
92
|
+
elements: [
|
|
93
|
+
{
|
|
94
|
+
type: "Image",
|
|
95
|
+
style: {
|
|
96
|
+
width: 24,
|
|
97
|
+
height: 24,
|
|
98
|
+
},
|
|
99
|
+
props: {
|
|
100
|
+
testID: "mobile-action-button-asset",
|
|
101
|
+
source: {
|
|
102
|
+
context: "navigation_action",
|
|
103
|
+
},
|
|
104
|
+
mobileActionRole: "asset",
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
type: "View",
|
|
109
|
+
style: {
|
|
110
|
+
flexDirection: "column",
|
|
111
|
+
},
|
|
112
|
+
props: {
|
|
113
|
+
mobileActionRole: "label_container",
|
|
114
|
+
},
|
|
115
|
+
elements: [
|
|
116
|
+
{
|
|
117
|
+
type: "Text",
|
|
118
|
+
style: {
|
|
119
|
+
fontSize: 15,
|
|
120
|
+
},
|
|
121
|
+
props: {
|
|
122
|
+
testID: "mobile-action-button-label",
|
|
123
|
+
label: {
|
|
124
|
+
context: "navigation_action",
|
|
125
|
+
name: "label_1",
|
|
126
|
+
},
|
|
127
|
+
focusedStyles: {
|
|
128
|
+
color: "rgba(20,20,20,1)",
|
|
129
|
+
},
|
|
130
|
+
normalStyles: {
|
|
131
|
+
color: "rgba(10,10,10,1)",
|
|
132
|
+
},
|
|
133
|
+
mobileActionRole: "label",
|
|
134
|
+
transformText: "default",
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
],
|
|
138
|
+
},
|
|
139
|
+
],
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
describe("PressableView", () => {
|
|
143
|
+
beforeEach(() => {
|
|
144
|
+
jest.clearAllMocks();
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
const renderNode = (node = baseNode) =>
|
|
148
|
+
render(
|
|
149
|
+
<React.Fragment>
|
|
150
|
+
{elementMapper(defaultComponents)(node as never)}
|
|
151
|
+
</React.Fragment>
|
|
152
|
+
);
|
|
153
|
+
|
|
154
|
+
it("renders nested image and text children through elementMapper", () => {
|
|
155
|
+
mockUseActions.mockReturnValue(buildActionContext());
|
|
156
|
+
|
|
157
|
+
const { getByText, getByTestId } = renderNode();
|
|
158
|
+
|
|
159
|
+
expect(getByTestId("mobile-action-button")).toBeTruthy();
|
|
160
|
+
expect(getByTestId("mobile-action-button-asset")).toBeTruthy();
|
|
161
|
+
expect(getByText("Play")).toBeTruthy();
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
it("applies focused styles when action entry state is active", () => {
|
|
165
|
+
mockUseActions.mockReturnValue(buildActionContext({ active: true }));
|
|
166
|
+
|
|
167
|
+
const { getByTestId, getByText } = renderNode();
|
|
168
|
+
|
|
169
|
+
expect(
|
|
170
|
+
getByTestId("mobile-action-button").props.style.backgroundColor
|
|
171
|
+
).toBe("rgba(3,3,3,1)");
|
|
172
|
+
|
|
173
|
+
expect(getByText("Play").props.style).toEqual(
|
|
174
|
+
expect.arrayContaining([
|
|
175
|
+
expect.objectContaining({ color: "rgba(20,20,20,1)" }),
|
|
176
|
+
])
|
|
177
|
+
);
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
it("invokes action on press", () => {
|
|
181
|
+
const actionContext = buildActionContext();
|
|
182
|
+
mockUseActions.mockReturnValue(actionContext);
|
|
183
|
+
|
|
184
|
+
const { getByTestId } = renderNode();
|
|
185
|
+
|
|
186
|
+
fireEvent.press(getByTestId("mobile-action-button"));
|
|
187
|
+
|
|
188
|
+
expect(actionContext.invokeAction).toHaveBeenCalledWith(
|
|
189
|
+
item,
|
|
190
|
+
expect.objectContaining({
|
|
191
|
+
updateState: expect.any(Function),
|
|
192
|
+
})
|
|
193
|
+
);
|
|
194
|
+
});
|
|
195
|
+
});
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { Asset } from "../Asset";
|
|
2
|
+
import { Button } from "../Button";
|
|
3
|
+
import { ButtonContainerView } from "../ButtonContainerView";
|
|
4
|
+
import { Spacer } from "../Spacer";
|
|
5
|
+
import { TextLabel } from "../TextLabel";
|
|
6
|
+
import { TextLabelsContainer } from "../TextLabelsContainer";
|
|
7
|
+
|
|
8
|
+
describe("mobile action button builders", () => {
|
|
9
|
+
const configuration = {
|
|
10
|
+
mobile_buttons_container_align: "left",
|
|
11
|
+
mobile_buttons_container_margin_top: 0,
|
|
12
|
+
mobile_buttons_container_margin_right: 12,
|
|
13
|
+
mobile_buttons_container_margin_bottom: 0,
|
|
14
|
+
mobile_buttons_container_margin_left: 6,
|
|
15
|
+
mobile_buttons_container_stacking: "horizontal",
|
|
16
|
+
mobile_button_1_button_enabled: true,
|
|
17
|
+
mobile_button_1_assign_action: "navigation_action",
|
|
18
|
+
mobile_button_1_display_mode: "dynamic",
|
|
19
|
+
mobile_button_1_contents_alignment: "center",
|
|
20
|
+
mobile_button_1_background_color: "rgba(1,1,1,1)",
|
|
21
|
+
mobile_button_1_border_color: "rgba(0,0,0,0)",
|
|
22
|
+
mobile_button_1_border_size: 0,
|
|
23
|
+
mobile_button_1_corner_radius: 8,
|
|
24
|
+
mobile_button_1_padding_top: 10,
|
|
25
|
+
mobile_button_1_padding_right: 10,
|
|
26
|
+
mobile_button_1_padding_bottom: 10,
|
|
27
|
+
mobile_button_1_padding_left: 10,
|
|
28
|
+
mobile_button_1_asset_enabled: true,
|
|
29
|
+
mobile_button_1_action_asset_flavour: "flavour_1",
|
|
30
|
+
mobile_button_1_asset_alignment: "left",
|
|
31
|
+
mobile_button_1_asset_width: 24,
|
|
32
|
+
mobile_button_1_asset_height: 24,
|
|
33
|
+
mobile_button_1_asset_margin_top: 1,
|
|
34
|
+
mobile_button_1_asset_margin_right: 2,
|
|
35
|
+
mobile_button_1_asset_margin_bottom: 3,
|
|
36
|
+
mobile_button_1_asset_margin_left: 4,
|
|
37
|
+
mobile_button_1_label_enabled: true,
|
|
38
|
+
mobile_button_1_font_color: "rgba(255,255,255,1)",
|
|
39
|
+
mobile_button_1_focused_font_color: "rgba(255,0,0,1)",
|
|
40
|
+
mobile_button_1_ios_font_family: "Ubuntu-Bold",
|
|
41
|
+
mobile_button_1_android_font_family: "Ubuntu-Bold",
|
|
42
|
+
mobile_button_1_font_size: 15,
|
|
43
|
+
mobile_button_1_line_height: 24,
|
|
44
|
+
mobile_button_1_ios_letter_spacing: -0.2,
|
|
45
|
+
mobile_button_1_android_letter_spacing: -0.2,
|
|
46
|
+
mobile_button_1_text_transform: "default",
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const value = (key) => configuration[key];
|
|
50
|
+
|
|
51
|
+
it("builds the container node with content style in additionalProps", () => {
|
|
52
|
+
const result = ButtonContainerView({
|
|
53
|
+
style: { position: "absolute" },
|
|
54
|
+
contentStyle: {
|
|
55
|
+
flexDirection: "row",
|
|
56
|
+
},
|
|
57
|
+
elements: [{ type: "PressableView" }],
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
expect(result).toEqual({
|
|
61
|
+
type: "View",
|
|
62
|
+
style: { position: "absolute" },
|
|
63
|
+
elements: [
|
|
64
|
+
{
|
|
65
|
+
type: "View",
|
|
66
|
+
style: {
|
|
67
|
+
flexDirection: "row",
|
|
68
|
+
},
|
|
69
|
+
elements: [{ type: "PressableView" }],
|
|
70
|
+
},
|
|
71
|
+
],
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it("builds the button node with asset and text label children", () => {
|
|
76
|
+
const result = Button({
|
|
77
|
+
index: 0,
|
|
78
|
+
value,
|
|
79
|
+
stylePrefix: "mobile_button_1",
|
|
80
|
+
specificPrefix: "mobile_button_1",
|
|
81
|
+
spacingStyle: { marginRight: 8 },
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
expect(result.type).toBe("PressableView");
|
|
85
|
+
expect(result.additionalProps.action.identifier).toBe("navigation_action");
|
|
86
|
+
|
|
87
|
+
expect(result.elements).toEqual(
|
|
88
|
+
expect.arrayContaining([
|
|
89
|
+
expect.objectContaining({ type: "Image" }),
|
|
90
|
+
expect.objectContaining({ type: "View" }),
|
|
91
|
+
])
|
|
92
|
+
);
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
it("builds the asset, label container, label and spacer nodes", () => {
|
|
96
|
+
expect(
|
|
97
|
+
Asset({
|
|
98
|
+
prefix: "mobile_button_1",
|
|
99
|
+
value,
|
|
100
|
+
actionIdentifier: "navigation_action",
|
|
101
|
+
})
|
|
102
|
+
).toEqual(
|
|
103
|
+
expect.objectContaining({
|
|
104
|
+
type: "Image",
|
|
105
|
+
})
|
|
106
|
+
);
|
|
107
|
+
|
|
108
|
+
expect(
|
|
109
|
+
TextLabelsContainer({
|
|
110
|
+
prefix: "mobile_button_1",
|
|
111
|
+
value,
|
|
112
|
+
actionIdentifier: "navigation_action",
|
|
113
|
+
})
|
|
114
|
+
).toEqual(
|
|
115
|
+
expect.objectContaining({
|
|
116
|
+
type: "View",
|
|
117
|
+
elements: [expect.objectContaining({ type: "Text" })],
|
|
118
|
+
})
|
|
119
|
+
);
|
|
120
|
+
|
|
121
|
+
expect(
|
|
122
|
+
TextLabel({
|
|
123
|
+
prefix: "mobile_button_1",
|
|
124
|
+
value,
|
|
125
|
+
actionIdentifier: "navigation_action",
|
|
126
|
+
})
|
|
127
|
+
).toEqual(
|
|
128
|
+
expect.objectContaining({
|
|
129
|
+
type: "Text",
|
|
130
|
+
})
|
|
131
|
+
);
|
|
132
|
+
|
|
133
|
+
expect(Spacer({ enabled: true })).toEqual({
|
|
134
|
+
type: "View",
|
|
135
|
+
style: {
|
|
136
|
+
flex: 1,
|
|
137
|
+
},
|
|
138
|
+
});
|
|
139
|
+
});
|
|
140
|
+
});
|
package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/__tests__/index.test.ts
ADDED
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import { MobileActionButtons } from "..";
|
|
2
|
+
|
|
3
|
+
describe("MobileActionButtons", () => {
|
|
4
|
+
const configuration = {
|
|
5
|
+
mobile_buttons_container_buttons_enabled: true,
|
|
6
|
+
mobile_buttons_container_position: "over_image",
|
|
7
|
+
mobile_buttons_container_align: "left",
|
|
8
|
+
mobile_buttons_container_margin_top: 0,
|
|
9
|
+
mobile_buttons_container_margin_right: 0,
|
|
10
|
+
mobile_buttons_container_margin_bottom: 0,
|
|
11
|
+
mobile_buttons_container_margin_left: 0,
|
|
12
|
+
mobile_buttons_container_stacking: "horizontal",
|
|
13
|
+
mobile_buttons_container_horizontal_gutter: 8,
|
|
14
|
+
mobile_buttons_container_vertical_gutter: 8,
|
|
15
|
+
mobile_buttons_container_independent_styles: true,
|
|
16
|
+
mobile_buttons_container_over_image_position: "top_right",
|
|
17
|
+
mobile_button_1_button_enabled: true,
|
|
18
|
+
mobile_button_1_assign_action: "navigation_action",
|
|
19
|
+
mobile_button_1_display_mode: "dynamic",
|
|
20
|
+
mobile_button_1_contents_alignment: "center",
|
|
21
|
+
mobile_button_1_background_color: "rgba(1,1,1,1)",
|
|
22
|
+
mobile_button_1_border_color: "rgba(0,0,0,0)",
|
|
23
|
+
mobile_button_1_border_size: 0,
|
|
24
|
+
mobile_button_1_corner_radius: 8,
|
|
25
|
+
mobile_button_1_padding_top: 10,
|
|
26
|
+
mobile_button_1_padding_right: 10,
|
|
27
|
+
mobile_button_1_padding_bottom: 10,
|
|
28
|
+
mobile_button_1_padding_left: 10,
|
|
29
|
+
mobile_button_1_asset_width: 24,
|
|
30
|
+
mobile_button_1_asset_height: 24,
|
|
31
|
+
mobile_button_1_asset_margin_top: 0,
|
|
32
|
+
mobile_button_1_asset_margin_right: 0,
|
|
33
|
+
mobile_button_1_asset_margin_bottom: 0,
|
|
34
|
+
mobile_button_1_asset_margin_left: 0,
|
|
35
|
+
mobile_button_1_asset_enabled: true,
|
|
36
|
+
mobile_button_1_label_enabled: true,
|
|
37
|
+
mobile_button_1_font_color: "rgba(255,255,255,1)",
|
|
38
|
+
mobile_button_1_focused_font_color: "rgba(255,0,0,1)",
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const value = (key) => configuration[key];
|
|
42
|
+
|
|
43
|
+
it("renders over-image buttons only for over_image placement", () => {
|
|
44
|
+
const result = MobileActionButtons({
|
|
45
|
+
value,
|
|
46
|
+
configuration,
|
|
47
|
+
placement: "over_image",
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
expect(result).toBeTruthy();
|
|
51
|
+
expect(result.type).toBe("View");
|
|
52
|
+
expect(result.style.position).toBe("absolute");
|
|
53
|
+
expect(result.style.top).toBe(0);
|
|
54
|
+
expect(result.style.right).toBe(0);
|
|
55
|
+
expect(result.elements).toHaveLength(1);
|
|
56
|
+
expect(result.elements[0].type).toBe("View");
|
|
57
|
+
expect(result.elements[0].style.flexDirection).toBe("row");
|
|
58
|
+
expect(result.elements[0].elements[0].type).toBe("PressableView");
|
|
59
|
+
|
|
60
|
+
expect(result.elements[0].elements[0].elements).toEqual(
|
|
61
|
+
expect.arrayContaining([
|
|
62
|
+
expect.objectContaining({ type: "Image" }),
|
|
63
|
+
expect.objectContaining({ type: "View" }),
|
|
64
|
+
])
|
|
65
|
+
);
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it("does not render label placement when position is over_image", () => {
|
|
69
|
+
const result = MobileActionButtons({
|
|
70
|
+
value,
|
|
71
|
+
configuration,
|
|
72
|
+
placement: "labels",
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
expect(result).toBeNull();
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it("renders button 1 when only button 1 is enabled", () => {
|
|
79
|
+
const configurationWithSingleButton = {
|
|
80
|
+
...configuration,
|
|
81
|
+
mobile_button_1_button_enabled: true,
|
|
82
|
+
mobile_button_2_button_enabled: false,
|
|
83
|
+
mobile_button_3_button_enabled: false,
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
const singleButtonValue = (key) => configurationWithSingleButton[key];
|
|
87
|
+
|
|
88
|
+
const result = MobileActionButtons({
|
|
89
|
+
value: singleButtonValue,
|
|
90
|
+
configuration: configurationWithSingleButton,
|
|
91
|
+
placement: "over_image",
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
expect(result?.elements?.[0]?.elements).toHaveLength(1);
|
|
95
|
+
expect(result?.elements?.[0]?.elements?.[0]?.type).toBe("PressableView");
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
it("renders button 2 when only button 2 is enabled", () => {
|
|
99
|
+
const configurationWithSingleButton = {
|
|
100
|
+
...configuration,
|
|
101
|
+
mobile_button_1_button_enabled: false,
|
|
102
|
+
mobile_button_2_button_enabled: true,
|
|
103
|
+
mobile_button_3_button_enabled: false,
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
const singleButtonValue = (key) => configurationWithSingleButton[key];
|
|
107
|
+
|
|
108
|
+
const result = MobileActionButtons({
|
|
109
|
+
value: singleButtonValue,
|
|
110
|
+
configuration: configurationWithSingleButton,
|
|
111
|
+
placement: "over_image",
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
expect(result?.elements?.[0]?.elements).toHaveLength(1);
|
|
115
|
+
expect(result?.elements?.[0]?.elements?.[0]?.type).toBe("PressableView");
|
|
116
|
+
|
|
117
|
+
expect(
|
|
118
|
+
result?.elements?.[0]?.elements?.[0]?.additionalProps?.action?.identifier
|
|
119
|
+
).toBe(configurationWithSingleButton.mobile_button_2_assign_action);
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
it("renders button 3 when only button 3 is enabled", () => {
|
|
123
|
+
const configurationWithSingleButton = {
|
|
124
|
+
...configuration,
|
|
125
|
+
mobile_button_1_button_enabled: false,
|
|
126
|
+
mobile_button_2_button_enabled: false,
|
|
127
|
+
mobile_button_3_button_enabled: true,
|
|
128
|
+
mobile_button_3_assign_action: "local_storage_favourites_action",
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
const singleButtonValue = (key) => configurationWithSingleButton[key];
|
|
132
|
+
|
|
133
|
+
const result = MobileActionButtons({
|
|
134
|
+
value: singleButtonValue,
|
|
135
|
+
configuration: configurationWithSingleButton,
|
|
136
|
+
placement: "over_image",
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
expect(result?.elements?.[0]?.elements).toHaveLength(1);
|
|
140
|
+
expect(result?.elements?.[0]?.elements?.[0]?.type).toBe("PressableView");
|
|
141
|
+
|
|
142
|
+
expect(
|
|
143
|
+
result?.elements?.[0]?.elements?.[0]?.additionalProps?.action?.identifier
|
|
144
|
+
).toBe(configurationWithSingleButton.mobile_button_3_assign_action);
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
it("renders sparse slots contiguously while preserving slot-specific actions", () => {
|
|
148
|
+
const configurationWithSparseButtons = {
|
|
149
|
+
...configuration,
|
|
150
|
+
mobile_button_1_button_enabled: true,
|
|
151
|
+
mobile_button_1_assign_action: "action_1",
|
|
152
|
+
mobile_button_2_button_enabled: false,
|
|
153
|
+
mobile_button_3_button_enabled: true,
|
|
154
|
+
mobile_button_3_assign_action: "action_3",
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
const sparseValue = (key) => configurationWithSparseButtons[key];
|
|
158
|
+
|
|
159
|
+
const result = MobileActionButtons({
|
|
160
|
+
value: sparseValue,
|
|
161
|
+
configuration: configurationWithSparseButtons,
|
|
162
|
+
placement: "over_image",
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
expect(result?.elements?.[0]?.elements).toHaveLength(2);
|
|
166
|
+
|
|
167
|
+
expect(
|
|
168
|
+
result?.elements?.[0]?.elements?.[0]?.additionalProps?.action?.identifier
|
|
169
|
+
).toBe("action_1");
|
|
170
|
+
|
|
171
|
+
expect(
|
|
172
|
+
result?.elements?.[0]?.elements?.[1]?.additionalProps?.action?.identifier
|
|
173
|
+
).toBe("action_3");
|
|
174
|
+
|
|
175
|
+
expect(result?.elements?.[0]?.elements?.[0]?.additionalProps?.testID).toBe(
|
|
176
|
+
"mobile_action_button_1"
|
|
177
|
+
);
|
|
178
|
+
|
|
179
|
+
expect(result?.elements?.[0]?.elements?.[1]?.additionalProps?.testID).toBe(
|
|
180
|
+
"mobile_action_button_2"
|
|
181
|
+
);
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
it("maps shared semantic layout data into content styles", () => {
|
|
185
|
+
const configurationWithLayout = {
|
|
186
|
+
...configuration,
|
|
187
|
+
mobile_buttons_container_align: "middle",
|
|
188
|
+
mobile_buttons_container_margin_top: 5,
|
|
189
|
+
mobile_buttons_container_margin_right: 6,
|
|
190
|
+
mobile_buttons_container_margin_bottom: 7,
|
|
191
|
+
mobile_buttons_container_margin_left: 8,
|
|
192
|
+
mobile_buttons_container_stacking: "vertical",
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
const layoutValue = (key) => configurationWithLayout[key];
|
|
196
|
+
|
|
197
|
+
const result = MobileActionButtons({
|
|
198
|
+
value: layoutValue,
|
|
199
|
+
configuration: configurationWithLayout,
|
|
200
|
+
placement: "labels",
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
expect(result).toBeNull();
|
|
204
|
+
|
|
205
|
+
const overImageResult = MobileActionButtons({
|
|
206
|
+
value: layoutValue,
|
|
207
|
+
configuration: configurationWithLayout,
|
|
208
|
+
placement: "over_image",
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
expect(overImageResult?.elements?.[0]?.style).toMatchObject({
|
|
212
|
+
flexDirection: "column",
|
|
213
|
+
alignItems: "center",
|
|
214
|
+
marginTop: 5,
|
|
215
|
+
marginRight: 6,
|
|
216
|
+
marginBottom: 7,
|
|
217
|
+
marginLeft: 8,
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
expect(overImageResult?.elements?.[0]?.style.alignSelf).toBeUndefined();
|
|
221
|
+
});
|
|
222
|
+
});
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { Platform } from "react-native";
|
|
2
|
+
|
|
3
|
+
export function isStringAsset(asset) {
|
|
4
|
+
return typeof asset === "string" || Array.isArray(asset);
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export function getAssetValue(asset, flavour, fallbackAsset = null) {
|
|
8
|
+
if (!asset) {
|
|
9
|
+
return fallbackAsset;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
if (typeof asset === "string") {
|
|
13
|
+
return asset;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
if (Array.isArray(asset)) {
|
|
17
|
+
const flavourIndex = Number(String(flavour || "").replace("flavour_", ""));
|
|
18
|
+
|
|
19
|
+
if (!Number.isNaN(flavourIndex) && flavourIndex > 0) {
|
|
20
|
+
return asset[flavourIndex - 1];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return asset[0];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return asset.src || fallbackAsset;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function getContentDirection(alignment = "left") {
|
|
30
|
+
switch (alignment) {
|
|
31
|
+
case "right":
|
|
32
|
+
return "row-reverse";
|
|
33
|
+
case "above":
|
|
34
|
+
return "column";
|
|
35
|
+
case "below":
|
|
36
|
+
return "column-reverse";
|
|
37
|
+
case "left":
|
|
38
|
+
default:
|
|
39
|
+
return "row";
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function getContentsAlignment(alignment = "center") {
|
|
44
|
+
switch (alignment) {
|
|
45
|
+
case "left":
|
|
46
|
+
return "flex-start";
|
|
47
|
+
case "right":
|
|
48
|
+
return "flex-end";
|
|
49
|
+
case "center":
|
|
50
|
+
default:
|
|
51
|
+
return "center";
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function resolveLabelText(label) {
|
|
56
|
+
if (typeof label === "string") {
|
|
57
|
+
return label;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return label?.label_1 || "";
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function resolveIsActive(actionState, fallbackSelected = false) {
|
|
64
|
+
if (actionState == null) {
|
|
65
|
+
return fallbackSelected;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return Boolean(
|
|
69
|
+
actionState?.active ??
|
|
70
|
+
actionState?.isActive ??
|
|
71
|
+
actionState?.selected ??
|
|
72
|
+
actionState?.isSelected ??
|
|
73
|
+
fallbackSelected
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export function buildLegacySelection(item, actionContext) {
|
|
78
|
+
const defaultIsSelected = (actionContext?.state || []).includes(item);
|
|
79
|
+
|
|
80
|
+
return actionContext?.masterCell?.isSelected
|
|
81
|
+
? actionContext?.masterCell?.isSelected(item)
|
|
82
|
+
: defaultIsSelected;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export function buildLabelStyle(label) {
|
|
86
|
+
if (!label?.enabled) {
|
|
87
|
+
return {};
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const platformFontFamily =
|
|
91
|
+
Platform.OS === "ios"
|
|
92
|
+
? label?.iosFontFamily || label?.normalStyle?.fontFamily
|
|
93
|
+
: label?.androidFontFamily || label?.normalStyle?.fontFamily;
|
|
94
|
+
|
|
95
|
+
const platformLetterSpacing =
|
|
96
|
+
Platform.OS === "ios"
|
|
97
|
+
? label?.iosLetterSpacing
|
|
98
|
+
: label?.androidLetterSpacing;
|
|
99
|
+
|
|
100
|
+
return {
|
|
101
|
+
...label?.normalStyle,
|
|
102
|
+
fontFamily: platformFontFamily,
|
|
103
|
+
letterSpacing: platformLetterSpacing,
|
|
104
|
+
};
|
|
105
|
+
}
|