无结果时隐藏格式化结果区域

This commit is contained in:
2026-07-12 16:54:32 +08:00
parent eefb7b2f5c
commit 44660190da
+2 -7
View File
@@ -18,8 +18,10 @@ struct FormatterView: View {
List {
inputSection
actionSection
if !outputText.isEmpty {
resultSection
}
}
.listStyle(.insetGrouped)
.navigationTitle("文案格式化")
.background(Color(.systemGroupedBackground).ignoresSafeArea())
@@ -83,20 +85,14 @@ struct FormatterView: View {
private var resultSection: some View {
Section {
if outputText.isEmpty {
Text("点击上方按钮生成格式化结果")
.foregroundStyle(.secondary)
} else {
TextEditor(text: .constant(outputText))
.frame(minHeight: 160)
.scrollContentBackground(.hidden)
.background(Color(.secondarySystemGroupedBackground))
}
} header: {
HStack {
Text("格式化结果")
Spacer()
if !outputText.isEmpty {
Button(action: copyOutput) {
Image(systemName: "doc.on.doc")
}
@@ -104,7 +100,6 @@ struct FormatterView: View {
}
}
}
}
private func dismissKeyboard() {
UIApplication.shared.sendAction(#selector(UIResponder.resignFirstResponder), to: nil, from: nil, for: nil)