mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-11-29 01:31:45 +00:00
[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:
Vendored
+14
-3
@@ -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";
|
||||
|
||||
@@ -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) {
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user