Files
ShhShell/ShhShell/Views/Themes/ThemePreview.swift
neon443 a607996ca5 fixed ui clipping
made the radius concentric and the padding perfect
2025-06-27 21:20:27 +01:00

51 lines
1.2 KiB
Swift

//
// ThemePreview.swift
// ShhShell
//
// Created by neon443 on 27/06/2025.
//
import SwiftUI
struct ThemePreview: View {
@State var theme: Theme
var body: some View {
ZStack(alignment: .center) {
RoundedRectangle(cornerRadius: 10)
.fill(theme.background.suiColor)
VStack(alignment: .leading) {
Text(theme.name)
.foregroundStyle(theme.foreground.suiColor)
.font(.headline)
Spacer()
HStack(spacing: 8) {
ForEach(0..<8, id: \.self) { index in
RoundedRectangle(cornerRadius: 2)
.frame(width: 16, height: 16)
.foregroundStyle(theme.ansi[index].suiColor)
}
}
HStack(spacing: 8) {
ForEach(8..<16, id: \.self) { index in
RoundedRectangle(cornerRadius: 2)
.frame(width: 16, height: 16)
.foregroundStyle(theme.ansi[index].suiColor)
}
}
}
.padding(8)
}
.frame(maxWidth: 200, maxHeight: 90)
}
}
#Preview {
let url = URL(string: "https://raw.githubusercontent.com/mbadolato/iTerm2-Color-Schemes/master/schemes/catppuccin-frappe.itermcolors")!
let data = try! Data(contentsOf: url)
ThemePreview(
theme: Theme.decodeTheme(name: "theme", data: data)!
)
}