mirror of
https://github.com/status-im/react-native.git
synced 2025-01-13 19:15:05 +00:00
Back out "[react-native][PR] Remove the deprecated isIPhoneX_deprecated
constant"
Summary: Original commit changeset: 0b0b3a2d7b80 Reverting D8714400 which removed the `isIPhoneX_deprecated` flag, which is still widely used across the RN codebase https://fburl.com/biggrep/16jg5bzn Reviewed By: hramos Differential Revision: D8743401 fbshipit-source-id: cfc44bdd8019eda41e67ca573b20be417d121d12
This commit is contained in:
parent
46ffb10627
commit
0f4926598a
@ -64,6 +64,21 @@ class SafeAreaViewExample extends React.Component<
|
||||
}
|
||||
}
|
||||
|
||||
class IsIPhoneXExample extends React.Component<{}> {
|
||||
render() {
|
||||
return (
|
||||
<View>
|
||||
<Text>
|
||||
Is this an iPhone X:{' '}
|
||||
{DeviceInfo.isIPhoneX_deprecated
|
||||
? 'Yeah!'
|
||||
: 'Nope. (Or `isIPhoneX_deprecated` was already removed.)'}
|
||||
</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
exports.examples = [
|
||||
{
|
||||
title: '<SafeAreaView> Example',
|
||||
@ -71,6 +86,15 @@ exports.examples = [
|
||||
'SafeAreaView automatically applies paddings reflect the portion of the view that is not covered by other (special) ancestor views.',
|
||||
render: () => <SafeAreaViewExample />,
|
||||
},
|
||||
{
|
||||
title: 'isIPhoneX_deprecated Example',
|
||||
description:
|
||||
'`DeviceInfo.isIPhoneX_deprecated` returns true only on iPhone X. ' +
|
||||
'Note: This prop is deprecated and will be removed right after June 01, 2018. ' +
|
||||
'Please use this only for a quick and temporary solution. ' +
|
||||
'Use <SafeAreaView> instead.',
|
||||
render: () => <IsIPhoneXExample />,
|
||||
},
|
||||
];
|
||||
|
||||
var styles = StyleSheet.create({
|
||||
|
@ -51,6 +51,22 @@ RCT_EXPORT_MODULE()
|
||||
#endif
|
||||
}
|
||||
|
||||
static BOOL RCTIsIPhoneX() {
|
||||
static BOOL isIPhoneX = NO;
|
||||
static dispatch_once_t onceToken;
|
||||
|
||||
dispatch_once(&onceToken, ^{
|
||||
RCTAssertMainQueue();
|
||||
|
||||
isIPhoneX = CGSizeEqualToSize(
|
||||
[UIScreen mainScreen].nativeBounds.size,
|
||||
CGSizeMake(1125, 2436)
|
||||
);
|
||||
});
|
||||
|
||||
return isIPhoneX;
|
||||
}
|
||||
|
||||
static NSDictionary *RCTExportedDimensions(RCTBridge *bridge)
|
||||
{
|
||||
RCTAssertMainQueue();
|
||||
@ -86,6 +102,11 @@ static NSDictionary *RCTExportedDimensions(RCTBridge *bridge)
|
||||
{
|
||||
return @{
|
||||
@"Dimensions": RCTExportedDimensions(_bridge),
|
||||
// Note:
|
||||
// This prop is deprecated and will be removed right after June 01, 2018.
|
||||
// Please use this only for a quick and temporary solution.
|
||||
// Use <SafeAreaView> instead.
|
||||
@"isIPhoneX_deprecated": @(RCTIsIPhoneX()),
|
||||
};
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user