{"id":22477724,"url":"https://github.com/swiftuiux/sharelink-for-swiftui-example","last_synced_at":"2025-08-02T13:31:14.477Z","repository":{"id":253779996,"uuid":"823514417","full_name":"swiftuiux/sharelink-for-swiftui-example","owner":"swiftuiux","description":"example demonstrates how to use ShareLink button for SwiftUI to share various types of data such as strings, URLs, images, data, attributed strings, and location ios14","archived":false,"fork":false,"pushed_at":"2024-11-27T11:49:04.000Z","size":4737,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-11-28T18:41:36.760Z","etag":null,"topics":["button","ios14","sharelink","swift","swiftui"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/swiftuiux.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-07-03T07:20:56.000Z","updated_at":"2024-11-27T11:49:08.000Z","dependencies_parsed_at":"2024-08-19T13:55:15.692Z","dependency_job_id":"dd7230a0-9f66-4341-9ee5-b9092bc64fde","html_url":"https://github.com/swiftuiux/sharelink-for-swiftui-example","commit_stats":null,"previous_names":["the-igor/sharelink-for-swiftui-example","igor11191708/sharelink-for-swiftui-example","swiftuiux/sharelink-for-swiftui-example"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swiftuiux%2Fsharelink-for-swiftui-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swiftuiux%2Fsharelink-for-swiftui-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swiftuiux%2Fsharelink-for-swiftui-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swiftuiux%2Fsharelink-for-swiftui-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/swiftuiux","download_url":"https://codeload.github.com/swiftuiux/sharelink-for-swiftui-example/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228476038,"owners_count":17926134,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["button","ios14","sharelink","swift","swiftui"],"created_at":"2024-12-06T14:12:02.972Z","updated_at":"2024-12-06T14:12:03.686Z","avatar_url":"https://github.com/swiftuiux.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ShareLink for SwiftUI Example\n\nThis example demonstrates how to use `ShareLinkButton` in SwiftUI to share various types of data such as strings, URLs, images, data, attributed strings, and locations\n\n## Requirements\n\n- iOS 14.0+\n- Swift 5.3+\n- Xcode 12.0+\n\n## Example Usage\n\nThis example demonstrates how to use the functionality provided by the [package](https://github.com/swiftuiux/sharelink-swiftui-ios). \n\n![ShareLinkButton Example](https://github.com/swiftuiux/sharelink-for-swiftui-example/blob/main/img/sharelink_swiftui.jpeg)\n\n## Usage\n\n### Supported Types\n\nThe `ShareLinkButton` supports sharing the following types:\n- `String`\n- `URL`\n- `UIImage`\n- `Data`\n- `NSAttributedString`\n- `CLLocation`\n- `UIActivityItemSource`\n\n### Examples\n\nHere are examples of how to use `ShareLinkButton` with various types of data.\n\n#### Sharing a String\n\n```swift\nlet sampleString = \"This is a sample string to share.\"\nShareLinkButton(item: sampleString) {\n    ButtonLabel(image: \"square.and.arrow.up\", text: \"Share String\", backgroundColor: .blue)\n}\n```\n\n#### Sharing a URL\n\n```swift\nlet sampleURL = URL(string: \"https://www.apple.com\")!\nShareLinkButton(item: sampleURL) {\n    ButtonLabel(image: \"square.and.arrow.up\", text: \"Share URL\", backgroundColor: .green)\n}\n```\n\n#### Sharing an Image\n\n```swift\nlet sampleImage = UIImage(named: \"vision\")!\nShareLinkButton(item: sampleImage) {\n    ButtonLabel(image: \"square.and.arrow.up\", text: \"Share Image\", backgroundColor: .orange)\n}\n```\n\n#### Sharing Data\n\n```swift\nlet sampleData = \"Sample data\".data(using: .utf8)!\nShareLinkButton(item: sampleData) {\n    ButtonLabel(image: \"square.and.arrow.up\", text: \"Share Data\", backgroundColor: .purple)\n}\n```\n\n#### Sharing an NSAttributedString\n\n```swift\nlet sampleAttributedString = NSAttributedString(string: \"Simple sample NSAttributedString\", attributes: [\n    .font: UIFont.systemFont(ofSize: 24),\n    .foregroundColor: UIColor.red\n])\nShareLinkButton(item: sampleAttributedString) {\n    ButtonLabel(image: \"square.and.arrow.up\", text: \"Share NSAttributedString\", backgroundColor: .red)\n}\n```\n\n#### Sharing a Location\n\n```swift\nlet sampleLocation = CLLocation(latitude: 37.7749, longitude: -122.4194)\nShareLinkButton(item: sampleLocation) {\n    ButtonLabel(image: \"square.and.arrow.up\", text: \"Share Location\", backgroundColor: .yellow, textColor: .blue)\n}\n```\n\n#### Creating a Custom Activity Item Source\n\nYou can also create your own custom activity item sources.\n\n```swift\nclass CustomActivityItemSource: NSObject, UIActivityItemSource {\n    private let text: String\n    \n    init(text: String) {\n        self.text = text\n    }\n    \n    func activityViewControllerPlaceholderItem(_ activityViewController: UIActivityViewController) -\u003e Any {\n        return text\n    }\n    \n    func activityViewController(_ activityViewController: UIActivityViewController, itemForActivityType activityType: UIActivity.ActivityType?) -\u003e Any? {\n        return text\n    }\n}\n\nShareLinkButton(itemSource: CustomActivityItemSource(text: \"Hello, world!\")) {\n    ButtonLabel(image: \"square.and.arrow.up\", text: \"Share Custom Text\", backgroundColor: .blue)\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fswiftuiux%2Fsharelink-for-swiftui-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fswiftuiux%2Fsharelink-for-swiftui-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fswiftuiux%2Fsharelink-for-swiftui-example/lists"}