标题栏改为更多菜单,支持复制和清除
This commit is contained in:
@@ -54,11 +54,18 @@ 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")
|
||||
}
|
||||
.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)
|
||||
@@ -175,6 +182,10 @@ struct FormatterView: View {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func clearText() {
|
||||
inputText = ""
|
||||
}
|
||||
}
|
||||
|
||||
#Preview {
|
||||
|
||||
Reference in New Issue
Block a user