@applicaster/zapp-react-native-ui-components 15.1.13-alpha.1034774223 → 15.1.13
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/MasterCell/DefaultComponents/ActionButton.tsx +1 -0
- package/Components/MasterCell/DefaultComponents/Button.tsx +1 -0
- package/Components/ModalComponent/AudioPlayer/Components/Action.tsx +87 -33
- package/Components/ModalComponent/AudioPlayer/Components/Button.tsx +74 -57
- package/Components/ModalComponent/AudioPlayer/Components/Header.tsx +107 -142
- package/Components/ModalComponent/AudioPlayer/Components/Item.tsx +159 -410
- package/Components/ModalComponent/AudioPlayer/Components/index.ts +4 -8
- package/Components/ModalComponent/BottomSheetModalContent.tsx +61 -379
- package/Components/ModalComponent/Button/index.tsx +3 -5
- package/Components/ModalComponent/Header/CloseButton.tsx +12 -0
- package/Components/ModalComponent/Header/__tests__/CloseButton.test.tsx +72 -0
- package/Components/ModalComponent/Header/index.tsx +7 -20
- package/Components/ModalComponent/Header/utils.ts +1 -1
- package/Components/ModalComponent/index.tsx +0 -11
- package/Components/ModalComponent/utils.ts +21 -82
- package/package.json +5 -6
- package/Components/ModalComponent/ActionsBottomSheet/ActionButton.tsx +0 -54
- package/Components/ModalComponent/ActionsBottomSheet/boundActionButton.tsx +0 -21
- package/Components/ModalComponent/ActionsBottomSheet/index.ts +0 -9
- package/Components/ModalComponent/ActionsBottomSheet/openActionsBottomSheet.ts +0 -58
- package/Components/ModalComponent/AudioPlayer/Components/Input.tsx +0 -653
- package/Components/ModalComponent/AudioPlayer/Components/NowPlayingHeaderSection.tsx +0 -89
- package/Components/ModalComponent/AudioPlayer/utils/__tests__/mergeStyles.test.ts +0 -230
- package/Components/ModalComponent/AudioPlayer/utils/mergeStyles.ts +0 -332
- package/Components/ModalComponent/ModalBlocksStyleContext.tsx +0 -10
- package/Components/ModalComponent/SortableList.tsx +0 -142
- package/Components/ModalComponent/SortableList.web.tsx +0 -102
- package/Components/ModalComponent/TextInputContent.tsx +0 -100
- package/Components/ModalComponent/__tests__/BottomSheetModalContent.test.tsx +0 -238
- package/Components/ModalComponent/__tests__/TextInputContent.test.tsx +0 -120
- package/Components/ModalComponent/__tests__/showTextInput.test.ts +0 -95
- package/Components/ModalComponent/presets/__tests__/getCell.test.ts +0 -66
- package/Components/ModalComponent/presets/dynamicCollectionCell.tsx +0 -78
- package/Components/ModalComponent/presets/index.ts +0 -27
- package/Components/ModalComponent/presets/selectableCell.tsx +0 -28
- package/Components/ModalComponent/presets/standardCell.tsx +0 -41
- package/Components/ModalComponent/presets/types.ts +0 -35
- package/Components/ModalComponent/showTextInput.ts +0 -43
- package/Hooks/useEntryActionsExpander.ts +0 -63
- /package/Decorators/ZappPipesDataConnector/__tests__/{Hero.tsx → Hero.js} +0 -0
|
@@ -4,7 +4,6 @@ import { Title, TitleProps } from "./Title";
|
|
|
4
4
|
import { CloseButton, CloseButtonProps } from "./CloseButton";
|
|
5
5
|
import { getCloseButtonProps, getTitleProps } from "./utils";
|
|
6
6
|
import { PluginConfiguration } from "../index";
|
|
7
|
-
import { useModalBlocksStyle } from "../ModalBlocksStyleContext";
|
|
8
7
|
|
|
9
8
|
type Props = {
|
|
10
9
|
dismiss: () => void;
|
|
@@ -29,14 +28,6 @@ const styles = StyleSheet.create({
|
|
|
29
28
|
|
|
30
29
|
export function ModalHeader(props: Props) {
|
|
31
30
|
const { configuration, dismiss, onLayout, summary, title } = props;
|
|
32
|
-
const modalBlocksStyle = useModalBlocksStyle();
|
|
33
|
-
const headerBlock = modalBlocksStyle?.header;
|
|
34
|
-
|
|
35
|
-
const containerStyle = useMemo(() => {
|
|
36
|
-
const bg = headerBlock?.container?.default?.backgroundColor;
|
|
37
|
-
|
|
38
|
-
return [styles.container, bg ? { backgroundColor: bg } : null];
|
|
39
|
-
}, [headerBlock?.container?.default?.backgroundColor]);
|
|
40
31
|
|
|
41
32
|
const closeButtonProps = useMemo<CloseButtonProps>(
|
|
42
33
|
() => ({
|
|
@@ -46,17 +37,13 @@ export function ModalHeader(props: Props) {
|
|
|
46
37
|
[configuration, dismiss]
|
|
47
38
|
);
|
|
48
39
|
|
|
49
|
-
const titleProps = useMemo<TitleProps>(
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
return {
|
|
54
|
-
...baseProps,
|
|
40
|
+
const titleProps = useMemo<TitleProps>(
|
|
41
|
+
() => ({
|
|
42
|
+
...getTitleProps(configuration, "title"),
|
|
55
43
|
text: title,
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}, [configuration, title, headerBlock?.title?.default]);
|
|
44
|
+
}),
|
|
45
|
+
[configuration, title]
|
|
46
|
+
);
|
|
60
47
|
|
|
61
48
|
const summaryProps = useMemo<TitleProps>(
|
|
62
49
|
() => ({
|
|
@@ -72,7 +59,7 @@ export function ModalHeader(props: Props) {
|
|
|
72
59
|
configuration.modal_bottom_sheet_close_margin_right;
|
|
73
60
|
|
|
74
61
|
return (
|
|
75
|
-
<View onLayout={onLayout} style={
|
|
62
|
+
<View onLayout={onLayout} style={styles.container}>
|
|
76
63
|
<View style={styles.flex}>
|
|
77
64
|
{title ? <Title {...titleProps} /> : null}
|
|
78
65
|
{summary ? <Title {...summaryProps} /> : null}
|
|
@@ -18,7 +18,7 @@ export function getCloseButtonProps(config: PluginConfiguration) {
|
|
|
18
18
|
return {
|
|
19
19
|
asset: modal_bottom_sheet_close_asset,
|
|
20
20
|
assetFocused: modal_bottom_sheet_close_focus_asset,
|
|
21
|
-
enabled: modal_bottom_sheet_close_switch
|
|
21
|
+
enabled: modal_bottom_sheet_close_switch,
|
|
22
22
|
width: modal_bottom_sheet_close_width,
|
|
23
23
|
height: modal_bottom_sheet_close_height,
|
|
24
24
|
marginTop: modal_bottom_sheet_close_margin_top,
|
|
@@ -1,18 +1,7 @@
|
|
|
1
1
|
import React, { useCallback, useState } from "react";
|
|
2
|
-
import { actionExecutor } from "@applicaster/zapp-react-native-utils/actionsExecutor/ActionExecutor";
|
|
3
2
|
|
|
4
3
|
import { BasicMeasurementsPortal as MeasurementsPortal } from "@applicaster/zapp-react-native-ui-components/Components/MeasurmentsPortal";
|
|
5
4
|
import { BottomSheetModalContent } from "./BottomSheetModalContent";
|
|
6
|
-
import { showTextInputAction } from "./showTextInput";
|
|
7
|
-
|
|
8
|
-
actionExecutor.registerAction("showTextInput", showTextInputAction);
|
|
9
|
-
|
|
10
|
-
export { SortableList, type SortableListProps } from "./SortableList";
|
|
11
|
-
|
|
12
|
-
export {
|
|
13
|
-
TextInputContent,
|
|
14
|
-
type TextInputContentProps,
|
|
15
|
-
} from "./TextInputContent";
|
|
16
5
|
|
|
17
6
|
export type PluginConfiguration = {
|
|
18
7
|
[key: string]: any;
|
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
import { platformSelect } from "@applicaster/zapp-react-native-utils/reactUtils";
|
|
2
|
-
import {
|
|
3
|
-
toNumberWithDefault,
|
|
4
|
-
toNumberWithDefaultZero,
|
|
5
|
-
} from "@applicaster/zapp-react-native-utils/numberUtils";
|
|
6
2
|
import { PluginConfiguration } from "./";
|
|
7
3
|
import { ItemIconProps } from "./Button/ItemIcon";
|
|
8
4
|
import { ItemLabelProps } from "./Button/ItemLabel";
|
|
@@ -10,8 +6,7 @@ import { ItemProps } from "./Button/Item";
|
|
|
10
6
|
|
|
11
7
|
export function defaultItemProps(
|
|
12
8
|
config: PluginConfiguration,
|
|
13
|
-
maxWidth: number
|
|
14
|
-
blockItemStyle?: Record<string, any>
|
|
9
|
+
maxWidth: number
|
|
15
10
|
): ItemProps {
|
|
16
11
|
const {
|
|
17
12
|
modal_bottom_sheet_item_background_color,
|
|
@@ -29,36 +24,19 @@ export function defaultItemProps(
|
|
|
29
24
|
modal_bottom_sheet_item_padding_top,
|
|
30
25
|
} = config;
|
|
31
26
|
|
|
32
|
-
const bgDefault = blockItemStyle?.background?.default;
|
|
33
|
-
|
|
34
|
-
const bgFocused =
|
|
35
|
-
blockItemStyle?.background?.focused || blockItemStyle?.background?.focus;
|
|
36
|
-
|
|
37
27
|
return {
|
|
38
|
-
backgroundColor:
|
|
39
|
-
|
|
40
|
-
focusedBackgroundColor:
|
|
41
|
-
bgFocused?.backgroundColor ||
|
|
42
|
-
modal_bottom_sheet_item_focus_background_color,
|
|
28
|
+
backgroundColor: modal_bottom_sheet_item_background_color,
|
|
29
|
+
focusedBackgroundColor: modal_bottom_sheet_item_focus_background_color,
|
|
43
30
|
selectedBackgroundColor: modal_bottom_sheet_item_selected_background_color,
|
|
44
31
|
focusedSelectedBackgroundColor:
|
|
45
32
|
modal_bottom_sheet_item_focused_selected_background_color,
|
|
46
|
-
borderRadius:
|
|
47
|
-
modal_bottom_sheet_item_corner_radius,
|
|
48
|
-
bgDefault?.borderRadius
|
|
49
|
-
),
|
|
33
|
+
borderRadius: modal_bottom_sheet_item_corner_radius,
|
|
50
34
|
marginBottom: modal_bottom_sheet_item_margin_bottom,
|
|
51
35
|
marginTop: modal_bottom_sheet_item_margin_top,
|
|
52
36
|
marginLeft: modal_bottom_sheet_item_margin_left,
|
|
53
37
|
marginRight: modal_bottom_sheet_item_margin_right,
|
|
54
|
-
paddingTop:
|
|
55
|
-
|
|
56
|
-
bgDefault?.paddingTop
|
|
57
|
-
),
|
|
58
|
-
paddingBottom: toNumberWithDefault(
|
|
59
|
-
modal_bottom_sheet_item_padding_bottom,
|
|
60
|
-
bgDefault?.paddingBottom
|
|
61
|
-
),
|
|
38
|
+
paddingTop: modal_bottom_sheet_item_padding_top,
|
|
39
|
+
paddingBottom: modal_bottom_sheet_item_padding_bottom,
|
|
62
40
|
paddingRight: modal_bottom_sheet_item_padding_right,
|
|
63
41
|
paddingLeft: modal_bottom_sheet_item_padding_left,
|
|
64
42
|
maxWidth,
|
|
@@ -67,8 +45,7 @@ export function defaultItemProps(
|
|
|
67
45
|
|
|
68
46
|
export function defaultItemLabelProps(
|
|
69
47
|
config: PluginConfiguration,
|
|
70
|
-
sheetWidth: number
|
|
71
|
-
blockItemStyle?: Record<string, any>
|
|
48
|
+
sheetWidth: number
|
|
72
49
|
): ItemLabelProps {
|
|
73
50
|
const {
|
|
74
51
|
modal_bottom_sheet_item_label_android_letter_spacing,
|
|
@@ -95,48 +72,15 @@ export function defaultItemLabelProps(
|
|
|
95
72
|
modal_bottom_sheet_item_padding_right,
|
|
96
73
|
} = config;
|
|
97
74
|
|
|
98
|
-
const iconWidth = toNumberWithDefaultZero(modal_bottom_sheet_item_icon_width);
|
|
99
|
-
|
|
100
|
-
const iconMarginLeft = toNumberWithDefaultZero(
|
|
101
|
-
modal_bottom_sheet_item_icon_margin_left
|
|
102
|
-
);
|
|
103
|
-
|
|
104
|
-
const iconMarginRight = toNumberWithDefaultZero(
|
|
105
|
-
modal_bottom_sheet_item_icon_margin_right
|
|
106
|
-
);
|
|
107
|
-
|
|
108
|
-
const itemMarginLeft = toNumberWithDefaultZero(
|
|
109
|
-
modal_bottom_sheet_item_margin_left
|
|
110
|
-
);
|
|
111
|
-
|
|
112
|
-
const itemMarginRight = toNumberWithDefaultZero(
|
|
113
|
-
modal_bottom_sheet_item_margin_right
|
|
114
|
-
);
|
|
115
|
-
|
|
116
|
-
const itemPaddingLeft = toNumberWithDefaultZero(
|
|
117
|
-
modal_bottom_sheet_item_padding_left
|
|
118
|
-
);
|
|
119
|
-
|
|
120
|
-
const itemPaddingRight = toNumberWithDefaultZero(
|
|
121
|
-
modal_bottom_sheet_item_padding_right
|
|
122
|
-
);
|
|
123
|
-
|
|
124
|
-
const calculatedMaxWidth =
|
|
125
|
-
sheetWidth -
|
|
126
|
-
(iconWidth +
|
|
127
|
-
iconMarginLeft +
|
|
128
|
-
iconMarginRight +
|
|
129
|
-
itemMarginLeft +
|
|
130
|
-
itemMarginRight +
|
|
131
|
-
itemPaddingLeft +
|
|
132
|
-
itemPaddingRight);
|
|
133
|
-
|
|
134
75
|
const maxWidth =
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
76
|
+
sheetWidth -
|
|
77
|
+
(modal_bottom_sheet_item_icon_width +
|
|
78
|
+
modal_bottom_sheet_item_icon_margin_left +
|
|
79
|
+
modal_bottom_sheet_item_icon_margin_right +
|
|
80
|
+
modal_bottom_sheet_item_margin_left +
|
|
81
|
+
modal_bottom_sheet_item_margin_right +
|
|
82
|
+
modal_bottom_sheet_item_padding_left +
|
|
83
|
+
modal_bottom_sheet_item_padding_right);
|
|
140
84
|
|
|
141
85
|
return {
|
|
142
86
|
fontFamily: platformSelect({
|
|
@@ -147,11 +91,8 @@ export function defaultItemLabelProps(
|
|
|
147
91
|
ios: modal_bottom_sheet_item_label_ios_letter_spacing,
|
|
148
92
|
android: modal_bottom_sheet_item_label_android_letter_spacing,
|
|
149
93
|
}),
|
|
150
|
-
fontSize:
|
|
151
|
-
|
|
152
|
-
label1Default?.fontSize
|
|
153
|
-
),
|
|
154
|
-
color: label1Default?.fontColor || modal_bottom_sheet_item_label_font_color,
|
|
94
|
+
fontSize: modal_bottom_sheet_item_label_font_size,
|
|
95
|
+
color: modal_bottom_sheet_item_label_font_color,
|
|
155
96
|
focusColor: modal_bottom_sheet_item_label_focus_font_color,
|
|
156
97
|
hoverSelectedColor: modal_bottom_sheet_item_label_hover_selected_font_color,
|
|
157
98
|
selectedColor: modal_bottom_sheet_item_label_selected_font_color,
|
|
@@ -205,8 +146,7 @@ export function getItemLabelProps(
|
|
|
205
146
|
width: number,
|
|
206
147
|
labelProps?:
|
|
207
148
|
| ((theme: PluginConfiguration, width: number) => ItemLabelProps)
|
|
208
|
-
| ItemLabelProps
|
|
209
|
-
blockItemStyle?: Record<string, any>
|
|
149
|
+
| ItemLabelProps
|
|
210
150
|
) {
|
|
211
151
|
if (labelProps) {
|
|
212
152
|
return typeof labelProps === "function"
|
|
@@ -214,7 +154,7 @@ export function getItemLabelProps(
|
|
|
214
154
|
: labelProps;
|
|
215
155
|
}
|
|
216
156
|
|
|
217
|
-
return defaultItemLabelProps(theme, width
|
|
157
|
+
return defaultItemLabelProps(theme, width);
|
|
218
158
|
}
|
|
219
159
|
|
|
220
160
|
export function getItemProps(
|
|
@@ -222,8 +162,7 @@ export function getItemProps(
|
|
|
222
162
|
width: number,
|
|
223
163
|
itemProps?:
|
|
224
164
|
| ((theme: PluginConfiguration, width: number) => ItemProps)
|
|
225
|
-
| ItemProps
|
|
226
|
-
blockItemStyle?: Record<string, any>
|
|
165
|
+
| ItemProps
|
|
227
166
|
) {
|
|
228
167
|
if (itemProps) {
|
|
229
168
|
return typeof itemProps === "function"
|
|
@@ -231,5 +170,5 @@ export function getItemProps(
|
|
|
231
170
|
: itemProps;
|
|
232
171
|
}
|
|
233
172
|
|
|
234
|
-
return defaultItemProps(theme, width
|
|
173
|
+
return defaultItemProps(theme, width);
|
|
235
174
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applicaster/zapp-react-native-ui-components",
|
|
3
|
-
"version": "15.1.13
|
|
3
|
+
"version": "15.1.13",
|
|
4
4
|
"description": "Applicaster Zapp React Native ui components for the Quick Brick App",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -28,13 +28,12 @@
|
|
|
28
28
|
},
|
|
29
29
|
"homepage": "https://github.com/applicaster/quickbrick#readme",
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@applicaster/applicaster-types": "15.1.13
|
|
32
|
-
"@applicaster/zapp-react-native-bridge": "15.1.13
|
|
33
|
-
"@applicaster/zapp-react-native-redux": "15.1.13
|
|
34
|
-
"@applicaster/zapp-react-native-utils": "15.1.13
|
|
31
|
+
"@applicaster/applicaster-types": "15.1.13",
|
|
32
|
+
"@applicaster/zapp-react-native-bridge": "15.1.13",
|
|
33
|
+
"@applicaster/zapp-react-native-redux": "15.1.13",
|
|
34
|
+
"@applicaster/zapp-react-native-utils": "15.1.13",
|
|
35
35
|
"fast-json-stable-stringify": "^2.1.0",
|
|
36
36
|
"promise": "^8.3.0",
|
|
37
|
-
"react-native-sortables": "1.7.1",
|
|
38
37
|
"url": "^0.11.0",
|
|
39
38
|
"uuid": "^3.3.2"
|
|
40
39
|
},
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { useEntryActionState } from "@applicaster/zapp-react-native-utils/reactHooks/actions";
|
|
3
|
-
import {
|
|
4
|
-
isActionAvailableFor,
|
|
5
|
-
RegisteredAction,
|
|
6
|
-
} from "@applicaster/zapp-react-native-utils/uiActionsRegistrator";
|
|
7
|
-
|
|
8
|
-
import { Button } from "../Button";
|
|
9
|
-
|
|
10
|
-
export type ActionButtonProps = {
|
|
11
|
-
entry: ZappEntry;
|
|
12
|
-
item: RegisteredAction;
|
|
13
|
-
configuration: any;
|
|
14
|
-
width: number;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
type Props = ActionButtonProps & {
|
|
18
|
-
onPress?: (item: any) => void;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Unified action button for the modal bottom sheet.
|
|
23
|
-
*
|
|
24
|
-
* Every item is a `RegisteredAction` resolved from the registry (entry actions,
|
|
25
|
-
* registry actions and legacy context-provider actions alike), so the button
|
|
26
|
-
* simply reads `item.action` and drives it through `useEntryActionState`
|
|
27
|
-
* (backed by the action's observable / `addListener`).
|
|
28
|
-
*/
|
|
29
|
-
export function ActionButton(props: Props) {
|
|
30
|
-
const { item, entry, onPress: onItemPress } = props;
|
|
31
|
-
|
|
32
|
-
const action = item?.action;
|
|
33
|
-
|
|
34
|
-
const { state, invokeAction } = useEntryActionState(action, entry);
|
|
35
|
-
|
|
36
|
-
const onPress = React.useCallback(
|
|
37
|
-
(_item) => {
|
|
38
|
-
invokeAction({
|
|
39
|
-
context: "toast",
|
|
40
|
-
dismiss: () => onItemPress?.(item),
|
|
41
|
-
});
|
|
42
|
-
},
|
|
43
|
-
[invokeAction, item, onItemPress]
|
|
44
|
-
);
|
|
45
|
-
|
|
46
|
-
if (!isActionAvailableFor(action, entry as ZappEntry)) return null;
|
|
47
|
-
|
|
48
|
-
return (
|
|
49
|
-
<Button {...props} item={state} onPress={onPress} label={state?.label} />
|
|
50
|
-
);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
// Explicitly set display name for the component
|
|
54
|
-
ActionButton.displayName = "ActionButton";
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
|
|
3
|
-
import { ActionButton, ActionButtonProps } from "./ActionButton";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Binds an entry to the sheet's row button.
|
|
7
|
-
*
|
|
8
|
-
* `BottomSheetModalContent` renders `buttonComponent` per item and does not
|
|
9
|
-
* know about entries, so the entry is closed over here instead.
|
|
10
|
-
*/
|
|
11
|
-
export const boundActionButton = (entry: ZappEntry | ZappFeed) => {
|
|
12
|
-
const ActionButtonWithEntry = (props: ActionButtonProps) => (
|
|
13
|
-
<ActionButton {...props} entry={entry as ZappEntry} />
|
|
14
|
-
);
|
|
15
|
-
|
|
16
|
-
ActionButtonWithEntry.displayName = "ActionButtonWithEntry";
|
|
17
|
-
|
|
18
|
-
return ActionButtonWithEntry;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
boundActionButton.displayName = "boundActionButton";
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export { ActionButton } from "./ActionButton";
|
|
2
|
-
|
|
3
|
-
export type { ActionButtonProps } from "./ActionButton";
|
|
4
|
-
|
|
5
|
-
export { boundActionButton } from "./boundActionButton";
|
|
6
|
-
|
|
7
|
-
export { openActionsBottomSheet } from "./openActionsBottomSheet";
|
|
8
|
-
|
|
9
|
-
export type { OpenActionsBottomSheetArgs } from "./openActionsBottomSheet";
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { createLogger } from "@applicaster/zapp-react-native-utils/logger";
|
|
2
|
-
import { openBottomSheetModal } from "@applicaster/zapp-react-native-utils/modalState";
|
|
3
|
-
import { noop } from "@applicaster/zapp-react-native-utils/functionUtils";
|
|
4
|
-
import { RegisteredAction } from "@applicaster/zapp-react-native-utils/uiActionsRegistrator";
|
|
5
|
-
|
|
6
|
-
import { boundActionButton } from "./boundActionButton";
|
|
7
|
-
|
|
8
|
-
const { log_warning } = createLogger({
|
|
9
|
-
subsystem: "ActionsBottomSheet",
|
|
10
|
-
category: "Presentation",
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
export type OpenActionsBottomSheetArgs = {
|
|
14
|
-
/** Entry the actions act on; bound into every row button. */
|
|
15
|
-
entry: ZappEntry | ZappFeed;
|
|
16
|
-
/** Already resolved and merged actions, in the order they should appear. */
|
|
17
|
-
actions: RegisteredAction[];
|
|
18
|
-
title?: string;
|
|
19
|
-
summary?: string;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Presents a list of resolved actions in the shared bottom sheet.
|
|
24
|
-
*
|
|
25
|
-
* This is the core entry point for "show these actions in a sheet": the
|
|
26
|
-
* open-modal-bottom-sheet plugin uses it for its configured list, and the
|
|
27
|
-
* player overflow uses it for the actions that did not fit on the overlay.
|
|
28
|
-
* Neither has to know about the other, and neither needs the plugin installed.
|
|
29
|
-
*/
|
|
30
|
-
export function openActionsBottomSheet({
|
|
31
|
-
entry,
|
|
32
|
-
actions,
|
|
33
|
-
title,
|
|
34
|
-
summary,
|
|
35
|
-
}: OpenActionsBottomSheetArgs): void {
|
|
36
|
-
if (!actions?.length) {
|
|
37
|
-
// Every action resolved away - unavailable for this entry, or not
|
|
38
|
-
// invokable. An empty sheet looks broken, so say why and stay put.
|
|
39
|
-
log_warning(
|
|
40
|
-
"openActionsBottomSheet: nothing to present - not opening the sheet",
|
|
41
|
-
{ entryId: (entry as ZappEntry)?.id }
|
|
42
|
-
);
|
|
43
|
-
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
openBottomSheetModal({
|
|
48
|
-
modalBottomSheetContentProps: {
|
|
49
|
-
// TODO: should be optional - the button handles its own tap, but
|
|
50
|
-
// BottomSheetModalContent still requires an onPress.
|
|
51
|
-
onPress: noop,
|
|
52
|
-
items: actions,
|
|
53
|
-
buttonComponent: boundActionButton(entry),
|
|
54
|
-
title,
|
|
55
|
-
summary,
|
|
56
|
-
},
|
|
57
|
-
});
|
|
58
|
-
}
|