Skip to content

Commit

Permalink
Merge pull request #40 from Nirma/sep2019/iPad10.2
Browse files Browse the repository at this point in the history
10.2 inch iPads and iPhone 11(s) notch
  • Loading branch information
Nirma authored Sep 26, 2019
2 parents 5430787 + fdeca3f commit 6d344ad
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 4 deletions.
5 changes: 4 additions & 1 deletion Sources/DeviceModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ extension DeviceModel {
case (6, 7), (6, 8): return .iPadPro12_9Inch
case (7, 1), (7, 2): return .iPadPro12_9Inch_SecondGen
case (8, 5), (8, 6), (8, 7), (8, 8): return .iPadPro12_9Inch_ThirdGen
// case (,): return .iPadSevenGen
case (7, 11), (7, 12): return .iPadSevenGen
default: return .unknown
}
}
Expand Down Expand Up @@ -222,6 +222,9 @@ extension DeviceModel {

case .iPhoneX, .iPhoneXS, .iPhoneXSMax, .iPhoneXR:
return true
case .iPhone11, .iPhone11Pro, .iPhone11ProMax:
return true

default:
return false
}
Expand Down
4 changes: 4 additions & 0 deletions Sources/Identifier.swift
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,10 @@ extension Identifier: CustomStringConvertible {
return "6th Gen iPad (WiFi)"
case (7, 6):
return "6th Gen iPad (Cellular)"
case (7 ,11):
return "7th Gen iPad (10.2 inch, WiFi)"
case (7, 12):
return "7th Gen iPad (10.2 inch, Cellular)"
case (8, 1):
return "iPad Pro (11 inch, Wi-Fi)"
case (8, 2):
Expand Down
3 changes: 2 additions & 1 deletion Sources/Screen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,9 @@ extension Screen {
func ipadSize1024() -> Double {
let deviceModel = UIDevice().dc.deviceModel
switch deviceModel {
case .iPadMini, .iPadMini2, .iPadMini3, .iPadMini4: return 7.9
case .iPadMini, .iPadMini2, .iPadMini3, .iPadMini4, .iPadMini5: return 7.9
case .iPadPro10_5Inch: return 10.5
case .iPadSevenGen: return 10.2
default: return 9.7
}
}
Expand Down
8 changes: 7 additions & 1 deletion Tests/DeviceModelTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,12 @@ class DeviceModelTests: XCTestCase {
XCTAssert(deviceModel1 == .iPadSixthGen && deviceModel2 == .iPadSixthGen , "DeviceModel - .iPadSixthGen is failing")
}

func testDeviceModelIPadSevenGen() {
let deviceModel1 = DeviceModel(identifier: Identifier("iPad7,11"))
let deviceModel2 = DeviceModel(identifier: Identifier("iPad7,12"))
XCTAssert(deviceModel1 == .iPadSevenGen && deviceModel2 == .iPadSevenGen , "DeviceModel - .iPadSevenGen is failing")
}

func testDeviceModelIPadAir() {
let deviceModel1 = DeviceModel(identifier: Identifier("iPad4,1"))
let deviceModel2 = DeviceModel(identifier: Identifier("iPad4,2"))
Expand Down Expand Up @@ -329,7 +335,7 @@ class DeviceModelTests: XCTestCase {

// MARK: Notch test
func testHasNotch() {
let notchModels: [DeviceModel] = [.iPhoneX, .iPhoneXS, .iPhoneXSMax, .iPhoneXR]
let notchModels: [DeviceModel] = [.iPhoneX, .iPhoneXS, .iPhoneXSMax, .iPhoneXR, .iPhone11, .iPhone11Pro, .iPhone11ProMax]

let noNotchModels: [DeviceModel] = DeviceModel.allCases.filter( { !notchModels.contains($0) })

Expand Down
8 changes: 8 additions & 0 deletions Tests/IdentifierTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,14 @@ class IdentifierTests: XCTestCase {
XCTAssert(Identifier("iPad8,1").description == "iPad Pro (11 inch, Wi-Fi)", "iPad8,1 is failing to produce a common device model string")
}

func testDisplayStringiPad7v12() {
XCTAssert(Identifier("iPad7,12").description == "7th Gen iPad (10.2 inch, Cellular)", "iPad7,12 is failing to produce a common device model string")
}

func testDisplayStringiPad7v11() {
XCTAssert(Identifier("iPad7,11").description == "7th Gen iPad (10.2 inch, WiFi)", "iPad7,11 is failing to produce a common device model string")
}

func testDisplayStringiPad7v6() {
XCTAssert(Identifier("iPad7,6").description == "6th Gen iPad (Cellular)", "iPad7,6 is failing to produce a common device model string")
}
Expand Down
2 changes: 1 addition & 1 deletion UIDeviceComplete.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'UIDeviceComplete'
s.version = '2.6.0'
s.version = '2.6.5'
s.summary = 'UIDevice extensions for device Model, Family, Screen size and more'

s.description = <<-DESC
Expand Down

0 comments on commit 6d344ad

Please sign in to comment.