-
-
Notifications
You must be signed in to change notification settings - Fork 118
/
Copy pathSettingsNavBarButton.swift
147 lines (131 loc) · 4.52 KB
/
SettingsNavBarButton.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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
//
// SettingsNavBarButton.swift
// Strongbox
//
// Created by Strongbox on 01/08/2024.
// Copyright © 2024 Mark McGuill. All rights reserved.
//
import SwiftUI
struct SettingsNavBarButton: View {
@ObservedObject
var model: DatabaseHomeViewModel
var biometricsIdName: String {
model.biometricsIsFaceId ? NSLocalizedString("settings_face_id_name", comment: "Face ID") : NSLocalizedString("settings_touch_id_name", comment: "Touch ID")
}
var body: some View {
Menu {
Toggle(isOn: $model.startWithSearch, label: {
HStack {
Text("browse_context_menu_start_with_search")
Image(systemName: "magnifyingglass")
}
})
Divider()
Menu("configure_home_show_sections", systemImage: "slider.horizontal.3") {
ForEach(HomeViewSection.allCases) { section in
Toggle(isOn: Binding(
get: {
model.isHomeViewSectionVisible(section: section)
},
set: { newValue in
model.setHomeViewSectionVisible(section: section, visible: newValue)
}
),
label: {
HStack {
Text(section.title)
Image(systemName: section.imageName)
}
})
}
}
Button(action: {
model.presentConfigureTabsView()
}, label: {
HStack {
Text("configure_tabs")
Image(systemName: "list.bullet.below.rectangle")
}
})
Divider()
Button(action: {
model.presentConvenienceUnlockPreferences()
}, label: {
HStack {
let title = String(format: NSLocalizedString("convenience_unlock_preferences_title_fmt", comment: "%@ & PIN Codes"), biometricsIdName)
Text(title)
Image(systemName: model.biometricsIsFaceId ? "faceid" : "touchid")
}
})
Button(action: {
model.presentAutoFillSettings()
}, label: {
HStack {
Text("generic_autofill_settings")
Image(systemName: "rectangle.and.pencil.and.ellipsis")
}
})
Button(action: {
model.presentAuditSettings()
}, label: {
HStack {
Text("browse_vc_action_audit")
Image(systemName: "checkmark.shield")
}
})
Button(action: {
model.presentAutoLockSettings()
}, label: {
HStack {
Text("generic_auto_lock_settings")
Image(systemName: "lock.rotation.open")
}
})
Button(action: {
model.presentEncryptionSettings()
}, label: {
HStack {
Text("generic_encryption_settings")
Image(systemName: "function")
}
})
Button(action: {
model.presentSetMasterCredentials()
}, label: {
HStack {
Text("browse_context_menu_set_master_credentials")
Image(systemName: "ellipsis.rectangle")
}
})
.disabled(model.database.isReadOnly)
Divider()
if model.shouldShowYubiKeySettingsOption {
Button(action: {
model.presentHardwareKeySettings()
}, label: {
HStack {
Text("generic_hardware_key")
Image(.yubikey)
}
})
}
Button(action: {
model.presentAdvancedSettings()
}, label: {
HStack {
Text("generic_advanced_noun")
Image(systemName: "gear")
}
})
} label: {
Image(systemName: "gear")
}
}
}
#Preview {
NavigationView {
Text("Test")
.navigationTitle("Testing")
.navigationBarItems(leading: SettingsNavBarButton(model: DatabaseHomeViewModel()))
}
}