Skip to content

Commit 166487e

Browse files
Added config for becoming first responder on channel appearance
1 parent e58c89b commit 166487e

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

Sources/StreamChatSwiftUI/ChatChannel/Composer/ComposerTextInputView.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ import UIKit
77

88
/// SwiftUI wrapper for a text field with multiple rows.
99
struct ComposerTextInputView: UIViewRepresentable {
10+
11+
@Injected(\.utils) private var utils
12+
1013
@Binding var text: String
1114
@Binding var height: CGFloat
1215
@Binding var selectedRangeLocation: Int
@@ -24,6 +27,10 @@ struct ComposerTextInputView: UIViewRepresentable {
2427
inputTextView.placeholderLabel.text = placeholder
2528
inputTextView.contentInsetAdjustmentBehavior = .never
2629

30+
if utils.messageListConfig.becomesFirstResponderOnOpen {
31+
inputTextView.becomeFirstResponder()
32+
}
33+
2734
return inputTextView
2835
}
2936

Sources/StreamChatSwiftUI/ChatChannel/MessageList/MessageListConfig.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ public struct MessageListConfig {
1616
dateIndicatorPlacement: DateIndicatorPlacement = .overlay,
1717
pageSize: Int = 50,
1818
messagePopoverEnabled: Bool = true,
19-
doubleTapOverlayEnabled: Bool = false
19+
doubleTapOverlayEnabled: Bool = false,
20+
becomesFirstResponderOnOpen: Bool = false
2021
) {
2122
self.messageListType = messageListType
2223
self.typingIndicatorPlacement = typingIndicatorPlacement
@@ -27,6 +28,7 @@ public struct MessageListConfig {
2728
self.pageSize = pageSize
2829
self.messagePopoverEnabled = messagePopoverEnabled
2930
self.doubleTapOverlayEnabled = doubleTapOverlayEnabled
31+
self.becomesFirstResponderOnOpen = becomesFirstResponderOnOpen
3032
}
3133

3234
let messageListType: MessageListType
@@ -38,6 +40,7 @@ public struct MessageListConfig {
3840
let pageSize: Int
3941
let messagePopoverEnabled: Bool
4042
let doubleTapOverlayEnabled: Bool
43+
let becomesFirstResponderOnOpen: Bool
4144
}
4245

4346
/// Contains information about the message paddings.

0 commit comments

Comments
 (0)