mirror of
https://github.com/neon443/ShhShell.git
synced 2026-03-11 13:26:16 +00:00
added changing app icons
added setappicon function
This commit is contained in:
@@ -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 }
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user