about summary refs log tree commit diff
path: root/src/lib/sharing.ts
diff options
context:
space:
mode:
authorTom Sherman <the.tomsherman@gmail.com>2025-02-13 01:11:13 +0000
committerGitHub <noreply@github.com>2025-02-13 01:11:13 +0000
commitd56efe250e8b83930d71793c44e6ba58cdecdaf4 (patch)
tree8cb6557b76e70c7c6b144f1694be9b1f822deb38 /src/lib/sharing.ts
parentdb25f95c33121da9d04a02dc2e77929a5d24a5ce (diff)
downloadvoidsky-d56efe250e8b83930d71793c44e6ba58cdecdaf4.tar.zst
Add dev mode for easy copying of at:// URIs and DIDs (#7723)
* Add dev mode for easy copying at:// URIs and DIDs

* Use storage API

* Share text instead of URL

* Cleanup persisted schema

* Change translation msg
Diffstat (limited to 'src/lib/sharing.ts')
-rw-r--r--src/lib/sharing.ts16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/lib/sharing.ts b/src/lib/sharing.ts
index c89d2d7a6..cdad6afe5 100644
--- a/src/lib/sharing.ts
+++ b/src/lib/sharing.ts
@@ -25,3 +25,19 @@ export async function shareUrl(url: string) {
     Toast.show(t`Copied to clipboard`, 'clipboard-check')
   }
 }
+
+/**
+ * This function shares a text using the native Share API if available, or copies it to the clipboard
+ * and displays a toast message if not (mostly on web)
+ *
+ * @param {string} text - A string representing the text that needs to be shared or copied to the
+ * clipboard.
+ */
+export async function shareText(text: string) {
+  if (isAndroid || isIOS) {
+    await Share.share({message: text})
+  } else {
+    await setStringAsync(text)
+    Toast.show(t`Copied to clipboard`, 'clipboard-check')
+  }
+}