showModal(params: Object)

Requires:
BaseKit≥2.0.1@ray-js/ray≥0.3.23
Platforms:
iOSAndroid
import { showModal } from '@ray-js/ray';

// Promise usage
try {
  const res = await showModal({ ...params });
  console.log(res);
} catch (err) {
  console.log(err.errorMsg);
}

Description

Show a modal dialog

Parameters

PropertyTypeRequiredDefaultDescriptionBaseKit Since
titlestringYes-Title-
contentstringNo-Content-
showCancelbooleanNotrueWhether to show a cancel button-
cancelTextstringNo"cancel"Text of the cancel button, up to 4 characters-
cancelColorstringNo-Cancel button text color, must be a hexadecimal color string-
confirmTextstringNo"confirm"Text of the confirm button, up to 4 characters-
confirmColorstringNo-Confirm button text color, must be a hexadecimal color string-
isShowGlobalbooleanNofalseWhether it's a global dialog; if so, it appears on topv3.14.3
modalStyle0 | 1No0Dialog stylev3.21.2
No-Dialog input field propertiesv3.21.2
complete() => voidNo-Completion callback (executed on both success and failure)-
success(params: Object) => voidNo-Callback on successful API call-
fail(params: Object) => voidNo-Failure callback-
success callback parameters
PropertyTypeDescriptionBaseKit Since
confirmbooleantrue indicates the user tapped the confirm buttonv3.2.6
cancelbooleantrue indicates the user tapped Cancel (used on Android to distinguish mask tap from cancel button)v3.2.6
inputContentstringInput valuev3.21.2
fail callback parameters
PropertyTypeDescription
errorMsgstringError message
errorCodestring | numberError code
Error extension

Return Value

None

Valid Values

modalStyle
ValueDescriptionBaseKit Since
0Default stylev3.21.2
1Input stylev3.21.2

Examples

import { showModal } from '@ray-js/ray'

// Show a modal dialog; the callback returns whether the user tapped confirm or cancel
showModal({
  title: "Prompt",
  content: "Are you sure you want to proceed?",
  showCancel: true,
  cancelText: "Cancel",
  confirmText: "Confirm",
  success: data => console.log("confirm:", data.confirm, "cancel:", data.cancel),
  fail: error => console.error(error),
});