better android loading
This commit is contained in:
committed by
Eric Bailey
parent
0d8f6fd116
commit
5f2dd5015e
@@ -10,9 +10,15 @@ import {
|
|||||||
import {Gesture, GestureDetector} from 'react-native-gesture-handler'
|
import {Gesture, GestureDetector} from 'react-native-gesture-handler'
|
||||||
import {runOnJS} from 'react-native-reanimated'
|
import {runOnJS} from 'react-native-reanimated'
|
||||||
import {SafeAreaView, useSafeAreaInsets} from 'react-native-safe-area-context'
|
import {SafeAreaView, useSafeAreaInsets} from 'react-native-safe-area-context'
|
||||||
|
import {useEvent} from 'expo'
|
||||||
import {Image} from 'expo-image'
|
import {Image} from 'expo-image'
|
||||||
import {LinearGradient} from 'expo-linear-gradient'
|
import {LinearGradient} from 'expo-linear-gradient'
|
||||||
import {useVideoPlayer, VideoPlayer, VideoView} from 'expo-video'
|
import {
|
||||||
|
useVideoPlayer,
|
||||||
|
VideoPlayer,
|
||||||
|
VideoPlayerStatus,
|
||||||
|
VideoView,
|
||||||
|
} from 'expo-video'
|
||||||
import {
|
import {
|
||||||
AppBskyEmbedVideo,
|
AppBskyEmbedVideo,
|
||||||
AppBskyFeedDefs,
|
AppBskyFeedDefs,
|
||||||
@@ -45,6 +51,7 @@ import {atoms as a, ThemeProvider, useTheme} from '#/alf'
|
|||||||
import {Button, ButtonText} from '#/components/Button'
|
import {Button, ButtonText} from '#/components/Button'
|
||||||
import * as Layout from '#/components/Layout'
|
import * as Layout from '#/components/Layout'
|
||||||
import {ListFooter} from '#/components/Lists'
|
import {ListFooter} from '#/components/Lists'
|
||||||
|
import {Loader} from '#/components/Loader'
|
||||||
import {RichText} from '#/components/RichText'
|
import {RichText} from '#/components/RichText'
|
||||||
import {Text} from '#/components/Typography'
|
import {Text} from '#/components/Typography'
|
||||||
|
|
||||||
@@ -268,6 +275,8 @@ function VibeItem({
|
|||||||
// set the video to be cover rather than contain
|
// set the video to be cover rather than contain
|
||||||
const isCloseEnough = videoAspectRatio < screenAspectRatio * 1.2
|
const isCloseEnough = videoAspectRatio < screenAspectRatio * 1.2
|
||||||
|
|
||||||
|
const {status} = useEvent(player, 'statusChange', {status: player.status})
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View
|
<View
|
||||||
style={{
|
style={{
|
||||||
@@ -292,7 +301,7 @@ function VibeItem({
|
|||||||
a.flex_1,
|
a.flex_1,
|
||||||
a.absolute,
|
a.absolute,
|
||||||
{
|
{
|
||||||
zIndex: -1,
|
zIndex: status === 'loading' ? 1 : -1,
|
||||||
top: 0,
|
top: 0,
|
||||||
left: insets.left,
|
left: insets.left,
|
||||||
right: insets.right,
|
right: insets.right,
|
||||||
@@ -302,7 +311,7 @@ function VibeItem({
|
|||||||
contentFit={isCloseEnough ? 'cover' : 'contain'}
|
contentFit={isCloseEnough ? 'cover' : 'contain'}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
<VibeOverlay player={player} post={post} />
|
<VibeOverlay player={player} post={post} status={status} />
|
||||||
</SafeAreaView>
|
</SafeAreaView>
|
||||||
</View>
|
</View>
|
||||||
)
|
)
|
||||||
@@ -311,9 +320,11 @@ function VibeItem({
|
|||||||
function VibeOverlay({
|
function VibeOverlay({
|
||||||
player,
|
player,
|
||||||
post,
|
post,
|
||||||
|
status,
|
||||||
}: {
|
}: {
|
||||||
player: VideoPlayer
|
player: VideoPlayer
|
||||||
post: AppBskyFeedDefs.PostView
|
post: AppBskyFeedDefs.PostView
|
||||||
|
status: VideoPlayerStatus
|
||||||
}) {
|
}) {
|
||||||
const postShadow = usePostShadow(post)
|
const postShadow = usePostShadow(post)
|
||||||
const insets = useSafeAreaInsets()
|
const insets = useSafeAreaInsets()
|
||||||
@@ -357,6 +368,7 @@ function VibeOverlay({
|
|||||||
})
|
})
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
<>
|
||||||
<GestureDetector gesture={gesture}>
|
<GestureDetector gesture={gesture}>
|
||||||
<View style={[a.absolute, a.inset_0, {bottom: insets.bottom}]}>
|
<View style={[a.absolute, a.inset_0, {bottom: insets.bottom}]}>
|
||||||
<Button
|
<Button
|
||||||
@@ -402,7 +414,10 @@ function VibeOverlay({
|
|||||||
record={record}
|
record={record}
|
||||||
logContext="FeedItem"
|
logContext="FeedItem"
|
||||||
onPressReply={() =>
|
onPressReply={() =>
|
||||||
navigation.navigate('PostThread', {name: post.author.did, rkey})
|
navigation.navigate('PostThread', {
|
||||||
|
name: post.author.did,
|
||||||
|
rkey,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
big
|
big
|
||||||
/>
|
/>
|
||||||
@@ -410,6 +425,20 @@ function VibeOverlay({
|
|||||||
</LinearGradient>
|
</LinearGradient>
|
||||||
</View>
|
</View>
|
||||||
</GestureDetector>
|
</GestureDetector>
|
||||||
|
{status === 'loading' && (
|
||||||
|
<View
|
||||||
|
style={[
|
||||||
|
a.absolute,
|
||||||
|
a.inset_0,
|
||||||
|
a.align_center,
|
||||||
|
a.justify_center,
|
||||||
|
a.z_10,
|
||||||
|
]}
|
||||||
|
pointerEvents="none">
|
||||||
|
<Loader size="2xl" />
|
||||||
|
</View>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user