diff --git a/damus/Features/Events/Models/NoteContent.swift b/damus/Features/Events/Models/NoteContent.swift
index 9b8b6a80..5f5aac5e 100644
--- a/damus/Features/Events/Models/NoteContent.swift
+++ b/damus/Features/Events/Models/NoteContent.swift
@@ -381,6 +381,11 @@ struct LongformContent {
let markdown: MarkdownContent
let words: Int
+ /// Estimated reading time in minutes, based on average reading speed of 200 words per minute.
+ var estimatedReadTimeMinutes: Int {
+ return max(1, words / 200)
+ }
+
init(_ markdown: String) {
// Pre-process markdown to ensure images are block-level (have blank lines around them)
// This prevents images from being parsed as inline within text paragraphs
diff --git a/damus/Features/Longform/Views/LongformPreview.swift b/damus/Features/Longform/Views/LongformPreview.swift
index 3560c77c..a1ab2601 100644
--- a/damus/Features/Longform/Views/LongformPreview.swift
+++ b/damus/Features/Longform/Views/LongformPreview.swift
@@ -35,10 +35,17 @@ struct LongformPreviewBody: View {
self._artifacts = ObservedObject(wrappedValue: state.events.get_cache_data(ev.id).artifacts_model)
}
+ /// Formats word count for display.
func Words(_ words: Int) -> Text {
let wordCount = pluralizedString(key: "word_count", count: words)
return Text(wordCount)
}
+
+ /// Formats estimated read time for display.
+ func ReadTime(_ minutes: Int) -> Text {
+ let readTime = pluralizedString(key: "read_time", count: minutes)
+ return Text(readTime)
+ }
var truncate: Bool {
return options.contains(.truncate_content)
@@ -161,8 +168,14 @@ struct LongformPreviewBody: View {
if case .loaded(let arts) = artifacts.state,
case .longform(let longform) = arts
{
- Words(longform.words).font(.footnote)
- .padding([.horizontal, .bottom], 10)
+ HStack(spacing: 8) {
+ ReadTime(longform.estimatedReadTimeMinutes)
+ Text("ยท")
+ Words(longform.words)
+ }
+ .font(.footnote)
+ .foregroundColor(.gray)
+ .padding([.horizontal, .bottom], 10)
}
}
.frame(maxWidth: .infinity, alignment: .leading)
diff --git a/damus/en-US.lproj/Localizable.stringsdict b/damus/en-US.lproj/Localizable.stringsdict
index 2d0c7c72..9622c41c 100644
--- a/damus/en-US.lproj/Localizable.stringsdict
+++ b/damus/en-US.lproj/Localizable.stringsdict
@@ -386,6 +386,22 @@
%d Words
+ read_time
+
+ NSStringLocalizedFormatKey
+ %#@MINUTES@
+ MINUTES
+
+ NSStringFormatSpecTypeKey
+ NSStringPluralRuleType
+ NSStringFormatValueTypeKey
+ d
+ one
+ %d min read
+ other
+ %d min read
+
+
zap_notification_no_message
NSStringLocalizedFormatKey