save settings on modify settings

updated icon picker
This commit is contained in:
neon443
2025-08-20 17:16:32 +01:00
parent 0b16e15044
commit 8fd10bb291
2 changed files with 22 additions and 9 deletions

View File

@@ -8,7 +8,7 @@
import Foundation
import SwiftUI
struct AppSettings: Codable, Sendable {
struct AppSettings: Codable, Sendable, Equatable {
var scrollback: CGFloat = 1_000
var cursorStyle: CursorStyle = .block
var locationPersist: Bool = false
@@ -19,17 +19,17 @@ struct AppSettings: Codable, Sendable {
var appIcon: AppIcon = .regular
}
enum CursorStyle: Codable, CaseIterable {
enum CursorStyle: Codable, CaseIterable, Equatable {
case block
case bar
}
enum TerminalFilter: Codable, CaseIterable {
enum TerminalFilter: Codable, CaseIterable, Equatable {
case none
case crt
}
enum AppIcon: Codable, CaseIterable {
enum AppIcon: Codable, CaseIterable, Equatable {
case regular
case blueprint

View File

@@ -51,17 +51,30 @@ struct SettingsView: View {
Text("\(filter)").tag(filter)
}
}
.pickerStyle(.inline)
Picker("appicon", selection: $hostsManager.settings.appIcon) {
ForEach(AppIcon.allCases, id: \.self) { icon in
Text("\(icon)").tag(icon)
icon.image
Section("App Icon") {
HStack {
ForEach(AppIcon.allCases, id: \.self) { icon in
VStack(alignment: .center) {
icon.image
.resizable().scaledToFit()
.frame(maxWidth: 50)
.clipShape(RoundedRectangle(cornerRadius: 11))
Text("\(icon)").tag(icon)
}
.onTapGesture {
hostsManager.settings.appIcon = icon
}
}
}
}
.pickerStyle(.inline)
}
.listStyle(.sidebar)
.scrollContentBackground(.hidden)
.onChange(of: hostsManager.settings) { _ in
hostsManager.saveSettings()
}
}
}
}