iOS: make timestamps in comments touchable

Timestamps in comments can now be touched and jump to the corresponding part in the video.

Signed-off-by: Toni Förster <toni.foerster@gmail.com>
This commit is contained in:
Toni Förster
2024-08-20 00:52:04 +02:00
parent af75afa912
commit 7e346bf49c
2 changed files with 96 additions and 18 deletions

View File

@@ -2,6 +2,7 @@ import SwiftUI
struct CommentsView: View {
@State private var repliesID: Comment.ID?
@State private var availableWidth = 0.0
@ObservedObject private var comments = CommentsModel.shared
@@ -14,16 +15,21 @@ struct CommentsView: View {
} else if !comments.loaded {
PlaceholderProgressView()
} else {
let last = comments.all.last
LazyVStack {
ForEach(comments.all) { comment in
CommentView(comment: comment, repliesID: $repliesID)
CommentView(comment: comment, repliesID: $repliesID, availableWidth: availableWidth)
.onAppear {
comments.loadNextPageIfNeeded(current: comment)
}
.borderBottom(height: comment != last ? 0.5 : 0, color: Color("ControlsBorderColor"))
.borderBottom(height: comment != comments.all.last ? 0.5 : 0, color: Color("ControlsBorderColor"))
}
}
.background(GeometryReader { geometry in
Color.clear
.onAppear {
self.availableWidth = Double(geometry.size.width)
}
})
}
}
.padding(.horizontal)