Move timeline item tap gestures to the items themselves instead of the bubbled styler (#3553)

* Stop observing the timeline context where not necessary.
* Rename the timeline `itemTapped` action to `mediaTapped`
This commit is contained in:
Stefan Ceriu
2024-11-26 16:25:46 +02:00
committed by GitHub
parent 3f0f442937
commit 36980840ed
13 changed files with 53 additions and 29 deletions
@@ -9,7 +9,7 @@ import Foundation
import SwiftUI
struct VideoRoomTimelineView: View {
@EnvironmentObject private var context: TimelineViewModel.Context
@Environment(\.timelineContext) private var context
let timelineItem: VideoRoomTimelineItem
private var hasMediaCaption: Bool { timelineItem.content.caption != nil }
@@ -24,6 +24,9 @@ struct VideoRoomTimelineView: View {
// This clip shape is distinct from the one in the styler as that one
// operates on the entire message so wouldn't round the bottom corners.
.clipShape(RoundedRectangle(cornerRadius: hasMediaCaption ? 6 : 0))
.onTapGesture {
context?.send(viewAction: .mediaTapped(itemID: timelineItem.id))
}
if let attributedCaption = timelineItem.content.formattedCaption {
FormattedBodyText(attributedString: attributedCaption,
@@ -45,7 +48,7 @@ struct VideoRoomTimelineView: View {
mediaType: .timelineItem(uniqueID: timelineItem.id.uniqueID.id),
blurhash: timelineItem.content.blurhash,
size: timelineItem.content.thumbnailInfo?.size,
mediaProvider: context.mediaProvider) { imageView in
mediaProvider: context?.mediaProvider) { imageView in
imageView
.overlay { playIcon }
} placeholder: {