1 | /**
|
2 | * Copyright (c) Meta Platforms, Inc. and affiliates.
|
3 | *
|
4 | * This source code is licensed under the MIT license found in the
|
5 | * LICENSE file in the root directory of this source tree.
|
6 | *
|
7 | * @format
|
8 | */
|
9 |
|
10 | import {ColorValue} from '../StyleSheet/StyleSheet';
|
11 |
|
12 | export type ShareContent =
|
13 | | {
|
14 | title?: string | undefined;
|
15 | url: string;
|
16 | message?: string | undefined;
|
17 | }
|
18 | | {
|
19 | title?: string | undefined;
|
20 | url?: string | undefined;
|
21 | message: string;
|
22 | };
|
23 |
|
24 | export type ShareOptions = {
|
25 | dialogTitle?: string | undefined;
|
26 | excludedActivityTypes?: Array<string> | undefined;
|
27 | tintColor?: ColorValue | undefined;
|
28 | subject?: string | undefined;
|
29 | anchor?: number | undefined;
|
30 | };
|
31 |
|
32 | export type ShareAction = {
|
33 | action: 'sharedAction' | 'dismissedAction';
|
34 | activityType?: string | null | undefined;
|
35 | };
|
36 |
|
37 | export interface ShareStatic {
|
38 | /**
|
39 | * Open a dialog to share text content.
|
40 | *
|
41 | * In iOS, Returns a Promise which will be invoked an object containing `action`, `activityType`.
|
42 | * If the user dismissed the dialog, the Promise will still be resolved with action being `Share.dismissedAction`
|
43 | * and all the other keys being undefined.
|
44 | *
|
45 | * In Android, Returns a Promise which always resolves with action being `Share.sharedAction`.
|
46 | *
|
47 | * ### Content
|
48 | *
|
49 | * #### iOS
|
50 | *
|
51 | * - `url` - a URL to share
|
52 | * - `message` - a message to share
|
53 | *
|
54 | * At least one of `URL` or `message` is required.
|
55 | *
|
56 | * #### Android
|
57 | *
|
58 | * - `title` - title of the message (optional)
|
59 | * - `message` - a message to share (often will include a URL).
|
60 | *
|
61 | * ### Options
|
62 | *
|
63 | * #### iOS
|
64 | *
|
65 | * - `subject` - a subject to share via email
|
66 | * - `excludedActivityTypes`
|
67 | * - `tintColor`
|
68 | *
|
69 | * #### Android
|
70 | *
|
71 | * - `dialogTitle`
|
72 | *
|
73 | */
|
74 | share(content: ShareContent, options?: ShareOptions): Promise<ShareAction>;
|
75 | sharedAction: 'sharedAction';
|
76 | dismissedAction: 'dismissedAction';
|
77 | }
|
78 |
|
79 | export const Share: ShareStatic;
|
80 | export type Share = ShareStatic;
|