about summary refs log tree commit diff
path: root/src/view/com/lightbox/Lightbox.tsx
diff options
context:
space:
mode:
authorAryan Goharzad <arrygoo@gmail.com>2023-01-25 18:25:34 -0500
committerGitHub <noreply@github.com>2023-01-25 17:25:34 -0600
commiteb33c3fa812cc087db14a6b6ba743e982b26c462 (patch)
treed098f7a804c67755f39e95bbbfd56887bacf476c /src/view/com/lightbox/Lightbox.tsx
parentadf328b50ce98c5ebd3282fe897ddfdcd0de8011 (diff)
downloadvoidsky-eb33c3fa812cc087db14a6b6ba743e982b26c462.tar.zst
Saves image on long press (#83)
* Saves image on long press

* Adds save on long press

* Forking lightbox

* move to wrapper only to the bottom sheet to reduce impact of this change

* lint

* lint

* lint

* Use official `share` API

* Clean up cache after download

* comment

* comment

* Reduce swipe close velocity

* Updates per feedback

* lint

* bugfix

* Adds delayed press-in for TouchableOpacity
Diffstat (limited to 'src/view/com/lightbox/Lightbox.tsx')
-rw-r--r--src/view/com/lightbox/Lightbox.tsx15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/view/com/lightbox/Lightbox.tsx b/src/view/com/lightbox/Lightbox.tsx
index 3369c2770..c777a5528 100644
--- a/src/view/com/lightbox/Lightbox.tsx
+++ b/src/view/com/lightbox/Lightbox.tsx
@@ -1,20 +1,22 @@
 import React from 'react'
 import {View} from 'react-native'
 import {observer} from 'mobx-react-lite'
-import ImageView from 'react-native-image-viewing'
+import ImageView from './ImageViewing'
 import {useStores} from '../../../state'
-
 import * as models from '../../../state/models/shell-ui'
+import {saveImageModal} from '../../../lib/images'
 
 export const Lightbox = observer(function Lightbox() {
   const store = useStores()
+  if (!store.shell.isLightboxActive) {
+    return null
+  }
+
   const onClose = () => {
-    console.log('hit')
     store.shell.closeLightbox()
   }
-
-  if (!store.shell.isLightboxActive) {
-    return <View />
+  const onLongPress = ({uri}: {uri: string}) => {
+    saveImageModal({uri})
   }
 
   if (store.shell.activeLightbox?.name === 'profile-image') {
@@ -35,6 +37,7 @@ export const Lightbox = observer(function Lightbox() {
         imageIndex={opts.index}
         visible
         onRequestClose={onClose}
+        onLongPress={onLongPress}
       />
     )
   } else {