Add reading progress tracking
All checks were successful
CI / build-and-deploy (push) Successful in 25s

- BrowserState: inject scroll-tracking JS after page load, report position
  via WKScriptMessageHandler (weak ref to avoid retain cycle)
- BrowserView: thin blue progress bar at top of viewport; saves progress
  to UserDefaults on dismiss; restores scroll position on revisit
- BookmarkRow: 2px progress bar below tags for partially-read articles
- BookmarksView: loads ReadingProgress.all() on appear, refreshes when
  browser sheet dismisses
- ReadingProgress: static helper for UserDefaults-backed [url: Double] store;
  removes entry when article is fully read (≥99%)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Krishna Kumar
2026-05-21 18:42:12 -05:00
parent bc16ee986d
commit db5092ce02
3 changed files with 125 additions and 32 deletions

View File

@@ -2,6 +2,7 @@ import SwiftUI
struct BookmarkRow: View {
let bookmark: Bookmark
var readingProgress: Double = 0
var body: some View {
VStack(alignment: .leading, spacing: 6) {
@@ -54,6 +55,22 @@ struct BookmarkRow: View {
}
.padding(.leading, 40)
}
// Reading progress indicator
if readingProgress > 0.02 {
GeometryReader { geo in
ZStack(alignment: .leading) {
Rectangle()
.fill(Color(.systemGray5))
Rectangle()
.fill(Color.blue.opacity(0.55))
.frame(width: geo.size.width * min(readingProgress, 1))
}
}
.frame(height: 2)
.clipShape(Capsule())
.padding(.leading, 40)
}
}
.padding(.vertical, 14)
.contentShape(Rectangle())