1
1
mirror of https://github.com/bitgapp/eqMac.git synced 2024-12-03 07:31:45 +03:00
eqMac/native/app/Source/Helpers/File.swift
2020-04-04 19:15:38 +01:00

44 lines
977 B
Swift

//
// File.swift
// eqMac
//
// Created by Romans Kisils on 16/06/2019.
// Copyright © 2019 Romans Kisils. All rights reserved.
//
import Foundation
import AppKit
class File {
static var openPanel = NSOpenPanel()
static var savePanel = NSSavePanel()
static func select (_ callback: @escaping (URL?) -> Void) {
DispatchQueue.main.async {
openPanel.selectSingleFile() { response in
if response == .OK {
callback(openPanel.url)
} else {
callback(nil)
}
}
}
}
static func save (extensions: [String]?, _ callback: @escaping (URL?) -> Void) {
DispatchQueue.main.async {
savePanel.saveFile(extensions: extensions) { response in
if response == .OK {
callback(savePanel.url)
} else {
callback(nil)
}
}
}
}
static var isPanelVisible: Bool {
return File.openPanel.isVisible || File.savePanel.isVisible
}
}