Skip to content

Commit

Permalink
Merge pull request #6291 from kakajann/iphonex-landscape-ui-fixes
Browse files Browse the repository at this point in the history
iPhoneX Landscape UI
  • Loading branch information
Julesssss authored Nov 16, 2021
2 parents 239e326 + 2caddf0 commit c7e618c
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {LocaleContextProvider} from './components/withLocalize';
import OnyxProvider from './components/OnyxProvider';
import HTMLEngineProvider from './components/HTMLEngineProvider';
import ComposeProviders from './components/ComposeProviders';
import SafeArea from './components/SafeArea';

LogBox.ignoreLogs([
// Basically it means that if the app goes in the background and back to foreground on Android,
Expand All @@ -25,6 +26,7 @@ const App = () => (
components={[
OnyxProvider,
SafeAreaProvider,
SafeArea,
LocaleContextProvider,
HTMLEngineProvider,
]}
Expand Down
4 changes: 4 additions & 0 deletions src/components/Modal/BaseModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,15 @@ class BaseModal extends PureComponent {
const {
paddingTop: safeAreaPaddingTop,
paddingBottom: safeAreaPaddingBottom,
paddingLeft: safeAreaPaddingLeft,
paddingRight: safeAreaPaddingRight,
} = getSafeAreaPadding(insets);

const modalPaddingStyles = getModalPaddingStyles({
safeAreaPaddingTop,
safeAreaPaddingBottom,
safeAreaPaddingLeft,
safeAreaPaddingRight,
shouldAddBottomSafeAreaPadding,
shouldAddTopSafeAreaPadding,
modalContainerStylePaddingTop: modalContainerStyle.paddingTop,
Expand Down
17 changes: 17 additions & 0 deletions src/components/SafeArea/index.ios.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import React from 'react';
import {SafeAreaView} from 'react-native-safe-area-context';
import PropTypes from 'prop-types';
import styles from '../../styles/styles';

const SafeArea = props => (
<SafeAreaView style={[styles.iPhoneXSafeArea]} edges={['left', 'right']}>
{props.children}
</SafeAreaView>
);

SafeArea.propTypes = {
/** App content */
children: PropTypes.node.isRequired,
};

export default SafeArea;
1 change: 1 addition & 0 deletions src/components/SafeArea/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default ({children}) => children;
11 changes: 11 additions & 0 deletions src/styles/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -2088,6 +2088,11 @@ const styles = {
googleListView: {
transform: [{scale: 0}],
},

iPhoneXSafeArea: {
backgroundColor: colors.black,
flex: 1,
},
};

const baseCodeTagStyles = {
Expand Down Expand Up @@ -2191,6 +2196,8 @@ function getSafeAreaPadding(insets) {
return {
paddingTop: insets.top,
paddingBottom: insets.bottom * variables.safeInsertPercentage,
paddingLeft: insets.left * variables.safeInsertPercentage,
paddingRight: insets.right * variables.safeInsertPercentage,
};
}

Expand Down Expand Up @@ -2403,6 +2410,8 @@ function getModalPaddingStyles({
shouldAddTopSafeAreaPadding,
safeAreaPaddingTop,
safeAreaPaddingBottom,
safeAreaPaddingLeft,
safeAreaPaddingRight,
modalContainerStylePaddingTop,
modalContainerStylePaddingBottom,
}) {
Expand All @@ -2413,6 +2422,8 @@ function getModalPaddingStyles({
paddingBottom: shouldAddBottomSafeAreaPadding
? (modalContainerStylePaddingBottom || 0) + safeAreaPaddingBottom
: modalContainerStylePaddingBottom || 0,
paddingLeft: safeAreaPaddingLeft || 0,
paddingRight: safeAreaPaddingRight || 0,
};
}

Expand Down

0 comments on commit c7e618c

Please sign in to comment.