-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Temporary fix for modal being on top of some action menus (#6362)
- Loading branch information
Showing
8 changed files
with
151 additions
and
136 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
14 changes: 8 additions & 6 deletions
14
...lib/navigation/hooks/useShareFromModal.ts → ...gation/hooks/useHideModalUntilResolved.ts
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 |
---|---|---|
@@ -1,23 +1,25 @@ | ||
import {useBottomSheet} from '@gorhom/bottom-sheet'; | ||
import {useCallback} from 'react'; | ||
import {Share, ShareContent, ShareOptions} from 'react-native'; | ||
|
||
/* | ||
This hook hides the current modal and opens the share modal to prevent it from being rendered behind the current modal | ||
Bottom sheet modals are rendered with FullWindowModal, which is a full-screen modal that covers the entire screen | ||
https://github.com/th3rdwave/react-navigation-bottom-sheet/blob/ef8c616559a3fdbb67149d6e1ebc9bb662d71255/src/BottomSheetView.tsx#L27-L31 | ||
*/ | ||
const useShareFromModal = () => { | ||
const useHideModalUntilResolved = <TArgs extends any[]>( | ||
fn: (...args: TArgs) => Promise<any>, | ||
) => { | ||
const bottomSheet = useBottomSheet(); | ||
return useCallback( | ||
async (content: ShareContent, options?: ShareOptions) => { | ||
async (...args: TArgs) => { | ||
const currentSnapIndex = bottomSheet.animatedIndex.value; | ||
bottomSheet.snapToPosition(0.0000001); // Hide without closing it | ||
await Share.share(content, options); | ||
const ret = await fn(...args); | ||
bottomSheet.snapToIndex(currentSnapIndex); // Restore the position | ||
return ret; | ||
}, | ||
[bottomSheet], | ||
[bottomSheet, fn], | ||
); | ||
}; | ||
|
||
export default useShareFromModal; | ||
export default useHideModalUntilResolved; |
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
Oops, something went wrong.