Skip to content

Commit 6709e82

Browse files
Updated reactions overlay keyboard display
1 parent 0884e47 commit 6709e82

File tree

6 files changed

+23
-2
lines changed

6 files changed

+23
-2
lines changed

Sources/StreamChatSwiftUI/ChatChannel/ChatChannelView.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,9 @@ public struct ChatChannelView<Factory: ViewFactory>: View, KeyboardReadable {
110110
messageDisplayInfo: messageDisplayInfo!,
111111
onBackgroundTap: {
112112
viewModel.reactionsShown = false
113+
if messageDisplayInfo?.keyboardWasShown == true {
114+
becomeFirstResponder()
115+
}
113116
}, onActionExecuted: { actionInfo in
114117
viewModel.messageActionExecuted(actionInfo)
115118
}

Sources/StreamChatSwiftUI/ChatChannel/MessageList/MessageContainerView.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,4 +319,5 @@ public struct MessageDisplayInfo {
319319
let contentWidth: CGFloat
320320
let isFirst: Bool
321321
var showsMessageActions: Bool = true
322+
var keyboardWasShown: Bool = false
322323
}

Sources/StreamChatSwiftUI/ChatChannel/MessageList/MessageListView.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,8 @@ public struct MessageListView<Factory: ViewFactory>: View, KeyboardReadable {
245245
message: messageDisplayInfo.message,
246246
frame: updatedFrame,
247247
contentWidth: messageDisplayInfo.contentWidth,
248-
isFirst: messageDisplayInfo.isFirst
248+
isFirst: messageDisplayInfo.isFirst,
249+
keyboardWasShown: true
249250
)
250251

251252
onLongPress(updatedDisplayInfo)

Sources/StreamChatSwiftUI/ChatChannel/Reactions/ReactionsOverlayView.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ public struct ReactionsOverlayView<Factory: ViewFactory>: View {
7171
Alert.defaultErrorAlert
7272
}
7373

74-
if !messageDisplayInfo.message.isSentByCurrentUser {
74+
if !messageDisplayInfo.message.isSentByCurrentUser &&
75+
utils.messageListConfig.messageDisplayOptions.showAvatars {
7576
factory.makeMessageAvatarView(
7677
for: utils.messageCachingUtils.authorInfo(from: messageDisplayInfo.message)
7778
)

Sources/StreamChatSwiftUI/Utils/Common/InputTextView.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,12 @@ class InputTextView: UITextView {
6565
name: UITextView.textDidChangeNotification,
6666
object: self
6767
)
68+
NotificationCenter.default.addObserver(
69+
self,
70+
selector: #selector(becomeFirstResponder),
71+
name: NSNotification.Name(firstResponderNotification),
72+
object: nil
73+
)
6874
}
6975

7076
open func setUpAppearance() {

Sources/StreamChatSwiftUI/Utils/KeyboardHandling.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,12 @@ func resignFirstResponder() {
8989
for: nil
9090
)
9191
}
92+
93+
let firstResponderNotification = "io.getstream.inputView.becomeFirstResponder"
94+
95+
func becomeFirstResponder() {
96+
NotificationCenter.default.post(
97+
name: NSNotification.Name(firstResponderNotification),
98+
object: nil
99+
)
100+
}

0 commit comments

Comments
 (0)