diff --git a/Resources/Assets.xcassets/beta.appiconset/Contents.json b/Resources/Assets.xcassets/beta.appiconset/Contents.json new file mode 100644 index 0000000..95cfafe --- /dev/null +++ b/Resources/Assets.xcassets/beta.appiconset/Contents.json @@ -0,0 +1,36 @@ +{ + "images" : [ + { + "filename" : "ShhShell 1.png", + "idiom" : "universal", + "platform" : "ios", + "size" : "1024x1024" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "idiom" : "universal", + "platform" : "ios", + "size" : "1024x1024" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "tinted" + } + ], + "idiom" : "universal", + "platform" : "ios", + "size" : "1024x1024" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Resources/Assets.xcassets/beta.appiconset/ShhShell 1.png b/Resources/Assets.xcassets/beta.appiconset/ShhShell 1.png new file mode 100644 index 0000000..303bea3 Binary files /dev/null and b/Resources/Assets.xcassets/beta.appiconset/ShhShell 1.png differ diff --git a/Resources/Assets.xcassets/betaBlueprint.appiconset/Contents.json b/Resources/Assets.xcassets/betaBlueprint.appiconset/Contents.json new file mode 100644 index 0000000..40d8808 --- /dev/null +++ b/Resources/Assets.xcassets/betaBlueprint.appiconset/Contents.json @@ -0,0 +1,36 @@ +{ + "images" : [ + { + "filename" : "ShhShell Blueprint@2x.png", + "idiom" : "universal", + "platform" : "ios", + "size" : "1024x1024" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "idiom" : "universal", + "platform" : "ios", + "size" : "1024x1024" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "tinted" + } + ], + "idiom" : "universal", + "platform" : "ios", + "size" : "1024x1024" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Resources/Assets.xcassets/betaBlueprint.appiconset/ShhShell Blueprint@2x.png b/Resources/Assets.xcassets/betaBlueprint.appiconset/ShhShell Blueprint@2x.png new file mode 100644 index 0000000..c9e2877 Binary files /dev/null and b/Resources/Assets.xcassets/betaBlueprint.appiconset/ShhShell Blueprint@2x.png differ diff --git a/Resources/Assets.xcassets/AppIcon.appiconset/Contents.json b/Resources/Assets.xcassets/regular.appiconset/Contents.json similarity index 100% rename from Resources/Assets.xcassets/AppIcon.appiconset/Contents.json rename to Resources/Assets.xcassets/regular.appiconset/Contents.json diff --git a/Resources/Assets.xcassets/AppIcon.appiconset/ShhShell@2x.png b/Resources/Assets.xcassets/regular.appiconset/ShhShell@2x.png similarity index 100% rename from Resources/Assets.xcassets/AppIcon.appiconset/ShhShell@2x.png rename to Resources/Assets.xcassets/regular.appiconset/ShhShell@2x.png diff --git a/ShhShell.xcodeproj/project.pbxproj b/ShhShell.xcodeproj/project.pbxproj index 4c45de6..6de2772 100644 --- a/ShhShell.xcodeproj/project.pbxproj +++ b/ShhShell.xcodeproj/project.pbxproj @@ -1030,8 +1030,10 @@ A92538BC2DEE06DE007E0A18 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_ALTERNATE_APPICON_NAMES = "beta betaBlueprint"; + ASSETCATALOG_COMPILER_APPICON_NAME = regular; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = YES; CODE_SIGN_ENTITLEMENTS = ShhShell/ShhShell.entitlements; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = "$(BUILD)"; @@ -1068,8 +1070,10 @@ A92538BD2DEE06DE007E0A18 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_ALTERNATE_APPICON_NAMES = "beta betaBlueprint"; + ASSETCATALOG_COMPILER_APPICON_NAME = regular; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = YES; CODE_SIGN_ENTITLEMENTS = ShhShell/ShhShell.entitlements; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = "$(BUILD)"; diff --git a/ShhShell/Host/HostsManager.swift b/ShhShell/Host/HostsManager.swift index d4c111d..2498e6f 100644 --- a/ShhShell/Host/HostsManager.swift +++ b/ShhShell/Host/HostsManager.swift @@ -47,6 +47,17 @@ class HostsManager: ObservableObject, @unchecked Sendable { } } + func setAppIcon() { + Task { @MainActor in + guard UIApplication.shared.supportsAlternateIcons else { return } + guard settings.appIcon.name != "regular" else { + UIApplication.shared.setAlternateIconName(nil) + return + } + UIApplication.shared.setAlternateIconName("\(settings.appIcon.name)") + } + } + func loadSettings() { guard let data = userDefaults.data(forKey: "settings") else { return } guard let decoded = try? JSONDecoder().decode(AppSettings.self, from: data) else { return } diff --git a/ShhShell/Settings/AppSettings.swift b/ShhShell/Settings/AppSettings.swift index 4c8ebde..68ffe12 100644 --- a/ShhShell/Settings/AppSettings.swift +++ b/ShhShell/Settings/AppSettings.swift @@ -9,7 +9,7 @@ import Foundation import SwiftUI struct AppSettings: Codable, Sendable, Equatable { - var scrollback: CGFloat = 1_000 + var scrollback: CGFloat = 10_000 var cursorStyle: CursorStyle = .block var locationPersist: Bool = false var bellSound: Bool = false @@ -19,25 +19,62 @@ struct AppSettings: Codable, Sendable, Equatable { var appIcon: AppIcon = .regular } -enum CursorStyle: Codable, CaseIterable, Equatable { +enum CursorStyle: Codable, CaseIterable, Equatable, CustomStringConvertible { case block case bar + + var description: String { + switch self { + case .block: + return "Block" + case .bar: + return "Bar" + } + } } -enum TerminalFilter: Codable, CaseIterable, Equatable { +enum TerminalFilter: Codable, CaseIterable, Equatable, CustomStringConvertible { case none case crt + + var description: String { + switch self { + case .none: + return "None" + case .crt: + return "CRT" + } + } } -enum AppIcon: Codable, CaseIterable, Equatable { +enum AppIcon: Codable, CaseIterable, Equatable, CustomStringConvertible { case regular case beta case betaBlueprint var image: Image { + return Image(self.name) + } + + var name: String { switch self { - case .regular, .beta, .betaBlueprint: - Image("\(self)") + case .regular: + return "regular" + case .beta: + return "beta" + case .betaBlueprint: + return "betaBlueprint" + } + } + + var description: String { + switch self { + case .regular: + return "Default" + case .beta: + return "Beta" + case .betaBlueprint: + return "Beta Blueprint" } } } diff --git a/ShhShell/Views/Settings/SettingsView.swift b/ShhShell/Views/Settings/SettingsView.swift index 3a53a09..b4147e7 100644 --- a/ShhShell/Views/Settings/SettingsView.swift +++ b/ShhShell/Views/Settings/SettingsView.swift @@ -33,7 +33,7 @@ struct SettingsView: View { Picker("Cursor", selection: $hostsManager.settings.cursorStyle) { ForEach(CursorStyle.allCases, id: \.self) { type in - Text("\(type)").tag(type) + Text(type.description).tag(type) } } .pickerStyle(.inline) @@ -48,7 +48,7 @@ struct SettingsView: View { Picker("terminal filter", selection: $hostsManager.settings.filter) { ForEach(TerminalFilter.allCases, id: \.self) { filter in - Text("\(filter)").tag(filter) + Text(filter.description).tag(filter) } } .pickerStyle(.inline) @@ -68,7 +68,7 @@ struct SettingsView: View { .clipShape(RoundedRectangle(cornerRadius: 16.5)) .padding(5) Spacer() - Text("\(icon)").tag(icon) + Text(icon.description).tag(icon) .font(.callout) .padding(5) .padding(.bottom, 5) @@ -77,7 +77,10 @@ struct SettingsView: View { } .frame(maxWidth: 85) .onTapGesture { - withAnimation { hostsManager.settings.appIcon = icon } + withAnimation { + hostsManager.settings.appIcon = icon + hostsManager.setAppIcon() + } } } }