diff --git a/src/components/ObsDetails/DetailsTab/DetailsTab.js b/src/components/ObsDetails/DetailsTab/DetailsTab.js
index b7281edd0..f9cf96a65 100644
--- a/src/components/ObsDetails/DetailsTab/DetailsTab.js
+++ b/src/components/ObsDetails/DetailsTab/DetailsTab.js
@@ -16,6 +16,7 @@ import { View } from "components/styledComponents";
import { t } from "i18next";
import type { Node } from "react";
import React from "react";
+import { Alert, Platform, Share } from "react-native";
import { useTheme } from "react-native-paper";
import { openExternalWebBrowser } from "sharedHelpers/util.ts";
@@ -27,15 +28,44 @@ type Props = {
observation: Object
}
+const OBSERVATION_URL = "https://www.inaturalist.org/observations";
+
+const handleShare = async url => {
+ const sharingOptions = {
+ url: "",
+ message: ""
+ };
+ if ( Platform.OS === "ios" ) {
+ sharingOptions.url = url;
+ } else {
+ sharingOptions.message = url;
+ }
+ try {
+ return await Share.share( sharingOptions );
+ } catch ( err ) {
+ Alert.alert( err.message );
+ return null;
+ }
+};
+
const ViewInBrowserButton = ( { id } ) => (
openExternalWebBrowser( `https://www.inaturalist.org/observations/${id}` )}
+ onPress={async () => openExternalWebBrowser( `${OBSERVATION_URL}/${id}` )}
>
{t( "View-in-browser" )}
);
+const ShareButton = ( { id } ) => (
+ handleShare( `${OBSERVATION_URL}/${id}` )}
+ >
+ {t( "Share" )}
+
+);
+
const qualityGradeOption = option => {
switch ( option ) {
case "research":
@@ -152,6 +182,7 @@ const DetailsTab = ( { currentUser, observation }: Props ): Node => {
+
>
);