{"id":15055366,"url":"https://github.com/dagronf/dsfdropfilesview","last_synced_at":"2025-10-18T01:06:49.210Z","repository":{"id":63907286,"uuid":"307598969","full_name":"dagronf/DSFDropFilesView","owner":"dagronf","description":"A Swift NSView class for nicely supporting drag/drop files.","archived":false,"fork":false,"pushed_at":"2025-04-17T00:10:59.000Z","size":99,"stargazers_count":33,"open_issues_count":0,"forks_count":6,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-27T15:49:34.235Z","etag":null,"topics":["drag-and-drop","files","nsview","objective-c","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dagronf.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2020-10-27T05:55:50.000Z","updated_at":"2025-09-05T09:43:38.000Z","dependencies_parsed_at":"2024-07-08T05:33:40.323Z","dependency_job_id":"19f7cd30-7fb2-4777-8ae5-e14734d6e37d","html_url":"https://github.com/dagronf/DSFDropFilesView","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/dagronf/DSFDropFilesView","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dagronf%2FDSFDropFilesView","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dagronf%2FDSFDropFilesView/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dagronf%2FDSFDropFilesView/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dagronf%2FDSFDropFilesView/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dagronf","download_url":"https://codeload.github.com/dagronf/DSFDropFilesView/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dagronf%2FDSFDropFilesView/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279445937,"owners_count":26171622,"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","status":"online","status_checked_at":"2025-10-17T02:00:07.504Z","response_time":56,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["drag-and-drop","files","nsview","objective-c","swift","swiftui"],"created_at":"2024-09-24T21:41:37.034Z","updated_at":"2025-10-18T01:06:49.183Z","avatar_url":"https://github.com/dagronf.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DSFDropFilesView\n\n![](https://github.com/dagronf/dagronf.github.io/blob/master/art/projects/DSFDropFilesView/screenshot.png?raw=true)\n\nA simple view class for dropping files onto. Supporting Swift, SwiftUI and Objective-C.\n\n![](https://img.shields.io/github/v/tag/dagronf/DSFDropFilesView) ![](https://img.shields.io/badge/macOS-10.13+-red) ![](https://img.shields.io/badge/Swift-5.0-orange.svg)\n![](https://img.shields.io/badge/License-MIT-lightgrey) [![](https://img.shields.io/badge/spm-compatible-brightgreen.svg?style=flat)](https://swift.org/package-manager)\n\n\n## Why\n\nI've need something like this many times. So here's a module to make my future life easier maybe.\n\n## Installation\n\n### Swift Package Manager\n\nAdd `https://github.com/dagronf/DSFDropFilesView` to your project.\n\n## Usage\n\n### Via Interface Builder\n\nAdd a new `NSView` instance using Interface Builder, then change the class type to `DSFDropFilesView`\n\n### Programatically\n\n```swift\nlet dropView = DSFDropFilesView(frame: .zero)\n```\n\n### SwiftUI\n\nSee below.\n\n### Objective-C\n\nAdd `https://github.com/dagronf/DSFDropFilesView` to your project.\n\nNote that if you need to use `DSFDropFilesView` in Objective-C projects supporting macOS earlier than 10.14, you will also need to make sure to set `Always Embed Swift Standard Libraries` to `Yes` in the project settings. Before macOS 10.14 the Swift standard libraries are not distributed as part of the macOS installation and you'll need to provide your own in your application.\n\n## Delegation\n\nTo receive callbacks from the control, set the `dropDelegate` to your view controller.\n\n```swift\n@objc optional func dropFilesViewWantsSelectFiles(_ sender: DSFDropFilesView)\n```\nAn optional method that gets called if the user clicks the 'Select files...' button on the control.\n\n```swift\nfunc dropFilesView(_ sender: DSFDropFilesView, validateFiles: [URL]) -\u003e NSDragOperation\n```\nCalled when the drag enters the view. Return the drag operation (or an empty array) to indicate how the drag is to proceed. Use this function to filter out if the 'wrong' types of files are dropped. (for example, if you only want to receive PDFs).\n\n```swift\nfunc dropFilesView(_ sender: DSFDropFilesView, didDropFiles files: [URL]) -\u003e Bool\n```\nCalled with the files when the user actually drops the files.\n\n## Customizations\n\n### Properties\n\nThese properties can all be configured via Interface Builder or programatically.\n\n#### Allowed drop counts\n\n* `allowsMultipleDrop` : Allow multiple files/folders to dropped\n\n#### Select files button (optional)\n\n* `selectFilesButtonLabel` : Embed a clickable button for accessibility with the specified label. If empty, doesn't display the button (default)\n* `selectFilesButtonIsLink` : If the select files button is display, show the button as a hyperlink (blue underlined text) instead of a button.\n\n#### Icon\n\n* `showIcon` : Should we display an icon\n* `icon` : The icon to display. A default icon is supplied\n\n#### Label\n\n* `label` : The text of the label. If empty, the label is hidden.\n* `lineWidth` : The line width for the dotted border\n* `cornerWidth` : The radius for the corners\n\n## SwiftUI\n\n### SwiftUI\n\nThere is a basic SwiftUI View that embeds the `DSFDropFilesView` control.\n\n```swift\nDSFDropFilesView.SwiftUI(\n   isEnabled: true,\n   allowsMultipleDrop: true,\n   iconLabel: \"Drop files here\",\n   selectFilesLabel: \"Select Files…\",\n   selectFilesButtonIsLink: true,\n   validateFiles: { urls in\n      // Check the urls, and return the appropriate drop mode\n      return .copy\n   },\n   dropFiles: { urls in\n      Swift.print(\"\\(urls)\")\n      return true\n   },\n   selectFiles: {\n      Swift.print(\"User clicked select files\")\n   }\n)\n```\n\n## License\n\n```\nMIT License\n\nCopyright (c) 2024 Darren Ford\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdagronf%2Fdsfdropfilesview","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdagronf%2Fdsfdropfilesview","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdagronf%2Fdsfdropfilesview/lists"}