Is this extension usable with ShareLink?

#2 · closed · 5 comments

View on GitHub ↗

markushx

I would like to share the screenshot with [ShareLink](https://developer.apple.com/documentation/swiftui/sharelink). How could this be integrated?

Comments

RickeyBoy

YES. ### Implement your view and store your image ``` ScreenshotableView(shotting: $shotting) { screenshot in self.screenshot = Image(uiImage: screenshot) } content: { style in Content(style: style) } ``` ### use ShareLink with image: `ShareLink(item: self.screenshot, preview: SharePreview("title", image: self.screenshot))`

markushx

How is $shotting toggled from the ShareLink? I am only getting an empty image in the preview.

RickeyBoy

I've pushed new code that implement Sharing part. I use `UIActivityViewController` instead of `ShareLink`. You can check with `ShareScreenshotView` file. Enjoy demo 🎉

supercosition

@StateObject var sasVM = SaveAndShareViewModel(). << Can not find SaveAndShareViewModel() in scope when i try to use in my project

RickeyBoy

> [@StateObject](https://github.com/StateObject) var sasVM = SaveAndShareViewModel(). << Can not find SaveAndShareViewModel() in scope when i try to use in my project You have to create an ObservableObject in you project. You can refer to `SuppotSaveAndShareViewModifier.swift` file in the demo project. @supercosition :)