-
-
Notifications
You must be signed in to change notification settings - Fork 118
/
Copy pathOtherViewsView.swift
71 lines (59 loc) · 3.54 KB
/
OtherViewsView.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
//
// OtherViewsView.swift
// Strongbox
//
// Created by Strongbox on 27/07/2024.
// Copyright © 2024 Mark McGuill. All rights reserved.
//
import Foundation
import SwiftUI
struct OtherViewsView: View {
private let twoColumnGrid = [GridItem(.flexible()), GridItem(.flexible())]
@ObservedObject
var model: DatabaseHomeViewModel
var body: some View {
LazyVGrid(columns: twoColumnGrid) {
if model.database.tagCount > 0 {
NavigationCapsule(model: model, title: "quick_view_title_all_tags_title", image: "tag.fill", count: String(model.database.tagCount), imageBackgroundColor: .blue, destination: .tags(tag: nil))
}
let auditModel = model.database.auditModel
if auditModel.isEnabled {
let issueCount = model.database.auditIssueEntryCount
NavigationCapsule(model: model,
title: "browse_vc_action_audit",
image: "checkmark.shield.fill",
count: issueCount == 0 ? "" : String(issueCount),
imageBackgroundColor: issueCount == 0 ? .green : .orange,
destination: .auditIssues)
}
if model.database.passkeyEntryCount > 0 {
NavigationCapsule(model: model, title: "generic_noun_plural_passkeys", image: "person.badge.key.fill", count: String(model.database.passkeyEntryCount), imageBackgroundColor: .purple, destination: .passkeys)
}
if model.database.sshKeyEntryCount > 0 {
if #available(iOS 17.0, *) {
NavigationCapsule(model: model, title: "sidebar_quick_view_keeagent_ssh_keys_title", image: "apple.terminal.fill", count: String(model.database.sshKeyEntryCount), imageBackgroundColor: .indigo, destination: .sshKeys)
} else {
NavigationCapsule(model: model, title: "sidebar_quick_view_keeagent_ssh_keys_title", image: "network", count: String(model.database.sshKeyEntryCount), imageBackgroundColor: .indigo, destination: .sshKeys)
}
}
if model.database.attachmentsEntryCount > 0 {
NavigationCapsule(model: model, title: "item_details_section_header_attachments", image: "doc.richtext.fill", count: String(model.database.attachmentsEntryCount), imageBackgroundColor: .mint, destination: .attachments)
}
if model.database.watchEntryCount > 0 {
NavigationCapsule(model: model, title: "sidebar_watch_entries", image: "applewatch", count: String(model.database.watchEntryCount), imageBackgroundColor: Color.brown, destination: .watchEntries)
}
if model.expireCount > 0 {
NavigationCapsule(model: model, title: "quick_view_title_expired_and_expiring", image: "calendar", count: String(model.expireCount), imageBackgroundColor: .cyan, destination: .expiredAndExpiring)
}
if let recycleBinGroup = model.recycleBinGroup, model.database.recycleBinCount > 0 {
NavigationCapsule(model: model, title: "generic_recycle_bin_name", image: "trash.fill", count: String(model.database.recycleBinCount), imageBackgroundColor: .yellow, destination: .recycleBin)
.contextMenu {
EntryViewContextMenu(model: model, item: recycleBinGroup)
}
}
}
}
}
#Preview {
OtherViewsView(model: DatabaseHomeViewModel(database: SwiftDummyDatabaseModel.testModel))
}