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