@applicaster/zapp-react-native-ui-components 13.0.0-alpha.3962361544 → 13.0.0-alpha.4012243505

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/Components/AudioPlayer/AudioPlayer.tsx +7 -0
  2. package/Components/AudioPlayer/helpers.tsx +1 -0
  3. package/Components/Cell/Cell.tsx +3 -13
  4. package/Components/Cell/CellWithFocusable.tsx +21 -15
  5. package/Components/Cell/CellWrapper.tsx +18 -0
  6. package/Components/Cell/styles.ts +17 -0
  7. package/Components/CellRendererResolver/index.ts +2 -1
  8. package/Components/ErrorScreen/index.tsx +8 -0
  9. package/Components/FocusableCell/index.tsx +1 -1
  10. package/Components/FocusableGroup/FocusableTvOS.tsx +3 -6
  11. package/Components/FocusableGroup/index.tsx +0 -1
  12. package/Components/GeneralContentScreen/GeneralContentScreen.tsx +3 -0
  13. package/Components/GeneralContentScreen/utils/useEventAlerts.ts +28 -0
  14. package/Components/HandlePlayable/HandlePlayable.tsx +21 -27
  15. package/Components/Layout/TV/LayoutBackground.tsx +28 -0
  16. package/Components/Layout/TV/ScreenContainer.tsx +8 -2
  17. package/Components/Layout/TV/ScreenLayoutContextProvider.tsx +5 -0
  18. package/Components/Layout/TV/__tests__/ScreenContainer.test.tsx +2 -1
  19. package/Components/Layout/TV/__tests__/__snapshots__/index.test.tsx.snap +15 -10
  20. package/Components/Layout/TV/__tests__/index.test.tsx +8 -2
  21. package/Components/Layout/TV/index.tsx +6 -20
  22. package/Components/Layout/TV/index.web.tsx +4 -1
  23. package/Components/MasterCell/DefaultComponents/Image/Image.ios.tsx +4 -3
  24. package/Components/MasterCell/DefaultComponents/Image/hooks/useImage.ts +11 -7
  25. package/Components/MasterCell/DefaultComponents/tv/TvActionButtons/const.ts +3 -0
  26. package/Components/MasterCell/DefaultComponents/tv/TvActionButtons/index.ts +6 -6
  27. package/Components/MasterCell/utils/behaviorProvider.ts +136 -0
  28. package/Components/MasterCell/utils/index.ts +8 -134
  29. package/Components/ModalComponent/BottomSheetModalContent.tsx +45 -19
  30. package/Components/ModalComponent/Button/Item.tsx +6 -5
  31. package/Components/ModalComponent/Button/assets.ts +1 -1
  32. package/Components/ModalComponent/Button/index.tsx +29 -42
  33. package/Components/ModalComponent/utils.ts +55 -7
  34. package/Components/OfflineHandler/utils/index.ts +1 -1
  35. package/Components/PlayerContainer/PlayerContainer.tsx +32 -6
  36. package/Components/PlayerImageBackground/index.tsx +4 -24
  37. package/Components/River/ComponentsMap/ComponentsMap.tsx +3 -0
  38. package/Components/River/ComponentsMap/hooks/useLoadingState.ts +3 -3
  39. package/Components/River/RiverItem.tsx +2 -1
  40. package/Components/Screen/TV/index.web.tsx +5 -6
  41. package/Components/Screen/hooks.ts +3 -6
  42. package/Components/TopMarginApplicator/TopMarginApplicator.tsx +2 -3
  43. package/Components/TrackedView/index.tsx +1 -0
  44. package/Components/Transitioner/AnimationManager.js +15 -15
  45. package/Components/VideoLive/PlayerLiveImageComponent.tsx +4 -0
  46. package/Components/VideoLive/__tests__/__snapshots__/PlayerLiveImageComponent.test.tsx.snap +1 -0
  47. package/Components/VideoModal/ModalAnimation/AnimatedPlayerModalWrapper.tsx +1 -1
  48. package/Components/VideoModal/ModalAnimation/AnimatedScrollModal.tsx +35 -19
  49. package/Components/VideoModal/ModalAnimation/AnimatedVideoPlayerComponent.tsx +3 -3
  50. package/Components/VideoModal/ModalAnimation/AnimationComponent.tsx +38 -13
  51. package/Components/VideoModal/ModalAnimation/ModalAnimationContext.tsx +10 -3
  52. package/Components/VideoModal/ModalAnimation/__tests__/getMoveUpValue.test.ts +108 -0
  53. package/Components/VideoModal/ModalAnimation/const.ts +5 -0
  54. package/Components/VideoModal/ModalAnimation/index.ts +2 -0
  55. package/Components/VideoModal/ModalAnimation/utils.ts +36 -0
  56. package/Components/VideoModal/PlayerDetails.tsx +9 -4
  57. package/Components/VideoModal/PlayerWrapper.tsx +26 -3
  58. package/Components/VideoModal/VideoModal.tsx +19 -4
  59. package/Components/VideoModal/__tests__/__snapshots__/PlayerDetails.test.tsx.snap +2 -40
  60. package/Components/VideoModal/utils.ts +3 -4
  61. package/Components/ZappUIComponent/index.tsx +4 -4
  62. package/Contexts/FocusableGroupContext/withFocusableContext.tsx +4 -10
  63. package/Contexts/HeaderOffsetContext/index.tsx +4 -6
  64. package/Contexts/ScreenContext/index.tsx +3 -10
  65. package/Contexts/ScreenLayoutContext/index.tsx +5 -3
  66. package/Decorators/RiverResolver/index.tsx +5 -7
  67. package/Decorators/ZappPipesDataConnector/index.tsx +4 -30
  68. package/package.json +5 -9
  69. package/tsconfig.json +2 -3
  70. package/.babelrc +0 -8
  71. package/Components/Cell/CellStyles/FallbackCellStyle/index.js +0 -157
  72. package/Components/Cell/CellStyles/Hero/index.js +0 -111
  73. package/Components/Cell/CellStyles/ScreenSelector/index.js +0 -68
  74. package/Components/Cell/CellStyles/cellStylesResolver.ts +0 -19
  75. package/Components/Cell/CellStyles/colors.js +0 -40
  76. package/Components/Cell/CellStyles/index.js +0 -15
@@ -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
- <StackNavigator Components={Components} />
29
+ <LayoutBackground Background={Components.Background}>
30
+ <StackNavigator Components={Components} />
31
+ </LayoutBackground>
29
32
  </ScreenLayoutContextProvider>
30
33
  );
31
34
  };
@@ -1,6 +1,6 @@
1
1
  import * as React from "react";
2
2
  import { Image as RnImage, ImageStyle } from "react-native";
3
- import * as R from "ramda";
3
+ import { equals, omit } from "ramda";
4
4
 
5
5
  import { useImageSource } from "./hooks";
6
6
 
@@ -17,7 +17,7 @@ type Props = Record<string, any> & {
17
17
  withDimensions: (source: Source) => Source;
18
18
  };
19
19
 
20
- const MemoizedImage = React.memo(RnImage, R.equals);
20
+ const MemoizedImage = React.memo(RnImage, equals);
21
21
 
22
22
  function Image({
23
23
  style,
@@ -44,11 +44,12 @@ function Image({
44
44
 
45
45
  return (
46
46
  <MemoizedImage
47
+ key={_source?.uri || "no-image"}
47
48
  style={style as ImageStyle}
48
49
  onError={React.useCallback(() => setErrorState(true), [])}
49
50
  // as we have defaults as "" for placeholder image, we need to pass undefined to source to not throw warnings
50
51
  source={_source?.uri ? _source : undefined}
51
- {...R.omit(["source"], otherProps)}
52
+ {...omit(["source"], otherProps)}
52
53
  />
53
54
  );
54
55
  }
@@ -1,5 +1,5 @@
1
1
  import * as React from "react";
2
- import * as R from "ramda";
2
+ import { path } from "ramda";
3
3
 
4
4
  import { isTV } from "@applicaster/zapp-react-native-utils/reactUtils";
5
5
  import { useActions } from "@applicaster/zapp-react-native-utils/reactHooks/actions";
@@ -7,9 +7,13 @@ import { extractAsset } from "./utils";
7
7
 
8
8
  type Return = { uri: string } | null;
9
9
 
10
+ const getSourceContext = path(["source", "context"]);
11
+ const getSourceUri = path(["source", "uri"]);
12
+ const getState = path(["state"]);
13
+
10
14
  export const useImageSource = ({ uri, entry, otherProps }): Return => {
11
- const uriContext = R.path(["source", "context"], otherProps);
12
- const uriState = R.path(["state"], otherProps);
15
+ const uriContext = getSourceContext(otherProps);
16
+ const uriState = getState(otherProps);
13
17
 
14
18
  const action = useActions(uriContext);
15
19
 
@@ -34,7 +38,7 @@ export const useImageSource = ({ uri, entry, otherProps }): Return => {
34
38
  return { uri };
35
39
  }
36
40
 
37
- const uriFromSource = R.path(["source", "uri"], otherProps);
41
+ const uriFromSource = getSourceUri(otherProps);
38
42
 
39
43
  if (uriFromSource) {
40
44
  return { uri: uriFromSource };
@@ -56,7 +60,7 @@ const getSource = (uri, showDefault, placeholderImage, otherProps) => {
56
60
  return { uri };
57
61
  }
58
62
 
59
- const uriFromSource = R.path(["source", "uri"], otherProps);
63
+ const uriFromSource = getSourceUri(otherProps);
60
64
 
61
65
  if (uriFromSource) {
62
66
  return { uri: uriFromSource };
@@ -72,8 +76,8 @@ export const useImageSourceWithDefault = ({
72
76
  placeholderImage,
73
77
  otherProps,
74
78
  }): Return => {
75
- const uriContext = R.path(["source", "context"], otherProps);
76
- const uriState = R.path(["state"], otherProps);
79
+ const uriContext = getSourceContext(otherProps);
80
+ const uriState = getState(otherProps);
77
81
 
78
82
  const action = useActions(uriContext);
79
83
 
@@ -0,0 +1,3 @@
1
+ export const PREFIX = "tv_buttons";
2
+
3
+ export const BUTTON_PREFIX = `${PREFIX}_button`;
@@ -1,4 +1,4 @@
1
- import * as R from "ramda";
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 PREFIX = "tv_buttons";
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
- R.times((index) => {
77
- const prefixSpecificButton = `${PREFIX}_button_${index + 1}`;
76
+ times((index) => {
77
+ const prefixSpecificButton = buttonId(index + 1);
78
78
 
79
79
  return Button({
80
- prefix: independentStyles ? prefixSpecificButton : prefix1Button,
80
+ prefix: independentStyles ? prefixSpecificButton : buttonId(1),
81
81
  value,
82
82
  platformValue,
83
83
  pluginIdentifier: getPluginIdentifier(configuration, PREFIX, index),
@@ -0,0 +1,136 @@
1
+ import { playerManager } from "@applicaster/zapp-react-native-utils/appUtils";
2
+ import { StorageSingleValueProvider } from "@applicaster/zapp-react-native-bridge/ZappStorage/StorageSingleSelectProvider";
3
+ import { PushTopicManager } from "@applicaster/zapp-react-native-bridge/PushNotifications/PushTopicManager";
4
+ import { StorageMultiSelectProvider } from "@applicaster/zapp-react-native-bridge/ZappStorage/StorageMultiSelectProvider";
5
+ import React, { useEffect } from "react";
6
+ import { usePlayer } from "@applicaster/zapp-react-native-utils/appUtils/playerManager/usePlayer";
7
+ import { BehaviorSubject } from "rxjs";
8
+ import { masterCellLogger } from "../logger";
9
+ import get from "lodash/get";
10
+
11
+ const parseContextKey = (key: string): string | null => {
12
+ if (!key?.startsWith("@{ctx/")) return null;
13
+
14
+ return key.substring("@{ctx/".length, key.length - 1);
15
+ };
16
+
17
+ const getDataSourceProvider = (
18
+ behavior: Behavior
19
+ ): BehaviorSubject<string[] | string> | null => {
20
+ if (!behavior) return null;
21
+
22
+ const selection = String(behavior.current_selection);
23
+ const contextKey = parseContextKey(selection);
24
+
25
+ if (contextKey) {
26
+ if (behavior.select_mode === "multi") {
27
+ return StorageMultiSelectProvider.getProvider(contextKey).getObservable();
28
+ }
29
+
30
+ if (behavior.select_mode === "single") {
31
+ return StorageSingleValueProvider.getProvider(contextKey).getObservable();
32
+ }
33
+ }
34
+
35
+ if (behavior.selection_source === "@{push/topics}") {
36
+ return PushTopicManager.getInstance().getEntryObservable();
37
+ }
38
+
39
+ return null;
40
+ };
41
+
42
+ export const useBehaviorUpdate = (behavior: Behavior) => {
43
+ const [lastUpdate, setLastUpdate] = React.useState<number | null>(null);
44
+ const player = usePlayer();
45
+
46
+ const triggerUpdate = () => setLastUpdate(Date.now());
47
+
48
+ useEffect(() => {
49
+ if (!behavior) return;
50
+
51
+ const dataSource = getDataSourceProvider(behavior);
52
+
53
+ if (dataSource) {
54
+ const subscription = dataSource.subscribe(triggerUpdate);
55
+
56
+ return () => subscription.unsubscribe();
57
+ }
58
+ }, [behavior]);
59
+
60
+ useEffect(() => {
61
+ if (!behavior || !player || behavior.selection_source !== "now_playing") {
62
+ return;
63
+ }
64
+
65
+ const subscription = player.getEntryObservable().subscribe(triggerUpdate);
66
+
67
+ return () => subscription.unsubscribe();
68
+ }, [behavior, player]);
69
+
70
+ return lastUpdate;
71
+ };
72
+
73
+ // We cant use async in this function (its inside render),
74
+ // so we rely on useBehaviorUpdate to update current value and trigger re-render
75
+ export const isCellSelected = (
76
+ item: ZappEntry,
77
+ behavior?: Behavior
78
+ ): boolean => {
79
+ if (!behavior) return false;
80
+
81
+ const id = behavior.selector ? get(item, behavior.selector) : item.id;
82
+
83
+ if (behavior.selection_source === "now_playing") {
84
+ const player = playerManager.getActivePlayer();
85
+
86
+ return player?.entry?.id === id;
87
+ }
88
+
89
+ if (behavior.selection_source === "@{push/topics}") {
90
+ if (behavior.select_mode === "single") {
91
+ masterCellLogger.warning(
92
+ "Unexpected single selection mode for push topics"
93
+ );
94
+ }
95
+
96
+ const tags = PushTopicManager.getInstance().getRegisteredTags();
97
+
98
+ return tags.includes(String(id));
99
+ }
100
+
101
+ const selection = String(behavior.current_selection);
102
+ const contextKey = parseContextKey(selection);
103
+
104
+ if (contextKey) {
105
+ if (behavior.select_mode === "single") {
106
+ const selectedItem =
107
+ StorageSingleValueProvider.getProvider(contextKey)?.getValue();
108
+
109
+ return selectedItem === String(id);
110
+ }
111
+
112
+ if (behavior.select_mode === "multi") {
113
+ const selectedItems =
114
+ StorageMultiSelectProvider.getProvider(contextKey)?.getSelectedItems();
115
+
116
+ return selectedItems?.includes(String(id));
117
+ }
118
+ }
119
+
120
+ if (behavior.select_mode === "single") {
121
+ return behavior.current_selection === id;
122
+ }
123
+
124
+ if (
125
+ behavior.select_mode === "multi" &&
126
+ Array.isArray(behavior.current_selection)
127
+ ) {
128
+ const currentSelection: string[] = behavior.current_selection.map(
129
+ (item): string => String(item)
130
+ );
131
+
132
+ return currentSelection.includes(String(id));
133
+ }
134
+
135
+ return false;
136
+ };
@@ -1,16 +1,13 @@
1
- import React, { useEffect, useMemo } from "react";
1
+ import React, { useMemo } from "react";
2
2
  import * as R from "ramda";
3
3
  import validateColor from "validate-color";
4
4
  import { platformSelect } from "@applicaster/zapp-react-native-utils/reactUtils";
5
5
  import { useActions } from "@applicaster/zapp-react-native-utils/reactHooks/actions";
6
6
 
7
7
  import { masterCellLogger } from "../logger";
8
- import { playerManager } from "@applicaster/zapp-react-native-utils/appUtils";
9
- import { usePlayer } from "@applicaster/zapp-react-native-utils/appUtils/playerManager/usePlayer";
10
- import { PushTopicManager } from "@applicaster/zapp-react-native-bridge/PushNotifications/PushTopicManager";
11
- import { StorageMultiSelectProvider } from "@applicaster/zapp-react-native-bridge/ZappStorage/StorageMultiSelectProvider";
12
8
  import { getCellState } from "../../Cell/utils";
13
9
  import { getColorFromData } from "@applicaster/zapp-react-native-utils/cellUtils";
10
+ import { isCellSelected, useBehaviorUpdate } from "./behaviorProvider";
14
11
 
15
12
  const hasElementSpecificViewType = (viewType) => (element) => {
16
13
  if (R.isNil(element)) {
@@ -193,147 +190,24 @@ export const getFocusedButtonId = (focusable) => {
193
190
  });
194
191
  };
195
192
 
196
- export const isSelected = (id: string | number, behavior?: Behavior) => {
197
- if (!behavior) {
198
- return false;
199
- }
200
-
201
- if (behavior?.selection_source === "now_playing") {
202
- const player = playerManager.getActivePlayer();
203
-
204
- if (player?.entry?.id === id) {
205
- return true;
206
- }
207
- }
208
-
209
- if (behavior?.select_mode === "single") {
210
- return behavior.current_selection === id;
211
- }
212
-
213
- if (behavior?.select_mode === "multi") {
214
- // TODO: Use generic resolver source
215
-
216
- if (behavior.selection_source === "@{push/topics}") {
217
- const tags = PushTopicManager.getInstance().getRegisteredTags();
218
-
219
- return tags.includes(String(id));
220
- }
221
-
222
- if (Array.isArray(behavior.current_selection)) {
223
- return behavior.current_selection.includes(id);
224
- }
225
-
226
- const currentSelection = String(behavior.current_selection);
227
-
228
- if (currentSelection?.startsWith("@{ctx/")) {
229
- const keyWithoutCtx = currentSelection.substring(
230
- "@{ctx/".length,
231
- currentSelection.length - 1
232
- );
233
-
234
- const selectedItems =
235
- StorageMultiSelectProvider.getProvider(
236
- keyWithoutCtx
237
- )?.getSelectedItems();
238
-
239
- return selectedItems?.includes(String(id));
240
- }
241
- }
242
-
243
- return false;
244
- };
245
-
246
- export const useBehaviorUpdate = (behavior: Behavior) => {
247
- const [lastUpdate, setLastUpdate] = React.useState(null);
248
-
249
- const player = usePlayer();
250
-
251
- const triggerUpdate = () => {
252
- setLastUpdate(Date.now());
253
- };
254
-
255
- // TODO: Create generic RX to state update
256
- useEffect(() => {
257
- // TODO: Use generic resolver source
258
- if (!behavior) {
259
- return;
260
- }
261
-
262
- const currentSelection = String(behavior.current_selection);
263
-
264
- if (currentSelection?.startsWith("@{ctx/")) {
265
- const keyWithoutCtx = currentSelection.substring(
266
- "@{ctx/".length,
267
- currentSelection.length - 1
268
- );
269
-
270
- if (keyWithoutCtx) {
271
- const subscription = StorageMultiSelectProvider.getProvider(
272
- keyWithoutCtx
273
- )
274
- .getObservable()
275
- .subscribe(() => {
276
- triggerUpdate();
277
- });
278
-
279
- return () => {
280
- subscription.unsubscribe();
281
- };
282
- }
283
- }
284
- }, [behavior]);
285
-
286
- useEffect(() => {
287
- if (!behavior) {
288
- return;
289
- }
290
-
291
- if (behavior?.selection_source === "@{push/topics}") {
292
- const subscription = PushTopicManager.getInstance()
293
- .getEntryObservable()
294
- .subscribe(() => {
295
- triggerUpdate();
296
- });
297
-
298
- return () => {
299
- subscription.unsubscribe();
300
- };
301
- }
302
- }, [behavior]);
303
-
304
- useEffect(() => {
305
- if (!behavior) {
306
- return;
307
- }
308
-
309
- if (behavior?.selection_source === "now_playing" && player) {
310
- const subscription = player.getEntryObservable().subscribe(() => {
311
- triggerUpdate();
312
- });
313
-
314
- return () => {
315
- subscription.unsubscribe();
316
- };
317
- }
318
- }, [behavior, player]);
319
-
320
- return lastUpdate;
193
+ export const isSelected = (item: ZappEntry, behavior?: Behavior) => {
194
+ return isCellSelected(item, behavior);
321
195
  };
322
196
 
323
197
  export const useCellState = ({
324
- id,
198
+ item,
325
199
  behavior,
326
200
  focused,
327
201
  }: {
328
- id: string | number;
202
+ item: ZappEntry;
329
203
  behavior: Behavior;
330
204
  focused: boolean;
331
205
  }): CellState => {
332
206
  const lastUpdate = useBehaviorUpdate(behavior);
333
207
 
334
208
  const _isSelected = useMemo(
335
- () => isSelected(id, behavior),
336
- [behavior, id, lastUpdate]
209
+ () => isSelected(item, behavior),
210
+ [behavior, item, lastUpdate]
337
211
  );
338
212
 
339
213
  return getCellState({ focused, selected: _isSelected });
@@ -10,13 +10,11 @@ import { Button } from "./Button";
10
10
  import { ItemIconProps } from "./Button/ItemIcon";
11
11
  import { ItemProps } from "./Button/Item";
12
12
  import { ItemLabelProps } from "./Button/ItemLabel";
13
- import {
14
- defaultItemIconProps,
15
- defaultItemLabelProps,
16
- defaultItemProps,
17
- } from "./utils";
13
+ import { getItemIconProps, getItemLabelProps, getItemProps } from "./utils";
18
14
  import { useTheme } from "@applicaster/zapp-react-native-utils/theme";
19
15
 
16
+ import type { PluginConfiguration } from "./";
17
+
20
18
  import { ModalHeader } from "./Header";
21
19
 
22
20
  type ModalComponentProps = {
@@ -30,6 +28,20 @@ type ModalComponentProps = {
30
28
  maxHeight?: number;
31
29
  dismiss: () => void;
32
30
  buttonComponent?: React.ComponentType;
31
+ iconProps?: ItemIconProps | ((theme: PluginConfiguration) => ItemIconProps);
32
+ itemProps?:
33
+ | ItemProps
34
+ | ((theme: PluginConfiguration, width: number) => ItemProps);
35
+ labelProps?:
36
+ | ItemLabelProps
37
+ | ((theme: PluginConfiguration, width: number) => ItemLabelProps);
38
+ getSelectedItemIcon: (
39
+ theme: PluginConfiguration
40
+ ) => ItemIconProps["asset"] | null;
41
+ getDefaultItemIcon: (
42
+ theme: PluginConfiguration
43
+ ) => ItemIconProps["asset"] | null;
44
+ iconPlacement?: "left" | "right";
33
45
  };
34
46
 
35
47
  export function BottomSheetModalContent(props: ModalComponentProps) {
@@ -43,14 +55,20 @@ export function BottomSheetModalContent(props: ModalComponentProps) {
43
55
  summary,
44
56
  title,
45
57
  buttonComponent: ButtonComponent = Button,
58
+ getSelectedItemIcon = (theme) =>
59
+ theme.modal_bottom_sheet_item_selected_icon,
60
+ getDefaultItemIcon = () => null,
61
+ iconPlacement,
46
62
  } = props;
47
63
 
48
64
  const [headerHeight, setHeaderHeight] = useState(0);
49
65
  const route = useRef(currentRoute);
50
66
  const theme = useTheme<BaseThemePropertiesMobile>();
67
+ const paddingTop = Number(theme.modal_bottom_sheet_padding_top);
68
+ const paddingBottom = Number(theme.modal_bottom_sheet_padding_bottom);
51
69
 
52
70
  const maxContentHeight = maxHeight
53
- ? maxHeight - headerHeight - Number(theme.modal_bottom_sheet_padding_top)
71
+ ? maxHeight - headerHeight - paddingTop
54
72
  : undefined;
55
73
 
56
74
  const onHeaderLayout = useCallback((event: LayoutChangeEvent) => {
@@ -64,26 +82,30 @@ export function BottomSheetModalContent(props: ModalComponentProps) {
64
82
  }, [currentRoute]);
65
83
 
66
84
  const iconBaseProps = useMemo<ItemIconProps>(() => {
67
- return defaultItemIconProps(theme);
68
- }, [theme]);
85
+ return getItemIconProps(theme, props.iconProps);
86
+ }, [theme, props.iconProps]);
69
87
 
70
88
  const itemBaseProps = useMemo<ItemProps>(() => {
71
- return defaultItemProps(theme, props.width);
72
- }, [theme, props.width]);
89
+ return getItemProps(theme, props.width, props.itemProps);
90
+ }, [theme, props.width, props.itemProps]);
73
91
 
74
92
  const labelBaseProps = useMemo<ItemLabelProps>(() => {
75
- return defaultItemLabelProps(theme, props.width);
76
- }, [theme, props.width]);
93
+ return getItemLabelProps(theme, props.width, props.labelProps);
94
+ }, [theme, props.width, props.labelProps]);
77
95
 
78
- const handlePress = (item: any) => {
79
- onPress(item);
80
- dismiss();
81
- };
96
+ const handlePress = useCallback(
97
+ (item: any) => {
98
+ onPress(item);
99
+ dismiss();
100
+ },
101
+ [onPress, dismiss]
102
+ );
82
103
 
83
104
  return (
84
105
  <View
85
106
  style={{
86
- paddingTop: Number(theme.modal_bottom_sheet_padding_top),
107
+ maxWidth: props.width,
108
+ paddingTop,
87
109
  }}
88
110
  >
89
111
  <ModalHeader
@@ -98,8 +120,8 @@ export function BottomSheetModalContent(props: ModalComponentProps) {
98
120
  bounces={false}
99
121
  style={{ maxHeight: maxContentHeight }}
100
122
  contentContainerStyle={{
101
- paddingBottom: Number(theme.modal_bottom_sheet_padding_bottom),
102
- paddingTop: Number(theme.modal_bottom_sheet_padding_top),
123
+ paddingBottom,
124
+ paddingTop,
103
125
  }}
104
126
  >
105
127
  {items.map((item, index) => (
@@ -110,9 +132,13 @@ export function BottomSheetModalContent(props: ModalComponentProps) {
110
132
  selectedItem={current_selection}
111
133
  item={item}
112
134
  onPress={handlePress}
135
+ label={theme[item?.label] ?? item?.label}
113
136
  iconBaseProps={iconBaseProps}
114
137
  itemBaseProps={itemBaseProps}
115
138
  labelBaseProps={labelBaseProps}
139
+ selectedItemIcon={getSelectedItemIcon(theme)}
140
+ defaultItemIcon={getDefaultItemIcon(theme)}
141
+ iconPlacement={iconPlacement}
116
142
  />
117
143
  ))}
118
144
  </ScrollView>
@@ -5,7 +5,7 @@ export type ItemProps = {
5
5
  backgroundColor: string;
6
6
  focusedBackgroundColor: string;
7
7
  selectedBackgroundColor?: string;
8
- focusectedBackgroundColor?: string;
8
+ focusedSelectedBackgroundColor?: string;
9
9
  borderRadius: number;
10
10
  marginBottom: number;
11
11
  marginLeft: number;
@@ -15,6 +15,7 @@ export type ItemProps = {
15
15
  paddingBottom: number;
16
16
  paddingRight: number;
17
17
  paddingLeft: number;
18
+ maxWidth: number;
18
19
  focused?: boolean;
19
20
  selected?: boolean;
20
21
  children?: ReactChild[];
@@ -33,11 +34,11 @@ function getBackgroundColor({
33
34
  backgroundColor,
34
35
  focusedBackgroundColor,
35
36
  selectedBackgroundColor,
36
- focusectedBackgroundColor,
37
+ focusedSelectedBackgroundColor,
37
38
  }) {
38
39
  switch (true) {
39
40
  case selected && focused:
40
- return focusectedBackgroundColor;
41
+ return focusedSelectedBackgroundColor;
41
42
  case selected && !focused:
42
43
  return selectedBackgroundColor;
43
44
  case !selected && focused:
@@ -51,7 +52,7 @@ export function Item(props: ItemProps) {
51
52
  const {
52
53
  backgroundColor,
53
54
  focusedBackgroundColor,
54
- focusectedBackgroundColor,
55
+ focusedSelectedBackgroundColor,
55
56
  selectedBackgroundColor,
56
57
  children,
57
58
  focused,
@@ -68,7 +69,7 @@ export function Item(props: ItemProps) {
68
69
  backgroundColor: getBackgroundColor({
69
70
  selected,
70
71
  focused,
71
- focusectedBackgroundColor,
72
+ focusedSelectedBackgroundColor,
72
73
  focusedBackgroundColor,
73
74
  selectedBackgroundColor,
74
75
  backgroundColor,
@@ -1,4 +1,4 @@
1
1
  /* eslint-disable max-len */
2
2
 
3
3
  export const defaultSelectedAsset: string =
4
- "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEgAAABICAYAAABV7bNHAAAACXBIWXMAACE4AAAhOAFFljFgAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAGsSURBVHgB7drdaYRAFIbhk2yuBTuwlXSQDrKdrOnErSSlpATBe0nOBxEMEXV+nDnjfg8MwiK4vKjMDIoQERERERERERHRY+j7vtHxJvTfb5wvHd/DMLyLpyc5IcTRw6eOZvrtcrlcq6q6i6PTBVqKM/GJdKpAa3EmrpGe5ST2xIFxHF/FwSnuoL1x1L2u66s4KD7QkXGg6EBHx4FiA6WIA0UGShUHiguUMg4UFSh1HCgmUI44UESgXHEgaCatf/wWslLeeY1GMsWBF/GEOHpodeouGkl8Vso7rtFIxjjg9YhNcea/+W4nrFyjkcxxwDnQUpxJrEhW4oBToLU4k9BIluKA60t6M6i+kzrfF7e1OODziLV6uG2d53onWYwDvi/pViJGshoHvCeKsSJZjgNBM+nQSNbjQPBSwzdSCXEgylrMNVIpcSDaYnVvJPWhA9OAZuO87HEg6mreIdIWE3Eg+nZHhEhm4sAh+0EBkUzFgcM2zDwimYsDh+4oOkQyGQcO33LdEclsHEiyJ70SyXScpBAJX3vNRif01yxSJ7SMH1USEREREREREREV7Ad//SBSU+GIIAAAAABJRU5ErkJggg==";
4
+ "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEgAAABICAYAAABV7bNHAAAACXBIWXMAACE4AAAhOAFFljFgAAAA+0lEQVR4nO3a3QnCQBBF4ZRiSXZgKVqKnVnCQBpQwb0QJA752ZjszPlg3/JwOU8b2K4DAAAAAAAAkIOZnczsvPeOQypxHmb27Pv+sveeQxnG0SFSMRaHSIUXJ32kKXHKue+99e+I4yCOgzgO4jiI4yCOgzgO4jiajfMedd366t50nK3/b0LE2SpSqDi1I4WMUytSs3G6z/jbhOGLIzUdR7aKFCKO1I4UKo7UihQyjqyNFDqOLI2UIo7MjZQqjkyNVL7LFUdmRMoXRypEihtHVkSKH0cWRMoTR2ZEyhdHJkTKG0ecSMSRkUjE+TaIRJxfeFQJAAAAAAAANOwFT0Mt2UgcaMoAAAAASUVORK5CYII=";