Assorted changes
This commit is contained in:
parent
94c39fb5c5
commit
d636f23ef3
|
@ -7,12 +7,12 @@
|
|||
<key>OTP.xcscheme_^#shared#^_</key>
|
||||
<dict>
|
||||
<key>orderHint</key>
|
||||
<integer>1</integer>
|
||||
<integer>0</integer>
|
||||
</dict>
|
||||
<key>OTPKit.xcscheme_^#shared#^_</key>
|
||||
<dict>
|
||||
<key>orderHint</key>
|
||||
<integer>0</integer>
|
||||
<integer>1</integer>
|
||||
</dict>
|
||||
</dict>
|
||||
</dict>
|
||||
|
|
|
@ -43,6 +43,15 @@ struct KeyData: Codable {
|
|||
}
|
||||
}
|
||||
|
||||
mutating func addOrUpdateFolders(_ folders: [Folder]) {
|
||||
for f in folders {
|
||||
guard !self.folders.contains(where: { $0.id == f.id }) else {
|
||||
continue
|
||||
}
|
||||
self.folders.append(f)
|
||||
}
|
||||
}
|
||||
|
||||
mutating func updateKey(entryID id: UUID, newKey: TOTPKey) {
|
||||
guard let index = entries.firstIndex(where: { $0.id == id }) else {
|
||||
return
|
||||
|
|
|
@ -51,6 +51,7 @@ class KeyStore: ObservableObject {
|
|||
data = newStore
|
||||
} else {
|
||||
data.addOrUpdateEntries(newStore.entries)
|
||||
data.addOrUpdateFolders(newStore.folders)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -84,6 +84,8 @@ extension AddQRView {
|
|||
return "Scanner: Bad Input"
|
||||
case .scanner(.badOutput):
|
||||
return "Scanner: Bad Output"
|
||||
case .scanner(.initError(let e)):
|
||||
return ("Scanner: Initialization: \(e)")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
//
|
||||
|
||||
import SwiftUI
|
||||
import UniformTypeIdentifiers
|
||||
|
||||
struct FoldersSection: View {
|
||||
@ObservedObject private var store: KeyStore = .shared
|
||||
|
@ -15,6 +16,20 @@ struct FoldersSection: View {
|
|||
Section {
|
||||
ForEach(store.sortedFolders) { (folder) in
|
||||
FolderRow(store: store, folder: folder)
|
||||
.onDrop(of: [.text], isTargeted: nil) { providers in
|
||||
guard let provider = providers.first,
|
||||
provider.canLoadObject(ofClass: NSString.self) else {
|
||||
return false
|
||||
}
|
||||
provider.loadObject(ofClass: NSString.self) { object, _ in
|
||||
guard let str = object as? NSString,
|
||||
let id = UUID(uuidString: str as String) else {
|
||||
return
|
||||
}
|
||||
store.moveEntryToFolder(entryID: id, folderID: folder.id)
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
.onDelete { (indices) in
|
||||
let folderIDs = indices.map { store.sortedFolders[$0].id }
|
||||
|
|
|
@ -35,9 +35,11 @@ struct KeysSection: View {
|
|||
ForEach(filteredEntries) { (entry) in
|
||||
KeyView(key: entry.key, currentCode: entry.code)
|
||||
// disabled because dropping onto list rows does not work :/
|
||||
// .onDrag {
|
||||
// NSItemProvider(object: entry.id.uuidString as NSString)
|
||||
// }
|
||||
.onDrag {
|
||||
let provider = NSItemProvider()
|
||||
provider.registerObject(entry.id.uuidString as NSString, visibility: .ownProcess)
|
||||
return provider
|
||||
}
|
||||
.contextMenu {
|
||||
self.keyMenu(entry: entry)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue