fix(ui): add MessageListView.ScrollViewKeyboardDismissBehavior
This commit is contained in:
@@ -45,6 +45,7 @@ class PositionedList extends StatefulWidget {
|
||||
this.addSemanticIndexes = true,
|
||||
this.addRepaintBoundaries = true,
|
||||
this.addAutomaticKeepAlives = true,
|
||||
this.keyboardDismissBehavior,
|
||||
}) : assert((positionedIndex == 0) || (positionedIndex < itemCount),
|
||||
'positionedIndex cannot be 0 and must be smaller than itemCount'),
|
||||
super(key: key);
|
||||
@@ -134,6 +135,10 @@ class PositionedList extends StatefulWidget {
|
||||
/// See [SliverChildBuilderDelegate.addAutomaticKeepAlives].
|
||||
final bool addAutomaticKeepAlives;
|
||||
|
||||
/// [ScrollViewKeyboardDismissBehavior] the defines how this [PositionedList] will
|
||||
/// dismiss the keyboard automatically.
|
||||
final ScrollViewKeyboardDismissBehavior? keyboardDismissBehavior;
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() => _PositionedListState();
|
||||
}
|
||||
@@ -173,6 +178,7 @@ class _PositionedListState extends State<PositionedList> {
|
||||
anchor: widget.alignment,
|
||||
center: _centerKey,
|
||||
controller: scrollController,
|
||||
keyboardDismissBehavior: widget.keyboardDismissBehavior,
|
||||
scrollDirection: widget.scrollDirection,
|
||||
reverse: widget.reverse,
|
||||
cacheExtent: widget.cacheExtent,
|
||||
|
||||
@@ -28,9 +28,12 @@ class UnboundedCustomScrollView extends CustomScrollView {
|
||||
List<Widget> slivers = const <Widget>[],
|
||||
int? semanticChildCount,
|
||||
DragStartBehavior dragStartBehavior = DragStartBehavior.start,
|
||||
ScrollViewKeyboardDismissBehavior? keyboardDismissBehavior,
|
||||
}) : _anchor = anchor,
|
||||
super(
|
||||
key: key,
|
||||
keyboardDismissBehavior: keyboardDismissBehavior ??
|
||||
ScrollViewKeyboardDismissBehavior.manual,
|
||||
scrollDirection: scrollDirection,
|
||||
reverse: reverse,
|
||||
controller: controller,
|
||||
|
||||
+9
@@ -52,6 +52,7 @@ class ScrollablePositionedList extends StatefulWidget {
|
||||
this.addRepaintBoundaries = true,
|
||||
this.minCacheExtent,
|
||||
this.findChildIndexCallback,
|
||||
this.keyboardDismissBehavior,
|
||||
}) : itemPositionsNotifier = itemPositionsListener as ItemPositionsNotifier?,
|
||||
separatorBuilder = null,
|
||||
super(key: key);
|
||||
@@ -77,6 +78,7 @@ class ScrollablePositionedList extends StatefulWidget {
|
||||
this.addRepaintBoundaries = true,
|
||||
this.minCacheExtent,
|
||||
this.findChildIndexCallback,
|
||||
this.keyboardDismissBehavior,
|
||||
}) : assert(separatorBuilder != null, 'seperatorBuilder cannot be null'),
|
||||
itemPositionsNotifier = itemPositionsListener as ItemPositionsNotifier?,
|
||||
super(key: key);
|
||||
@@ -92,6 +94,10 @@ class ScrollablePositionedList extends StatefulWidget {
|
||||
/// index of the child element with that associated key, or null if not found.
|
||||
final ChildIndexGetter? findChildIndexCallback;
|
||||
|
||||
/// [ScrollViewKeyboardDismissBehavior] the defines how this [PositionedList] will
|
||||
/// dismiss the keyboard automatically.
|
||||
final ScrollViewKeyboardDismissBehavior? keyboardDismissBehavior;
|
||||
|
||||
/// Number of items the [itemBuilder] can produce.
|
||||
final int itemCount;
|
||||
|
||||
@@ -344,6 +350,7 @@ class _ScrollablePositionedListState extends State<ScrollablePositionedList>
|
||||
child: NotificationListener<ScrollNotification>(
|
||||
onNotification: (_) => _isTransitioning,
|
||||
child: PositionedList(
|
||||
keyboardDismissBehavior: widget.keyboardDismissBehavior,
|
||||
itemBuilder: widget.itemBuilder,
|
||||
separatorBuilder: widget.separatorBuilder,
|
||||
itemCount: widget.itemCount,
|
||||
@@ -374,6 +381,8 @@ class _ScrollablePositionedListState extends State<ScrollablePositionedList>
|
||||
child: NotificationListener<ScrollNotification>(
|
||||
onNotification: (_) => false,
|
||||
child: PositionedList(
|
||||
keyboardDismissBehavior:
|
||||
widget.keyboardDismissBehavior,
|
||||
itemBuilder: widget.itemBuilder,
|
||||
separatorBuilder: widget.separatorBuilder,
|
||||
itemCount: widget.itemCount,
|
||||
|
||||
@@ -171,8 +171,13 @@ class MessageListView extends StatefulWidget {
|
||||
this.reverse = true,
|
||||
this.paginationLimit = 20,
|
||||
this.paginationLoadingIndicatorBuilder,
|
||||
this.keyboardDismissBehavior = ScrollViewKeyboardDismissBehavior.onDrag,
|
||||
}) : super(key: key);
|
||||
|
||||
/// [ScrollViewKeyboardDismissBehavior] the defines how this [PositionedList] will
|
||||
/// dismiss the keyboard automatically.
|
||||
final ScrollViewKeyboardDismissBehavior keyboardDismissBehavior;
|
||||
|
||||
/// Function used to build a custom message widget
|
||||
final MessageBuilder? messageBuilder;
|
||||
|
||||
@@ -443,9 +448,6 @@ class _MessageListViewState extends State<MessageListView> {
|
||||
childAnchor: Alignment.topCenter,
|
||||
message: statusString,
|
||||
child: LazyLoadScrollView(
|
||||
onPageScrollStart: () {
|
||||
//FocusScope.of(context).unfocus();
|
||||
},
|
||||
onStartOfPage: () async {
|
||||
_inBetweenList = false;
|
||||
if (!_upToDate) {
|
||||
@@ -471,6 +473,7 @@ class _MessageListViewState extends State<MessageListView> {
|
||||
key: (initialIndex != 0 && initialAlignment != 0)
|
||||
? ValueKey('$initialIndex-$initialAlignment')
|
||||
: null,
|
||||
keyboardDismissBehavior: widget.keyboardDismissBehavior,
|
||||
itemPositionsListener: _itemPositionListener,
|
||||
initialScrollIndex: initialIndex,
|
||||
initialAlignment: initialAlignment,
|
||||
|
||||
Reference in New Issue
Block a user