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.xcodeproj/project.pbxproj | 4 ++ 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 +++++++++++++++++++++ 9 files changed, 127 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 diff --git a/Hotline.xcodeproj/project.pbxproj b/Hotline.xcodeproj/project.pbxproj index d6ea58a..ab013d5 100644 --- a/Hotline.xcodeproj/project.pbxproj +++ b/Hotline.xcodeproj/project.pbxproj @@ -25,6 +25,7 @@ DA4F2C012B1A558E00D8ADDC /* ChatView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA4F2C002B1A558E00D8ADDC /* ChatView.swift */; platformFilter = ios; }; DA55AC732BE42AF000034857 /* AsyncLinkPreview.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA55AC722BE42AF000034857 /* AsyncLinkPreview.swift */; platformFilters = (macos, ); }; DA55AC752BE4888300034857 /* InstantMessage.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA55AC742BE4888300034857 /* InstantMessage.swift */; }; + DA55AC772BE589F700034857 /* AboutView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA55AC762BE589F700034857 /* AboutView.swift */; platformFilters = (macos, ); }; DA5753682B33E88A00FAC277 /* HotlineFileClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA5753672B33E88A00FAC277 /* HotlineFileClient.swift */; }; DA57536C2B36BA1D00FAC277 /* TextDocument.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA57536B2B36BA1D00FAC277 /* TextDocument.swift */; }; DA6300972B24036B0034CBFD /* HotlineClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA6300962B24036B0034CBFD /* HotlineClient.swift */; }; @@ -98,6 +99,7 @@ DA4F2C002B1A558E00D8ADDC /* ChatView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChatView.swift; sourceTree = ""; }; DA55AC722BE42AF000034857 /* AsyncLinkPreview.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AsyncLinkPreview.swift; sourceTree = ""; }; DA55AC742BE4888300034857 /* InstantMessage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InstantMessage.swift; sourceTree = ""; }; + DA55AC762BE589F700034857 /* AboutView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AboutView.swift; sourceTree = ""; }; DA5753672B33E88A00FAC277 /* HotlineFileClient.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HotlineFileClient.swift; sourceTree = ""; }; DA57536B2B36BA1D00FAC277 /* TextDocument.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextDocument.swift; sourceTree = ""; }; DA6300962B24036B0034CBFD /* HotlineClient.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HotlineClient.swift; sourceTree = ""; }; @@ -321,6 +323,7 @@ DA72A0DC2B4CD0BF00A0F48A /* NewsEditorView.swift */, DA2863D72B37AD1C00A7D050 /* SettingsView.swift */, DAE136B92B9D1147007D8307 /* HotlinePanelView.swift */, + DA55AC762BE589F700034857 /* AboutView.swift */, ); path = macOS; sourceTree = ""; @@ -427,6 +430,7 @@ DADDB28F2B238D850024040D /* Hotline.swift in Sources */, DADDB28D2B22B5920024040D /* Server.swift in Sources */, DABE8C042B57940B00884D28 /* DAKeychain.swift in Sources */, + DA55AC772BE589F700034857 /* AboutView.swift in Sources */, DA72A0E22B4DAA4000A0F48A /* NewsArticle.swift in Sources */, DAE734FB2B2E41F9000C56F6 /* TrackerView.swift in Sources */, DAE136BA2B9D1147007D8307 /* HotlinePanelView.swift in Sources */, 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