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/MapEditor.swift | |
| parent | 86e296f3b194979de41715ddffe8af262c23c4ba (diff) | |
Add sharing
Diffstat (limited to 'Map/Presentation/MapEditor.swift')
| -rw-r--r-- | Map/Presentation/MapEditor.swift | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/Map/Presentation/MapEditor.swift b/Map/Presentation/MapEditor.swift index c323882..fcf465e 100644 --- a/Map/Presentation/MapEditor.swift +++ b/Map/Presentation/MapEditor.swift @@ -12,13 +12,19 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see https://map.tranquil.systems. +import SharedWithYou import SwiftUI import WmapParser struct MapEditor: View { + @Binding var document: MapDocument + @FocusedValue(\.fileURL) var fileURL: URL? + @State var selectedEvolution: StageType = .behavior @State var isSearching: Bool = false + @State var isPresentingSharingSheet: Bool = false + var parsedMap: WmapParser.Map { document.parsed } @@ -209,6 +215,17 @@ struct MapEditor: View { } } .toolbar { + + if let fileURL { + if fileIsShared { + ToolbarItem(placement: .primaryAction) { + CollaborationButton(fileURL: fileURL) + } + } + ToolbarItem(placement: .primaryAction) { + ShareLink(item: fileURL) + } + } if #unavailable(macOS 26) { ToolbarItem(placement: .primaryAction) { EvolutionPicker(selectedEvolution: $selectedEvolution) @@ -219,6 +236,18 @@ struct MapEditor: View { .focusedSceneValue(\.selectedEvolution, $selectedEvolution) } + private var fileIsShared: Bool { + do { + if let fileURL { + let resourceValues = try fileURL.resourceValues(forKeys: [.ubiquitousItemIsSharedKey]) + return resourceValues.ubiquitousItemIsShared ?? false + } + return false + } catch { + return false + } + } + @ViewBuilder func adaptiveStack<Content: View>(@ViewBuilder content: () -> Content) -> some View { if viewStyle == .horizontal { |