File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -57,22 +57,22 @@ extension Share {
5757 self . shareValue = shareValue
5858 }
5959
60- public func title( _ title: String ) -> Link {
60+ public func title( _ title: String ? ) -> Link {
6161 self . title = title
6262 return self
6363 }
6464
65- public func icon( _ url: URL ) -> Link {
65+ public func icon( _ url: URL ? ) -> Link {
6666 icon = url
6767 return self
6868 }
6969
70- public func image( _ url: URL ) -> Link {
70+ public func image( _ url: URL ? ) -> Link {
7171 self . image = url
7272 return self
7373 }
7474
75- public func video( _ url: URL ) -> Link {
75+ public func video( _ url: URL ? ) -> Link {
7676 self . video = url
7777 return self
7878 }
Original file line number Diff line number Diff line change @@ -83,3 +83,38 @@ extension Share {
8383 }
8484}
8585#endif
86+
87+ #if canImport(SwiftUI)
88+ import SwiftUI
89+
90+ @available ( iOS 13 . 0 , * )
91+ extension Share . Sheet {
92+
93+ public struct View : UIViewControllerRepresentable , ShareDelegate {
94+ public typealias Action = ( ( Share . Service . Status ) -> ( ) )
95+
96+ let sharable : Sharable
97+
98+ var onStatusChange : Action = { _ in }
99+
100+ public func didChange( status: Share . Service . Status ) {
101+ onStatusChange ( status)
102+ }
103+
104+ public func onStatusChange( _ action: @escaping Action ) -> View {
105+ View ( sharable: sharable, onStatusChange: action)
106+ }
107+
108+ public func makeUIViewController( context: UIViewControllerRepresentableContext < View > ) -> UIActivityViewController {
109+ return Share . Sheet ( for: sharable, delegate: self )
110+ }
111+
112+ public func updateUIViewController( _ uiViewController: UIActivityViewController , context: UIViewControllerRepresentableContext < View > ) { }
113+ }
114+
115+ public func view( ) -> View {
116+ . init( sharable: sharable)
117+ }
118+ }
119+
120+ #endif
You can’t perform that action at this time.
0 commit comments