[react-native] Action types for Share api

Adds types for the returned actions as documented at https://facebook.github.io/react-native/docs/share
This commit is contained in:
Manduro
2019-01-12 11:06:14 +01:00
parent 3a69de74e2
commit 143446c12a
2 changed files with 31 additions and 3 deletions
+14 -3
View File
@@ -6709,6 +6709,17 @@ export type ShareOptions = {
tintColor?: string;
};
export type ShareSharedAction = {
action: "sharedAction";
activityType?: string;
};
export type ShareDismissedAction = {
action: "dismissedAction"
};
export type ShareAction = ShareSharedAction | ShareDismissedAction;
export interface ShareStatic {
/**
* Open a dialog to share text content.
@@ -6742,9 +6753,9 @@ export interface ShareStatic {
* - `dialogTitle`
*
*/
share(content: ShareContent, options?: ShareOptions): Promise<Object>;
sharedAction: string;
dismissedAction: string;
share(content: ShareContent, options?: ShareOptions): Promise<ShareAction>;
sharedAction: "sharedAction";
dismissedAction: "dismissedAction";
}
type AccessibilityEventName = "change" | "announcementFinished";
+17
View File
@@ -53,6 +53,9 @@ import {
ScrollView,
ScrollViewProps,
SectionListRenderItemInfo,
Share,
ShareDismissedAction,
ShareSharedAction,
Switch,
RefreshControl,
RegisteredStyle,
@@ -810,3 +813,17 @@ const NativeIDTest = () => (
<Text nativeID={"nativeID"}>Text</Text>
</ScrollView>
);
const ShareTest = () => {
Share.share(
{ title: "title", message: "message" },
{ dialogTitle: "dialogTitle", excludedActivityTypes: ["activity"], tintColor: "red" }
);
Share.share({ title: "title", url: "url" });
Share.share({ message: "message" }).then(result => {
if (result.action === Share.sharedAction) {
const activity = result.activityType;
} else if (result.action === Share.dismissedAction) {
}
});
};