fix: list scroll keyboard behaviour (#304)
* fix: Keyboard now closes by clicking on space or scrolling. * fix: Exposed system and normal message tap builders * fmt: dartfmt
This commit is contained in:
@@ -136,6 +136,8 @@ class MessageListView extends StatefulWidget {
|
|||||||
this.messageListBuilder,
|
this.messageListBuilder,
|
||||||
this.errorWidgetBuilder,
|
this.errorWidgetBuilder,
|
||||||
this.customAttachmentBuilders,
|
this.customAttachmentBuilders,
|
||||||
|
this.onMessageTap,
|
||||||
|
this.onSystemMessageTap,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
/// Function used to build a custom message widget
|
/// Function used to build a custom message widget
|
||||||
@@ -216,6 +218,12 @@ class MessageListView extends StatefulWidget {
|
|||||||
/// Please change this in the [MessageWidget] if you are using a custom implementation
|
/// Please change this in the [MessageWidget] if you are using a custom implementation
|
||||||
final Map<String, AttachmentBuilder> customAttachmentBuilders;
|
final Map<String, AttachmentBuilder> customAttachmentBuilders;
|
||||||
|
|
||||||
|
/// Called when any message is tapped except a system message (use [onSystemMessageTap] instead)
|
||||||
|
final void Function(Message) onMessageTap;
|
||||||
|
|
||||||
|
/// Called when system message is tapped
|
||||||
|
final void Function(Message) onSystemMessageTap;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_MessageListViewState createState() => _MessageListViewState();
|
_MessageListViewState createState() => _MessageListViewState();
|
||||||
}
|
}
|
||||||
@@ -364,6 +372,9 @@ 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) {
|
||||||
@@ -812,6 +823,12 @@ class _MessageListViewState extends State<MessageListView> {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
customAttachmentBuilders: widget.customAttachmentBuilders,
|
customAttachmentBuilders: widget.customAttachmentBuilders,
|
||||||
|
onMessageTap: (message) {
|
||||||
|
if (widget.onMessageTap != null) {
|
||||||
|
widget.onMessageTap(message);
|
||||||
|
}
|
||||||
|
FocusScope.of(context).unfocus();
|
||||||
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -825,6 +842,12 @@ class _MessageListViewState extends State<MessageListView> {
|
|||||||
SystemMessage(
|
SystemMessage(
|
||||||
key: ValueKey<String>('MESSAGE-${message.id}'),
|
key: ValueKey<String>('MESSAGE-${message.id}'),
|
||||||
message: message,
|
message: message,
|
||||||
|
onMessageTap: (message) {
|
||||||
|
if (widget.onSystemMessageTap != null) {
|
||||||
|
widget.onSystemMessageTap(message);
|
||||||
|
}
|
||||||
|
FocusScope.of(context).unfocus();
|
||||||
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -974,6 +997,12 @@ class _MessageListViewState extends State<MessageListView> {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
customAttachmentBuilders: widget.customAttachmentBuilders,
|
customAttachmentBuilders: widget.customAttachmentBuilders,
|
||||||
|
onMessageTap: (message) {
|
||||||
|
if (widget.onMessageTap != null) {
|
||||||
|
widget.onMessageTap(message);
|
||||||
|
}
|
||||||
|
FocusScope.of(context).unfocus();
|
||||||
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!message.isDeleted &&
|
if (!message.isDeleted &&
|
||||||
|
|||||||
@@ -143,6 +143,9 @@ class MessageWidget extends StatefulWidget {
|
|||||||
/// Function called when quotedMessage is tapped
|
/// Function called when quotedMessage is tapped
|
||||||
final OnQuotedMessageTap onQuotedMessageTap;
|
final OnQuotedMessageTap onQuotedMessageTap;
|
||||||
|
|
||||||
|
/// Function called when message is tapped
|
||||||
|
final void Function(Message) onMessageTap;
|
||||||
|
|
||||||
///
|
///
|
||||||
MessageWidget({
|
MessageWidget({
|
||||||
Key key,
|
Key key,
|
||||||
@@ -157,6 +160,7 @@ class MessageWidget extends StatefulWidget {
|
|||||||
this.borderRadiusGeometry,
|
this.borderRadiusGeometry,
|
||||||
this.attachmentBorderRadiusGeometry,
|
this.attachmentBorderRadiusGeometry,
|
||||||
this.onMentionTap,
|
this.onMentionTap,
|
||||||
|
this.onMessageTap,
|
||||||
this.showReactionPickerIndicator = false,
|
this.showReactionPickerIndicator = false,
|
||||||
this.showUserAvatar = DisplayWidget.show,
|
this.showUserAvatar = DisplayWidget.show,
|
||||||
this.showSendingIndicator = true,
|
this.showSendingIndicator = true,
|
||||||
@@ -311,6 +315,9 @@ class _MessageWidgetState extends State<MessageWidget>
|
|||||||
type: MaterialType.transparency,
|
type: MaterialType.transparency,
|
||||||
child: Portal(
|
child: Portal(
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
|
onTap: () {
|
||||||
|
widget.onMessageTap(widget.message);
|
||||||
|
},
|
||||||
onLongPress: widget.message.isDeleted && !isFailedState
|
onLongPress: widget.message.isDeleted && !isFailedState
|
||||||
? null
|
? null
|
||||||
: () => onLongPress(context),
|
: () => onLongPress(context),
|
||||||
|
|||||||
Reference in New Issue
Block a user