Skip to content

Commit 5f9ef24

Browse files
Fixed tap issue on image attachments with number indicator
1 parent 10881e2 commit 5f9ef24

File tree

5 files changed

+55
-1
lines changed

5 files changed

+55
-1
lines changed

Sources/StreamChatSwiftUI/ChatChannel/Composer/ComposerTextInputView.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,9 @@ struct ComposerTextInputView: UIViewRepresentable {
7272
height = TextSizeConstants.minimumHeight
7373
}
7474
if textInput.height != height {
75-
textInput.height = height
75+
withAnimation {
76+
textInput.height = height
77+
}
7678
}
7779
}
7880

Sources/StreamChatSwiftUI/ChatChannel/MessageList/ImageAttachmentView.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,10 +234,12 @@ struct ImageAttachmentView: View {
234234

235235
if notDisplayedImages > 0 {
236236
Color.black.opacity(0.4)
237+
.allowsHitTesting(false)
237238

238239
Text("+\(notDisplayedImages)")
239240
.foregroundColor(Color(colors.staticColorText))
240241
.font(fonts.title)
242+
.allowsHitTesting(false)
241243
}
242244
}
243245
.frame(width: width / 2, height: fullHeight / 2)

StreamChatSwiftUITests/Tests/ChatChannel/MessageContainerView_Tests.swift

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,56 @@ class MessageContainerView_Tests: StreamChatTestCase {
106106
assertSnapshot(matching: view, as: .image)
107107
}
108108

109+
func test_imageAttachments_snapshot() {
110+
// Given
111+
let message = ChatMessage.mock(
112+
id: .unique,
113+
cid: .unique,
114+
text: "Test message",
115+
author: .mock(id: .unique),
116+
attachments: ChatChannelTestHelpers.imageAttachments
117+
)
118+
119+
// When
120+
let view = ImageAttachmentContainer(
121+
factory: DefaultViewFactory.shared,
122+
message: message,
123+
width: 200,
124+
isFirst: true,
125+
scrolledId: .constant(nil)
126+
)
127+
.frame(width: 200)
128+
129+
// Then
130+
assertSnapshot(matching: view, as: .image)
131+
}
132+
133+
func test_imageAttachments_snapshotFiveImages() {
134+
// Given
135+
let attachment = ChatChannelTestHelpers.imageAttachments[0]
136+
let attachments = [AnyChatMessageAttachment](repeating: attachment, count: 5)
137+
let message = ChatMessage.mock(
138+
id: .unique,
139+
cid: .unique,
140+
text: "Test message",
141+
author: .mock(id: .unique),
142+
attachments: attachments
143+
)
144+
145+
// When
146+
let view = ImageAttachmentContainer(
147+
factory: DefaultViewFactory.shared,
148+
message: message,
149+
width: 200,
150+
isFirst: true,
151+
scrolledId: .constant(nil)
152+
)
153+
.frame(width: 200)
154+
155+
// Then
156+
assertSnapshot(matching: view, as: .image)
157+
}
158+
109159
// MARK: - private
110160

111161
func testMessageViewContainerSnapshot(message: ChatMessage) {
Loading
Loading

0 commit comments

Comments
 (0)