Skip to content

Commit b0073b9

Browse files
committed
Add pull request "Add IPhone X Support devgeeks#48"
1 parent 0bc0f59 commit b0073b9

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

src/ios/PrivacyScreenPlugin.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ typedef struct {
1414
BOOL iPhone5;
1515
BOOL iPhone6;
1616
BOOL iPhone6Plus;
17+
BOOL iPhoneX;
1718
BOOL retina;
1819

1920
} CDV_iOSDevice;

src/ios/PrivacyScreenPlugin.m

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ - (CDV_iOSDevice) getCurrentDevice
7070
// this is appropriate for detecting the runtime screen environment
7171
device.iPhone6 = (device.iPhone && limit == 667.0);
7272
device.iPhone6Plus = (device.iPhone && limit == 736.0);
73+
device.iPhoneX = (device.iPhone && limit == 812.0);
7374

7475
return device;
7576
}
@@ -100,8 +101,12 @@ - (NSString*)getImageName:(UIInterfaceOrientation)currentOrientation delegate:(i
100101
imageName = [imageName stringByAppendingString:@"-700"];
101102
} else if(device.iPhone6) {
102103
imageName = [imageName stringByAppendingString:@"-800"];
103-
} else if(device.iPhone6Plus) {
104-
imageName = [imageName stringByAppendingString:@"-800"];
104+
} else if(device.iPhone6Plus || device.iPhoneX) {
105+
if(device.iPhone6Plus) {
106+
imageName = [imageName stringByAppendingString:@"-800"];
107+
} else {
108+
imageName = [imageName stringByAppendingString:@"-1100"];
109+
}
105110
if (currentOrientation == UIInterfaceOrientationPortrait || currentOrientation == UIInterfaceOrientationPortraitUpsideDown) {
106111
imageName = [imageName stringByAppendingString:@"-Portrait"];
107112
}
@@ -115,7 +120,7 @@ - (NSString*)getImageName:(UIInterfaceOrientation)currentOrientation delegate:(i
115120
imageName = isLandscape ? nil : [imageName stringByAppendingString:@"-568h"];
116121
} else if (device.iPhone6) { // does not support landscape
117122
imageName = isLandscape ? nil : [imageName stringByAppendingString:@"-667h"];
118-
} else if (device.iPhone6Plus) { // supports landscape
123+
} else if (device.iPhone6Plus || device.iPhoneX) { // supports landscape
119124
if (isOrientationLocked) {
120125
imageName = [imageName stringByAppendingString:(supportsLandscape ? @"-Landscape" : @"")];
121126
} else {
@@ -128,7 +133,11 @@ - (NSString*)getImageName:(UIInterfaceOrientation)currentOrientation delegate:(i
128133
break;
129134
}
130135
}
131-
imageName = [imageName stringByAppendingString:@"-736h"];
136+
if (device.iPhoneX) {
137+
imageName = [imageName stringByAppendingString:@"-2436h"];
138+
} else {
139+
imageName = [imageName stringByAppendingString:@"-736h"];
140+
}
132141

133142
} else if (device.iPad) { // supports landscape
134143
if (isOrientationLocked) {

0 commit comments

Comments
 (0)