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

@ -5,13 +5,14 @@ import {
LayoutChangeEvent,
StyleProp,
StyleSheet,
TouchableWithoutFeedback,
TouchableOpacity,
View,
ViewStyle,
} from 'react-native'
import {Text} from '../text/Text'
import {useTheme} from '../../../lib/ThemeContext'
import {usePalette} from '../../../lib/hooks/usePalette'
import {DELAY_PRESS_IN} from './constants'
const MAX_HEIGHT = 300
@ -23,6 +24,7 @@ interface Dim {
export function AutoSizedImage({
uri,
onPress,
onLongPress,
style,
containerStyle,
}: {
@ -80,7 +82,10 @@ export function AutoSizedImage({
return (
<View style={style}>
<TouchableWithoutFeedback onPress={onPress}>
<TouchableOpacity
onPress={onPress}
onLongPress={onLongPress}
delayPressIn={DELAY_PRESS_IN}>
{error ? (
<View style={[styles.errorContainer, errPal.view, containerStyle]}>
<Text style={errPal.text}>{error}</Text>
@ -99,7 +104,7 @@ export function AutoSizedImage({
onLayout={onLayout}
/>
)}
</TouchableWithoutFeedback>
</TouchableOpacity>
</View>
)
}