diff options
| author | Ruben Beltran del Rio <jj@r.bdr.sh> | 2025-12-18 15:13:52 +0100 |
|---|---|---|
| committer | Ruben Beltran del Rio <jj@r.bdr.sh> | 2025-12-18 17:07:20 +0100 |
| commit | 1b55fdad5984841334e864db942693cfef10e645 (patch) | |
| tree | 656a0aaf4058e54cd20d423b150cc82907c1e12b /Map/Presentation/Base Components | |
| parent | 86e296f3b194979de41715ddffe8af262c23c4ba (diff) | |
Add sharing
Diffstat (limited to 'Map/Presentation/Base Components')
| -rw-r--r-- | Map/Presentation/Base Components/CollaborationButton.swift | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/Map/Presentation/Base Components/CollaborationButton.swift b/Map/Presentation/Base Components/CollaborationButton.swift new file mode 100644 index 0000000..49dd2c5 --- /dev/null +++ b/Map/Presentation/Base Components/CollaborationButton.swift @@ -0,0 +1,51 @@ +import SharedWithYou +import SwiftUI + +struct CollaborationButton: NSViewRepresentable { + let fileURL: URL + + func makeNSView(context: Context) -> SWCollaborationView { + let itemProvider = NSItemProvider(contentsOf: fileURL)! + let view = SWCollaborationView(itemProvider: itemProvider) + + view.activeParticipantCount = 0 + view.cloudSharingDelegate = context.coordinator + + return view + } + + func updateNSView(_ nsView: SWCollaborationView, context: Context) { + // Update participant count as needed + } + + func makeCoordinator() -> Coordinator { + Coordinator(fileURL: fileURL) + } + + class Coordinator: NSObject, NSCloudSharingServiceDelegate { + let fileURL: URL + + init(fileURL: URL) { + self.fileURL = fileURL + } + + func sharingService( + _ sharingService: NSSharingService, + didFailToShareItems items: [Any], + error: Error + ) { + print("Failed to share: \(error)") + } + + func sharingService( + _ sharingService: NSSharingService, + didCompleteForItems items: [Any] + ) { + print("Sharing completed") + } + + func options(for: NSSharingService, share: NSItemProvider) -> NSSharingService.CloudKitOptions { + return [.allowPublic, .allowPrivate, .allowReadWrite] + } + } +} |