From 8712976a473ff54dd8a5bdd62bb72fb610b62022 Mon Sep 17 00:00:00 2001 From: Marc Rousavy Date: Fri, 19 Feb 2021 19:08:38 +0100 Subject: [PATCH] Update Media.tsx --- example/src/Media.tsx | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/example/src/Media.tsx b/example/src/Media.tsx index 0d2fa20..a24743b 100644 --- a/example/src/Media.tsx +++ b/example/src/Media.tsx @@ -3,6 +3,8 @@ import { StyleSheet, View, Text, Image, Pressable } from 'react-native'; import { Navigation, NavigationFunctionComponent } from 'react-native-navigation'; import Video from 'react-native-video'; import { CONTENT_SPACING } from './Constants'; +import { useIsForeground } from './hooks/useIsForeground'; +import { useIsScreenFocused } from './hooks/useIsScreenFocused'; interface MediaProps { path: string, @@ -10,6 +12,10 @@ interface MediaProps { } export const Media: NavigationFunctionComponent = ({ componentId, type, path }) => { + const isForeground = useIsForeground(); + const isScreenFocused = useIsScreenFocused(componentId); + const isVideoPaused = !isForeground || !isScreenFocused; + const onClosePressed = useCallback(() => { Navigation.dismissModal(componentId); }, [componentId]); @@ -18,8 +24,27 @@ export const Media: NavigationFunctionComponent = ({ componentId, ty return ( - {type === "photo" && ()} - {type === "video" && (