added changing app icons

added setappicon function
This commit is contained in:
neon443
2025-08-22 12:46:17 +01:00
parent b651c03364
commit 3e45de2d32
10 changed files with 139 additions and 12 deletions

View File

@@ -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
}
}

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 124 KiB

View File

@@ -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
}
}

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 558 KiB

View File

Before

Width:  |  Height:  |  Size: 253 KiB

After

Width:  |  Height:  |  Size: 253 KiB

View File

@@ -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)";

View File

@@ -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 }

View File

@@ -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"
}
}
}

View File

@@ -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()
}
}
}
}