Skip to content

Commit

Permalink
Add support for Apple Watch Series 10
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentneo committed Sep 13, 2024
1 parent a2ae000 commit 9b68f35
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 8 deletions.
3 changes: 2 additions & 1 deletion Sources/DeviceModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ public enum DeviceModel: CaseIterable {
case ultra
case series9
case ultra2
case series10
#endif

case unknown
Expand Down Expand Up @@ -300,7 +301,7 @@ extension DeviceModel {
case (6, 18): return .ultra
case (7, 1), (7, 2), (7, 3), (7, 4): return .series9
case (7, 5): return .ultra2
case (7, 8), (7, 9), (7, 10), (7, 11): return .series10
default: return .unknown
}
}
Expand Down
8 changes: 8 additions & 0 deletions Sources/Identifier.swift
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,14 @@ extension Identifier: CustomStringConvertible {
return "Apple Watch Series 9, 45mm case (GPS + Cellular)"
case (7, 5):
return "Apple Watch Ultra 2"
case (7, 8):
return "Apple Watch Series 10, 42mm case (GPS)"
case (7, 9):
return "Apple Watch Series 10, 46mm case (GPS)"
case (7, 10):
return "Apple Watch Series 10, 42mm case (GPS + Cellular)"
case (7, 11):
return "Apple Watch Series 10, 46mm case (GPS + Cellular)"
default:
return "unknown"
}
Expand Down
39 changes: 32 additions & 7 deletions Sources/Screen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -106,28 +106,53 @@ extension Screen {
#if os(watchOS)
extension Screen {
public var caseSize: Int? {
switch size {
case .small(let mm):
return mm
case .medium(let mm):
return mm
case .ultra(let mm):
return mm
default:
return nil
}
}

public var size: Size? {
guard let major = identifier.version.major,
let minor = identifier.version.minor
else { return nil }

switch (major, minor) {
case (1, 1), (2, 3), (2, 6), (3, 1), (3, 3): return 38
case (1, 2), (2, 4), (2, 7), (3, 2), (3, 4): return 42
case (1, 1), (2, 3), (2, 6), (3, 1), (3, 3): return .small(mm: 38)
case (1, 2), (2, 4), (2, 7), (3, 2), (3, 4): return .medium(mm: 42)

case (4, 1), (4, 3), (5, 1), (5, 3), (5, 9),
(5, 11), (6, 1), (6, 3), (6, 10), (6, 12): return 40
(5, 11), (6, 1), (6, 3), (6, 10), (6, 12): return .small(mm: 40)
case (4, 2), (4, 4), (5, 2), (5, 4), (5, 10),
(5, 12), (6, 2), (6, 4), (6, 11), (6, 13): return 44
(5, 12), (6, 2), (6, 4), (6, 11), (6, 13): return .medium(mm: 44)

case (6, 6), (6, 8), (6, 14), (6, 16),
(7, 1), (7, 3): return 41
(7, 1), (7, 3): return .small(mm: 41)
case (6, 7), (6, 9), (6, 15), (6, 17),
(7, 2), (7, 4): return 45
(7, 2), (7, 4): return .medium(mm: 45)

case (6, 18), (7, 5): return 49
case (6, 18), (7, 5): return .ultra(mm: 49)

case (7, 8), (7, 10): return .small(mm: 42)
case (7, 9), (7, 11): return .medium(mm: 46)

default: return nil
}
}

public enum Size {
/// The smaller Apple Watch size (traditionally: 38/40/41mm)
case small(mm: Int)
/// The larger Apple Watch size (traditionally: 42/44/45mm)
case medium(mm: Int)
/// Apple Watch Ultra size
case ultra(mm: Int)
}
}
#endif

0 comments on commit 9b68f35

Please sign in to comment.