|
1 | 1 | import React from 'react'; |
2 | | -import { Animated, Platform, StyleSheet, View } from 'react-native'; |
| 2 | +import { Animated, Dimensions, Platform, StyleSheet, View } from 'react-native'; |
3 | 3 | import { withNavigation, HeaderBackButton } from 'react-navigation'; |
4 | 4 |
|
| 5 | +const X_WIDTH = 375; |
| 6 | +const X_HEIGHT = 812; |
| 7 | +const { height: D_HEIGHT, width: D_WIDTH } = Dimensions.get('window'); |
| 8 | +const isIPhoneX = |
| 9 | + Platform.OS === 'ios' && (D_HEIGHT === X_HEIGHT && D_WIDTH === X_WIDTH); |
| 10 | + |
| 11 | +const NOTCH_HEIGHT = isIPhoneX ? 20 : 0; |
5 | 12 | const APPBAR_HEIGHT = Platform.OS === 'ios' ? 50 : 56; |
6 | 13 | const STATUSBAR_HEIGHT = Platform.OS === 'ios' ? 20 : 0; |
7 | 14 | const TITLE_OFFSET = Platform.OS === 'ios' ? 70 : 56; |
8 | 15 |
|
9 | 16 | @withNavigation |
10 | 17 | export default class Header extends React.PureComponent { |
11 | | - static HEIGHT = APPBAR_HEIGHT + STATUSBAR_HEIGHT; |
| 18 | + static HEIGHT = APPBAR_HEIGHT + STATUSBAR_HEIGHT + NOTCH_HEIGHT; |
12 | 19 |
|
13 | 20 | _navigateBack = () => { |
14 | 21 | this.props.navigation.goBack(null); |
@@ -71,8 +78,8 @@ if (Platform.OS === 'ios') { |
71 | 78 | const styles = StyleSheet.create({ |
72 | 79 | container: { |
73 | 80 | backgroundColor: '#fff', |
74 | | - paddingTop: STATUSBAR_HEIGHT, |
75 | | - height: STATUSBAR_HEIGHT + APPBAR_HEIGHT, |
| 81 | + paddingTop: STATUSBAR_HEIGHT + NOTCH_HEIGHT, |
| 82 | + height: STATUSBAR_HEIGHT + APPBAR_HEIGHT + NOTCH_HEIGHT, |
76 | 83 | ...platformContainerStyles, |
77 | 84 | }, |
78 | 85 | appBar: { |
|
0 commit comments