mirror of
https://github.com/neon443/ShhShell.git
synced 2026-03-11 13:26:16 +00:00
80 lines
1.8 KiB
Swift
80 lines
1.8 KiB
Swift
//
|
|
// FontManagerView.swift
|
|
// ShhShell
|
|
//
|
|
// Created by neon443 on 06/07/2025.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
struct FontManagerView: View {
|
|
@ObservedObject var hostsManager: HostsManager
|
|
|
|
@State var testLine: String = "the lazy brown fox jumps over the lazy dog"
|
|
|
|
var body: some View {
|
|
ZStack {
|
|
hostsManager.selectedTheme.background.suiColor.opacity(0.7)
|
|
.ignoresSafeArea(.all)
|
|
List {
|
|
VStack {
|
|
HStack {
|
|
Text("Font Size")
|
|
Spacer()
|
|
Text("\(Int(hostsManager.fontSize))")
|
|
.contentTransition(.numericText())
|
|
}
|
|
.padding(.horizontal)
|
|
|
|
Slider(value: $hostsManager.fontSize, in: 1...20, step: 1) {
|
|
|
|
} minimumValueLabel: {
|
|
Image(systemName: "textformat.size.smaller")
|
|
} maximumValueLabel: {
|
|
Image(systemName: "textformat.size.larger")
|
|
} onEditingChanged: { bool in
|
|
hostsManager.saveFonts()
|
|
}
|
|
}
|
|
|
|
ForEach(FontFamilies.allCasesRaw, id: \.self) { fontName in
|
|
let selected = hostsManager.selectedFont == fontName
|
|
Button() {
|
|
hostsManager.selectFont(fontName)
|
|
} label: {
|
|
VStack(alignment: .leading, spacing: 5) {
|
|
Text(fontName)
|
|
.foregroundStyle(.gray)
|
|
HStack {
|
|
Circle()
|
|
.frame(width: 20)
|
|
.opacity(selected ? 1 : 0)
|
|
.foregroundStyle(.green)
|
|
.animation(.spring, value: selected)
|
|
.transition(.scale)
|
|
Text(testLine)
|
|
.font(.custom(fontName, size: 15))
|
|
.bold(selected)
|
|
.opacity(selected ? 1 : 0.8)
|
|
.contentTransition(.numericText())
|
|
.animation(.default, value: testLine)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
Section("Test String") {
|
|
TextField("", text: $testLine)
|
|
.fixedSize()
|
|
}
|
|
}
|
|
}
|
|
.navigationTitle("Fonts")
|
|
.scrollContentBackground(.hidden)
|
|
}
|
|
}
|
|
|
|
#Preview {
|
|
FontManagerView(hostsManager: HostsManager())
|
|
}
|