mirror of
https://github.com/neon443/ShhShell.git
synced 2026-03-11 13:26:16 +00:00
added font size
This commit is contained in:
@@ -20,6 +20,7 @@ class HostsManager: ObservableObject, @unchecked Sendable {
|
|||||||
|
|
||||||
@Published var fonts: [UIFont] = []
|
@Published var fonts: [UIFont] = []
|
||||||
@Published var selectedFont: String = "SF Mono"
|
@Published var selectedFont: String = "SF Mono"
|
||||||
|
@Published var fontSize: CGFloat = 12
|
||||||
|
|
||||||
var tint: SwiftUI.Color {
|
var tint: SwiftUI.Color {
|
||||||
selectedTheme.ansi[selectedAnsi].suiColor
|
selectedTheme.ansi[selectedAnsi].suiColor
|
||||||
@@ -36,13 +37,15 @@ class HostsManager: ObservableObject, @unchecked Sendable {
|
|||||||
for family in UIFont.familyNames.sorted() {
|
for family in UIFont.familyNames.sorted() {
|
||||||
if FontFamilies.allCasesRaw.contains(family) {
|
if FontFamilies.allCasesRaw.contains(family) {
|
||||||
guard let family = FontFamilies(rawValue: family) else { return }
|
guard let family = FontFamilies(rawValue: family) else { return }
|
||||||
guard let customFont = UIFont(name: family.description, size: UIFont.systemFontSize) else { return }
|
guard let customFont = UIFont(name: family.description, size: fontSize) else { return }
|
||||||
customFonts.append(customFont)
|
customFonts.append(customFont)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self.fonts = customFonts
|
self.fonts = customFonts
|
||||||
|
|
||||||
|
userDefaults.synchronize()
|
||||||
self.selectedFont = userDefaults.string(forKey: "selectedFontName") ?? "Menlo"
|
self.selectedFont = userDefaults.string(forKey: "selectedFontName") ?? "Menlo"
|
||||||
|
self.fontSize = CGFloat(userDefaults.double(forKey: "fontSize"))
|
||||||
}
|
}
|
||||||
|
|
||||||
func selectFont(_ fontName: String) {
|
func selectFont(_ fontName: String) {
|
||||||
@@ -53,6 +56,8 @@ class HostsManager: ObservableObject, @unchecked Sendable {
|
|||||||
|
|
||||||
func saveFonts() {
|
func saveFonts() {
|
||||||
userDefaults.set(selectedFont, forKey: "selectedFontName")
|
userDefaults.set(selectedFont, forKey: "selectedFontName")
|
||||||
|
userDefaults.set(fontSize, forKey: "fontSize")
|
||||||
|
userDefaults.synchronize()
|
||||||
}
|
}
|
||||||
|
|
||||||
func loadThemes() {
|
func loadThemes() {
|
||||||
|
|||||||
@@ -14,6 +14,16 @@ struct FontManagerView: View {
|
|||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
List {
|
List {
|
||||||
|
Slider(value: $hostsManager.fontSize, in: 1...15, step: 1) {
|
||||||
|
Label("Size", systemImage: "textformat.size")
|
||||||
|
} minimumValueLabel: {
|
||||||
|
Label("1", systemImage: "textformat.size.smaller")
|
||||||
|
} maximumValueLabel: {
|
||||||
|
Label("15", systemImage: "textformat.size.larger")
|
||||||
|
} onEditingChanged: { bool in
|
||||||
|
hostsManager.saveFonts()
|
||||||
|
}
|
||||||
|
|
||||||
ForEach(FontFamilies.allCasesRaw, id: \.self) { fontName in
|
ForEach(FontFamilies.allCasesRaw, id: \.self) { fontName in
|
||||||
let selected = hostsManager.selectedFont == fontName
|
let selected = hostsManager.selectedFont == fontName
|
||||||
Button() {
|
Button() {
|
||||||
|
|||||||
Reference in New Issue
Block a user