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 characters
| @IBAction func didClickOnExploreButton(_ sender: NSButtonCell) | |
| { | |
| toggleViewStates(state: false) | |
| files = [String:Media]() | |
| switch sender.tag { | |
| case 101: | |
| getFilesFromDoucmentDir(type: .image) | |
| case 102: | |
| getFilesFromDoucmentDir(type: .video) | |
| case 103: |
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 characters
| func createDirectory(sourcePath: String, type: MediaType) { | |
| // path to documents directory | |
| let documentDirectoryPath = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true).first | |
| if let documentDirectoryPath = documentDirectoryPath { | |
| // create the custom folder path | |
| var subDirectoryPath = "" | |
| switch type | |
| { | |
| case .audio: | |
| subDirectoryPath = documentDirectoryPath.appending("/audios") |
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 characters
| override func viewDidLoad() { | |
| super.viewDidLoad() | |
| dragDropAreaView.delegate = self | |
| setupView() | |
| } | |
| override func viewDidAppear() { | |
| let flowLayout = NSCollectionViewFlowLayout() | |
| flowLayout.itemSize = NSSize(width: 160.0, height: 120.0) |
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 characters
| import Cocoa | |
| class CollectionViewItem: NSCollectionViewItem { | |
| override func viewDidLoad() { | |
| super.viewDidLoad() | |
| view.wantsLayer = true | |
| view.layer?.backgroundColor = NSColor.lightGray.cgColor | |
| } | |
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 characters
| class DragDropAreView: NSView { | |
| private var fileTypeIsOk = false | |
| private var acceptedFileExtensions = ["jpg","png","doc","docx","pdf","mov","mp4","mp3"] | |
| var delegate: DragDropViewDelegate? | |
| var isReceivingDrag = false { | |
| didSet { | |
| needsDisplay = true | |
| } |
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 characters
| enum MediaType | |
| { | |
| case image | |
| case video | |
| case audio | |
| case document | |
| } | |
| struct Media | |
| { |
NewerOlder