From 7850a3839a671258e33b0e23722fcda713a601c2 Mon Sep 17 00:00:00 2001 From: neon443 <69979447+neon443@users.noreply.github.com> Date: Sat, 2 Aug 2025 20:45:45 +0100 Subject: [PATCH] added a basic about thingy - added a Bundle.swift to manage getting info from the Bundle.main.infoDictionary - extended UIImage to show the app's icon via UIImage().appIcon --- ShhShell.xcodeproj/project.pbxproj | 16 ++++++++++++ ShhShell/Misc/Bundle.swift | 30 ++++++++++++++++++++++ ShhShell/Views/About/AboutView.swift | 22 ++++++++++++++++ ShhShell/Views/ContentView.swift | 38 ++++++++++++++++++---------- 4 files changed, 92 insertions(+), 14 deletions(-) create mode 100644 ShhShell/Misc/Bundle.swift create mode 100644 ShhShell/Views/About/AboutView.swift diff --git a/ShhShell.xcodeproj/project.pbxproj b/ShhShell.xcodeproj/project.pbxproj index 47adc32..ee11109 100644 --- a/ShhShell.xcodeproj/project.pbxproj +++ b/ShhShell.xcodeproj/project.pbxproj @@ -17,6 +17,8 @@ A90936AE2E1AE9AB00856059 /* JetBrainsMonoNerdFontMono-Regular.ttf in Resources */ = {isa = PBXBuildFile; fileRef = A909369D2E1AE9AB00856059 /* JetBrainsMonoNerdFontMono-Regular.ttf */; }; A90936AF2E1AE9AB00856059 /* MesloLGS NF Bold.ttf in Resources */ = {isa = PBXBuildFile; fileRef = A909369F2E1AE9AB00856059 /* MesloLGS NF Bold.ttf */; }; A90936B02E1AE9AB00856059 /* MesloLGS NF Italic.ttf in Resources */ = {isa = PBXBuildFile; fileRef = A90936A12E1AE9AB00856059 /* MesloLGS NF Italic.ttf */; }; + A90B38322E3E8FC9002B56FC /* AboutView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A90B38312E3E8FC9002B56FC /* AboutView.swift */; }; + A90B38342E3EA046002B56FC /* Bundle.swift in Sources */ = {isa = PBXBuildFile; fileRef = A90B38332E3EA046002B56FC /* Bundle.swift */; }; A923172A2E07113100ECE1E6 /* TerminalController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A92317292E07113100ECE1E6 /* TerminalController.swift */; }; A923172D2E07138000ECE1E6 /* SSHTerminalDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = A923172C2E07138000ECE1E6 /* SSHTerminalDelegate.swift */; }; A923172F2E08851200ECE1E6 /* ShellView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A923172E2E08851200ECE1E6 /* ShellView.swift */; }; @@ -140,6 +142,8 @@ A90936A22E1AE9AB00856059 /* MesloLGS NF Regular.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "MesloLGS NF Regular.ttf"; sourceTree = ""; }; A90936A42E1AE9AB00856059 /* SF-Mono-Regular.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "SF-Mono-Regular.otf"; sourceTree = ""; }; A90936A52E1AE9AB00856059 /* SF-Mono-RegularItalic.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "SF-Mono-RegularItalic.otf"; sourceTree = ""; }; + A90B38312E3E8FC9002B56FC /* AboutView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AboutView.swift; sourceTree = ""; }; + A90B38332E3EA046002B56FC /* Bundle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Bundle.swift; sourceTree = ""; }; A92317292E07113100ECE1E6 /* TerminalController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TerminalController.swift; sourceTree = ""; }; A923172C2E07138000ECE1E6 /* SSHTerminalDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SSHTerminalDelegate.swift; sourceTree = ""; }; A923172E2E08851200ECE1E6 /* ShellView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = ShellView.swift; path = ShhShell/Views/Terminal/ShellView.swift; sourceTree = SOURCE_ROOT; }; @@ -313,6 +317,14 @@ path = sfMono; sourceTree = ""; }; + A90B38302E3E8FBA002B56FC /* About */ = { + isa = PBXGroup; + children = ( + A90B38312E3E8FC9002B56FC /* AboutView.swift */, + ); + path = About; + sourceTree = ""; + }; A923172B2E0712F200ECE1E6 /* Terminal */ = { isa = PBXGroup; children = ( @@ -395,6 +407,7 @@ A9D8192B2E0E9EA400442D38 /* Themes */, A9485C742E1AF58C00209824 /* Fonts */, A93F283E2E2A5DDE0092B8D5 /* Snippets */, + A90B38302E3E8FBA002B56FC /* About */, A96C6B032E0C523600F377FE /* Misc */, ); path = Views; @@ -542,6 +555,7 @@ isa = PBXGroup; children = ( A9C060EA2E357FD300CA9374 /* Haptics.swift */, + A90B38332E3EA046002B56FC /* Bundle.swift */, ); path = Misc; sourceTree = ""; @@ -772,6 +786,7 @@ A96C6A8A2E0C0B1100F377FE /* SSHState.swift in Sources */, A9FD37692E16A6BF005319A8 /* ShellTabView.swift in Sources */, A9DA97732E0D40C100142DDC /* HostSymbolPreview.swift in Sources */, + A90B38342E3EA046002B56FC /* Bundle.swift in Sources */, A9FD376B2E16DABF005319A8 /* AnsiPickerView.swift in Sources */, A96BE6A62E113DB000C0FEE9 /* ColorCodable.swift in Sources */, A92538C82DEE0742007E0A18 /* ContentView.swift in Sources */, @@ -803,6 +818,7 @@ A90936882E1AC51100856059 /* Fonts.swift in Sources */, A9FD37552E143D23005319A8 /* SecKeyConvertible.swift in Sources */, A96C6AFE2E0C43B600F377FE /* Keypair.swift in Sources */, + A90B38322E3E8FC9002B56FC /* AboutView.swift in Sources */, A9C4140C2E096DB7005E3047 /* SSHError.swift in Sources */, A96BE6AA2E116EC000C0FEE9 /* TerminalViewContainer.swift in Sources */, A9FD375B2E143D77005319A8 /* GenericPasswordStore.swift in Sources */, diff --git a/ShhShell/Misc/Bundle.swift b/ShhShell/Misc/Bundle.swift new file mode 100644 index 0000000..0393ac7 --- /dev/null +++ b/ShhShell/Misc/Bundle.swift @@ -0,0 +1,30 @@ +// +// Bundle.swift +// ShhShell +// +// Created by neon443 on 02/08/2025. +// + +import Foundation +import SwiftUI + +//app icon +extension Bundle { + var iconFilename: String? { + guard let icons = infoDictionary?["CFBundleIcons"] as? [String: Any], + let primaryIcon = icons["CFBundlePrimaryIcon"] as? [String: Any], + let iconFiles = primaryIcon["CFBundleIconFiles"] as? [String], + let iconFileName = iconFiles.last + else { return nil } + return iconFileName + } +} + +extension UIImage { + var appIcon: Image { + let fallback = Image(uiImage: UIImage()) + guard let filename = Bundle.main.iconFilename else { return fallback } + guard let uiImage = UIImage(named: filename) else { return fallback } + return Image(uiImage: uiImage) + } +} diff --git a/ShhShell/Views/About/AboutView.swift b/ShhShell/Views/About/AboutView.swift new file mode 100644 index 0000000..0893641 --- /dev/null +++ b/ShhShell/Views/About/AboutView.swift @@ -0,0 +1,22 @@ +// +// AboutView.swift +// ShhShell +// +// Created by neon443 on 02/08/2025. +// + +import SwiftUI + +struct AboutView: View { + var body: some View { + HStack { + UIImage().appIcon + Image(uiImage: UIImage(named: "AppIcon") ?? UIImage()) + Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/) + } + } +} + +#Preview { + AboutView() +} diff --git a/ShhShell/Views/ContentView.swift b/ShhShell/Views/ContentView.swift index d7dbe2e..0bfb07f 100644 --- a/ShhShell/Views/ContentView.swift +++ b/ShhShell/Views/ContentView.swift @@ -43,22 +43,32 @@ struct ContentView: View { } } - NavigationLink { - SnippetManagerView(hostsManager: hostsManager) - } label: { - Label("Snippets", systemImage: "paperclip") + Section { + NavigationLink { + SnippetManagerView(hostsManager: hostsManager) + } label: { + Label("Snippets", systemImage: "paperclip") + } + + NavigationLink { + KeyManagerView(hostsManager: hostsManager, keyManager: keyManager) + } label: { + Label("Keys", systemImage: "key.fill") + } + + NavigationLink { + HostkeysView(hostsManager: hostsManager) + } label: { + Label("Hostkey Fingerprints", systemImage: "lock.display") + } } - NavigationLink { - KeyManagerView(hostsManager: hostsManager, keyManager: keyManager) - } label: { - Label("Keys", systemImage: "key.fill") - } - - NavigationLink { - HostkeysView(hostsManager: hostsManager) - } label: { - Label("Hostkey Fingerprints", systemImage: "lock.display") + Section { + NavigationLink { + AboutView() + } label: { + Label("About", systemImage: "info.square") + } } } .scrollContentBackground(.hidden)