Skip to content
This repository was archived by the owner on Dec 3, 2024. It is now read-only.

Commit 2661f48

Browse files
committed
Better notch handling
1 parent a9e647d commit 2661f48

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
{
22
"name": "react-navigation-addon-search-layout",
3-
"version": "0.12.4",
3+
"version": "0.12.5",
44
"main": "index.js",
55
"license": "MIT",
66
"types": "react-navigation-search-layout.d.ts",
77
"dependencies": {
8+
"react-native-iphone-x-helper": "^1.2.0",
89
"react-native-platform-touchable": "^1.1.1"
910
}
1011
}

src/Header.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
import React from 'react';
22
import { Animated, Dimensions, Platform, StatusBar, StyleSheet, View } from 'react-native';
33
import { withNavigation, HeaderBackButton } from 'react-navigation';
4+
import { isIphoneX } from 'react-native-iphone-x-helper'
5+
6+
// @todo: make this work properly when in landscape
7+
const hasNotch = isIphoneX();
48

59
const APPBAR_HEIGHT = Platform.OS === 'ios' ? 50 : 56;
610
const TITLE_OFFSET = Platform.OS === 'ios' ? 70 : 56;
711

812
// @todo: this is static and we don't know if it's visible or not on iOS.
913
// need to use a more reliable and cross-platform API when one exists, like
1014
// LayoutContext.
11-
const STATUSBAR_HEIGHT = Platform.OS === 'ios' ? 25 : StatusBar.currentHeight;
15+
const STATUSBAR_HEIGHT = Platform.OS === 'ios' ? (hasNotch ? 40 : 25) : StatusBar.currentHeight;
1216

1317
@withNavigation
1418
export default class Header extends React.PureComponent {

yarn.lock

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22
# yarn lockfile v1
33

44

5+
react-native-iphone-x-helper@^1.2.0:
6+
version "1.2.0"
7+
resolved "https://registry.yarnpkg.com/react-native-iphone-x-helper/-/react-native-iphone-x-helper-1.2.0.tgz#9f8a376eb00bc712115abff4420318a0063fa796"
8+
integrity sha512-xIeTo4s77wwKgBZLVRIZC9tM9/PkXS46Ul76NXmvmixEb3ZwqGdQesR3zRiLMOoIdfOURB6N9bba9po7+x9Bag==
9+
510
react-native-platform-touchable@^1.1.1:
611
version "1.1.1"
712
resolved "https://registry.yarnpkg.com/react-native-platform-touchable/-/react-native-platform-touchable-1.1.1.tgz#fde4acc65eea585d28b164d0c3716a42129a68e4"
13+
integrity sha1-/eSsxl7qWF0osWTQw3FqQhKaaOQ=

0 commit comments

Comments
 (0)