Verwendung

Offer actions for an item

Dieser Typ wird verwendet von actionSheet

tsx
import { Pressable, Text, actionSheet } from 'kuito';

export function EpisodeMenu(props: {
  id: string;
  title: string;
  onDelete: (id: string) => Promise<void>;
}) {
  const remove = { text: 'Delete', style: 'destructive' } as const;

  return (
    <Pressable
      onPress={async (event) => {
        const picked = await actionSheet({
          buttons: [
            { text: 'Share' },
            { text: 'Add to list' },
            remove,
            { text: 'Cancel', style: 'cancel' },
          ],
          title: props.title,
          anchor: { x: event.pageX ?? 0, y: event.pageY ?? 0 },
        });

        if (picked === remove) await props.onDelete(props.id);
      }}
    >
      <Text>More</Text>
    </Pressable>
  );
}

Typdeklaration

ts
export type ActionSheetButton = {
  text: string;
  /**
   * `cancel` is shown apart, at the bottom, and is what dismissing the sheet
   * picks; at most one button is `cancel`. `destructive` is drawn in red.
   */
  style?: AlertButtonStyle;
  /** Shown dimmed; it can't be picked. */
  disabled?: boolean;
};

Mitglieder 3

NameTypErforderlichBeschreibung
textstringJa—
styleAlertButtonStyleNeincancel is shown apart, at the bottom, and is what dismissing the sheet picks; at most one button is cancel. destructive is drawn in red.
disabledbooleanNeinShown dimmed; it can't be picked.
Generiert aus den öffentlichen TypeScript-Deklarationen: Signaturen, Props und Standardwerte stammen aus der geprüften Quelle, Beschreibungen aus deren JSDoc. Kein Standardwert ist erfunden.