mirror of
https://github.com/neon443/ShhShell.git
synced 2026-11-30 12:44:51 +00:00
live updating of themepreview
This commit is contained in:
3 files changed
+5
-60
No files matched your search
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
}
|
||||