From 529dfe802ce4ef143f2a55e47475dcbb9f89fb4d Mon Sep 17 00:00:00 2001 From: Zandor Smith Date: Sat, 28 Dec 2019 16:25:32 +0100 Subject: [PATCH] Fix bug: Incorrect values being returned on simulator. (#227) --- Source/Device.generated.swift | 15 ++++++++------- Source/Device.swift.gyb | 15 ++++++++------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/Source/Device.generated.swift b/Source/Device.generated.swift index 22ee31f..0b8210a 100644 --- a/Source/Device.generated.swift +++ b/Source/Device.generated.swift @@ -686,12 +686,12 @@ public enum Device { /// Returns whether or not the device has Touch ID public var isTouchIDCapable: Bool { - return isOneOf(Device.allTouchIDCapableDevices) + return isOneOf(Device.allTouchIDCapableDevices) || isOneOf(Device.allTouchIDCapableDevices.map(Device.simulator)) } /// Returns whether or not the device has Face ID public var isFaceIDCapable: Bool { - return isOneOf(Device.allFaceIDCapableDevices) + return isOneOf(Device.allFaceIDCapableDevices) || isOneOf(Device.allFaceIDCapableDevices.map(Device.simulator)) } /// Returns whether or not the device has any biometric sensor (i.e. Touch ID or Face ID) @@ -706,7 +706,7 @@ public enum Device { /// Returns whether or not the device has a sensor housing public var hasSensorHousing: Bool { - return isOneOf(Device.allDevicesWithSensorHousing) + return isOneOf(Device.allDevicesWithSensorHousing) || isOneOf(Device.allDevicesWithSensorHousing.map(Device.simulator)) } /// All devices that feature a screen with rounded corners. @@ -716,7 +716,7 @@ public enum Device { /// Returns whether or not the device has a screen with rounded corners. public var hasRoundedDisplayCorners: Bool { - return isOneOf(Device.allDevicesWithRoundedDisplayCorners) + return isOneOf(Device.allDevicesWithRoundedDisplayCorners) || isOneOf(Device.allDevicesWithRoundedDisplayCorners.map(Device.simulator)) } /// All devices that have 3D Touch support. @@ -726,7 +726,7 @@ public enum Device { /// Returns whether or not the device has 3D Touch support. public var has3dTouchSupport: Bool { - return isOneOf(Device.allDevicesWith3dTouchSupport) + return isOneOf(Device.allDevicesWith3dTouchSupport) || isOneOf(Device.allDevicesWith3dTouchSupport.map(Device.simulator)) } /// All devices that support wireless charging. @@ -736,7 +736,7 @@ public enum Device { /// Returns whether or not the device supports wireless charging public var supportsWirelessCharging: Bool { - return isOneOf(Device.allDevicesWithWirelessChargingSupport) + return isOneOf(Device.allDevicesWithWirelessChargingSupport) || isOneOf(Device.allDevicesWithWirelessChargingSupport.map(Device.simulator)) } #elseif os(tvOS) /// All TVs @@ -766,7 +766,7 @@ public enum Device { /// Returns whether or not the device has Force Touch support. public var hasForceTouchSupport: Bool { - return isOneOf(Device.allWatchesWithForceTouchSupport) + return isOneOf(Device.allWatchesWithForceTouchSupport) || isOneOf(Device.allWatchesWithForceTouchSupport.map(Device.simulator)) } #endif @@ -1321,6 +1321,7 @@ extension Device { case .iPadPro10Inch: return .firstGeneration case .iPadPro11Inch: return .secondGeneration case .iPadPro12Inch3: return .secondGeneration + case .simulator(let model): return model.applePencilSupport default: return [] } } diff --git a/Source/Device.swift.gyb b/Source/Device.swift.gyb index 3a208ba..4622f97 100644 --- a/Source/Device.swift.gyb +++ b/Source/Device.swift.gyb @@ -482,12 +482,12 @@ public enum Device { /// Returns whether or not the device has Touch ID public var isTouchIDCapable: Bool { - return isOneOf(Device.allTouchIDCapableDevices) + return isOneOf(Device.allTouchIDCapableDevices) || isOneOf(Device.allTouchIDCapableDevices.map(Device.simulator)) } /// Returns whether or not the device has Face ID public var isFaceIDCapable: Bool { - return isOneOf(Device.allFaceIDCapableDevices) + return isOneOf(Device.allFaceIDCapableDevices) || isOneOf(Device.allFaceIDCapableDevices.map(Device.simulator)) } /// Returns whether or not the device has any biometric sensor (i.e. Touch ID or Face ID) @@ -502,7 +502,7 @@ public enum Device { /// Returns whether or not the device has a sensor housing public var hasSensorHousing: Bool { - return isOneOf(Device.allDevicesWithSensorHousing) + return isOneOf(Device.allDevicesWithSensorHousing) || isOneOf(Device.allDevicesWithSensorHousing.map(Device.simulator)) } /// All devices that feature a screen with rounded corners. @@ -512,7 +512,7 @@ public enum Device { /// Returns whether or not the device has a screen with rounded corners. public var hasRoundedDisplayCorners: Bool { - return isOneOf(Device.allDevicesWithRoundedDisplayCorners) + return isOneOf(Device.allDevicesWithRoundedDisplayCorners) || isOneOf(Device.allDevicesWithRoundedDisplayCorners.map(Device.simulator)) } /// All devices that have 3D Touch support. @@ -522,7 +522,7 @@ public enum Device { /// Returns whether or not the device has 3D Touch support. public var has3dTouchSupport: Bool { - return isOneOf(Device.allDevicesWith3dTouchSupport) + return isOneOf(Device.allDevicesWith3dTouchSupport) || isOneOf(Device.allDevicesWith3dTouchSupport.map(Device.simulator)) } /// All devices that support wireless charging. @@ -532,7 +532,7 @@ public enum Device { /// Returns whether or not the device supports wireless charging public var supportsWirelessCharging: Bool { - return isOneOf(Device.allDevicesWithWirelessChargingSupport) + return isOneOf(Device.allDevicesWithWirelessChargingSupport) || isOneOf(Device.allDevicesWithWirelessChargingSupport.map(Device.simulator)) } #elseif os(tvOS) /// All TVs @@ -562,7 +562,7 @@ public enum Device { /// Returns whether or not the device has Force Touch support. public var hasForceTouchSupport: Bool { - return isOneOf(Device.allWatchesWithForceTouchSupport) + return isOneOf(Device.allWatchesWithForceTouchSupport) || isOneOf(Device.allWatchesWithForceTouchSupport.map(Device.simulator)) } #endif @@ -1012,6 +1012,7 @@ extension Device { % for device in list(filter(lambda device: device.applePencilSupport == 2, iOSDevices)): case .${device.caseName}: return .secondGeneration % end + case .simulator(let model): return model.applePencilSupport default: return [] } }