mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-08-02 14:57:31 +03:00
refactor: hide buttons when URLs are invalid and change variable mutability and visibility.
This commit is contained in:
@ -4,23 +4,23 @@ struct AboutView: View {
|
|||||||
@Environment(\.openURL) var openURL
|
@Environment(\.openURL) var openURL
|
||||||
|
|
||||||
/// Eventually this should be a redirect like https://go.ghostty.dev/discord or https://go.ghostty.dev/github
|
/// Eventually this should be a redirect like https://go.ghostty.dev/discord or https://go.ghostty.dev/github
|
||||||
@State var discordLink: String = "https://discord.gg/ghostty"
|
private let discordLink = URL(string: "https://discord.gg/ghostty")
|
||||||
@State var githubLink: String = "https://github.com/ghostty-org/ghostty"
|
private let githubLink = URL(string: "https://github.com/ghostty-org/ghostty")
|
||||||
|
|
||||||
/// Read the commit from the bundle.
|
/// Read the commit from the bundle.
|
||||||
var build: String? { Bundle.main.infoDictionary?["CFBundleVersion"] as? String }
|
private var build: String? { Bundle.main.infoDictionary?["CFBundleVersion"] as? String }
|
||||||
var commit: String? { Bundle.main.infoDictionary?["GhosttyCommit"] as? String }
|
private var commit: String? { Bundle.main.infoDictionary?["GhosttyCommit"] as? String }
|
||||||
var version: String? { Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String }
|
private var version: String? { Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String }
|
||||||
var copyright: String? { Bundle.main.infoDictionary?["NSHumanReadableCopyright"] as? String }
|
private var copyright: String? { Bundle.main.infoDictionary?["NSHumanReadableCopyright"] as? String }
|
||||||
|
|
||||||
struct ValuePair<Value: Equatable>: Identifiable {
|
private struct ValuePair<Value: Equatable>: Identifiable {
|
||||||
var id = UUID()
|
var id = UUID()
|
||||||
public let key: LocalizedStringResource
|
public let key: LocalizedStringResource
|
||||||
public let value: Value
|
public let value: Value
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var computedStrings: [ValuePair<String>] {
|
private var computedStrings: [ValuePair<String>] {
|
||||||
let list: [ValuePair<String?>] = [
|
let list: [ValuePair<String?>] = [
|
||||||
ValuePair(key: "Version", value: self.version),
|
ValuePair(key: "Version", value: self.version),
|
||||||
ValuePair(key: "Build", value: self.build),
|
ValuePair(key: "Build", value: self.build),
|
||||||
@ -37,7 +37,7 @@ struct AboutView: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if os(macOS)
|
#if os(macOS)
|
||||||
struct VisualEffectBackground: NSViewRepresentable {
|
private struct VisualEffectBackground: NSViewRepresentable {
|
||||||
let material: NSVisualEffectView.Material
|
let material: NSVisualEffectView.Material
|
||||||
let blendingMode: NSVisualEffectView.BlendingMode
|
let blendingMode: NSVisualEffectView.BlendingMode
|
||||||
let isEmphasized: Bool
|
let isEmphasized: Bool
|
||||||
@ -103,18 +103,19 @@ struct AboutView: View {
|
|||||||
.frame(maxWidth: .infinity)
|
.frame(maxWidth: .infinity)
|
||||||
|
|
||||||
HStack(spacing: 8) {
|
HStack(spacing: 8) {
|
||||||
|
if let url = discordLink {
|
||||||
Button("Discord") {
|
Button("Discord") {
|
||||||
guard let url = URL(string: discordLink) else { return
|
|
||||||
}
|
|
||||||
openURL(url)
|
openURL(url)
|
||||||
}
|
}
|
||||||
Button("Github") {
|
|
||||||
guard let url = URL(string: githubLink) else { return
|
|
||||||
}
|
}
|
||||||
|
if let url = githubLink {
|
||||||
|
Button("GitHub") {
|
||||||
openURL(url)
|
openURL(url)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
if let copy = self.copyright {
|
if let copy = self.copyright {
|
||||||
Text(copy)
|
Text(copy)
|
||||||
.font(.caption)
|
.font(.caption)
|
||||||
|
Reference in New Issue
Block a user