forked from berty/berty
-
-
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.
Signed-off-by: Sakul <sakulbudhathoki977@gmail.com>
- Loading branch information
1 parent
af37ff8
commit 48ba6b0
Showing
8 changed files
with
77 additions
and
21 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
64 changes: 47 additions & 17 deletions
64
js/packages/components/shared-components/KeyboardAvoidingView.tsx
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,18 +1,48 @@ | ||
import React from 'react' | ||
import { KeyboardAvoidingView as KeyboardAvoiding, KeyboardAvoidingViewProps } from 'react-native' | ||
// import { useSafeAreaInsets } from 'react-native-safe-area-context' | ||
// import { useMusicPlayer } from '@berty-tech/music-player' | ||
// import { HEIGHT_OF_PLAYER, MARGIN_FIX } from './StickyMusicPlayer' | ||
export const KeyboardAvoidingView: React.FC<KeyboardAvoidingViewProps> = (props) => { | ||
// const { top } = useSafeAreaInsets() | ||
// const { | ||
// player: { player }, | ||
// } = useMusicPlayer() | ||
|
||
return ( | ||
<KeyboardAvoiding | ||
{...props} | ||
// keyboardVerticalOffset={player ? HEIGHT_OF_PLAYER - top + MARGIN_FIX : 0} | ||
/> | ||
) | ||
import React, { useState } from 'react' | ||
import { | ||
KeyboardAvoidingView as KeyboardAvoiding, | ||
KeyboardAvoidingViewProps, | ||
Platform, | ||
StatusBar, | ||
} from 'react-native' | ||
|
||
import { useMusicPlayer } from '@berty-tech/music-player' | ||
import { HEIGHT_OF_PLAYER } from './StickyMusicPlayer' | ||
|
||
interface CustomKeyboardAvoidingViewProps extends KeyboardAvoidingViewProps { | ||
bottomFixedViewPadding?: number | ||
} | ||
|
||
export const KeyboardAvoidingView: React.FC<CustomKeyboardAvoidingViewProps> = ({ | ||
bottomFixedViewPadding = 0, | ||
...props | ||
}) => { | ||
const { | ||
player: { player }, | ||
} = useMusicPlayer() | ||
|
||
const [initialMode] = useState(!!player) | ||
|
||
const defaultAndroidStatusBarHeight = 24 | ||
let offset = Platform.OS === 'android' ? bottomFixedViewPadding : 0 | ||
|
||
if ( | ||
Platform.OS === 'android' && | ||
StatusBar.currentHeight && | ||
StatusBar.currentHeight > defaultAndroidStatusBarHeight | ||
) { | ||
offset += StatusBar.currentHeight - defaultAndroidStatusBarHeight | ||
} | ||
|
||
if (Platform.OS === 'android' && initialMode !== !!player) { | ||
if (player) { | ||
offset += HEIGHT_OF_PLAYER * 2 | ||
} else { | ||
offset -= HEIGHT_OF_PLAYER | ||
} | ||
} else if (player) { | ||
offset += HEIGHT_OF_PLAYER | ||
} | ||
|
||
return <KeyboardAvoiding {...props} keyboardVerticalOffset={offset} /> | ||
} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.