File tree Expand file tree Collapse file tree 5 files changed +64
-1
lines changed
Sources/StreamChatSwiftUI
StreamChatSwiftUITests/Tests/Utils Expand file tree Collapse file tree 5 files changed +64
-1
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
6
6
### 🐞 Fixed
7
7
- Fixed the text input cursor when a message is being edited
8
8
9
+ ### ✅ Added
10
+ - Added a factory method for customizing the composer text input view
11
+
9
12
# [ 4.31.0] ( https://github.com/GetStream/stream-chat-swiftui/releases/tag/4.31.0 )
10
13
_ April 25, 2023_
11
14
Original file line number Diff line number Diff line change @@ -311,7 +311,7 @@ public struct ComposerInputView<Factory: ViewFactory>: View {
311
311
. cornerRadius ( 16 )
312
312
}
313
313
314
- ComposerTextInputView (
314
+ factory . makeComposerTextInputView (
315
315
text: $text,
316
316
height: $textHeight,
317
317
selectedRangeLocation: $selectedRangeLocation,
Original file line number Diff line number Diff line change @@ -543,6 +543,26 @@ extension ViewFactory {
543
543
}
544
544
}
545
545
546
+ public func makeComposerTextInputView(
547
+ text: Binding < String > ,
548
+ height: Binding < CGFloat > ,
549
+ selectedRangeLocation: Binding < Int > ,
550
+ placeholder: String ,
551
+ editable: Bool ,
552
+ maxMessageLength: Int ? ,
553
+ currentHeight: CGFloat
554
+ ) -> some View {
555
+ ComposerTextInputView (
556
+ text: text,
557
+ height: height,
558
+ selectedRangeLocation: selectedRangeLocation,
559
+ placeholder: placeholder,
560
+ editable: editable,
561
+ maxMessageLength: maxMessageLength,
562
+ currentHeight: currentHeight
563
+ )
564
+ }
565
+
546
566
public func makeTrailingComposerView(
547
567
enabled: Bool ,
548
568
cooldownDuration: Int ,
Original file line number Diff line number Diff line change @@ -536,6 +536,27 @@ public protocol ViewFactory: AnyObject {
536
536
shouldScroll: Bool ,
537
537
removeAttachmentWithId: @escaping ( String ) -> Void
538
538
) -> ComposerInputViewType
539
+
540
+ associatedtype ComposerTextInputViewType : View
541
+ /// Creates the composer input view.
542
+ /// - Parameters:
543
+ /// - text: the text displayed in the input view.
544
+ /// - height: the height of the view.
545
+ /// - selectedRangeLocation: the selected range location of a text.
546
+ /// - placeholder: the placeholder shown when there's no text.
547
+ /// - editable: whether the text view should be editable.
548
+ /// - maxMessageLength: the maximum allowed message length.
549
+ /// - currentHeight: the current height of the view.
550
+ /// - Returns: View shown in the composer text input slot.
551
+ func makeComposerTextInputView(
552
+ text: Binding < String > ,
553
+ height: Binding < CGFloat > ,
554
+ selectedRangeLocation: Binding < Int > ,
555
+ placeholder: String ,
556
+ editable: Bool ,
557
+ maxMessageLength: Int ? ,
558
+ currentHeight: CGFloat
559
+ ) -> ComposerTextInputViewType
539
560
540
561
associatedtype TrailingComposerViewType : View
541
562
/// Creates the trailing composer view.
Original file line number Diff line number Diff line change @@ -773,6 +773,25 @@ class ViewFactory_Tests: StreamChatTestCase {
773
773
// Then
774
774
XCTAssert ( view is NewMessagesIndicator )
775
775
}
776
+
777
+ func test_viewFactory_makeComposerTextInputView( ) {
778
+ // Given
779
+ let viewFactory = DefaultViewFactory . shared
780
+
781
+ // When
782
+ let view = viewFactory. makeComposerTextInputView (
783
+ text: . constant( " test " ) ,
784
+ height: . constant( 40 ) ,
785
+ selectedRangeLocation: . constant( 0 ) ,
786
+ placeholder: " Send a message " ,
787
+ editable: true ,
788
+ maxMessageLength: nil ,
789
+ currentHeight: 40
790
+ )
791
+
792
+ // Then
793
+ XCTAssert ( view is ComposerTextInputView )
794
+ }
776
795
}
777
796
778
797
extension ChannelAction : Equatable {
You can’t perform that action at this time.
0 commit comments