Skip to content

Commit 03ee4ef

Browse files
fixed issue with clickable area in image attachments
1 parent 8d3d484 commit 03ee4ef

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

Sources/StreamChatSwiftUI/ChatChannel/Gallery/VideoPlayerView.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,13 @@ public struct VideoPlayerView: View {
3939
)
4040
VideoPlayer(player: avPlayer)
4141
Spacer()
42+
HStack {
43+
ShareButtonView(content: [attachment.payload.videoURL])
44+
.standardPadding()
45+
46+
Spacer()
47+
}
48+
.foregroundColor(Color(colors.text))
4249
}
4350
.onAppear {
4451
avPlayer.play()

Sources/StreamChatSwiftUI/ChatChannel/MessageList/ImageAttachmentView.swift

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -288,16 +288,21 @@ struct LazyLoadingImage: View {
288288
var body: some View {
289289
ZStack {
290290
if let image = image {
291+
imageView(for: image)
291292
if let imageTapped = imageTapped {
292-
imageView(for: image, allowsHitTesting: true)
293+
// NOTE: needed because of bug with SwiftUI.
294+
// The click area expands outside the image view (although not visible).
295+
Rectangle()
296+
.opacity(0.000001)
297+
.frame(width: width)
298+
.clipped()
299+
.allowsHitTesting(true)
293300
.highPriorityGesture(
294301
TapGesture()
295302
.onEnded { _ in
296303
imageTapped(index ?? 0)
297304
}
298305
)
299-
} else {
300-
imageView(for: image, allowsHitTesting: false)
301306
}
302307
} else if error != nil {
303308
Color(.secondarySystemBackground)
@@ -332,16 +337,13 @@ struct LazyLoadingImage: View {
332337
.clipped()
333338
}
334339

335-
func imageView(
336-
for image: UIImage,
337-
allowsHitTesting: Bool
338-
) -> some View {
340+
func imageView(for image: UIImage) -> some View {
339341
Image(uiImage: image)
340342
.resizable()
341343
.scaledToFill()
342344
.aspectRatio(contentMode: .fill)
343345
.clipped()
344-
.allowsHitTesting(allowsHitTesting)
346+
.allowsHitTesting(false)
345347
}
346348
}
347349

0 commit comments

Comments
 (0)