Merge pull request #124 from kkebo/refactor-buttons-and-menus

refactor: refactor `Button`s and `Menu`s
This commit is contained in:
Kenta Kubo 2025-09-02 22:18:44 +09:00 committed by GitHub
commit 2b1277347d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 11 deletions

View file

@ -305,14 +305,12 @@ extension ContentView: View {
@ToolbarContentBuilder private var toolbarContent: some ToolbarContent {
ToolbarItem(placement: .topBarLeading) {
Menu {
Menu("Add", systemImage: "plus") {
Button("DNS-over-TLS", action: self.addNewDoTServer)
Button("DNS-over-HTTPS", action: self.addNewDoHServer)
Button("Restore from Presets") {
self.isRestoring = true
}
} label: {
Image(systemName: "plus")
}
.sheet(isPresented: self.$isRestoring) {
RestorationView(onAdd: self.restoreFromPresets)
@ -330,10 +328,8 @@ extension ContentView: View {
Text(self.isEnabled ? "Active" : "Inactive")
}
if !self.isEnabled {
Button {
Button("How to Activate", systemImage: "questionmark.circle") {
self.isGuidePresented = true
} label: {
Label("How to Activate", systemImage: "questionmark.circle")
}
.labelStyle(.titleAndIcon)
.font(.caption)

View file

@ -26,13 +26,12 @@ extension LazyTextField: View {
TextField(self.title, text: self.$localText)
.focused(self.$isFocused)
if self.isFocused && !self.localText.isEmpty {
Button {
Button("Clear", systemImage: "xmark.circle.fill") {
self.text.removeAll()
} label: {
Image(systemName: "xmark.circle.fill")
.foregroundStyle(Color.primary)
.opacity(0.2)
}
.foregroundStyle(Color.primary)
.opacity(0.2)
.labelStyle(.iconOnly)
.buttonStyle(.borderless)
.hoverEffect()
}