diff --git a/src/components/ResourceCard.tsx b/src/components/ResourceCard.tsx index 3e53636..6fd11dd 100644 --- a/src/components/ResourceCard.tsx +++ b/src/components/ResourceCard.tsx @@ -3,6 +3,7 @@ import { useState } from "react"; import { ActivityIndicator, Pressable, + Share, StyleSheet, Text, TextInput, @@ -63,6 +64,20 @@ export function ResourceCard({ resource, onCopyUrl, onRegister }: ResourceCardPr onCopyUrl("Resource URL copied"); } + /** + * Opens the native iOS/Android share sheet with the resource title and URL. + * - `message` is used on Android (plain text share). + * - `url` is used on iOS (triggers the URL sharing path in the share sheet). + * Both are included so the shared content always contains title + URL. + */ + async function handleShare() { + await Share.share({ + title: resource.title, + message: `${resource.title}\n${resource.accessUrl}`, + url: resource.accessUrl, + }); + } + async function handleSavePrice() { resetError(); setSuccessMessage(null); @@ -97,13 +112,13 @@ export function ResourceCard({ resource, onCopyUrl, onRegister }: ResourceCardPr - - + + {resource.verificationStatus} - - + + {resource.onchainStatus === "none" ? "not on-chain" : resource.onchainStatus} @@ -111,15 +126,20 @@ export function ResourceCard({ resource, onCopyUrl, onRegister }: ResourceCardPr {resource.price} USDC - - Copy URL - + + + Share + + + Copy URL + + {editing ? ( @@ -178,6 +198,9 @@ export function ResourceCard({ resource, onCopyUrl, onRegister }: ResourceCardPr Edit price )} + + ); +} const styles = StyleSheet.create({ badges: { @@ -191,6 +214,13 @@ const styles = StyleSheet.create({ justifyContent: "space-between", marginTop: 4, }, + actions: { + flexDirection: "row", + gap: 8, + }, + shareButton: { + backgroundColor: colors.primary, + }, editor: { marginTop: 16, gap: 10,