Add loading spinners to lightbox views (close #38)

This commit is contained in:
Paul Frazee 2023-01-17 10:40:09 -06:00
parent 4e312d1d24
commit e11d53b67d
2 changed files with 35 additions and 2 deletions

View file

@ -1,5 +1,11 @@
import React from 'react'
import {Image, StyleSheet, useWindowDimensions, View} from 'react-native'
import {
ActivityIndicator,
Image,
StyleSheet,
useWindowDimensions,
View,
} from 'react-native'
export function Component({
uris,
@ -12,8 +18,16 @@ export function Component({
}) {
const winDim = useWindowDimensions()
const left = index * winDim.width * -1
const spinnerStyle = React.useMemo(
() => ({
left: winDim.width / 2 - 20,
top: winDim.height / 2 - 50,
}),
[winDim.width, winDim.height],
)
return (
<View style={[styles.container, {left}]}>
<ActivityIndicator style={[styles.loading, spinnerStyle]} size="large" />
{uris.map((uri, i) => (
<Image
key={i}
@ -36,6 +50,9 @@ const styles = StyleSheet.create({
left: 0,
width: '100%',
},
loading: {
position: 'absolute',
},
image: {
position: 'absolute',
top: 200,