Created
January 8, 2025 11:11
-
-
Save VAndrJ/4cd24d66694acbcec3153f76aafb63d9 to your computer and use it in GitHub Desktop.
Revisions
-
VAndrJ created this gist
Jan 8, 2025 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,42 @@ import SwiftUI struct ContentView: View { var body: some View { VStack { Text("Drag me") .font(.largeTitle) .padding() .frame(maxWidth: .infinity, idealHeight: 200) .border(.blue) .background(.green.opacity(0.1)) .draggable(Draggable(identifier: "identifier")) Spacer() Text("Drop here") .font(.largeTitle) .frame(width: 200, height: 100) .background(.blue.opacity(0.2)) .dropDestination(for: Draggable.self) { items, location in print(items, location) return true } } .padding() } } import UniformTypeIdentifiers extension UTType { static let draggable = UTType(exportedAs: "com.vandrj.DraggableMRE.draggable") } struct Draggable: Codable, Transferable { let identifier: String static var transferRepresentation: some TransferRepresentation { CodableRepresentation(contentType: .draggable) } }