Skip to content

Commit

Permalink
✨ Add isTV and isMac helpers (#142)
Browse files Browse the repository at this point in the history
* ✨ Add isTV and isMac helpers

* Update CHANGELOG.md

---------

Co-authored-by: Jakub Olejník <[email protected]>
  • Loading branch information
leinhauplk and olejnjak authored Dec 28, 2023
1 parent 31e80fa commit a0b8ee5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
```

## Next
- Add `isTV` and `isMac` for `UIDevice` ([#142](https://github.com/AckeeCZ/ACKategories/pull/142), kudos to @leinhauplk)
- Add helper function for easier back gesture setup ([#141](https://github.com/AckeeCZ/ACKategories/pull/141), kudos to @leinhauplk)
- Support tvOS & watchOS, use single multiplatform target for Carthage ([#140](https://github.com/AckeeCZ/ACKategories/pull/140), kudos to @olejnjak)
- Add helpers for `SwiftUI.EdgeInsets` ([#138](https://github.com/AckeeCZ/ACKategories/pull/138), kudos to @olejnjak)
Expand Down
11 changes: 11 additions & 0 deletions Sources/ACKategories/UIDeviceExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,17 @@ extension UIDevice {
return userInterfaceIdiom == .pad
}

/// Return **true** if device is Apple TV
public var isTV: Bool {
userInterfaceIdiom == .tv
}

/// Return **true** if device is Mac (Catalyst)
@available(iOS 14.0, tvOS 14.0, *)
public var isMac: Bool {
userInterfaceIdiom == .mac
}

/// Returns device model name e.g. "iPhone11,6" for XS Max
public var modelName: String {
var systemInfo = utsname()
Expand Down

0 comments on commit a0b8ee5

Please sign in to comment.