mirror of
https://github.com/status-im/react-native.git
synced 2025-02-07 23:25:41 +00:00
Summary:Updated docs: ![screen shot 2016-03-27 at 12 41 02](https://cloud.githubusercontent.com/assets/3316532/14066504/35509612-f419-11e5-923f-e354ad939ee5.png) Closes https://github.com/facebook/react-native/pull/6685 Differential Revision: D3119791 Pulled By: javache fb-gh-sync-id: fadd5ea1a1b979f79b41c80b6a19fdb9ea3f100f fbshipit-source-id: fadd5ea1a1b979f79b41c80b6a19fdb9ea3f100f
82 lines
2.5 KiB
JavaScript
82 lines
2.5 KiB
JavaScript
/**
|
|
* Copyright (c) 2015-present, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule ActionSheetIOS
|
|
* @flow
|
|
*/
|
|
'use strict';
|
|
|
|
var RCTActionSheetManager = require('NativeModules').ActionSheetManager;
|
|
|
|
var invariant = require('fbjs/lib/invariant');
|
|
var processColor = require('processColor');
|
|
|
|
var ActionSheetIOS = {
|
|
/**
|
|
* Display an iOS action sheet. The `options` object must contain one or more
|
|
* of:
|
|
*
|
|
* - `options` (array of strings) - a list of button titles (required)
|
|
* - `cancelButtonIndex` (int) - index of cancel button in `options`
|
|
* - `destructiveButtonIndex` (int) - index of destructive button in `options`
|
|
* - `title` (string) - a title to show above the action sheet
|
|
* - `message` (string) - a message to show below the title
|
|
*/
|
|
showActionSheetWithOptions(options: Object, callback: Function) {
|
|
invariant(
|
|
typeof options === 'object' && options !== null,
|
|
'Options must be a valid object'
|
|
);
|
|
invariant(
|
|
typeof callback === 'function',
|
|
'Must provide a valid callback'
|
|
);
|
|
RCTActionSheetManager.showActionSheetWithOptions(
|
|
{...options, tintColor: processColor(options.tintColor)},
|
|
callback
|
|
);
|
|
},
|
|
|
|
/**
|
|
* Display the iOS share sheet. The `options` object should contain
|
|
* one or both of:
|
|
*
|
|
* - `message` (string) - a message to share
|
|
* - `url` (string) - a URL to share
|
|
*
|
|
* NOTE: if `url` points to a local file, or is a base64-encoded
|
|
* uri, the file it points to will be loaded and shared directly.
|
|
* In this way, you can share images, videos, PDF files, etc.
|
|
*/
|
|
showShareActionSheetWithOptions(
|
|
options: Object,
|
|
failureCallback: Function,
|
|
successCallback: Function
|
|
) {
|
|
invariant(
|
|
typeof options === 'object' && options !== null,
|
|
'Options must be a valid object'
|
|
);
|
|
invariant(
|
|
typeof failureCallback === 'function',
|
|
'Must provide a valid failureCallback'
|
|
);
|
|
invariant(
|
|
typeof successCallback === 'function',
|
|
'Must provide a valid successCallback'
|
|
);
|
|
RCTActionSheetManager.showShareActionSheetWithOptions(
|
|
{...options, tintColor: processColor(options.tintColor)},
|
|
failureCallback,
|
|
successCallback
|
|
);
|
|
}
|
|
};
|
|
|
|
module.exports = ActionSheetIOS;
|