Skip to content

Commit

Permalink
still working on video, added real arrows to page tho (forgot style lol)
Browse files Browse the repository at this point in the history
  • Loading branch information
CodyGarciaa committed Nov 18, 2024
1 parent e05d683 commit 6c10e67
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 49 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"react-native-safe-area-context": "4.12.0",
"react-native-screens": "~4.0.0",
"react-native-slider": "^0.11.0",
"react-native-video": "^6.6.4",
"react-native-video": "^6.8.0",
"react-native-video-controls": "^2.8.1"
},
"devDependencies": {
Expand Down
Binary file added src/assets/images/left-arrow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/images/right-arrow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 15 additions & 23 deletions src/screens/LegalRights/VideoPage/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { useEffect, useRef, useState } from 'react';
import { Pressable, ScrollView, Text, View } from 'react-native';
import Video from 'react-native-video';
import { Image, Pressable, ScrollView, Text, View } from 'react-native';
import { Video } from 'expo-av';
import leftArrow from '@/assets/images/left-arrow.png';
import rightArrow from '@/assets/images/right-arrow.png';
import { LegalScreenProps } from '@/navigation/types';
import { getVideoLink } from '@/supabase/queries/storageQueries';
import { styles } from './styles';
Expand All @@ -10,6 +12,8 @@ export default function VideoPage({
route,
}: LegalScreenProps<'VideoPage'>) {
const { currentModules, pageNumber, language } = route.params;

// var for array of all the pages for the current language
const [preaData, setPreaData] = useState([
{
id: 'string',
Expand All @@ -23,16 +27,14 @@ export default function VideoPage({
},
]);
const [index, setIndex] = useState(10); // index of current page in full array of pages; have to set to infinite or else if the first page (actually index 0) is pressed, the videopage wont update
// const [language, setLanguage] = useState('english'); // which language associated to array of pages

const videoLinkRef = useRef(
'https://d23dyxeqlo5psv.cloudfront.net/big_buck_bunny.mp4',
);

//
const [renderTrigger, setRenderTrigger] = useState(0);
const [paused, setPaused] = useState(false);
const [duration, setDuration] = useState(0);
const [currentTime, setCurrentTime] = useState(0);

const nextPage = () => {
setIndex(prevIndex => Math.min(prevIndex + 1, preaData.length - 1)); // next index in array of pages
Expand All @@ -57,37 +59,27 @@ export default function VideoPage({
fetchVideoLink();
}, [index]); // run useEffect every time value of index changes

const onLoad = (data: any) => {
setDuration(data.duration);
};

const onProgress = (data: any) => {
setCurrentTime(data.currentTime);
};

return (
<ScrollView style={styles.container}>
<Video
key={renderTrigger}
key={renderTrigger} // changing the key forces re-mount and playback reset
source={{ uri: videoLinkRef.current }}
rate={1.0}
volume={1.0}
paused={paused}
muted={false}
resizeMode="contain"
onLoad={onLoad}
onProgress={onProgress}
onEnd={() => console.log('Video finished')}
repeat
isMuted={false}
shouldPlay
isLooping
style={styles.video}
/>

<View style={styles.buttonContainer}>
<Pressable style={[styles.captionButtons]} onPress={prevPage}>
<Text style={styles.buttonText}>{'< Previous Section'}</Text>
<Image style={[styles.arrows]} source={leftArrow} />
<Text style={styles.buttonText}>{'Previous Section'}</Text>
</Pressable>
<Pressable style={[styles.captionButtons]} onPress={nextPage}>
<Text style={styles.buttonText}>{'Next Section >'}</Text>
<Text style={styles.buttonText}>{'Next Section'}</Text>
<Image style={[styles.arrows]} source={rightArrow} />
</Pressable>
</View>
</ScrollView>
Expand Down
7 changes: 7 additions & 0 deletions src/screens/LegalRights/VideoPage/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ export const styles = StyleSheet.create({
paddingVertical: 25,
},
captionButtons: {
display: 'flex',
gap: 10,
flexDirection: 'row',
borderRadius: 10,
width: 180,
height: 50,
Expand All @@ -31,4 +34,8 @@ export const styles = StyleSheet.create({
buttonText: {
fontWeight: 'bold',
},
arrows: {
width: 20,
height: 20,
},
});
2 changes: 1 addition & 1 deletion src/screens/LegalRights/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Image, Pressable, ScrollView, Text, View } from 'react-native';
import placeholderPoster from '@/assets/images/placeholder.png';
import { LegalScreenProps } from '@/navigation/types';
import { getPreaByLanguage } from '@/supabase/queries/generalQueries';
import { getPosterLink } from '@/supabase/queries/storageQueries 2';
import { getPosterLink } from '@/supabase/queries/storageQueries';
import { VideoResource } from '@/types/types';
import { styles } from './styles';

Expand Down
20 changes: 0 additions & 20 deletions src/supabase/queries/storageQueries 2.tsx

This file was deleted.

11 changes: 11 additions & 0 deletions src/supabase/queries/storageQueries.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,14 @@ export const getVideoLink = (language: string, videoName: string): string => {

return data.publicUrl;
};

export const getPosterLink = (
language: string,
videoName: string,
): string | null => {
let { data } = supabase.storage
.from('PREA_videos')
.getPublicUrl(`${language}/${videoName}.png`);

return data.publicUrl;
};

0 comments on commit 6c10e67

Please sign in to comment.