mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-08-02 14:57:31 +03:00
macos: prefer private View structs to functions
This commit is contained in:
@ -64,14 +64,14 @@ struct AboutView: View {
|
|||||||
|
|
||||||
VStack(spacing: 2) {
|
VStack(spacing: 2) {
|
||||||
if let version {
|
if let version {
|
||||||
propertyRow("Version", text: version)
|
PropertyRow(label: "Version", text: version)
|
||||||
}
|
}
|
||||||
if let build {
|
if let build {
|
||||||
propertyRow("Build", text: build)
|
PropertyRow(label: "Build", text: build)
|
||||||
}
|
}
|
||||||
if let commit, commit != "",
|
if let commit, commit != "",
|
||||||
let url = githubURL?.appendingPathComponent("/commits/\(commit)") {
|
let url = githubURL?.appendingPathComponent("/commits/\(commit)") {
|
||||||
propertyRow("Commit", text: commit, url: url)
|
PropertyRow(label: "Commit", text: commit, url: url)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.frame(maxWidth: .infinity)
|
.frame(maxWidth: .infinity)
|
||||||
@ -105,25 +105,40 @@ struct AboutView: View {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
private func propertyRow(_ label: LocalizedStringResource, text: String, url: URL? = nil) -> some View {
|
private struct PropertyRow: View {
|
||||||
|
let label: String
|
||||||
|
let text: String
|
||||||
|
let url: URL?
|
||||||
|
|
||||||
|
init(label: String, text: String, url: URL? = nil) {
|
||||||
|
self.label = label
|
||||||
|
self.text = text
|
||||||
|
self.url = url
|
||||||
|
}
|
||||||
|
|
||||||
|
var body: some View {
|
||||||
HStack(spacing: 4) {
|
HStack(spacing: 4) {
|
||||||
Text(label)
|
Text(label)
|
||||||
.frame(width: 126, alignment: .trailing)
|
.frame(width: 126, alignment: .trailing)
|
||||||
.padding(.trailing, 2)
|
.padding(.trailing, 2)
|
||||||
if let url {
|
if let url {
|
||||||
Link(destination: url) {
|
Link(destination: url) {
|
||||||
propertyText(text)
|
PropertyText(text: text)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
propertyText(text)
|
PropertyText(text: text)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.font(.callout)
|
.font(.callout)
|
||||||
.textSelection(.enabled)
|
.textSelection(.enabled)
|
||||||
.frame(maxWidth: .infinity)
|
.frame(maxWidth: .infinity)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private func propertyText(_ text: String) -> some View {
|
private struct PropertyText: View {
|
||||||
|
let text: String
|
||||||
|
|
||||||
|
var body: some View {
|
||||||
Text(text)
|
Text(text)
|
||||||
.frame(width: 125, alignment: .leading)
|
.frame(width: 125, alignment: .leading)
|
||||||
.padding(.leading, 2)
|
.padding(.leading, 2)
|
||||||
@ -132,6 +147,7 @@ struct AboutView: View {
|
|||||||
.monospaced()
|
.monospaced()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
struct AboutView_Previews: PreviewProvider {
|
struct AboutView_Previews: PreviewProvider {
|
||||||
static var previews: some View {
|
static var previews: some View {
|
||||||
|
Reference in New Issue
Block a user