Skip to content

Commit

Permalink
Extend conformances Photos, StoreKit, UIKit (#1)
Browse files Browse the repository at this point in the history
* Conform UIScrollView.ContentInsetAdjustmentBehavior

* Conform some Photos enums

* Conform some StoreKit enums

* Update Sources/CustomDump/Conformances/UIKit.swift

* Fix availability

Co-authored-by: Stephen Celis <[email protected]>
Co-authored-by: Stephen Celis <[email protected]>
  • Loading branch information
3 people authored Aug 23, 2021
1 parent 4f743ea commit 8655495
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 0 deletions.
38 changes: 38 additions & 0 deletions Sources/CustomDump/Conformances/Photos.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#if canImport(Photos)
import Photos

@available(iOS 14, macCatalyst 14, macOS 11, tvOS 14, *)
extension PHAccessLevel: CustomDumpStringConvertible {
public var customDumpDescription: String {
switch self {
case .addOnly:
return "PHAccessLevel.addOnly"
case .readWrite:
return "PHAccessLevel.readWrite"
@unknown default:
return "PHAccessLevel.(@unknown default, rawValue: \(self.rawValue))"
}
}
}

@available(iOS 8, macCatalyst 13, macOS 10.13, tvOS 10, *)
extension PHAuthorizationStatus: CustomDumpStringConvertible {
public var customDumpDescription: String {
switch self {
case .authorized:
return "PHAuthorizationStatus.authorized"
case .denied:
return "PHAuthorizationStatus.denied"
case .notDetermined:
return "PHAuthorizationStatus.notDetermined"
case .restricted:
return "PHAuthorizationStatus.restricted"
case .limited:
return "PHAuthorizationStatus.limited"
@unknown default:
return "PHAuthorizationStatus.(@unknown default, rawValue: \(self.rawValue))"
}
}
}

#endif
41 changes: 41 additions & 0 deletions Sources/CustomDump/Conformances/StoreKit.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#if canImport(StoreKit)
import StoreKit

@available(iOS 3, macCatalyst 13, macOS 10.7, tvOS 9, watchOS 6.2, *)
extension SKPaymentTransactionState: CustomDumpStringConvertible {
public var customDumpDescription: String {
switch self {
case .purchasing:
return "SKPaymentTransactionState.purchasing"
case .purchased:
return "SKPaymentTransactionState.purchased"
case .failed:
return "SKPaymentTransactionState.failed"
case .restored:
return "SKPaymentTransactionState.restored"
case .deferred:
return "SKPaymentTransactionState.deferred"
@unknown default:
return "SKPaymentTransactionState.(@unknown default, rawValue: \(self.rawValue))"
}
}
}

@available(iOS 11.2, macCatalyst 13, macOS 10.13.2, tvOS 11.2, watchOS 6.2, *)
extension SKProduct.PeriodUnit: CustomDumpStringConvertible {
public var customDumpDescription: String {
switch self {
case .day:
return "SKProduct.PeriodUnit.day"
case .week:
return "SKProduct.PeriodUnit.week"
case .month:
return "SKProduct.PeriodUnit.month"
case .year:
return "SKProduct.PeriodUnit.year"
@unknown default:
return "SKProduct.PeriodUnit.(@unknown default, rawValue: \(self.rawValue))"
}
}
}
#endif
19 changes: 19 additions & 0 deletions Sources/CustomDump/Conformances/UIKit.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,24 @@
}
}
}

@available(iOS 11, macCatalyst 13, tvOS 11, *)
@available(watchOS, unavailable)
extension UIScrollView.ContentInsetAdjustmentBehavior: CustomDumpStringConvertible {
public var customDumpDescription: String {
switch self {
case .always:
return "UIScrollView.ContentInsetAdjustmentBehavior.always"
case .automatic:
return "UIScrollView.ContentInsetAdjustmentBehavior.automatic"
case .never:
return "UIScrollView.ContentInsetAdjustmentBehavior.never"
case .scrollableAxes:
return "UIScrollView.ContentInsetAdjustmentBehavior.scrollableAxes"
@unknown default:
return "UIScrollView.ContentInsetAdjustmentBehavior.(@unknown default, rawValue: \(self.rawValue))"
}
}
}
#endif
#endif

0 comments on commit 8655495

Please sign in to comment.