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

This commit is contained in:
2026-07-12 16:54:32 +08:00
parent eefb7b2f5c
commit 44660190da
+10 -15
View File
@@ -18,7 +18,9 @@ struct FormatterView: View {
List { List {
inputSection inputSection
actionSection actionSection
resultSection if !outputText.isEmpty {
resultSection
}
} }
.listStyle(.insetGrouped) .listStyle(.insetGrouped)
.navigationTitle("文案格式化") .navigationTitle("文案格式化")
@@ -83,25 +85,18 @@ struct FormatterView: View {
private var resultSection: some View { private var resultSection: some View {
Section { Section {
if outputText.isEmpty { TextEditor(text: .constant(outputText))
Text("点击上方按钮生成格式化结果") .frame(minHeight: 160)
.foregroundStyle(.secondary) .scrollContentBackground(.hidden)
} else { .background(Color(.secondarySystemGroupedBackground))
TextEditor(text: .constant(outputText))
.frame(minHeight: 160)
.scrollContentBackground(.hidden)
.background(Color(.secondarySystemGroupedBackground))
}
} header: { } header: {
HStack { HStack {
Text("格式化结果") Text("格式化结果")
Spacer() Spacer()
if !outputText.isEmpty { Button(action: copyOutput) {
Button(action: copyOutput) { Image(systemName: "doc.on.doc")
Image(systemName: "doc.on.doc")
}
.font(.subheadline)
} }
.font(.subheadline)
} }
} }
} }