@applicaster/zapp-react-native-ui-components 13.0.0-alpha.6400875052 → 13.0.0-alpha.6444233049
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/AudioPlayer/AudioPlayer.tsx +0 -11
- package/Components/AudioPlayer/helpers.tsx +0 -2
- package/Components/Cell/CellWithFocusable.tsx +4 -2
- package/Components/Cell/CellWrapper.tsx +18 -0
- package/Components/CellRendererResolver/index.ts +2 -1
- package/Components/GeneralContentScreen/GeneralContentScreen.tsx +3 -0
- package/Components/GeneralContentScreen/utils/useCurationAPI.ts +4 -2
- package/Components/GeneralContentScreen/utils/useEventAlerts.ts +30 -0
- package/Components/Layout/TV/LayoutBackground.tsx +28 -0
- package/Components/Layout/TV/ScreenContainer.tsx +0 -1
- package/Components/Layout/TV/__tests__/__snapshots__/index.test.tsx.snap +15 -10
- package/Components/Layout/TV/__tests__/index.test.tsx +8 -2
- package/Components/Layout/TV/index.tsx +6 -20
- package/Components/Layout/TV/index.web.tsx +4 -1
- package/Components/MasterCell/DefaultComponents/tv/TvActionButtons/const.ts +3 -0
- package/Components/MasterCell/DefaultComponents/tv/TvActionButtons/index.ts +6 -6
- package/Components/ModalComponent/BottomSheetModalContent.tsx +34 -45
- package/Components/ModalComponent/Button/Item.tsx +5 -5
- package/Components/ModalComponent/Button/index.tsx +25 -29
- package/Components/ModalComponent/Header/index.tsx +9 -8
- package/Components/ModalComponent/utils.ts +3 -3
- package/Components/PlayerContainer/PlayerContainer.tsx +18 -5
- package/Components/River/ComponentsMap/ComponentsMap.tsx +11 -3
- package/Components/River/RiverItem.tsx +8 -3
- package/Components/River/__tests__/__snapshots__/componentsMap.test.js.snap +7 -1
- package/Components/Screen/TV/__tests__/index.web.test.tsx +26 -0
- package/Components/Screen/__tests__/Screen.test.tsx +22 -14
- package/Components/Screen/__tests__/__snapshots__/Screen.test.tsx.snap +2 -2
- package/Components/TopMarginApplicator/TopMarginApplicator.tsx +2 -3
- package/Components/VideoModal/ModalAnimation/AnimatedScrollModal.tsx +4 -2
- package/Components/VideoModal/ModalAnimation/AnimationComponent.tsx +17 -10
- package/Components/VideoModal/ModalAnimation/ModalAnimationContext.tsx +9 -1
- package/Components/VideoModal/ModalAnimation/__tests__/getMoveUpValue.test.ts +108 -0
- package/Components/VideoModal/ModalAnimation/const.ts +5 -0
- package/Components/VideoModal/ModalAnimation/index.ts +2 -0
- package/Components/VideoModal/ModalAnimation/utils.ts +30 -0
- package/Components/VideoModal/PlayerDetails.tsx +5 -0
- package/Components/VideoModal/PlayerWrapper.tsx +9 -19
- package/Components/VideoModal/__tests__/__snapshots__/PlayerDetails.test.tsx.snap +2 -40
- package/Components/VideoModal/utils.ts +3 -4
- package/package.json +5 -5
- package/Components/Cell/CellWrapper.ts +0 -5
|
@@ -22,8 +22,6 @@ type Props = {
|
|
|
22
22
|
audio_player_title_color?: string;
|
|
23
23
|
audio_player_summary_color?: string;
|
|
24
24
|
audio_player_rtl?: boolean;
|
|
25
|
-
magic_background?: boolean;
|
|
26
|
-
audio_player_background_image_query?: string;
|
|
27
25
|
audio_player_background_image_default_color?: string;
|
|
28
26
|
start_time?: string;
|
|
29
27
|
end_time?: string;
|
|
@@ -34,8 +32,6 @@ type Props = {
|
|
|
34
32
|
audio_player_title_color?: string;
|
|
35
33
|
audio_player_summary_color?: string;
|
|
36
34
|
audio_player_rtl?: string;
|
|
37
|
-
magic_background?: string;
|
|
38
|
-
audio_player_background_image_query?: string;
|
|
39
35
|
audio_player_background_image_default_color?: string;
|
|
40
36
|
audio_player_background_image?: string;
|
|
41
37
|
audio_player_artwork_aspect_ratio?: string;
|
|
@@ -76,11 +72,6 @@ export function AudioPlayer(props: Props) {
|
|
|
76
72
|
const artworkAspectRatio = getProp("audio_player_artwork_aspect_ratio");
|
|
77
73
|
const channelIcon = getProp("audio_player_channel_icon");
|
|
78
74
|
const rtlFlag = getProp("audio_player_rtl");
|
|
79
|
-
const magicBackground = getProp("magic_background");
|
|
80
|
-
|
|
81
|
-
const audioPlayerBackgroundImageQuery = getProp(
|
|
82
|
-
"audio_player_background_image_query"
|
|
83
|
-
);
|
|
84
75
|
|
|
85
76
|
const audioPlayerBackgroundImageDefaultColor = getProp(
|
|
86
77
|
"audio_player_background_image_default_color"
|
|
@@ -162,8 +153,6 @@ export function AudioPlayer(props: Props) {
|
|
|
162
153
|
runTimeFontSize,
|
|
163
154
|
artworkAspectRatio,
|
|
164
155
|
channelIcon,
|
|
165
|
-
magicBackground,
|
|
166
|
-
audioPlayerBackgroundImageQuery,
|
|
167
156
|
audioPlayerBackgroundImageDefaultColor,
|
|
168
157
|
};
|
|
169
158
|
}, [getProp]);
|
|
@@ -23,6 +23,8 @@ type Props = {
|
|
|
23
23
|
focused?: boolean;
|
|
24
24
|
};
|
|
25
25
|
|
|
26
|
+
const addPrefix = (id: string) => `focusable-cell-wrapper-${id}`;
|
|
27
|
+
|
|
26
28
|
export function CellWithFocusable(props: Props) {
|
|
27
29
|
const {
|
|
28
30
|
index,
|
|
@@ -81,7 +83,7 @@ export function CellWithFocusable(props: Props) {
|
|
|
81
83
|
|
|
82
84
|
return (
|
|
83
85
|
<FocusableGroup
|
|
84
|
-
id={
|
|
86
|
+
id={addPrefix(id)}
|
|
85
87
|
testID={"cell-with-focusable-cell-renderer-focusable-group"}
|
|
86
88
|
groupId={groupId}
|
|
87
89
|
preferredFocus={preferredFocus}
|
|
@@ -94,7 +96,7 @@ export function CellWithFocusable(props: Props) {
|
|
|
94
96
|
<CellRenderer
|
|
95
97
|
testID={"cell-with-focusable-cell-renderer"}
|
|
96
98
|
item={item}
|
|
97
|
-
groupId={
|
|
99
|
+
groupId={addPrefix(id)}
|
|
98
100
|
onToggleFocus={handleToggleFocus}
|
|
99
101
|
state={state}
|
|
100
102
|
prefixId={id}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { View, ViewStyle } from "react-native";
|
|
3
|
+
import { isTvOSPlatform } from "@applicaster/zapp-react-native-utils/reactUtils";
|
|
4
|
+
|
|
5
|
+
const isTvOS = isTvOSPlatform();
|
|
6
|
+
|
|
7
|
+
type Props = {
|
|
8
|
+
style: ViewStyle;
|
|
9
|
+
children: React.ReactNode;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export const CellWrapper = ({ style, children }: Props) => {
|
|
13
|
+
if (isTvOS) {
|
|
14
|
+
return <View style={style}>{children}</View>;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return <>{children}</>;
|
|
18
|
+
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { findPluginByIdentifier } from "@applicaster/zapp-react-native-utils/pluginUtils";
|
|
2
|
+
import { isGroup } from "@applicaster/zapp-react-native-utils/componentsUtils";
|
|
2
3
|
|
|
3
4
|
import { componentsLogger } from "../../Helpers/logger";
|
|
4
5
|
import defaultCellRenderer from "../default-cell-renderer";
|
|
@@ -80,7 +81,7 @@ export function CellRendererResolver({
|
|
|
80
81
|
}: Props) {
|
|
81
82
|
const cellRendererPlugin = getRendererPlugin(component, plugins, cellStyles);
|
|
82
83
|
|
|
83
|
-
if (!cellRendererPlugin && component
|
|
84
|
+
if (!cellRendererPlugin && !isGroup(component)) {
|
|
84
85
|
logger.warning({
|
|
85
86
|
message: "Could not resolve cell builder plugin",
|
|
86
87
|
data: { component },
|
|
@@ -11,6 +11,7 @@ import { allSettled } from "promise";
|
|
|
11
11
|
import { createLogger } from "@applicaster/zapp-react-native-utils/logger";
|
|
12
12
|
import { isNilOrEmpty } from "@applicaster/zapp-react-native-utils/reactUtils/helpers";
|
|
13
13
|
import { ScreenTrackedViewPositionsContext } from "@applicaster/zapp-react-native-ui-components/Contexts/ScreenTrackedViewPositionsContext";
|
|
14
|
+
import { useEventAlerts } from "./utils/useEventAlerts";
|
|
14
15
|
|
|
15
16
|
const { log_info } = createLogger({
|
|
16
17
|
category: "ScreenContainer",
|
|
@@ -103,6 +104,8 @@ export const GeneralContentScreen = ({
|
|
|
103
104
|
[typeof cellTapAction === "function" ? cellTapAction : onCellTapAction]
|
|
104
105
|
);
|
|
105
106
|
|
|
107
|
+
useEventAlerts(screenData);
|
|
108
|
+
|
|
106
109
|
if (!isReady || isNilOrEmpty(components || uiComponents)) return null;
|
|
107
110
|
|
|
108
111
|
return (
|
|
@@ -3,8 +3,10 @@ import { all, equals, path, prop, isEmpty, pluck, values } from "ramda";
|
|
|
3
3
|
import { useEffect, useMemo } from "react";
|
|
4
4
|
import { useDispatch } from "react-redux";
|
|
5
5
|
|
|
6
|
-
import {
|
|
7
|
-
|
|
6
|
+
import {
|
|
7
|
+
useLayoutPresets,
|
|
8
|
+
useZappPipesFeeds,
|
|
9
|
+
} from "@applicaster/zapp-react-native-redux/hooks";
|
|
8
10
|
import { loadPipesData } from "@applicaster/zapp-react-native-redux/ZappPipes";
|
|
9
11
|
import { isEmptyOrNil } from "@applicaster/zapp-react-native-utils/cellUtils";
|
|
10
12
|
import { Categories } from "./logger";
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { showAlertDialog } from "@applicaster/zapp-react-native-utils/alertUtils";
|
|
3
|
+
import { TOGGLE_FLAG_MAX_ITEMS_REACHED_EVENT } from "@applicaster/zapp-react-native-utils/actionsExecutor/consts";
|
|
4
|
+
import { useLocalizedStrings } from "@applicaster/zapp-react-native-utils/localizationUtils";
|
|
5
|
+
import { useIsScreenActive } from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
6
|
+
import { useSubscriberFor } from "@applicaster/zapp-react-native-utils/reactHooks/useSubscriberFor";
|
|
7
|
+
|
|
8
|
+
export const useEventAlerts = (screenData: ZappRiver) => {
|
|
9
|
+
const localizations = useLocalizedStrings({
|
|
10
|
+
localizations: screenData?.localizations || {},
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
const isActive = useIsScreenActive();
|
|
14
|
+
|
|
15
|
+
const onMaxTagsReached = React.useCallback(() => {
|
|
16
|
+
// We can't skip subscribe hook call, so we have to check.
|
|
17
|
+
if (!isActive || !localizations?.msg_maximum_selection_reached_message) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
showAlertDialog({
|
|
22
|
+
title: "",
|
|
23
|
+
message: localizations.msg_maximum_selection_reached_message,
|
|
24
|
+
okButtonText:
|
|
25
|
+
localizations.msg_maximum_selection_reached_message_ok_button || "OK",
|
|
26
|
+
});
|
|
27
|
+
}, [localizations, isActive]);
|
|
28
|
+
|
|
29
|
+
useSubscriberFor(TOGGLE_FLAG_MAX_ITEMS_REACHED_EVENT, onMaxTagsReached);
|
|
30
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks/usePickFromState";
|
|
3
|
+
import { getBackgroundImageUrl } from "../utils";
|
|
4
|
+
import { useTheme } from "@applicaster/zapp-react-native-utils/theme";
|
|
5
|
+
|
|
6
|
+
export const LayoutBackground = ({
|
|
7
|
+
Background,
|
|
8
|
+
children,
|
|
9
|
+
}: {
|
|
10
|
+
Background: React.ComponentType<any>;
|
|
11
|
+
children: React.ReactNode;
|
|
12
|
+
}) => {
|
|
13
|
+
const theme = useTheme();
|
|
14
|
+
|
|
15
|
+
const { remoteConfigurations } = usePickFromState(["remoteConfigurations"]);
|
|
16
|
+
|
|
17
|
+
const backgroundColor = theme.app_background_color;
|
|
18
|
+
const backgroundImageUrl = getBackgroundImageUrl(remoteConfigurations);
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<Background
|
|
22
|
+
backgroundColor={backgroundColor}
|
|
23
|
+
backgroundImageUrl={backgroundImageUrl}
|
|
24
|
+
>
|
|
25
|
+
{children}
|
|
26
|
+
</Background>
|
|
27
|
+
);
|
|
28
|
+
};
|
|
@@ -2,18 +2,23 @@
|
|
|
2
2
|
|
|
3
3
|
exports[`Layout TV renders 1`] = `
|
|
4
4
|
<View
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
preferredFocus={true}
|
|
5
|
+
backgroundColor="#000000"
|
|
6
|
+
testID="background-component"
|
|
8
7
|
>
|
|
9
8
|
<View
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
excludeFromFocusSearching={true}
|
|
10
|
+
id="/river/A1234"
|
|
11
|
+
preferredFocus={true}
|
|
12
|
+
>
|
|
13
|
+
<View
|
|
14
|
+
Components={
|
|
15
|
+
{
|
|
16
|
+
"Background": [Function],
|
|
17
|
+
"NavBar": [Function],
|
|
18
|
+
}
|
|
14
19
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
20
|
+
route="/river/A1234"
|
|
21
|
+
/>
|
|
22
|
+
</View>
|
|
18
23
|
</View>
|
|
19
24
|
`;
|
|
@@ -5,6 +5,14 @@ import { render } from "@testing-library/react-native";
|
|
|
5
5
|
import { Provider } from "react-redux";
|
|
6
6
|
import { NavigationContext } from "@applicaster/zapp-react-native-ui-components/Contexts/NavigationContext";
|
|
7
7
|
import configureStore from "redux-mock-store";
|
|
8
|
+
import Layout from "../index.web";
|
|
9
|
+
|
|
10
|
+
// mock useTheme to provide app_background_color
|
|
11
|
+
jest.mock("@applicaster/zapp-react-native-utils/theme", () => ({
|
|
12
|
+
useTheme: () => ({
|
|
13
|
+
app_background_color: "#000000",
|
|
14
|
+
}),
|
|
15
|
+
}));
|
|
8
16
|
|
|
9
17
|
const withoutChildren = omit(["children"]);
|
|
10
18
|
|
|
@@ -16,8 +24,6 @@ jest.mock("../../../Screen/TV/index.web", () => {
|
|
|
16
24
|
};
|
|
17
25
|
});
|
|
18
26
|
|
|
19
|
-
const Layout = require("../index.web").default;
|
|
20
|
-
|
|
21
27
|
const mockStore = configureStore()({
|
|
22
28
|
appState: { appReady: true },
|
|
23
29
|
});
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import * as R from "ramda";
|
|
3
2
|
import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
|
|
4
3
|
import { useNavigation } from "@applicaster/zapp-react-native-utils/reactHooks/navigation";
|
|
5
|
-
import { useTheme } from "@applicaster/zapp-react-native-utils/theme";
|
|
6
4
|
|
|
7
|
-
import { getBackgroundImageUrl } from "../utils";
|
|
8
5
|
import { LayoutContainer } from "./LayoutContainer";
|
|
9
6
|
import { ScreenContainer } from "./ScreenContainer";
|
|
10
7
|
|
|
@@ -12,6 +9,7 @@ import { ScreenLayoutContextProvider } from "./ScreenLayoutContextProvider";
|
|
|
12
9
|
import { PathnameContext } from "../../../Contexts/PathnameContext";
|
|
13
10
|
import { ScreenDataContext } from "../../../Contexts/ScreenDataContext";
|
|
14
11
|
import { ScreenContextProvider } from "../../../Contexts/ScreenContext";
|
|
12
|
+
import { LayoutBackground } from "./LayoutBackground";
|
|
15
13
|
|
|
16
14
|
type Components = {
|
|
17
15
|
NavBar: React.ComponentType<any>;
|
|
@@ -19,7 +17,6 @@ type Components = {
|
|
|
19
17
|
};
|
|
20
18
|
|
|
21
19
|
type ComponentsExtraProps = {
|
|
22
|
-
Background?: Record<string, any>;
|
|
23
20
|
NavBar?: Record<string, any>;
|
|
24
21
|
};
|
|
25
22
|
|
|
@@ -31,17 +28,10 @@ type Props = {
|
|
|
31
28
|
|
|
32
29
|
const Layout = ({ Components, ComponentsExtraProps, children }: Props) => {
|
|
33
30
|
const navigator = useNavigation();
|
|
34
|
-
const theme = useTheme();
|
|
35
31
|
|
|
36
|
-
const { appState: { appReady = false } = {}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
const backgroundColor = React.useMemo(() => theme.app_background_color, []);
|
|
40
|
-
|
|
41
|
-
const backgroundImageUrl = React.useMemo(
|
|
42
|
-
() => getBackgroundImageUrl(remoteConfigurations),
|
|
43
|
-
[remoteConfigurations]
|
|
44
|
-
);
|
|
32
|
+
const { appState: { appReady = false } = {} } = usePickFromState([
|
|
33
|
+
"appState",
|
|
34
|
+
]);
|
|
45
35
|
|
|
46
36
|
if (!appReady) {
|
|
47
37
|
return null;
|
|
@@ -50,11 +40,7 @@ const Layout = ({ Components, ComponentsExtraProps, children }: Props) => {
|
|
|
50
40
|
return (
|
|
51
41
|
<LayoutContainer>
|
|
52
42
|
<ScreenLayoutContextProvider>
|
|
53
|
-
<Components.Background
|
|
54
|
-
backgroundColor={backgroundColor}
|
|
55
|
-
backgroundImageUrl={backgroundImageUrl}
|
|
56
|
-
{...R.omit(["ref"])(ComponentsExtraProps?.Background)}
|
|
57
|
-
>
|
|
43
|
+
<LayoutBackground Background={Components.Background}>
|
|
58
44
|
<ScreenDataContext.Provider value={navigator.data}>
|
|
59
45
|
<PathnameContext.Provider value={navigator.currentRoute}>
|
|
60
46
|
<ScreenContextProvider pathname={navigator.currentRoute}>
|
|
@@ -67,7 +53,7 @@ const Layout = ({ Components, ComponentsExtraProps, children }: Props) => {
|
|
|
67
53
|
</ScreenContextProvider>
|
|
68
54
|
</PathnameContext.Provider>
|
|
69
55
|
</ScreenDataContext.Provider>
|
|
70
|
-
</
|
|
56
|
+
</LayoutBackground>
|
|
71
57
|
</ScreenLayoutContextProvider>
|
|
72
58
|
</LayoutContainer>
|
|
73
59
|
);
|
|
@@ -5,6 +5,7 @@ import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
|
|
|
5
5
|
|
|
6
6
|
import { ScreenLayoutContextProvider } from "./ScreenLayoutContextProvider";
|
|
7
7
|
import { StackNavigator } from "../../Navigator";
|
|
8
|
+
import { LayoutBackground } from "./LayoutBackground";
|
|
8
9
|
|
|
9
10
|
type Components = {
|
|
10
11
|
NavBar: React.ComponentType<any>;
|
|
@@ -25,7 +26,9 @@ const Layout = ({ Components }: Props) => {
|
|
|
25
26
|
|
|
26
27
|
return (
|
|
27
28
|
<ScreenLayoutContextProvider>
|
|
28
|
-
<
|
|
29
|
+
<LayoutBackground Background={Components.Background}>
|
|
30
|
+
<StackNavigator Components={Components} />
|
|
31
|
+
</LayoutBackground>
|
|
29
32
|
</ScreenLayoutContextProvider>
|
|
30
33
|
);
|
|
31
34
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { times } from "@applicaster/zapp-react-native-utils/utils";
|
|
2
2
|
import { toNumberWithDefaultZero } from "@applicaster/zapp-react-native-utils/numberUtils";
|
|
3
3
|
|
|
4
4
|
import { Button } from "./Button";
|
|
@@ -9,13 +9,14 @@ import {
|
|
|
9
9
|
} from "./utils";
|
|
10
10
|
|
|
11
11
|
import { compact } from "@applicaster/zapp-react-native-utils/cellUtils";
|
|
12
|
+
import { PREFIX, BUTTON_PREFIX } from "./const";
|
|
12
13
|
|
|
13
14
|
export {
|
|
14
15
|
insertButtonsBetweenLabels,
|
|
15
16
|
insertButtonsBetweenLabelContainers,
|
|
16
17
|
} from "./utils";
|
|
17
18
|
|
|
18
|
-
const
|
|
19
|
+
const buttonId = (index: number) => `${BUTTON_PREFIX}_${index}`;
|
|
19
20
|
|
|
20
21
|
type Props = {
|
|
21
22
|
value: Function;
|
|
@@ -42,7 +43,6 @@ export const TvActionButtons = ({
|
|
|
42
43
|
return null;
|
|
43
44
|
}
|
|
44
45
|
|
|
45
|
-
const prefix1Button = `${PREFIX}_button_1`;
|
|
46
46
|
const independentStyles = value(`${PREFIX}_container_independent_styles`);
|
|
47
47
|
|
|
48
48
|
return {
|
|
@@ -73,11 +73,11 @@ export const TvActionButtons = ({
|
|
|
73
73
|
buttonsCount,
|
|
74
74
|
},
|
|
75
75
|
elements: compact(
|
|
76
|
-
|
|
77
|
-
const prefixSpecificButton =
|
|
76
|
+
times((index) => {
|
|
77
|
+
const prefixSpecificButton = buttonId(index + 1);
|
|
78
78
|
|
|
79
79
|
return Button({
|
|
80
|
-
prefix: independentStyles ? prefixSpecificButton :
|
|
80
|
+
prefix: independentStyles ? prefixSpecificButton : buttonId(1),
|
|
81
81
|
value,
|
|
82
82
|
platformValue,
|
|
83
83
|
pluginIdentifier: getPluginIdentifier(configuration, PREFIX, index),
|
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
|
|
3
|
-
useEffect,
|
|
4
|
-
useMemo,
|
|
5
|
-
useRef,
|
|
6
|
-
useState,
|
|
7
|
-
} from "react";
|
|
8
|
-
import { View, LayoutChangeEvent, ScrollView } from "react-native";
|
|
1
|
+
import React, { useCallback, useEffect, useMemo, useRef } from "react";
|
|
2
|
+
import { View, ScrollView } from "react-native";
|
|
9
3
|
import { Button } from "./Button";
|
|
10
4
|
import { ItemIconProps } from "./Button/ItemIcon";
|
|
11
5
|
import { ItemProps } from "./Button/Item";
|
|
@@ -15,7 +9,8 @@ import { useTheme } from "@applicaster/zapp-react-native-utils/theme";
|
|
|
15
9
|
|
|
16
10
|
import type { PluginConfiguration } from "./";
|
|
17
11
|
|
|
18
|
-
import { ModalHeader } from "./Header";
|
|
12
|
+
import { ModalHeader as DefaultModalHeader } from "./Header";
|
|
13
|
+
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
|
19
14
|
|
|
20
15
|
type ModalComponentProps = {
|
|
21
16
|
items: any[];
|
|
@@ -27,6 +22,7 @@ type ModalComponentProps = {
|
|
|
27
22
|
title?: string;
|
|
28
23
|
maxHeight?: number;
|
|
29
24
|
dismiss: () => void;
|
|
25
|
+
headerComponent?: React.ComponentType;
|
|
30
26
|
buttonComponent?: React.ComponentType;
|
|
31
27
|
iconProps?: ItemIconProps | ((theme: PluginConfiguration) => ItemIconProps);
|
|
32
28
|
itemProps?:
|
|
@@ -48,30 +44,24 @@ export function BottomSheetModalContent(props: ModalComponentProps) {
|
|
|
48
44
|
const {
|
|
49
45
|
items,
|
|
50
46
|
currentRoute,
|
|
51
|
-
maxHeight,
|
|
52
47
|
current_selection = null,
|
|
53
48
|
onPress,
|
|
54
49
|
dismiss,
|
|
55
50
|
summary,
|
|
56
51
|
title,
|
|
52
|
+
headerComponent: ModalHeader = DefaultModalHeader,
|
|
57
53
|
buttonComponent: ButtonComponent = Button,
|
|
58
|
-
getSelectedItemIcon = (
|
|
59
|
-
|
|
54
|
+
getSelectedItemIcon = ({
|
|
55
|
+
modal_bottom_sheet_item_selected_icon,
|
|
56
|
+
}: BaseThemePropertiesMobile) => modal_bottom_sheet_item_selected_icon,
|
|
60
57
|
getDefaultItemIcon = () => null,
|
|
61
58
|
iconPlacement,
|
|
62
59
|
} = props;
|
|
63
60
|
|
|
64
|
-
const [headerHeight, setHeaderHeight] = useState(0);
|
|
65
61
|
const route = useRef(currentRoute);
|
|
66
62
|
const theme = useTheme<BaseThemePropertiesMobile>();
|
|
67
|
-
|
|
68
|
-
const
|
|
69
|
-
? maxHeight - headerHeight - Number(theme.modal_bottom_sheet_padding_top)
|
|
70
|
-
: undefined;
|
|
71
|
-
|
|
72
|
-
const onHeaderLayout = useCallback((event: LayoutChangeEvent) => {
|
|
73
|
-
setHeaderHeight(event.nativeEvent.layout.height);
|
|
74
|
-
}, []);
|
|
63
|
+
const paddingTop = Number(theme.modal_bottom_sheet_padding_top);
|
|
64
|
+
const paddingBottom = Number(theme.modal_bottom_sheet_padding_bottom);
|
|
75
65
|
|
|
76
66
|
useEffect(() => {
|
|
77
67
|
if (currentRoute !== route.current) {
|
|
@@ -99,45 +89,44 @@ export function BottomSheetModalContent(props: ModalComponentProps) {
|
|
|
99
89
|
[onPress, dismiss]
|
|
100
90
|
);
|
|
101
91
|
|
|
92
|
+
const bottomInset = useSafeAreaInsets().bottom;
|
|
93
|
+
|
|
102
94
|
return (
|
|
103
95
|
<View
|
|
104
96
|
style={{
|
|
105
|
-
|
|
97
|
+
maxHeight: props.maxHeight,
|
|
98
|
+
paddingTop: paddingTop,
|
|
106
99
|
}}
|
|
107
100
|
>
|
|
108
101
|
<ModalHeader
|
|
109
|
-
width={props.width}
|
|
110
102
|
dismiss={dismiss}
|
|
111
103
|
configuration={theme}
|
|
112
|
-
onLayout={onHeaderLayout}
|
|
113
104
|
summary={summary}
|
|
114
105
|
title={title}
|
|
115
106
|
/>
|
|
116
107
|
<ScrollView
|
|
117
|
-
bounces={false}
|
|
118
|
-
style={{ maxHeight: maxContentHeight }}
|
|
119
108
|
contentContainerStyle={{
|
|
120
|
-
paddingBottom:
|
|
121
|
-
paddingTop: Number(theme.modal_bottom_sheet_padding_top),
|
|
109
|
+
paddingBottom: paddingBottom + bottomInset,
|
|
122
110
|
}}
|
|
123
111
|
>
|
|
124
|
-
{items.map((item, index) =>
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
112
|
+
{items.map((item, index) =>
|
|
113
|
+
item ? (
|
|
114
|
+
<ButtonComponent
|
|
115
|
+
key={index}
|
|
116
|
+
configuration={theme}
|
|
117
|
+
selectedItem={current_selection}
|
|
118
|
+
item={item}
|
|
119
|
+
onPress={handlePress}
|
|
120
|
+
label={theme[item?.label] ?? item?.label}
|
|
121
|
+
iconBaseProps={iconBaseProps}
|
|
122
|
+
itemBaseProps={itemBaseProps}
|
|
123
|
+
labelBaseProps={labelBaseProps}
|
|
124
|
+
selectedItemIcon={getSelectedItemIcon(theme)}
|
|
125
|
+
defaultItemIcon={getDefaultItemIcon(theme)}
|
|
126
|
+
iconPlacement={iconPlacement}
|
|
127
|
+
/>
|
|
128
|
+
) : null
|
|
129
|
+
)}
|
|
141
130
|
</ScrollView>
|
|
142
131
|
</View>
|
|
143
132
|
);
|
|
@@ -5,7 +5,7 @@ export type ItemProps = {
|
|
|
5
5
|
backgroundColor: string;
|
|
6
6
|
focusedBackgroundColor: string;
|
|
7
7
|
selectedBackgroundColor?: string;
|
|
8
|
-
|
|
8
|
+
focusedSelectedBackgroundColor?: string;
|
|
9
9
|
borderRadius: number;
|
|
10
10
|
marginBottom: number;
|
|
11
11
|
marginLeft: number;
|
|
@@ -34,11 +34,11 @@ function getBackgroundColor({
|
|
|
34
34
|
backgroundColor,
|
|
35
35
|
focusedBackgroundColor,
|
|
36
36
|
selectedBackgroundColor,
|
|
37
|
-
|
|
37
|
+
focusedSelectedBackgroundColor,
|
|
38
38
|
}) {
|
|
39
39
|
switch (true) {
|
|
40
40
|
case selected && focused:
|
|
41
|
-
return
|
|
41
|
+
return focusedSelectedBackgroundColor;
|
|
42
42
|
case selected && !focused:
|
|
43
43
|
return selectedBackgroundColor;
|
|
44
44
|
case !selected && focused:
|
|
@@ -52,7 +52,7 @@ export function Item(props: ItemProps) {
|
|
|
52
52
|
const {
|
|
53
53
|
backgroundColor,
|
|
54
54
|
focusedBackgroundColor,
|
|
55
|
-
|
|
55
|
+
focusedSelectedBackgroundColor,
|
|
56
56
|
selectedBackgroundColor,
|
|
57
57
|
children,
|
|
58
58
|
focused,
|
|
@@ -69,7 +69,7 @@ export function Item(props: ItemProps) {
|
|
|
69
69
|
backgroundColor: getBackgroundColor({
|
|
70
70
|
selected,
|
|
71
71
|
focused,
|
|
72
|
-
|
|
72
|
+
focusedSelectedBackgroundColor,
|
|
73
73
|
focusedBackgroundColor,
|
|
74
74
|
selectedBackgroundColor,
|
|
75
75
|
backgroundColor,
|
|
@@ -7,7 +7,6 @@ import { defaultSelectedAsset } from "./assets";
|
|
|
7
7
|
|
|
8
8
|
type ButtonProps = {
|
|
9
9
|
configuration: any;
|
|
10
|
-
width: number;
|
|
11
10
|
selectedItem?: any;
|
|
12
11
|
item: any; // Adjust type as needed
|
|
13
12
|
onPress: (item: any) => void; // Adjust type as needed
|
|
@@ -33,7 +32,6 @@ export function Button({
|
|
|
33
32
|
item,
|
|
34
33
|
onPress,
|
|
35
34
|
configuration,
|
|
36
|
-
width,
|
|
37
35
|
iconBaseProps,
|
|
38
36
|
itemBaseProps: itemProps,
|
|
39
37
|
labelBaseProps,
|
|
@@ -65,34 +63,32 @@ export function Button({
|
|
|
65
63
|
if (disabled) return null;
|
|
66
64
|
|
|
67
65
|
return (
|
|
68
|
-
<
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
>
|
|
75
|
-
<
|
|
76
|
-
|
|
77
|
-
{iconPlacement === "left" && renderItemIcon}
|
|
66
|
+
<TouchableOpacity
|
|
67
|
+
activeOpacity={1}
|
|
68
|
+
onPress={() => onPress(item)}
|
|
69
|
+
onPressIn={() => setFocused(true)}
|
|
70
|
+
onPressOut={() => setFocused(false)}
|
|
71
|
+
>
|
|
72
|
+
<Item {...itemProps} focused={focused} selected={selected}>
|
|
73
|
+
<View style={styles.label_icon_container}>
|
|
74
|
+
{iconPlacement === "left" && renderItemIcon}
|
|
78
75
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
76
|
+
{label ? (
|
|
77
|
+
<ItemLabel
|
|
78
|
+
{...labelBaseProps}
|
|
79
|
+
label={label ?? null}
|
|
80
|
+
focused={focused}
|
|
81
|
+
selected={selected}
|
|
82
|
+
/>
|
|
83
|
+
) : null}
|
|
84
|
+
</View>
|
|
88
85
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
</View>
|
|
86
|
+
{selected ? (
|
|
87
|
+
<ItemIcon {...iconBaseProps} asset={selectedItemIconPropsAssets} />
|
|
88
|
+
) : (
|
|
89
|
+
iconPlacement === "right" && renderItemIcon
|
|
90
|
+
)}
|
|
91
|
+
</Item>
|
|
92
|
+
</TouchableOpacity>
|
|
97
93
|
);
|
|
98
94
|
}
|