Skip to content

Commit

Permalink
Seperate dynamic island check, from hasNotch
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentneo committed Sep 14, 2023
1 parent c9d5d67 commit e7efc9f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
14 changes: 13 additions & 1 deletion Sources/DeviceModel.swift
Expand Up @@ -246,7 +246,19 @@ extension DeviceModel {
return true
case .iPhone13mini, .iPhone13, .iPhone13Pro, .iPhone13ProMax:
return true
case .iPhone14, .iPhone14Plus, .iPhone14Pro, .iPhone14ProMax:
case .iPhone14, .iPhone14Plus:
return true

default:
return false
}
}

public var hasDynamicIsland: Bool {
switch self {
case .iPhone14Pro, .iPhone14ProMax:
return true
case .iPhone15, .iPhone15Plus, .iPhone15Pro, .iPhone15ProMax:
return true

default:
Expand Down
14 changes: 13 additions & 1 deletion Tests/DeviceModelTests.swift
Expand Up @@ -492,11 +492,23 @@ class DeviceModelTests: XCTestCase {
.iPhone11, .iPhone11Pro, .iPhone11ProMax,
.iPhone12, .iPhone12Pro, .iPhone12ProMax, .iPhone12mini,
.iPhone13, .iPhone13mini, .iPhone13Pro, .iPhone13ProMax,
.iPhone14, .iPhone14Plus, .iPhone14Pro, .iPhone14ProMax]
.iPhone14, .iPhone14Plus]

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

notchModels.forEach { XCTAssertTrue($0.hasNotch) }
noNotchModels.forEach { XCTAssertFalse($0.hasNotch) }
}

// MARK: Dynamic Island Test

func testHasDynamicIsland() {
let withModels: [DeviceModel] = [.iPhone14Pro, .iPhone14ProMax,
.iPhone15, .iPhone15Plus, .iPhone15Pro, .iPhone15ProMax]

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

withModels.forEach { XCTAssertTrue($0.hasDynamicIsland) }
withoutModels.forEach { XCTAssertFalse($0.hasDynamicIsland) }
}
}

0 comments on commit e7efc9f

Please sign in to comment.