forked from shaps80/SwiftUIBackports
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
665 additions
and
436 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#if os(iOS) | ||
|
||
import UIKit | ||
|
||
public typealias PlatformImage = UIImage | ||
|
||
internal typealias PlatformView = UIView | ||
internal typealias PlatformViewController = UIViewController | ||
|
||
#elseif os(macOS) | ||
|
||
import AppKit | ||
|
||
public typealias PlatformImage = NSImage | ||
|
||
internal typealias PlatformView = NSView | ||
internal typealias PlatformViewController = NSViewController | ||
|
||
#endif |
12 changes: 12 additions & 0 deletions
12
Sources/SwiftUIBackports/Internal/String+LocalizationKey.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import SwiftUI | ||
|
||
extension String { | ||
internal init?(_ stringKey: LocalizedStringKey) { | ||
guard let key = Mirror(reflecting: stringKey).children | ||
.first(where: { $0.label == "key" })?.value as? String else { | ||
return nil | ||
} | ||
|
||
self = NSLocalizedString(key, comment: "") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
115 changes: 0 additions & 115 deletions
115
Sources/SwiftUIBackports/Shared/ShareLink/ActivityView.swift
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
Sources/SwiftUIBackports/Shared/ShareLink/Multiple Items/Items+Label+Preview.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import SwiftUI | ||
|
||
@available(iOS, deprecated: 16) | ||
@available(macOS, deprecated: 13) | ||
@available(watchOS, deprecated: 9) | ||
@available(tvOS, unavailable) | ||
public extension Backport.ShareLink where Wrapped == Any { | ||
init<S: StringProtocol>(_ title: S, items: Data, subject: String? = nil, message: String? = nil, preview: @escaping (Data.Element) -> SharePreview<PreviewImage, PreviewIcon>) | ||
where Data.Element: BackportTransferable, Label == DefaultShareLinkLabel | ||
{ | ||
self.label = .init(title) | ||
self.data = items | ||
self.subject = subject | ||
self.message = message | ||
self.preview = preview | ||
} | ||
|
||
init(_ titleKey: LocalizedStringKey, items: Data, subject: String? = nil, message: String? = nil, preview: @escaping (Data.Element) -> SharePreview<PreviewImage, PreviewIcon>) | ||
where Data.Element: BackportTransferable, Label == DefaultShareLinkLabel | ||
{ | ||
self.label = .init(titleKey) | ||
self.data = items | ||
self.subject = subject | ||
self.message = message | ||
self.preview = preview | ||
} | ||
|
||
init(_ title: Text, items: Data, subject: String? = nil, message: String? = nil, preview: @escaping (Data.Element) -> SharePreview<PreviewImage, PreviewIcon>) | ||
where Data.Element: BackportTransferable, Label == DefaultShareLinkLabel | ||
{ | ||
self.label = .init(title) | ||
self.data = items | ||
self.subject = subject | ||
self.message = message | ||
self.preview = preview | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
Sources/SwiftUIBackports/Shared/ShareLink/Multiple Items/Items+Label.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import SwiftUI | ||
|
||
@available(iOS, deprecated: 16) | ||
@available(macOS, deprecated: 13) | ||
@available(watchOS, deprecated: 9) | ||
@available(tvOS, unavailable) | ||
public extension Backport.ShareLink where Wrapped == Any { | ||
init<S: StringProtocol>(_ title: S, items: Data, subject: String? = nil, message: String? = nil) | ||
where PreviewImage == Never, PreviewIcon == Never, Data.Element == String, Label == DefaultShareLinkLabel { | ||
self.label = .init(title) | ||
self.data = items | ||
self.subject = subject | ||
self.message = message | ||
self.preview = { .init($0) } | ||
} | ||
|
||
init(_ titleKey: LocalizedStringKey, items: Data, subject: String? = nil, message: String? = nil) | ||
where PreviewImage == Never, PreviewIcon == Never, Data.Element == String, Label == DefaultShareLinkLabel { | ||
self.label = .init(titleKey) | ||
self.data = items | ||
self.subject = subject | ||
self.message = message | ||
self.preview = { .init($0) } | ||
} | ||
|
||
init(_ title: Text, items: Data, subject: String? = nil, message: String? = nil) | ||
where PreviewImage == Never, PreviewIcon == Never, Data.Element == String, Label == DefaultShareLinkLabel { | ||
self.label = .init(title) | ||
self.data = items | ||
self.subject = subject | ||
self.message = message | ||
self.preview = { .init($0) } | ||
} | ||
|
||
init<S: StringProtocol>(_ title: S, items: Data, subject: String? = nil, message: String? = nil) | ||
where PreviewImage == Never, PreviewIcon == Never, Data.Element == URL, Label == DefaultShareLinkLabel { | ||
self.label = .init(title) | ||
self.data = items | ||
self.subject = subject | ||
self.message = message | ||
self.preview = { .init($0.absoluteString) } | ||
} | ||
|
||
init(_ titleKey: LocalizedStringKey, items: Data, subject: String? = nil, message: String? = nil) | ||
where PreviewImage == Never, PreviewIcon == Never, Data.Element == URL, Label == DefaultShareLinkLabel { | ||
self.label = .init(titleKey) | ||
self.data = items | ||
self.subject = subject | ||
self.message = message | ||
self.preview = { .init($0.absoluteString) } | ||
} | ||
|
||
init(_ title: Text, items: Data, subject: String? = nil, message: String? = nil) | ||
where PreviewImage == Never, PreviewIcon == Never, Data.Element == URL, Label == DefaultShareLinkLabel { | ||
self.label = .init(title) | ||
self.data = items | ||
self.subject = subject | ||
self.message = message | ||
self.preview = { .init($0.absoluteString) } | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
Sources/SwiftUIBackports/Shared/ShareLink/Multiple Items/Items+Preview.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import SwiftUI | ||
|
||
@available(iOS, deprecated: 16) | ||
@available(macOS, deprecated: 13) | ||
@available(watchOS, deprecated: 9) | ||
@available(tvOS, unavailable) | ||
public extension Backport.ShareLink where Wrapped == Any { | ||
init(items: Data, subject: String? = nil, message: String? = nil, preview: @escaping (Data.Element) -> SharePreview<PreviewImage, PreviewIcon>) | ||
where Data.Element: BackportTransferable, Label == DefaultShareLinkLabel { | ||
self.label = .init() | ||
self.data = items | ||
self.subject = subject | ||
self.message = message | ||
self.preview = preview | ||
} | ||
|
||
init(items: Data, subject: String? = nil, message: String? = nil, preview: @escaping (Data.Element) -> SharePreview<PreviewImage, PreviewIcon>, @ViewBuilder label: () -> Label) | ||
where Data.Element: BackportTransferable { | ||
self.label = label() | ||
self.data = items | ||
self.subject = subject | ||
self.message = message | ||
self.preview = preview | ||
} | ||
} |
Oops, something went wrong.