live updating of themepreview

This commit is contained in:
neon443
2025-07-09 13:40:09 +01:00
parent b98387ae92
commit 10310be80e
3 changed files with 5 additions and 60 deletions

View File

@@ -72,7 +72,6 @@
A98554632E0587DF009051BD /* HostsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A98554622E0587DF009051BD /* HostsView.swift */; };
A9A587202E0BF220006B31E6 /* SwiftTerm in Frameworks */ = {isa = PBXBuildFile; productRef = A9A5871F2E0BF220006B31E6 /* SwiftTerm */; };
A9BA1D192E1D9AE1005BDCEF /* SwiftTerm.Color.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9BA1D182E1D9AE1005BDCEF /* SwiftTerm.Color.swift */; };
A9BA1D1B2E1E81CA005BDCEF /* ThemePreview.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9BA1D1A2E1E81CA005BDCEF /* ThemePreview.swift */; };
A9C4140C2E096DB7005E3047 /* SSHError.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9C4140B2E096DB7005E3047 /* SSHError.swift */; };
A9C897EF2DF1A9A400EF9A5F /* SSHHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9C897EE2DF1A9A400EF9A5F /* SSHHandler.swift */; };
A9D819292E0E904200442D38 /* Theme.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9D819282E0E904200442D38 /* Theme.swift */; };
@@ -195,7 +194,6 @@
A98554602E058433009051BD /* HostsManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HostsManager.swift; sourceTree = "<group>"; };
A98554622E0587DF009051BD /* HostsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HostsView.swift; sourceTree = "<group>"; };
A9BA1D182E1D9AE1005BDCEF /* SwiftTerm.Color.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftTerm.Color.swift; sourceTree = "<group>"; };
A9BA1D1A2E1E81CA005BDCEF /* ThemePreview.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThemePreview.swift; sourceTree = "<group>"; };
A9C4140B2E096DB7005E3047 /* SSHError.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SSHError.swift; sourceTree = "<group>"; };
A9C897EE2DF1A9A400EF9A5F /* SSHHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SSHHandler.swift; sourceTree = "<group>"; };
A9D819282E0E904200442D38 /* Theme.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Theme.swift; sourceTree = "<group>"; };
@@ -538,7 +536,6 @@
A9D8192E2E0F1BEE00442D38 /* ThemeButton.swift */,
A9FD376A2E16DABF005319A8 /* AnsiPickerView.swift */,
A9485C772E1BFA5000209824 /* ThemeEditorView.swift */,
A9BA1D1A2E1E81CA005BDCEF /* ThemePreview.swift */,
);
path = Themes;
sourceTree = "<group>";
@@ -726,7 +723,6 @@
A923172F2E08851200ECE1E6 /* ShellView.swift in Sources */,
A9D819292E0E904200442D38 /* Theme.swift in Sources */,
A9D8192D2E0E9EB500442D38 /* ThemeManagerView.swift in Sources */,
A9BA1D1B2E1E81CA005BDCEF /* ThemePreview.swift in Sources */,
A9FD375D2E143D7E005319A8 /* KeyStoreError.swift in Sources */,
A9835C3C2E17CCA500969508 /* TrafficLights.swift in Sources */,
A9485C782E1BFA5000209824 /* ThemeEditorView.swift in Sources */,

View File

@@ -20,17 +20,15 @@ struct ThemeEditorView: View {
hostsManager.selectedTheme.background.suiColor.opacity(0.7)
.ignoresSafeArea(.all)
NavigationStack {
ThemePreview(theme: $theme, padding: 10, paletteR: 20)
ThemeButton(hostsManager: hostsManager, theme: $theme, canModify: false)
.id(theme)
.padding(.bottom)
.fixedSize(horizontal: false, vertical: true)
List {
Section("Name") {
TextField("Name", text: $theme.name)
.textFieldStyle(.roundedBorder)
.onChange(of: theme) { _ in
print(theme)
}
List {
Section("Main Colors") {
ColorPicker("Text", selection: $theme.foreground.suiColor, supportsOpacity: false)
ColorPicker("Background", selection: $theme.background.suiColor, supportsOpacity: false)

View File

@@ -1,49 +0,0 @@
//
// ThemePreview.swift
// ShhShell
//
// Created by neon443 on 09/07/2025.
//
import SwiftUI
struct ThemePreview: View {
@Binding var theme: Theme
@State var padding: CGFloat
@State var paletteR: CGFloat
var body: some View {
VStack {
Text(theme.name)
.foregroundStyle(theme.foreground.suiColor)
.font(.headline)
.lineLimit(1)
Spacer()
VStack(spacing: 0) {
HStack(spacing: 0) {
ForEach(0..<8, id: \.self) { index in
Rectangle()
.aspectRatio(CGSize(width: 1, height: 1), contentMode: .fit)
.foregroundStyle(theme.ansi[index].suiColor)
}
}
HStack(spacing: 0) {
ForEach(8..<16, id: \.self) { index in
Rectangle()
.aspectRatio(CGSize(width: 1, height: 1), contentMode: .fit)
.foregroundStyle(theme.ansi[index].suiColor)
}
}
}
.clipShape(RoundedRectangle(cornerRadius: paletteR))
}
.padding(padding)
}
}
#Preview {
ThemePreview(theme: .constant(Theme.defaultTheme), padding: 5, paletteR: 10)
}