Fixes tvOS and watchOS
This commit is contained in:
parent
2cf2c091c3
commit
c4936d438e
|
@ -11,21 +11,21 @@ internal typealias PlatformViewController = UIViewController
|
|||
|
||||
extension UIScreen {
|
||||
@nonobjc
|
||||
public static var mainScreen: UIScreen {
|
||||
return .main
|
||||
}
|
||||
public static var mainScreen: UIScreen { .main }
|
||||
}
|
||||
|
||||
extension UIImage {
|
||||
public var png: Data? {
|
||||
return self.pngData()
|
||||
public var png: Data? { pngData() }
|
||||
public func jpg(quality: CGFloat) -> Data? { jpegData(compressionQuality: quality) }
|
||||
}
|
||||
|
||||
public func jpg(quality: CGFloat) -> Data? {
|
||||
return self.jpegData(compressionQuality: quality)
|
||||
extension CGContext {
|
||||
internal static var current: CGContext? {
|
||||
UIGraphicsGetCurrentContext()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#elseif os(macOS)
|
||||
|
||||
import AppKit
|
||||
|
@ -38,13 +38,8 @@ internal typealias PlatformScrollView = NSScrollView
|
|||
internal typealias PlatformViewController = NSViewController
|
||||
|
||||
extension NSScreen {
|
||||
public static var mainScreen: NSScreen {
|
||||
return NSScreen.main!
|
||||
}
|
||||
|
||||
public var scale: CGFloat {
|
||||
return backingScaleFactor
|
||||
}
|
||||
public static var mainScreen: NSScreen { NSScreen.main! }
|
||||
public var scale: CGFloat { backingScaleFactor }
|
||||
}
|
||||
|
||||
extension NSImage {
|
||||
|
@ -57,16 +52,9 @@ extension NSImage {
|
|||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
extension CGContext {
|
||||
|
||||
internal static var current: CGContext? {
|
||||
#if os(OSX)
|
||||
return NSGraphicsContext.current?.cgContext
|
||||
#else
|
||||
return UIGraphicsGetCurrentContext()
|
||||
NSGraphicsContext.current?.cgContext
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#if os(macOS) || os(iOS)
|
||||
import SwiftUI
|
||||
|
||||
public extension Backport<Any> {
|
||||
|
@ -76,3 +77,4 @@ private extension NSView {
|
|||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import Photos
|
||||
#if os(iOS)
|
||||
import PhotosUI
|
||||
|
||||
/// Represents a `PHFetchResult` that can be used as a `RandomAccessCollection` in a SwiftUI view such as `List`, `ForEach`, etc...
|
||||
internal struct MediaResults<Result>: RandomAccessCollection where Result: PHObject {
|
||||
|
@ -38,3 +39,4 @@ internal final class ResultsObserver<Result>: NSObject, ObservableObject, PHPhot
|
|||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#if os(iOS)
|
||||
import Foundation
|
||||
import Photos
|
||||
import PhotosUI
|
||||
|
||||
internal extension PHFetchOptions {
|
||||
|
||||
|
@ -61,3 +62,4 @@ internal extension PHFetchOptions {
|
|||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
#if os(iOS)
|
||||
import SwiftUI
|
||||
import Photos
|
||||
import PhotosUI
|
||||
|
||||
extension PHObject: Identifiable {
|
||||
public var id: String { localIdentifier }
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#if os(iOS)
|
||||
import Photos
|
||||
import SwiftUI
|
||||
|
||||
|
@ -58,3 +59,4 @@ internal final class AssetObserver: NSObject, ObservableObject, PHPhotoLibraryCh
|
|||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#if os(iOS)
|
||||
import Photos
|
||||
import SwiftUI
|
||||
|
||||
|
@ -93,3 +94,4 @@ internal extension FetchAssetCollection {
|
|||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#if os(iOS)
|
||||
import Photos
|
||||
import SwiftUI
|
||||
|
||||
|
@ -114,3 +115,4 @@ internal extension FetchAssetList {
|
|||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#if os(iOS)
|
||||
import Photos
|
||||
import SwiftUI
|
||||
|
||||
|
@ -103,3 +104,4 @@ internal extension FetchCollectionList {
|
|||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#if os(iOS)
|
||||
import SwiftUI
|
||||
|
||||
/*
|
||||
|
@ -15,3 +16,4 @@ private extension Backport where Wrapped: View {
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#if os(macOS) || os(iOS)
|
||||
import SwiftUI
|
||||
|
||||
@available(iOS, deprecated: 16)
|
||||
|
@ -59,3 +60,4 @@ public extension Backport.ShareLink where Wrapped == Any {
|
|||
self.preview = { .init($0.absoluteString) }
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#if os(macOS) || os(iOS)
|
||||
import SwiftUI
|
||||
|
||||
@available(iOS, deprecated: 16)
|
||||
|
@ -41,3 +42,4 @@ public extension Backport.ShareLink where Wrapped == Any {
|
|||
self.preview = { .init($0.absoluteString) }
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
#if os(macOS) || os(iOS)
|
||||
import SwiftUI
|
||||
#if canImport(LinkPresentation)
|
||||
import LinkPresentation
|
||||
#endif
|
||||
|
||||
@available(iOS, deprecated: 16)
|
||||
@available(macOS, deprecated: 13)
|
||||
|
@ -65,3 +68,4 @@ public extension Backport where Wrapped == Any {
|
|||
// override func activityViewController(_ activityViewController: UIActivityViewController, subjectForActivityType activityType: UIActivity.ActivityType?) -> String { subject ?? "" }
|
||||
//
|
||||
//}
|
||||
#endif
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import SwiftUI
|
||||
|
||||
#if os(macOS) || os(iOS)
|
||||
extension View {
|
||||
@ViewBuilder
|
||||
func shareSheet<Data>(item activityItems: Binding<ActivityItem<Data>?>) -> some View where Data: RandomAccessCollection, Data.Element: Shareable {
|
||||
|
@ -10,6 +11,7 @@ extension View {
|
|||
#endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if os(macOS)
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#if os(macOS) || os(iOS)
|
||||
import SwiftUI
|
||||
|
||||
@available(iOS, deprecated: 16)
|
||||
|
@ -59,3 +60,4 @@ public extension Backport.ShareLink where Wrapped == Any {
|
|||
self.preview = { .init($0.absoluteString) }
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#if os(macOS) || os(iOS)
|
||||
import SwiftUI
|
||||
|
||||
@available(iOS, deprecated: 16)
|
||||
|
@ -41,3 +42,4 @@ public extension Backport.ShareLink where Wrapped == Any {
|
|||
self.preview = { .init($0.absoluteString) }
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#if os(macOS) || os(iOS)
|
||||
import SwiftUI
|
||||
|
||||
@available(iOS, deprecated: 16.0)
|
||||
|
@ -7,6 +8,8 @@ import SwiftUI
|
|||
/// TEMPORARY, DO NOT RELY ON THIS!
|
||||
///
|
||||
/// - Note: This **will be removed** in an upcoming release, regardless of semantic versioning
|
||||
@available(iOS, message: "This **will be removed** in an upcoming release, regardless of semantic versioning")
|
||||
@available(macOS, message: "This **will be removed** in an upcoming release, regardless of semantic versioning")
|
||||
public protocol Shareable {
|
||||
var pathExtension: String { get }
|
||||
var itemProvider: NSItemProvider? { get }
|
||||
|
@ -75,3 +78,4 @@ extension PlatformImage: Shareable {
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue