diff --git a/package.json b/package.json index c842862e..f6435679 100644 --- a/package.json +++ b/package.json @@ -44,6 +44,7 @@ "react-native-svg": "13.9.0", "react-native-vector-icons": "9.2.0", "react-native-video": "6.0.0-alpha.6", + "react-native-video-controls": "2.8.1", "react-syntax-highlighter": "15.5.0", "turndown": "7.1.2", "zustand": "4.3.8" diff --git a/src/screens/Video/index.tsx b/src/screens/Video/index.tsx index f9f503d1..4746c29e 100644 --- a/src/screens/Video/index.tsx +++ b/src/screens/Video/index.tsx @@ -1,16 +1,20 @@ import { StackParamList } from "../../router/types"; import { logError } from "../../utils/log"; import { NativeStackScreenProps } from "@react-navigation/native-stack"; -import { FunctionComponent } from "react"; -import { Linking, Share, StyleSheet, View } from "react-native"; -import { Appbar } from "react-native-paper"; -import Video from "react-native-video"; +import { FunctionComponent, useState } from "react"; +import { Dimensions, Linking, Share, StyleSheet, View } from "react-native"; +import { FAB, Text } from "react-native-paper"; +import VideoPlayer from "react-native-video-controls"; type Props = NativeStackScreenProps; +const { width } = Dimensions.get("window"); + const ArticleScreen: FunctionComponent = ({ route, navigation }) => { const { params } = route; const { source, title, url, cover } = params; + const [isFullScreen, setIsFullScreen] = useState(false); + const [isControlsVisible, setIsControlsVisible] = useState(true); const onBackActionPress = () => { navigation.goBack(); @@ -34,28 +38,44 @@ const ArticleScreen: FunctionComponent = ({ route, navigation }) => { return ( - - - - - - - ); }; @@ -63,6 +83,8 @@ const ArticleScreen: FunctionComponent = ({ route, navigation }) => { const styles = StyleSheet.create({ container: { flex: 1, + backgroundColor: "#000", + position: "relative", }, listContainer: { margin: 8, @@ -72,6 +94,21 @@ const styles = StyleSheet.create({ backgroundVideo: { flex: 1, }, + titleContainer: { + position: "absolute", + bottom: 100, + left: 16, + width: width * (3 / 4), + }, + title: { + color: "#fff", + }, + fabActions: { + position: "absolute", + gap: 16, + bottom: 100, + right: 16, + }, }); export default ArticleScreen; diff --git a/src/types/react-native-video-controls.d.ts b/src/types/react-native-video-controls.d.ts new file mode 100644 index 00000000..7057a575 --- /dev/null +++ b/src/types/react-native-video-controls.d.ts @@ -0,0 +1,43 @@ +declare module "react-native-video-controls" { + import * as React from "react"; + import { VideoProperties } from "react-native-video"; + + type VideoControlsProps = { + onEnterFullscreen?: () => void; + onExitFullscreen?: () => void; + onHideControls?: () => void; + onShowControls?: () => void; + onError?: () => void; + onPause?: () => void; + onPlay?: () => void; + onBack?: () => void; + onEnd?: () => void; + toggleResizeModeOnFullscreen?: boolean; + controlTimeout?: number; + showOnStart?: boolean; + showTimeRemaining?: boolean; + tapAnywhereToPause?: boolean; + disableFullscreen?: boolean; + disablePlayPause?: boolean; + disableSeekbar?: boolean; + disableVolume?: boolean; + disableTimer?: boolean; + disableBack?: boolean; + }; + + export default class Video extends React.Component< + VideoProperties & VideoControlsProps + > { + player: { + ref: { + presentFullscreenPlayer(): void; + dismissFullscreenPlayer(): void; + restoreUserInterfaceForPictureInPictureStopCompleted( + restored: boolean, + ): void; + save(): Promise; + seek(time: number, tolerance?: number): void; + }; + }; + } +} diff --git a/todos.md b/todos.md index 2f03356d..73af0d6b 100644 --- a/todos.md +++ b/todos.md @@ -2,10 +2,10 @@ ## V1 -- [ ] Empty screen for bookmarks +- [x] Empty screen for bookmarks - [ ] Splash screen -- [ ] Full screen video page -- [ ] Custom icons for video player controls +- [x] Full screen video page +- [x] Custom icons for video player controls - [ ] Loading placeholder for feeds - [ ] Image component loading behaviour - [ ] Link preview error handling diff --git a/yarn.lock b/yarn.lock index 99973dde..18c71620 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5550,7 +5550,7 @@ lodash.upperfirst@^4.3.1: resolved "https://registry.yarnpkg.com/lodash.upperfirst/-/lodash.upperfirst-4.3.1.tgz#1365edf431480481ef0d1c68957a5ed99d49f7ce" integrity sha512-sReKOYJIJf74dhJONhU4e0/shzi1trVbSWDOhKYE5XV2O+H7Sb2Dihwuc7xWxVl+DgFPyTqIN3zMfT9cq5iWDg== -lodash@^4.17.15, lodash@^4.17.21: +lodash@^4.16.4, lodash@^4.17.15, lodash@^4.17.21: version "4.17.21" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c" integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg== @@ -6770,6 +6770,13 @@ react-native-vector-icons@9.2.0: prop-types "^15.7.2" yargs "^16.1.1" +react-native-video-controls@2.8.1: + version "2.8.1" + resolved "https://registry.yarnpkg.com/react-native-video-controls/-/react-native-video-controls-2.8.1.tgz#30ae707d8d218fed34bba3fc027b3943c5f438d9" + integrity sha512-dBmrE3TAKaR1gYMfbukjAM6Xo8OMZyRrxPzZtnaUgWcvGo11PQwzaI/j8HPD5fLgO+rlweP2pDpEJyIBsJvJkw== + dependencies: + lodash "^4.16.4" + react-native-video@6.0.0-alpha.6: version "6.0.0-alpha.6" resolved "https://registry.yarnpkg.com/react-native-video/-/react-native-video-6.0.0-alpha.6.tgz#8acdd70dbb4a213bc92dd9f25852488c46baa4d2"