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/Application-macOS.swift | 20 ++++++++++ .../About Hotline.imageset/Contents.json | 23 +++++++++++ .../About Hotline.imageset/Group 3.png | Bin 0 -> 14188 bytes .../About Hotline.imageset/Group 3@2x.png | Bin 0 -> 38758 bytes .../About Hotline.imageset/Group 3@3x.png | Bin 0 -> 71532 bytes .../Hotline Red.colorset/Contents.json | 38 +++++++++++++++++++ .../Unread Message Dot.colorset/Contents.json | 38 ------------------- Hotline/macOS/AboutView.swift | 42 +++++++++++++++++++++ 8 files changed, 123 insertions(+), 38 deletions(-) create mode 100644 Hotline/Assets.xcassets/About Hotline.imageset/Contents.json create mode 100644 Hotline/Assets.xcassets/About Hotline.imageset/Group 3.png create mode 100644 Hotline/Assets.xcassets/About Hotline.imageset/Group 3@2x.png create mode 100644 Hotline/Assets.xcassets/About Hotline.imageset/Group 3@3x.png create mode 100644 Hotline/Assets.xcassets/Hotline Red.colorset/Contents.json delete mode 100644 Hotline/Assets.xcassets/Unread Message Dot.colorset/Contents.json create mode 100644 Hotline/macOS/AboutView.swift (limited to 'Hotline') diff --git a/Hotline/Application-macOS.swift b/Hotline/Application-macOS.swift index ec42a89..eb5be32 100644 --- a/Hotline/Application-macOS.swift +++ b/Hotline/Application-macOS.swift @@ -60,6 +60,25 @@ struct Application: App { } } + Window("About", id: "about") { + AboutView() + .ignoresSafeArea() + .background(Color.hotlineRed) + } + .windowResizability(.contentSize) + .windowStyle(.hiddenTitleBar) + .defaultSize(width: 300, height: 400) + .defaultPosition(.center) + .commands { + CommandGroup(replacing: CommandGroupPlacement.appInfo) { + Button(action: { + openWindow(id: "about") + }) { + Text("About Hotline") + } + } + } + // MARK: Server Window WindowGroup(id: "server", for: Server.self) { server in ServerView(server: server) @@ -165,6 +184,7 @@ struct Application: App { SettingsView() } + // MARK: News Editor Window // WindowGroup(id: "news-editor", for: NewsArticle.self) { $article in // NewsEditorView(article: $article) diff --git a/Hotline/Assets.xcassets/About Hotline.imageset/Contents.json b/Hotline/Assets.xcassets/About Hotline.imageset/Contents.json new file mode 100644 index 0000000..84fb02e --- /dev/null +++ b/Hotline/Assets.xcassets/About Hotline.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "filename" : "Group 3.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "Group 3@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "Group 3@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Hotline/Assets.xcassets/About Hotline.imageset/Group 3.png b/Hotline/Assets.xcassets/About Hotline.imageset/Group 3.png new file mode 100644 index 0000000..84f7790 Binary files /dev/null and b/Hotline/Assets.xcassets/About Hotline.imageset/Group 3.png differ diff --git a/Hotline/Assets.xcassets/About Hotline.imageset/Group 3@2x.png b/Hotline/Assets.xcassets/About Hotline.imageset/Group 3@2x.png new file mode 100644 index 0000000..e0961c2 Binary files /dev/null and b/Hotline/Assets.xcassets/About Hotline.imageset/Group 3@2x.png differ diff --git a/Hotline/Assets.xcassets/About Hotline.imageset/Group 3@3x.png b/Hotline/Assets.xcassets/About Hotline.imageset/Group 3@3x.png new file mode 100644 index 0000000..a3ef5d0 Binary files /dev/null and b/Hotline/Assets.xcassets/About Hotline.imageset/Group 3@3x.png differ diff --git a/Hotline/Assets.xcassets/Hotline Red.colorset/Contents.json b/Hotline/Assets.xcassets/Hotline Red.colorset/Contents.json new file mode 100644 index 0000000..1f6e488 --- /dev/null +++ b/Hotline/Assets.xcassets/Hotline Red.colorset/Contents.json @@ -0,0 +1,38 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0x00", + "green" : "0x00", + "red" : "0xE1" + } + }, + "idiom" : "universal" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0x00", + "green" : "0x00", + "red" : "0xE1" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Hotline/Assets.xcassets/Unread Message Dot.colorset/Contents.json b/Hotline/Assets.xcassets/Unread Message Dot.colorset/Contents.json deleted file mode 100644 index 05fcb96..0000000 --- a/Hotline/Assets.xcassets/Unread Message Dot.colorset/Contents.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "colors" : [ - { - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0x00", - "green" : "0x00", - "red" : "0xF1" - } - }, - "idiom" : "universal" - }, - { - "appearances" : [ - { - "appearance" : "luminosity", - "value" : "dark" - } - ], - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0x00", - "green" : "0x00", - "red" : "0xF1" - } - }, - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} 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