live updating of themepreview

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

No files matched your search

+5 -7
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)
-49
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)
}
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.