setting: adjustable font size for jack the zapper
Changelog-Added: Adjustable font size
This commit is contained in:
@@ -102,18 +102,18 @@ func make_actionbar_model(ev: NoteId, damus: DamusState) -> ActionBarModel {
|
||||
return model
|
||||
}
|
||||
|
||||
func eventviewsize_to_font(_ size: EventViewKind) -> Font {
|
||||
func eventviewsize_to_font(_ size: EventViewKind, font_size: Double) -> Font {
|
||||
switch size {
|
||||
case .small:
|
||||
return .body
|
||||
return Font.system(size: 12.0 * font_size)
|
||||
case .normal:
|
||||
return .body
|
||||
return Font.system(size: 17.0 * font_size) // Assuming .body is 17pt by default
|
||||
case .selected:
|
||||
return .custom("selected", size: 21.0)
|
||||
return .custom("selected", size: 21.0 * font_size)
|
||||
case .title:
|
||||
return .title
|
||||
return Font.system(size: 24.0 * font_size) // Assuming .title is 24pt by default
|
||||
case .subheadline:
|
||||
return .subheadline
|
||||
return Font.system(size: 14.0 * font_size) // Assuming .subheadline is 14pt by default
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,8 @@ struct NoteContentView: View {
|
||||
|
||||
@ObservedObject var artifacts_model: NoteArtifactsModel
|
||||
@ObservedObject var preview_model: PreviewModel
|
||||
|
||||
@ObservedObject var settings: UserSettingsStore
|
||||
|
||||
var note_artifacts: NoteArtifacts {
|
||||
return self.artifacts_model.state.artifacts ?? .separated(.just_content(event.get_content(damus_state.keypair.privkey)))
|
||||
}
|
||||
@@ -48,6 +49,7 @@ struct NoteContentView: View {
|
||||
let cached = damus_state.events.get_cache_data(event.id)
|
||||
self._preview_model = ObservedObject(wrappedValue: cached.preview_model)
|
||||
self._artifacts_model = ObservedObject(wrappedValue: cached.artifacts_model)
|
||||
self._settings = ObservedObject(wrappedValue: damus_state.settings)
|
||||
}
|
||||
|
||||
var truncate: Bool {
|
||||
@@ -72,10 +74,10 @@ struct NoteContentView: View {
|
||||
Group {
|
||||
if truncate {
|
||||
TruncatedText(text: content)
|
||||
.font(eventviewsize_to_font(size))
|
||||
.font(eventviewsize_to_font(size, font_size: damus_state.settings.font_size))
|
||||
} else {
|
||||
content.text
|
||||
.font(eventviewsize_to_font(size))
|
||||
.font(eventviewsize_to_font(size, font_size: damus_state.settings.font_size))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ struct EventProfileName: View {
|
||||
|
||||
Text(verbatim: "@\(both.username)")
|
||||
.foregroundColor(.gray)
|
||||
.font(eventviewsize_to_font(size))
|
||||
.font(eventviewsize_to_font(size, font_size: damus_state.settings.font_size))
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -8,12 +8,39 @@
|
||||
import SwiftUI
|
||||
|
||||
|
||||
struct ResizedEventPreview: View {
|
||||
let damus_state: DamusState
|
||||
@ObservedObject var settings: UserSettingsStore
|
||||
|
||||
var body: some View {
|
||||
EventView(damus: damus_state, event: test_note, pubkey: test_note.pubkey, options: [.wide, .no_action_bar])
|
||||
}
|
||||
}
|
||||
|
||||
struct AppearanceSettingsView: View {
|
||||
let damus_state: DamusState
|
||||
@ObservedObject var settings: UserSettingsStore
|
||||
@Environment(\.dismiss) var dismiss
|
||||
|
||||
var FontSize: some View {
|
||||
VStack(alignment: .leading) {
|
||||
Slider(value: $settings.font_size, in: 0.5...2.0, step: 0.1) {
|
||||
Text("Font Size")
|
||||
}
|
||||
.padding()
|
||||
|
||||
// Sample text to show how the font size would look
|
||||
ResizedEventPreview(damus_state: damus_state, settings: settings)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
Form {
|
||||
Section("Font Size") {
|
||||
FontSize
|
||||
}
|
||||
|
||||
// MARK: - Text Truncation
|
||||
Section(header: Text(NSLocalizedString("Text Truncation", comment: "Section header for damus text truncation user configuration"))) {
|
||||
Toggle(NSLocalizedString("Truncate timeline text", comment: "Setting to truncate text in timeline"), isOn: $settings.truncate_timeline_text)
|
||||
@@ -63,6 +90,6 @@ struct AppearanceSettingsView: View {
|
||||
|
||||
struct TextFormattingSettings_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
AppearanceSettingsView(settings: UserSettingsStore())
|
||||
AppearanceSettingsView(damus_state: test_damus_state(), settings: UserSettingsStore())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user