Add loading spinners to lightbox views (close #38)
parent
4e312d1d24
commit
e11d53b67d
|
@ -1,5 +1,11 @@
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import {Image, StyleSheet, useWindowDimensions, View} from 'react-native'
|
import {
|
||||||
|
ActivityIndicator,
|
||||||
|
Image,
|
||||||
|
StyleSheet,
|
||||||
|
useWindowDimensions,
|
||||||
|
View,
|
||||||
|
} from 'react-native'
|
||||||
|
|
||||||
export function Component({
|
export function Component({
|
||||||
uris,
|
uris,
|
||||||
|
@ -12,8 +18,16 @@ export function Component({
|
||||||
}) {
|
}) {
|
||||||
const winDim = useWindowDimensions()
|
const winDim = useWindowDimensions()
|
||||||
const left = index * winDim.width * -1
|
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 (
|
return (
|
||||||
<View style={[styles.container, {left}]}>
|
<View style={[styles.container, {left}]}>
|
||||||
|
<ActivityIndicator style={[styles.loading, spinnerStyle]} size="large" />
|
||||||
{uris.map((uri, i) => (
|
{uris.map((uri, i) => (
|
||||||
<Image
|
<Image
|
||||||
key={i}
|
key={i}
|
||||||
|
@ -36,6 +50,9 @@ const styles = StyleSheet.create({
|
||||||
left: 0,
|
left: 0,
|
||||||
width: '100%',
|
width: '100%',
|
||||||
},
|
},
|
||||||
|
loading: {
|
||||||
|
position: 'absolute',
|
||||||
|
},
|
||||||
image: {
|
image: {
|
||||||
position: 'absolute',
|
position: 'absolute',
|
||||||
top: 200,
|
top: 200,
|
||||||
|
|
|
@ -1,13 +1,26 @@
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import {StyleSheet, useWindowDimensions, View} from 'react-native'
|
import {
|
||||||
|
ActivityIndicator,
|
||||||
|
StyleSheet,
|
||||||
|
useWindowDimensions,
|
||||||
|
View,
|
||||||
|
} from 'react-native'
|
||||||
import {UserAvatar} from '../util/UserAvatar'
|
import {UserAvatar} from '../util/UserAvatar'
|
||||||
import {ProfileViewModel} from '../../../state/models/profile-view'
|
import {ProfileViewModel} from '../../../state/models/profile-view'
|
||||||
|
|
||||||
export function Component({profileView}: {profileView: ProfileViewModel}) {
|
export function Component({profileView}: {profileView: ProfileViewModel}) {
|
||||||
const winDim = useWindowDimensions()
|
const winDim = useWindowDimensions()
|
||||||
const top = winDim.height / 2 - (winDim.width - 40) / 2 - 100
|
const top = winDim.height / 2 - (winDim.width - 40) / 2 - 100
|
||||||
|
const spinnerStyle = React.useMemo(
|
||||||
|
() => ({
|
||||||
|
left: winDim.width / 2 - 30,
|
||||||
|
top: winDim.height / 2 - (winDim.width - 40) / 2 - 80,
|
||||||
|
}),
|
||||||
|
[winDim.width, winDim.height],
|
||||||
|
)
|
||||||
return (
|
return (
|
||||||
<View style={[styles.container, {top}]}>
|
<View style={[styles.container, {top}]}>
|
||||||
|
<ActivityIndicator style={[styles.loading, spinnerStyle]} size="large" />
|
||||||
<UserAvatar
|
<UserAvatar
|
||||||
handle={profileView.handle}
|
handle={profileView.handle}
|
||||||
displayName={profileView.displayName}
|
displayName={profileView.displayName}
|
||||||
|
@ -23,4 +36,7 @@ const styles = StyleSheet.create({
|
||||||
position: 'absolute',
|
position: 'absolute',
|
||||||
left: 20,
|
left: 20,
|
||||||
},
|
},
|
||||||
|
loading: {
|
||||||
|
position: 'absolute',
|
||||||
|
},
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue