Skip to content

Commit c9f4e91

Browse files
authored
Merge pull request #2 from iSapozhnik/feature/adding-new-devices
Feature/adding new devices
2 parents b341f4a + f4c2fd5 commit c9f4e91

File tree

3 files changed

+73
-31
lines changed

3 files changed

+73
-31
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>IDEDidComputeMac32BitWarning</key>
6+
<true/>
7+
</dict>
8+
</plist>

Haptico.podspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
Pod::Spec.new do |s|
1010
s.name = 'Haptico'
11-
s.version = '1.0.1'
11+
s.version = '1.0.2'
1212
s.summary = 'Haptico - easy to use haptic feedback generator with pattern-play support'
1313

1414
# This description is used to generate tags and improve search results.

Haptico/Classes/Extensions/UIDevice+Extensions.swift

+64-30
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import Foundation
99

1010
// https://github.com/schickling/Device.swift/blob/master/Device/UIDeviceExtension.swift
11+
// https://ipsw.me/otas
1112
// MARK: -
1213
internal extension UIDevice {
1314

@@ -21,21 +22,24 @@ internal extension UIDevice {
2122
return deviceType == .iPhone6S || deviceType == .iPhone6SPlus ||
2223
deviceType == .iPhone7 || deviceType == .iPhone7Plus ||
2324
deviceType == .iPhone8 || deviceType == .iPhone8Plus ||
24-
deviceType == .iPhoneX
25+
deviceType == .iPhoneX || deviceType == .iPhoneXR ||
26+
deviceType == .iPhoneXS || deviceType == .iPhoneXSMax
27+
2528
}
2629
}
2730

2831
internal var hasHapticFeedback: Bool {
2932
get {
3033
return deviceType == .iPhone7 || deviceType == .iPhone7Plus ||
31-
deviceType == .iPhone8 || deviceType == .iPhone8Plus ||
32-
deviceType == .iPhoneX
34+
deviceType == .iPhone8 || deviceType == .iPhone8Plus ||
35+
deviceType == .iPhoneX || deviceType == .iPhoneXR ||
36+
deviceType == .iPhoneXS || deviceType == .iPhoneXSMax
3337
}
3438
}
3539
}
3640

3741
/// Enum representing the different types of iOS devices available
38-
internal enum DeviceType: String, EnumProtocol {
42+
internal enum DeviceType: String {
3943
case iPhone2G
4044

4145
case iPhone3G
@@ -63,6 +67,9 @@ internal enum DeviceType: String, EnumProtocol {
6367
case iPhone8Plus
6468

6569
case iPhoneX
70+
case iPhoneXS
71+
case iPhoneXSMax
72+
case iPhoneXR
6673

6774
case iPodTouch1G
6875
case iPodTouch2G
@@ -113,7 +120,6 @@ internal enum DeviceType: String, EnumProtocol {
113120
// MARK: Variables
114121
/// Returns the display name of the device type
115122
internal var displayName: String {
116-
117123
switch self {
118124
case .iPhone2G: return "iPhone 2G"
119125
case .iPhone3G: return "iPhone 3G"
@@ -133,6 +139,9 @@ internal enum DeviceType: String, EnumProtocol {
133139
case .iPhone8: return "iPhone 8"
134140
case .iPhone8Plus: return "iPhone 8 Plus"
135141
case .iPhoneX: return "iPhone X"
142+
case .iPhoneXS: return "iPHone XS"
143+
case .iPhoneXSMax: return "iPhone XS Max"
144+
case .iPhoneXR: return "iPhone XR"
136145
case .iPodTouch1G: return "iPod Touch 1G"
137146
case .iPodTouch2G: return "iPod Touch 2G"
138147
case .iPodTouch3G: return "iPod Touch 3G"
@@ -181,7 +190,10 @@ internal enum DeviceType: String, EnumProtocol {
181190
case .iPhone8: return ["iPhone10,1", "iPhone10,4"]
182191
case .iPhone8Plus: return ["iPhone10,2", "iPhone10,5"]
183192
case .iPhoneX: return ["iPhone10,3", "iPhone10,6"]
184-
193+
case .iPhoneXS: return ["iPhone11,2"]
194+
case .iPhoneXSMax: return ["iPhone11,4", "iPhone11,6"]
195+
case .iPhoneXR: return ["iPhone11,8"]
196+
185197
case .iPodTouch1G: return ["iPod1,1"]
186198
case .iPodTouch2G: return ["iPod2,1"]
187199
case .iPodTouch3G: return ["iPod3,1"]
@@ -224,29 +236,51 @@ internal enum DeviceType: String, EnumProtocol {
224236
}
225237
}
226238

227-
228-
// MARK: - EnumProtocol
229-
internal protocol EnumProtocol: Hashable {
230-
/// -returns: All Enum Values
231-
static var all: [Self] { get }
232-
}
233-
234-
// MARK: -
235-
// MARK: - Extensions
236-
internal extension EnumProtocol {
237-
238-
static var all: [Self] {
239-
typealias Type = Self
240-
let cases = AnySequence { () -> AnyIterator<Type> in
241-
var raw = 0
242-
return AnyIterator {
243-
let current: Self = withUnsafePointer(to: &raw) { $0.withMemoryRebound(to: Type.self, capacity: 1) { $0.pointee } }
244-
guard current.hashValue == raw else { return nil }
245-
raw += 1
246-
return current
247-
}
248-
}
249-
250-
return Array(cases)
239+
extension DeviceType {
240+
static var all: [DeviceType] {
241+
return [
242+
iPhone2G,
243+
iPhone3G,
244+
iPhone3GS,
245+
iPhone4,
246+
iPhone4S,
247+
iPhone5,
248+
iPhone5C,
249+
iPhone5S,
250+
iPhone6,
251+
iPhone6Plus,
252+
iPhone6S,
253+
iPhone6SPlus,
254+
iPhoneSE,
255+
iPhone7,
256+
iPhone7Plus,
257+
iPhone8,
258+
iPhone8Plus,
259+
iPhoneX,
260+
iPhoneXS,
261+
iPhoneXSMax,
262+
iPhoneXR,
263+
iPodTouch1G,
264+
iPodTouch2G,
265+
iPodTouch3G,
266+
iPodTouch4G,
267+
iPodTouch5G,
268+
iPodTouch6G,
269+
iPad,
270+
iPad2,
271+
iPad3,
272+
iPad4,
273+
iPadMini,
274+
iPadMiniRetina,
275+
iPadMini3,
276+
iPadMini4,
277+
iPadAir,
278+
iPadAir2,
279+
iPadPro9Inch,
280+
iPadPro10p5Inch,
281+
iPadPro12Inch,
282+
simulator,
283+
notAvailable
284+
]
251285
}
252286
}

0 commit comments

Comments
 (0)