damus

nostr ios client
git clone git://jb55.com/damus
Log | Files | Refs | README | LICENSE

commit 9ba3543d913253a11456c3b9ca4bbf1828a4dca8
parent 35ee2f5744152fbe66ce162d29d1203569cbf1a8
Author: William Casarin <jb55@jb55.com>
Date:   Fri, 31 Mar 2023 09:26:39 -0700

Fixed size of translated text

Changelog-Fixed: Fixed size of translated text

Diffstat:
Mdamus/Components/SelectableText.swift | 4+++-
Mdamus/Components/TranslateView.swift | 5+++--
Mdamus/Views/EventView.swift | 11++++++++++-
Mdamus/Views/NoteContentView.swift | 4++--
4 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/damus/Components/SelectableText.swift b/damus/Components/SelectableText.swift @@ -15,12 +15,14 @@ struct SelectableText: View { @State private var selectedTextHeight: CGFloat = .zero @State private var selectedTextWidth: CGFloat = .zero + let size: EventViewKind + var body: some View { GeometryReader { geo in TextViewRepresentable( attributedString: attributedString, textColor: UIColor.label, - font: UIFont.preferredFont(forTextStyle: .title2), + font: eventviewsize_to_uifont(size), fixedWidth: selectedTextWidth, height: $selectedTextHeight ) diff --git a/damus/Components/TranslateView.swift b/damus/Components/TranslateView.swift @@ -11,6 +11,7 @@ import NaturalLanguage struct TranslateView: View { let damus_state: DamusState let event: NostrEvent + let size: EventViewKind @State var checkingTranslationStatus: Bool = false @State var currentLanguage: String = "en" @@ -65,7 +66,7 @@ struct TranslateView: View { } .translate_button_style() - SelectableText(attributedString: artifacts.content) + SelectableText(attributedString: artifacts.content, size: self.size) } } @@ -129,6 +130,6 @@ extension View { struct TranslateView_Previews: PreviewProvider { static var previews: some View { let ds = test_damus_state() - TranslateView(damus_state: ds, event: test_event) + TranslateView(damus_state: ds, event: test_event, size: .normal) } } diff --git a/damus/Views/EventView.swift b/damus/Views/EventView.swift @@ -25,7 +25,16 @@ func eventviewsize_to_font(_ size: EventViewKind) -> Font { } } - +func eventviewsize_to_uifont(_ size: EventViewKind) -> UIFont { + switch size { + case .small: + return .preferredFont(forTextStyle: .body) + case .normal: + return .preferredFont(forTextStyle: .body) + case .selected: + return .preferredFont(forTextStyle: .title2) + } +} struct EventView: View { let event: NostrEvent diff --git a/damus/Views/NoteContentView.swift b/damus/Views/NoteContentView.swift @@ -63,7 +63,7 @@ struct NoteContentView: View { } var translateView: some View { - TranslateView(damus_state: damus_state, event: event) + TranslateView(damus_state: damus_state, event: event, size: self.size) } var previewView: some View { @@ -85,7 +85,7 @@ struct NoteContentView: View { var MainContent: some View { VStack(alignment: .leading) { if size == .selected { - SelectableText(attributedString: artifacts.content) + SelectableText(attributedString: artifacts.content, size: self.size) } else { if with_padding { truncatedText