-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: extract Android specific safe area logic and simplify safe area …
…components/hooks
- Loading branch information
1 parent
dbcaad9
commit b011c91
Showing
10 changed files
with
43 additions
and
64 deletions.
There are no files selected for viewing
This file was deleted.
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
File renamed without changes.
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
const defaultInsets = {top: 0, bottom: 0, left: 0, right: 0}; | ||
|
||
export default defaultInsets; |
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,18 @@ | ||
import type {EdgeInsets} from 'react-native-safe-area-context'; | ||
import StatusBar from '@libs/StatusBar'; | ||
import defaultInsets from './defaultInsets'; | ||
|
||
/** | ||
* On Android we want to use the StatusBar height rather than the top safe area inset. | ||
* @returns | ||
*/ | ||
function getSafeAreaInsets(safeAreaInsets: EdgeInsets | null): EdgeInsets { | ||
const insets = safeAreaInsets ?? defaultInsets; | ||
|
||
return { | ||
...insets, | ||
top: StatusBar.currentHeight ?? insets.top, | ||
}; | ||
} | ||
|
||
export default getSafeAreaInsets; |
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,13 @@ | ||
import type {EdgeInsets} from 'react-native-safe-area-context'; | ||
import defaultInsets from './defaultInsets'; | ||
|
||
/** | ||
* Noop on web and iOS. This utility function is only needed on Android. | ||
* @returns | ||
*/ | ||
function getSafeAreaInsets(safeAreaInsets: EdgeInsets | null): EdgeInsets { | ||
const insets = safeAreaInsets ?? defaultInsets; | ||
return insets; | ||
} | ||
|
||
export default getSafeAreaInsets; |
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