标题栏改为更多菜单,支持复制和清除

This commit is contained in:
2026-07-12 17:02:35 +08:00
parent 252f8a294f
commit 0da31b468c
+14 -3
View File
@@ -54,11 +54,18 @@ struct FormatterView: View {
.font(.largeTitle.bold()) .font(.largeTitle.bold())
.foregroundStyle(.primary) .foregroundStyle(.primary)
Spacer() Spacer()
if !inputText.isEmpty { Menu {
Button(action: copyText) { Button(action: copyText) {
Image(systemName: "doc.on.doc") Label("复制", systemImage: "doc.on.doc")
} }
.font(.title3) .disabled(inputText.isEmpty)
Button(role: .destructive, action: clearText) {
Label("清除", systemImage: "xmark.circle")
}
.disabled(inputText.isEmpty)
} label: {
Image(systemName: "ellipsis.circle")
.font(.title3)
} }
} }
.frame(maxWidth: .infinity, minHeight: 44) .frame(maxWidth: .infinity, minHeight: 44)
@@ -175,6 +182,10 @@ struct FormatterView: View {
} }
} }
} }
private func clearText() {
inputText = ""
}
} }
#Preview { #Preview {