forked from Expensify/App
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request Expensify#38407 from software-mansion-labs/@Skalak…
…id/fix-video-element-sharing Fix video sharing
- Loading branch information
Showing
11 changed files
with
165 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import React, {useCallback, useContext, useMemo, useRef} from 'react'; | ||
import type WindowDimensions from '@hooks/useWindowDimensions/types'; | ||
import type ChildrenProps from '@src/types/utils/ChildrenProps'; | ||
import type {FullScreenContext} from './types'; | ||
|
||
const Context = React.createContext<FullScreenContext | null>(null); | ||
|
||
function FullScreenContextProvider({children}: ChildrenProps) { | ||
const isFullScreenRef = useRef(false); | ||
const lockedWindowDimensionsRef = useRef<WindowDimensions | null>(null); | ||
|
||
const lockWindowDimensions = useCallback((newWindowDimensions: WindowDimensions) => { | ||
lockedWindowDimensionsRef.current = newWindowDimensions; | ||
}, []); | ||
|
||
const unlockWindowDimensions = useCallback(() => { | ||
lockedWindowDimensionsRef.current = null; | ||
}, []); | ||
|
||
const contextValue = useMemo(() => ({isFullScreenRef, lockedWindowDimensionsRef, lockWindowDimensions, unlockWindowDimensions}), [lockWindowDimensions, unlockWindowDimensions]); | ||
return <Context.Provider value={contextValue}>{children}</Context.Provider>; | ||
} | ||
|
||
function useFullScreenContext() { | ||
const fullscreenContext = useContext(Context); | ||
if (!fullscreenContext) { | ||
throw new Error('useFullScreenContext must be used within a FullScreenContextProvider'); | ||
} | ||
return fullscreenContext; | ||
} | ||
|
||
FullScreenContextProvider.displayName = 'FullScreenContextProvider'; | ||
|
||
export {Context as FullScreenContext, FullScreenContextProvider, useFullScreenContext}; |
Oops, something went wrong.