Moved autoCorrect flag to v4 message input and added doc comments for scrollToBottomBuilder
This commit is contained in:
@@ -195,7 +195,6 @@ class MessageInput extends StatefulWidget {
|
|||||||
this.customOverlays = const [],
|
this.customOverlays = const [],
|
||||||
this.mentionAllAppUsers = false,
|
this.mentionAllAppUsers = false,
|
||||||
this.shouldKeepFocusAfterMessage,
|
this.shouldKeepFocusAfterMessage,
|
||||||
this.autocorrectEnabled,
|
|
||||||
}) : assert(
|
}) : assert(
|
||||||
initialMessage == null || editMessage == null,
|
initialMessage == null || editMessage == null,
|
||||||
"Can't provide both `initialMessage` and `editMessage`",
|
"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.
|
/// The default behaviour keeps focus until a command is enabled.
|
||||||
final bool? shouldKeepFocusAfterMessage;
|
final bool? shouldKeepFocusAfterMessage;
|
||||||
|
|
||||||
final bool? autocorrectEnabled;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
MessageInputState createState() => MessageInputState();
|
MessageInputState createState() => MessageInputState();
|
||||||
|
|
||||||
@@ -701,7 +698,6 @@ class MessageInputState extends State<MessageInput> {
|
|||||||
textAlignVertical: TextAlignVertical.center,
|
textAlignVertical: TextAlignVertical.center,
|
||||||
decoration: _getInputDecoration(context),
|
decoration: _getInputDecoration(context),
|
||||||
textCapitalization: TextCapitalization.sentences,
|
textCapitalization: TextCapitalization.sentences,
|
||||||
autocorrect: widget.autocorrectEnabled ?? true,
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -213,6 +213,7 @@ class StreamMessageInput extends StatefulWidget {
|
|||||||
this.enableSafeArea,
|
this.enableSafeArea,
|
||||||
this.elevation,
|
this.elevation,
|
||||||
this.shadow,
|
this.shadow,
|
||||||
|
this.autoCorrect,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
/// List of options for showing overlays.
|
/// List of options for showing overlays.
|
||||||
@@ -332,6 +333,10 @@ class StreamMessageInput extends StatefulWidget {
|
|||||||
/// Shadow for the [StreamMessageInput] widget
|
/// Shadow for the [StreamMessageInput] widget
|
||||||
final BoxShadow? shadow;
|
final BoxShadow? shadow;
|
||||||
|
|
||||||
|
/// Disable autoCorrect by passing false
|
||||||
|
/// autoCorrect is enabled by default
|
||||||
|
final bool? autoCorrect;
|
||||||
|
|
||||||
static bool _defaultValidator(Message message) =>
|
static bool _defaultValidator(Message message) =>
|
||||||
message.text?.isNotEmpty == true || message.attachments.isNotEmpty;
|
message.text?.isNotEmpty == true || message.attachments.isNotEmpty;
|
||||||
|
|
||||||
@@ -363,6 +368,8 @@ class StreamMessageInputState extends State<StreamMessageInput>
|
|||||||
bool get _isEditing =>
|
bool get _isEditing =>
|
||||||
_effectiveController.value.status != MessageSendingStatus.sending;
|
_effectiveController.value.status != MessageSendingStatus.sending;
|
||||||
|
|
||||||
|
bool get _autoCorrect => widget.autoCorrect ?? true;
|
||||||
|
|
||||||
RestorableMessageInputController? _controller;
|
RestorableMessageInputController? _controller;
|
||||||
|
|
||||||
MessageInputController get _effectiveController =>
|
MessageInputController get _effectiveController =>
|
||||||
@@ -805,6 +812,7 @@ class StreamMessageInputState extends State<StreamMessageInput>
|
|||||||
textAlignVertical: TextAlignVertical.center,
|
textAlignVertical: TextAlignVertical.center,
|
||||||
decoration: _getInputDecoration(context),
|
decoration: _getInputDecoration(context),
|
||||||
textCapitalization: TextCapitalization.sentences,
|
textCapitalization: TextCapitalization.sentences,
|
||||||
|
autocorrect: _autoCorrect,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -248,6 +248,20 @@ class StreamMessageListView extends StatefulWidget {
|
|||||||
/// messages and the scroll offset is not zero
|
/// messages and the scroll offset is not zero
|
||||||
final bool showScrollToBottom;
|
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(
|
final Widget Function(
|
||||||
int unreadCount,
|
int unreadCount,
|
||||||
Future<void> Function(int) scrollToBottomDefaultTapAction,
|
Future<void> Function(int) scrollToBottomDefaultTapAction,
|
||||||
|
|||||||
Reference in New Issue
Block a user