-
-
Notifications
You must be signed in to change notification settings - Fork 118
/
Copy pathSwiftDummyEntryModel.swift
93 lines (70 loc) · 2.29 KB
/
SwiftDummyEntryModel.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
//
// SwiftDummyEntryModel.swift
// Strongbox
//
// Created by Strongbox on 28/07/2024.
// Copyright © 2024 Mark McGuill. All rights reserved.
//
import Foundation
import OrderedCollections
class SwiftDummyEntryModel: SwiftEntryModelInterface {
var customFields: OrderedDictionary<String, StringValue> {
.init()
}
var launchableUrl: URL? {
guard !url.isEmpty else { return nil }
return url.urlExtendedParseAddingDefaultScheme
}
var isFlaggedByAudit: Bool { false }
static func == (lhs: SwiftDummyEntryModel, rhs: SwiftDummyEntryModel) -> Bool {
lhs.uuid == rhs.uuid
}
static func < (lhs: SwiftDummyEntryModel, rhs: SwiftDummyEntryModel) -> Bool {
lhs.title < rhs.title
}
var tags: [String] = []
var favourite = false
func toggleFavourite() -> Bool {
favourite.toggle()
return false
}
var appleWatch = false
func toggleAppleWatch() -> Bool {
appleWatch.toggle()
return false
}
var isWatchEntry: Bool { appleWatch }
var isFavourite: Bool { favourite }
var isGroup: Bool { false }
var searchFoundInPath: String { "in Database/Finance/Another Folder" }
var id: UUID { uuid }
let uuid: UUID = .init()
var title: String = ""
var username: String = ""
var password: String = ""
var email: String = ""
var notes: String = ""
var url: String = ""
var image: IMAGE_TYPE_PTR
var totp: OTPToken?
init(title: String = "Dummy", username: String = "Username", password: String = "pw1234", imageSystemName: String = "doc", favourite: Bool = false, tags: [String] = [], totpUrl: String? = nil) {
#if os(iOS)
let i = UIImage(systemName: imageSystemName)!
let tinted = i.withTintColor(.blue, renderingMode: .alwaysTemplate)
#else
let i = NSImage(systemSymbolName: imageSystemName, accessibilityDescription: nil)!
let tinted = i
#endif
var totp: OTPToken? = nil
if let totpUrl {
totp = OTPToken(url: URL(string: totpUrl))
}
self.title = title
self.username = username
self.password = password
image = tinted
self.totp = totp
self.favourite = favourite
self.tags = tags
}
}