Skip to content

Commit 266865a

Browse files
[SWUI-98] Fixed tap area of images in attachment picker
1 parent e8d052c commit 266865a

File tree

1 file changed

+27
-17
lines changed

1 file changed

+27
-17
lines changed

Sources/StreamChatSwiftUI/ChatChannel/Composer/PhotoAttachmentPickerView.swift

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -53,26 +53,36 @@ public struct PhotoAttachmentCell: View {
5353
ZStack {
5454
if let image = assetLoader.loadedImages[asset.localIdentifier] {
5555
GeometryReader { reader in
56-
Image(uiImage: image)
57-
.resizable()
58-
.aspectRatio(contentMode: .fill)
59-
.frame(width: reader.size.width, height: reader.size.height)
60-
.clipped()
61-
.onTapGesture {
62-
withAnimation {
63-
if let assetURL = assetURL {
64-
onImageTap(
65-
AddedAsset(
66-
image: image,
67-
id: asset.localIdentifier,
68-
url: assetURL,
69-
type: asset.mediaType == .video ? .video : .image,
70-
extraData: asset.mediaType == .video ? ["duration": asset.durationString] : [:]
56+
ZStack {
57+
Image(uiImage: image)
58+
.resizable()
59+
.aspectRatio(contentMode: .fill)
60+
.frame(width: reader.size.width, height: reader.size.height)
61+
.allowsHitTesting(false)
62+
.clipped()
63+
64+
// Needed because of SwiftUI bug with tap area of Image.
65+
Rectangle()
66+
.opacity(0.000001)
67+
.frame(width: reader.size.width, height: reader.size.height)
68+
.clipped()
69+
.allowsHitTesting(true)
70+
.onTapGesture {
71+
withAnimation {
72+
if let assetURL = assetURL {
73+
onImageTap(
74+
AddedAsset(
75+
image: image,
76+
id: asset.localIdentifier,
77+
url: assetURL,
78+
type: asset.mediaType == .video ? .video : .image,
79+
extraData: asset.mediaType == .video ? ["duration": asset.durationString] : [:]
80+
)
7181
)
72-
)
82+
}
7383
}
7484
}
75-
}
85+
}
7686
}
7787
} else {
7888
Color(colors.background1)

0 commit comments

Comments
 (0)