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

This commit is contained in:
John Fawcett 2023-03-19 17:39:37 -05:00 committed by GitHub
parent db6b198d18
commit c31ffdac1b

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}>
<View style={styles.imageCenterer}>
<Image source={imgs[index]} style={styles.image} /> <Image source={imgs[index]} style={styles.image} />
{canGoLeft && ( {canGoLeft && (
<TouchableOpacity <TouchableOpacity
onPress={onPressLeft} onPress={onPressLeft}
style={[styles.btn, styles.leftBtn]}> style={[styles.btn, styles.leftBtn]}>
<FontAwesomeIcon icon="angle-left" style={styles.icon} size={40} /> <FontAwesomeIcon
icon="angle-left"
style={styles.icon}
size={40}
/>
</TouchableOpacity> </TouchableOpacity>
)} )}
{canGoRight && ( {canGoRight && (
<TouchableOpacity <TouchableOpacity
onPress={onPressRight} onPress={onPressRight}
style={[styles.btn, styles.rightBtn]}> style={[styles.btn, styles.rightBtn]}>
<FontAwesomeIcon icon="angle-right" style={styles.icon} size={40} /> <FontAwesomeIcon
icon="angle-right"
style={styles.icon}
size={40}
/>
</TouchableOpacity> </TouchableOpacity>
)} )}
</View> </View>
</TouchableWithoutFeedback> </TouchableWithoutFeedback>
<View style={styles.closeBtn}>
<ImageDefaultHeader onRequestClose={onClose} />
</View>
</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',