-
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.
* add loader component to video * fix image sizing * add back handler for modal dismissals * show recent conversations in chat forward
- Loading branch information
1 parent
85cca2b
commit 766b2a4
Showing
10 changed files
with
393 additions
and
101 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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,38 @@ | ||
import { BottomSheetModal, BottomSheetModalProps } from '@gorhom/bottom-sheet'; | ||
import { useCallback, useRef } from 'react'; | ||
import { BackHandler, NativeEventSubscription } from 'react-native'; | ||
|
||
/** | ||
* src: https://gist.github.com/vanenshi/6c2938d2f7424979d76c06d66703df19 | ||
* hook that dismisses the bottom sheet on the hardware back button press if it is visible | ||
* @param bottomSheetRef ref to the bottom sheet which is going to be closed/dismissed on the back press | ||
*/ | ||
export const useBottomSheetBackHandler = ( | ||
bottomSheetRef: React.RefObject<BottomSheetModal | null>, | ||
) => { | ||
const backHandlerSubscriptionRef = useRef<NativeEventSubscription | null>( | ||
null, | ||
); | ||
const handleSheetPositionChange = useCallback< | ||
NonNullable<BottomSheetModalProps['onChange']> | ||
>( | ||
index => { | ||
const isBottomSheetVisible = index >= 0; | ||
if (isBottomSheetVisible && !backHandlerSubscriptionRef.current) { | ||
// setup the back handler if the bottom sheet is right in front of the user | ||
backHandlerSubscriptionRef.current = BackHandler.addEventListener( | ||
'hardwareBackPress', | ||
() => { | ||
bottomSheetRef.current?.dismiss(); | ||
return true; | ||
}, | ||
); | ||
} else if (!isBottomSheetVisible) { | ||
backHandlerSubscriptionRef.current?.remove(); | ||
backHandlerSubscriptionRef.current = null; | ||
} | ||
}, | ||
[bottomSheetRef, backHandlerSubscriptionRef], | ||
); | ||
return { handleSheetPositionChange }; | ||
}; |
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