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
This commit is contained in:
Aryan Goharzad 2023-01-25 18:25:34 -05:00 committed by GitHub
parent adf328b50c
commit eb33c3fa81
23 changed files with 1568 additions and 46 deletions

View file

@ -10,6 +10,7 @@ import {ImagesLightbox} from '../../../state/models/shell-ui'
import {useStores} from '../../../state'
import {usePalette} from '../../lib/hooks/usePalette'
import {gradients} from '../../lib/styles'
import {saveImageModal} from '../../../lib/images'
type Embed =
| AppBskyEmbedImages.Presented
@ -31,6 +32,10 @@ export function PostEmbeds({
const openLightbox = (index: number) => {
store.shell.openLightbox(new ImagesLightbox(uris, index))
}
const onLongPress = (index: number) => {
saveImageModal({uri: uris[index]})
}
if (embed.images.length === 4) {
return (
<View style={[styles.imagesContainer, style]}>
@ -38,6 +43,7 @@ export function PostEmbeds({
type="four"
uris={embed.images.map(img => img.thumb)}
onPress={openLightbox}
onLongPress={onLongPress}
/>
</View>
)
@ -48,6 +54,7 @@ export function PostEmbeds({
type="three"
uris={embed.images.map(img => img.thumb)}
onPress={openLightbox}
onLongPress={onLongPress}
/>
</View>
)
@ -58,6 +65,7 @@ export function PostEmbeds({
type="two"
uris={embed.images.map(img => img.thumb)}
onPress={openLightbox}
onLongPress={onLongPress}
/>
</View>
)
@ -67,6 +75,7 @@ export function PostEmbeds({
<AutoSizedImage
uri={embed.images[0].thumb}
onPress={() => openLightbox(0)}
onLongPress={() => onLongPress(0)}
containerStyle={styles.singleImage}
/>
</View>