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

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