1.0.2 • Published 9 months ago

expo-dialogs v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

expo-dialogs

Create native Android dialogs with Expo. This library is a wrapper around the native Android dialogs. Only a few dialog types are supported at the moment.

Installation

npx expo install expo-dialogs

Usage

Show dialog

This Dialog is quite similair to the Alert.alert() method in React Native.

import * as ExpoDialogs from "expo-dialogs";

const result = await ExpoDialogs.showDialog({
  title: "Hello World",
  message: "This is a message",
  positiveButtonText: "OK",
  negativeButtonText: "Cancel",
});

// result is true if the positive button was clicked, false if the negative button was clicked
console.log("Dialog result:", result);

Show selection dialog

import * as ExpoDialogs from "expo-dialogs";

const result = await ExpoDialogs.showSelectionDialog({
  options: ["Option 1", "Option 2", "Option 3"],
  title: "Hello World",
  negativeButtonText: "Cancel",
});

console.log("Selected index:", result);

Show radio button dialog

import * as ExpoDialogs from "expo-dialogs";

const result = await ExpoDialogs.showRadioButtonDialog({
  options: ["Option 1", "Option 2", "Option 3"],
  title: "Hello World",
  selectedIndex: 1,
  negativeButtonText: "Cancel",
});

console.log("Selected index:", result);

Show checkbox dialog

import * as ExpoDialogs from "expo-dialogs";

const result = await ExpoDialogs.showCheckboxDialog({
  options: ["Option 1", "Option 2", "Option 3"],
  title: "Hello World",
  selectedIndices: [1],
  negativeButtonText: "Cancel",
});

console.log(`Selected indices: ${JSON.stringify(result)}`);
1.0.2

9 months ago

1.0.0

10 months ago

0.2.0

10 months ago

0.1.0

1 year ago