macos: further simplify using a @ViewBuilder

This commit is contained in:
Jon Parise
2024-11-15 22:43:21 -05:00
parent 2db43158a8
commit de60382824

View File

@ -116,6 +116,15 @@ struct AboutView: View {
self.url = url self.url = url
} }
@ViewBuilder private var textView: some View {
Text(text)
.frame(width: 125, alignment: .leading)
.padding(.leading, 2)
.tint(.secondary)
.opacity(0.8)
.monospaced()
}
var body: some View { var body: some View {
HStack(spacing: 4) { HStack(spacing: 4) {
Text(label) Text(label)
@ -123,10 +132,10 @@ struct AboutView: View {
.padding(.trailing, 2) .padding(.trailing, 2)
if let url { if let url {
Link(destination: url) { Link(destination: url) {
PropertyText(text: text) textView
} }
} else { } else {
PropertyText(text: text) textView
} }
} }
.font(.callout) .font(.callout)
@ -134,19 +143,6 @@ struct AboutView: View {
.frame(maxWidth: .infinity) .frame(maxWidth: .infinity)
} }
} }
private struct PropertyText: View {
let text: String
var body: some View {
Text(text)
.frame(width: 125, alignment: .leading)
.padding(.leading, 2)
.tint(.secondary)
.opacity(0.8)
.monospaced()
}
}
} }
struct AboutView_Previews: PreviewProvider { struct AboutView_Previews: PreviewProvider {