From ddad63af533dd7905b1f818f2466918a0f12f4d5 Mon Sep 17 00:00:00 2001 From: Tobias Kuhlebrock Date: Sat, 3 Feb 2018 17:56:59 +0100 Subject: [PATCH] Add iPhone X support --- src/ios/PrivacyScreenPlugin.h | 1 + src/ios/PrivacyScreenPlugin.m | 17 +++++++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/ios/PrivacyScreenPlugin.h b/src/ios/PrivacyScreenPlugin.h index 6ce5c3a..7b86c65 100644 --- a/src/ios/PrivacyScreenPlugin.h +++ b/src/ios/PrivacyScreenPlugin.h @@ -14,6 +14,7 @@ typedef struct { BOOL iPhone5; BOOL iPhone6; BOOL iPhone6Plus; + BOOL iPhoneX; BOOL retina; } CDV_iOSDevice; diff --git a/src/ios/PrivacyScreenPlugin.m b/src/ios/PrivacyScreenPlugin.m index 67303ee..fb85ad5 100644 --- a/src/ios/PrivacyScreenPlugin.m +++ b/src/ios/PrivacyScreenPlugin.m @@ -70,6 +70,7 @@ - (CDV_iOSDevice) getCurrentDevice // this is appropriate for detecting the runtime screen environment device.iPhone6 = (device.iPhone && limit == 667.0); device.iPhone6Plus = (device.iPhone && limit == 736.0); + device.iPhoneX = (device.iPhone && limit == 812.0); return device; } @@ -100,8 +101,12 @@ - (NSString*)getImageName:(UIInterfaceOrientation)currentOrientation delegate:(i imageName = [imageName stringByAppendingString:@"-700"]; } else if(device.iPhone6) { imageName = [imageName stringByAppendingString:@"-800"]; - } else if(device.iPhone6Plus) { - imageName = [imageName stringByAppendingString:@"-800"]; + } else if(device.iPhone6Plus || device.iPhoneX) { + if(device.iPhone6Plus) { + imageName = [imageName stringByAppendingString:@"-800"]; + } else { + imageName = [imageName stringByAppendingString:@"-1100"]; + } if (currentOrientation == UIInterfaceOrientationPortrait || currentOrientation == UIInterfaceOrientationPortraitUpsideDown) { imageName = [imageName stringByAppendingString:@"-Portrait"]; } @@ -115,7 +120,7 @@ - (NSString*)getImageName:(UIInterfaceOrientation)currentOrientation delegate:(i imageName = isLandscape ? nil : [imageName stringByAppendingString:@"-568h"]; } else if (device.iPhone6) { // does not support landscape imageName = isLandscape ? nil : [imageName stringByAppendingString:@"-667h"]; - } else if (device.iPhone6Plus) { // supports landscape + } else if (device.iPhone6Plus || device.iPhoneX) { // supports landscape if (isOrientationLocked) { imageName = [imageName stringByAppendingString:(supportsLandscape ? @"-Landscape" : @"")]; } else { @@ -128,7 +133,11 @@ - (NSString*)getImageName:(UIInterfaceOrientation)currentOrientation delegate:(i break; } } - imageName = [imageName stringByAppendingString:@"-736h"]; + if (device.iPhoneX) { + imageName = [imageName stringByAppendingString:@"-2436h"]; + } else { + imageName = [imageName stringByAppendingString:@"-736h"]; + } } else if (device.iPad) { // supports landscape if (isOrientationLocked) {