Fixes the lightbox not having a close button on web (#306) (#323)

zio/stable
John Fawcett 2023-03-19 17:39:37 -05:00 committed by GitHub
parent db6b198d18
commit c31ffdac1b
1 changed files with 40 additions and 18 deletions

View File

@ -11,6 +11,7 @@ import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome'
import {useStores} from 'state/index' import {useStores} from 'state/index'
import * as models from 'state/models/ui/shell' import * as models from 'state/models/ui/shell'
import {colors} from 'lib/styles' import {colors} from 'lib/styles'
import ImageDefaultHeader from './ImageViewing/components/ImageDefaultHeader'
interface Img { interface Img {
uri: string uri: string
@ -59,25 +60,38 @@ function LightboxInner({imgs, onClose}: {imgs: Img[]; onClose: () => void}) {
} }
return ( return (
<TouchableWithoutFeedback onPress={onClose}> <View style={styles.mask}>
<View style={styles.mask}> <TouchableWithoutFeedback onPress={onClose}>
<Image source={imgs[index]} style={styles.image} /> <View style={styles.imageCenterer}>
{canGoLeft && ( <Image source={imgs[index]} style={styles.image} />
<TouchableOpacity {canGoLeft && (
onPress={onPressLeft} <TouchableOpacity
style={[styles.btn, styles.leftBtn]}> onPress={onPressLeft}
<FontAwesomeIcon icon="angle-left" style={styles.icon} size={40} /> style={[styles.btn, styles.leftBtn]}>
</TouchableOpacity> <FontAwesomeIcon
)} icon="angle-left"
{canGoRight && ( style={styles.icon}
<TouchableOpacity size={40}
onPress={onPressRight} />
style={[styles.btn, styles.rightBtn]}> </TouchableOpacity>
<FontAwesomeIcon icon="angle-right" style={styles.icon} size={40} /> )}
</TouchableOpacity> {canGoRight && (
)} <TouchableOpacity
onPress={onPressRight}
style={[styles.btn, styles.rightBtn]}>
<FontAwesomeIcon
icon="angle-right"
style={styles.icon}
size={40}
/>
</TouchableOpacity>
)}
</View>
</TouchableWithoutFeedback>
<View style={styles.closeBtn}>
<ImageDefaultHeader onRequestClose={onClose} />
</View> </View>
</TouchableWithoutFeedback> </View>
) )
} }
@ -89,6 +103,9 @@ const styles = StyleSheet.create({
width: '100%', width: '100%',
height: '100%', height: '100%',
backgroundColor: '#000c', backgroundColor: '#000c',
},
imageCenterer: {
flex: 1,
alignItems: 'center', alignItems: 'center',
justifyContent: 'center', justifyContent: 'center',
}, },
@ -100,6 +117,11 @@ const styles = StyleSheet.create({
icon: { icon: {
color: colors.white, color: colors.white,
}, },
closeBtn: {
position: 'absolute',
top: 10,
right: 10,
},
btn: { btn: {
position: 'absolute', position: 'absolute',
backgroundColor: '#000', backgroundColor: '#000',