Moved autoCorrect flag to v4 message input and added doc comments for scrollToBottomBuilder

This commit is contained in:
Ayush Shekhar
2022-03-21 14:08:24 +05:30
parent b42b545c1e
commit c2f5b2b038
3 changed files with 22 additions and 4 deletions
@@ -195,7 +195,6 @@ class MessageInput extends StatefulWidget {
this.customOverlays = const [],
this.mentionAllAppUsers = false,
this.shouldKeepFocusAfterMessage,
this.autocorrectEnabled,
}) : assert(
initialMessage == null || editMessage == null,
"Can't provide both `initialMessage` and `editMessage`",
@@ -312,8 +311,6 @@ class MessageInput extends StatefulWidget {
/// The default behaviour keeps focus until a command is enabled.
final bool? shouldKeepFocusAfterMessage;
final bool? autocorrectEnabled;
@override
MessageInputState createState() => MessageInputState();
@@ -701,7 +698,6 @@ class MessageInputState extends State<MessageInput> {
textAlignVertical: TextAlignVertical.center,
decoration: _getInputDecoration(context),
textCapitalization: TextCapitalization.sentences,
autocorrect: widget.autocorrectEnabled ?? true,
),
),
],
@@ -213,6 +213,7 @@ class StreamMessageInput extends StatefulWidget {
this.enableSafeArea,
this.elevation,
this.shadow,
this.autoCorrect,
}) : super(key: key);
/// List of options for showing overlays.
@@ -332,6 +333,10 @@ class StreamMessageInput extends StatefulWidget {
/// Shadow for the [StreamMessageInput] widget
final BoxShadow? shadow;
/// Disable autoCorrect by passing false
/// autoCorrect is enabled by default
final bool? autoCorrect;
static bool _defaultValidator(Message message) =>
message.text?.isNotEmpty == true || message.attachments.isNotEmpty;
@@ -363,6 +368,8 @@ class StreamMessageInputState extends State<StreamMessageInput>
bool get _isEditing =>
_effectiveController.value.status != MessageSendingStatus.sending;
bool get _autoCorrect => widget.autoCorrect ?? true;
RestorableMessageInputController? _controller;
MessageInputController get _effectiveController =>
@@ -805,6 +812,7 @@ class StreamMessageInputState extends State<StreamMessageInput>
textAlignVertical: TextAlignVertical.center,
decoration: _getInputDecoration(context),
textCapitalization: TextCapitalization.sentences,
autocorrect: _autoCorrect,
),
),
],
@@ -248,6 +248,20 @@ class StreamMessageListView extends StatefulWidget {
/// messages and the scroll offset is not zero
final bool showScrollToBottom;
/// Function used to build a custom scroll to bottom widget
///
/// Provides the current unread messages count and a reference
/// to the function that is executed on tap of this widget by default
///
/// As an example:
/// MessageListView(
/// scrollToBottomBuilder: (unreadCount, defaultTapAction) {
/// return InkWell(
/// onTap: () => defaultTapAction(unreadCount),
/// child: Text('Scroll To Bottom'),
/// );
/// },
/// ),
final Widget Function(
int unreadCount,
Future<void> Function(int) scrollToBottomDefaultTapAction,