import { createLogger } from "@applicaster/zapp-react-native-utils/logger"; import { openBottomSheetModal } from "@applicaster/zapp-react-native-utils/modalState"; import { noop } from "@applicaster/zapp-react-native-utils/functionUtils"; import { RegisteredAction } from "@applicaster/zapp-react-native-utils/uiActionsRegistrator"; import { boundActionButton } from "./boundActionButton"; const { log_warning } = createLogger({ subsystem: "ActionsBottomSheet", category: "Presentation", }); export type OpenActionsBottomSheetArgs = { /** Entry the actions act on; bound into every row button. */ entry: ZappEntry | ZappFeed; /** Already resolved and merged actions, in the order they should appear. */ actions: RegisteredAction[]; title?: string; summary?: string; /** List that opened the sheet; forwarded into row invokeAction context. */ component?: ZappUIComponent & { parent?: ZappUIComponent }; }; /** * Presents a list of resolved actions in the shared bottom sheet. * * This is the core entry point for "show these actions in a sheet": the * open-modal-bottom-sheet plugin uses it for its configured list, and the * player overflow uses it for the actions that did not fit on the overlay. * Neither has to know about the other, and neither needs the plugin installed. */ export function openActionsBottomSheet({ entry, actions, title, summary, component, }: OpenActionsBottomSheetArgs): void { if (!actions?.length) { // Every action resolved away - unavailable for this entry, or not // invokable. An empty sheet looks broken, so say why and stay put. log_warning( "openActionsBottomSheet: nothing to present - not opening the sheet", { entryId: (entry as ZappEntry)?.id } ); return; } openBottomSheetModal({ modalBottomSheetContentProps: { // TODO: should be optional - the button handles its own tap, but // BottomSheetModalContent still requires an onPress. onPress: noop, items: actions, buttonComponent: boundActionButton(entry, component), title, summary, }, }); }