Skip to content

Commit 2b12773

Browse files
authored
Merge pull request #124 from kkebo/refactor-buttons-and-menus
refactor: refactor `Button`s and `Menu`s
2 parents 41dfa8b + 4bea9ab commit 2b12773

2 files changed

Lines changed: 6 additions & 11 deletions

File tree

DNSecure/Views/ContentView.swift

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -305,14 +305,12 @@ extension ContentView: View {
305305

306306
@ToolbarContentBuilder private var toolbarContent: some ToolbarContent {
307307
ToolbarItem(placement: .topBarLeading) {
308-
Menu {
308+
Menu("Add", systemImage: "plus") {
309309
Button("DNS-over-TLS", action: self.addNewDoTServer)
310310
Button("DNS-over-HTTPS", action: self.addNewDoHServer)
311311
Button("Restore from Presets") {
312312
self.isRestoring = true
313313
}
314-
} label: {
315-
Image(systemName: "plus")
316314
}
317315
.sheet(isPresented: self.$isRestoring) {
318316
RestorationView(onAdd: self.restoreFromPresets)
@@ -330,10 +328,8 @@ extension ContentView: View {
330328
Text(self.isEnabled ? "Active" : "Inactive")
331329
}
332330
if !self.isEnabled {
333-
Button {
331+
Button("How to Activate", systemImage: "questionmark.circle") {
334332
self.isGuidePresented = true
335-
} label: {
336-
Label("How to Activate", systemImage: "questionmark.circle")
337333
}
338334
.labelStyle(.titleAndIcon)
339335
.font(.caption)

DNSecure/Views/LazyTextField.swift

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,12 @@ extension LazyTextField: View {
2626
TextField(self.title, text: self.$localText)
2727
.focused(self.$isFocused)
2828
if self.isFocused && !self.localText.isEmpty {
29-
Button {
29+
Button("Clear", systemImage: "xmark.circle.fill") {
3030
self.text.removeAll()
31-
} label: {
32-
Image(systemName: "xmark.circle.fill")
33-
.foregroundStyle(Color.primary)
34-
.opacity(0.2)
3531
}
32+
.foregroundStyle(Color.primary)
33+
.opacity(0.2)
34+
.labelStyle(.iconOnly)
3635
.buttonStyle(.borderless)
3736
.hoverEffect()
3837
}

0 commit comments

Comments
 (0)