about summary refs log tree commit diff
path: root/src/view/com/lightbox/Lightbox.tsx
diff options
context:
space:
mode:
authorPaul Frazee <pfrazee@gmail.com>2023-06-30 11:34:04 -0500
committerGitHub <noreply@github.com>2023-06-30 11:34:04 -0500
commitc72e24f841b5771d74e82114e40ed81f15ec97a7 (patch)
tree9cde253f90c3a22bce0d27fd8991b32213526436 /src/view/com/lightbox/Lightbox.tsx
parent5fcca171291bbbfc63a0f9eaa153efd5d046c33e (diff)
downloadvoidsky-c72e24f841b5771d74e82114e40ed81f15ec97a7.tar.zst
[APP-716] Add 'save image' button to the lightbox (#926)
* Add 'save image' button to the lightbox

* Fix types

* Fix types
Diffstat (limited to 'src/view/com/lightbox/Lightbox.tsx')
-rw-r--r--src/view/com/lightbox/Lightbox.tsx24
1 files changed, 22 insertions, 2 deletions
diff --git a/src/view/com/lightbox/Lightbox.tsx b/src/view/com/lightbox/Lightbox.tsx
index 18440c55d..d1fd701cf 100644
--- a/src/view/com/lightbox/Lightbox.tsx
+++ b/src/view/com/lightbox/Lightbox.tsx
@@ -5,7 +5,8 @@ import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome'
 import ImageView from './ImageViewing'
 import {useStores} from 'state/index'
 import * as models from 'state/models/ui/shell'
-import {saveImageModal} from 'lib/media/manip'
+import {shareImageModal, saveImageToAlbum} from 'lib/media/manip'
+import * as Toast from '../util/Toast'
 import {Text} from '../util/text/Text'
 import {s, colors} from 'lib/styles'
 import {Button} from '../util/forms/Button'
@@ -54,7 +55,16 @@ export const Lightbox = observer(function Lightbox() {
             <Button
               type="primary-outline"
               style={styles.footerBtn}
-              onPress={() => saveImageModal({uri})}>
+              onPress={() => saveImageToAlbumWithToasts(uri)}>
+              <FontAwesomeIcon icon={['far', 'floppy-disk']} style={s.white} />
+              <Text type="xl" style={s.white}>
+                Save
+              </Text>
+            </Button>
+            <Button
+              type="primary-outline"
+              style={styles.footerBtn}
+              onPress={() => shareImageModal({uri})}>
               <FontAwesomeIcon icon="arrow-up-from-bracket" style={s.white} />
               <Text type="xl" style={s.white}>
                 Share
@@ -96,6 +106,15 @@ export const Lightbox = observer(function Lightbox() {
   }
 })
 
+async function saveImageToAlbumWithToasts(uri: string) {
+  try {
+    await saveImageToAlbum({uri, album: 'Bluesky'})
+    Toast.show('Saved to the "Bluesky" album.')
+  } catch (e: any) {
+    Toast.show(`Failed to save image: ${String(e)}`)
+  }
+}
+
 const styles = StyleSheet.create({
   footer: {
     paddingTop: 16,
@@ -109,6 +128,7 @@ const styles = StyleSheet.create({
   footerBtns: {
     flexDirection: 'row',
     justifyContent: 'center',
+    gap: 8,
   },
   footerBtn: {
     flexDirection: 'row',