From fc798a575aed94718dcc4c5555b6e01cf8da93e9 Mon Sep 17 00:00:00 2001 From: Dustin Mierau Date: Fri, 3 May 2024 14:46:42 -0700 Subject: Nicer about box. --- Hotline/macOS/AboutView.swift | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 Hotline/macOS/AboutView.swift (limited to 'Hotline/macOS') diff --git a/Hotline/macOS/AboutView.swift b/Hotline/macOS/AboutView.swift new file mode 100644 index 0000000..378385a --- /dev/null +++ b/Hotline/macOS/AboutView.swift @@ -0,0 +1,42 @@ +import SwiftUI + +struct AboutView: View { + @Environment(\.openURL) private var openURL + + var body: some View { + VStack(alignment: .center) { + Spacer() + Image("About Hotline") + .padding(.top, 32) + Text("Hotline") + .font(.title) + .fontWeight(.semibold) + .padding(.top, 16) + let appDetails = getAppVersionAndBuild() + Text("\(appDetails.version)b\(appDetails.build)") + .fontWeight(.semibold) + .opacity(0.6) + Button("Download Latest") { + if let url = URL(string: "https://github.com/mierau/hotline/releases/latest") { + openURL(url) + } + } + .controlSize(.large) + .padding(.top, 16) + Spacer() + } + .frame(width: 300, height: 400) + .ignoresSafeArea() + } + + func getAppVersionAndBuild() -> (version: String, build: String) { + let infoDictionary = Bundle.main.infoDictionary + let version = infoDictionary?["CFBundleShortVersionString"] as? String ?? "Unknown" + let build = infoDictionary?["CFBundleVersion"] as? String ?? "Unknown" + return (version, build) + } +} + +#Preview { + AboutView() +} -- cgit