Fresh history cut from cynarAI/evoo antigravity-handoff/project-timeline (Voice First + project timeline). Brand docs/titles as evOo; keep @rakazo/* packages as tech debt. Excludes node_modules, caches, secrets, voice blobs.
44 lines
1.2 KiB
TypeScript
44 lines
1.2 KiB
TypeScript
import { ActionSheetIOS, Alert, Platform } from "react-native";
|
|
|
|
type MessageAction = { text: string; onPress: () => void };
|
|
|
|
export function presentMessageActionSheet({
|
|
actions,
|
|
title,
|
|
cancel,
|
|
more,
|
|
colorScheme,
|
|
}: {
|
|
actions: MessageAction[];
|
|
title?: string;
|
|
cancel: string;
|
|
more: string;
|
|
colorScheme: "light" | "dark";
|
|
}): void {
|
|
if (Platform.OS === "ios") {
|
|
ActionSheetIOS.showActionSheetWithOptions(
|
|
{
|
|
options: [...actions.map((action) => action.text), cancel],
|
|
cancelButtonIndex: actions.length,
|
|
title,
|
|
userInterfaceStyle: colorScheme,
|
|
},
|
|
(index) => actions[index]?.onPress(),
|
|
);
|
|
return;
|
|
}
|
|
|
|
function showPage(remaining: MessageAction[]) {
|
|
// Android alerts support three buttons. Back/outside tap dismisses every page.
|
|
const buttons =
|
|
remaining.length > 3
|
|
? [...remaining.slice(0, 2), { text: more, onPress: () => showPage(remaining.slice(2)) }]
|
|
: [
|
|
...remaining,
|
|
...(remaining.length < 3 ? [{ text: cancel, style: "cancel" as const }] : []),
|
|
];
|
|
Alert.alert(title ?? "", undefined, buttons, { cancelable: true });
|
|
}
|
|
showPage(actions);
|
|
}
|