Skip to content

Commit

Permalink
preview font (#125)
Browse files Browse the repository at this point in the history
  • Loading branch information
eagleoflqj authored May 17, 2024
1 parent e75ed0a commit 11008ef
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
Binary file modified assets/zh-Hans.lproj/Localizable.strings
Binary file not shown.
16 changes: 12 additions & 4 deletions src/config/optionviews.swift
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ struct FontOptionView: OptionView {
@ObservedObject var model: FontOption
@State private var selectorIsOpen = false
@State var searchInput = ""
@State var previewInput = NSLocalizedString("Preview", comment: "")

// If initialize [], the sheet will list nothing on first open.
@State var availableFontFamilies = NSFontManager.shared.availableFontFamilies
Expand All @@ -337,9 +338,16 @@ struct FontOptionView: OptionView {
.sheet(isPresented: $selectorIsOpen) {
VStack {
TextField(NSLocalizedString("Search", comment: ""), text: $searchInput)
TextField(NSLocalizedString("Preview", comment: ""), text: $previewInput)
Text(previewInput).font(Font.custom(selectedFontFamily ?? model.value, size: 32)).frame(
height: 64)
List(selection: $selectedFontFamily) {
ForEach(filteredFontFamilies, id: \.self) { family in
Text(localize(family))
HStack {
Text(localize(family)).font(Font.custom(family, size: 14))
Spacer()
Text(localize(family))
}
}
}.contextMenu(forSelectionType: String.self) { items in
} primaryAction: { items in
Expand All @@ -357,12 +365,12 @@ struct FontOptionView: OptionView {
select()
} label: {
Text("Select")
}
.disabled(selectedFontFamily == nil)
}.buttonStyle(.borderedProminent)
.disabled(selectedFontFamily == nil)
}
}
.padding()
.frame(minWidth: 400, minHeight: 400)
.frame(minWidth: 500, minHeight: 600)
}
}

Expand Down

0 comments on commit 11008ef

Please sign in to comment.