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