Skip to content

Commit

Permalink
feat: add loading overlay for StoryDetailItem
Browse files Browse the repository at this point in the history
  • Loading branch information
JonatanSalas committed Oct 26, 2020
1 parent 848603c commit e0819b1
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/components/StoryDetailItem/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import Video from 'react-native-video';
import React, { useEffect, useState } from 'react';
import { Overlay } from 'react-native-elements';
import { ActivityIndicator } from 'react-native';
import React, { useEffect, useState, useRef } from 'react';

import { styles } from './styles';
import { useRef } from 'react';

export type StoryDetailHeaderProps = {
/**
Expand Down Expand Up @@ -71,6 +72,7 @@ export const StoryDetailItem: React.FC<StoryDetailItemProps> = ({
}) => {
const videoRef: any = useRef(null);

const [visible, setVisible] = useState(false);
const [paused, setPaused] = useState(true);
const [muted, setMuted] = useState(false);

Expand All @@ -87,6 +89,17 @@ export const StoryDetailItem: React.FC<StoryDetailItemProps> = ({

return (
<>
<Overlay
fullScreen
isVisible={visible && isCurrentStory}
overlayStyle={{ backgroundColor: '#000000' }}
>
<ActivityIndicator
animating={true}
color="#FFFFFF"
style={{ height: '100%' }}
/>
</Overlay>
<StoryDetailItemHeader
muted={muted}
goBack={() => onBackPress()}
Expand All @@ -100,6 +113,8 @@ export const StoryDetailItem: React.FC<StoryDetailItemProps> = ({
resizeMode="cover"
source={{ uri: video }}
style={styles.container}
onLoadStart={() => setVisible(true)}
onReadyForDisplay={() => setVisible(false)}
onLoad={(nativeEvent: any) => {
setProgress(nativeEvent.currentPosition);
setDuration(nativeEvent.duration);
Expand Down

0 comments on commit e0819b1

Please sign in to comment.