[MessageListView] fix onQuotedMessageTap
Signed-off-by: Sahil Kumar <[email protected]>
This commit is contained in:
@@ -775,15 +775,24 @@ class _MessageListViewState extends State<MessageListView> {
|
|||||||
bottom: index == 0 ? 30 : (isNextUser ? 2 : 7),
|
bottom: index == 0 ? 30 : (isNextUser ? 2 : 7),
|
||||||
top: 3,
|
top: 3,
|
||||||
),
|
),
|
||||||
onQuotedMessageTap: (quotedMessageId) {
|
onQuotedMessageTap: (quotedMessageId) async {
|
||||||
if (messages.map((e) => e.id).contains(quotedMessageId)) {
|
final scrollToIndex = () {
|
||||||
final index = messages.indexWhere((m) => m.id == quotedMessageId);
|
final index = messages.indexWhere((m) => m.id == quotedMessageId);
|
||||||
_scrollController?.scrollTo(
|
_scrollController?.scrollTo(
|
||||||
index: index,
|
index: index,
|
||||||
duration: const Duration(milliseconds: 350),
|
duration: const Duration(milliseconds: 350),
|
||||||
);
|
);
|
||||||
|
};
|
||||||
|
if (messages.map((e) => e.id).contains(quotedMessageId)) {
|
||||||
|
scrollToIndex();
|
||||||
} else {
|
} else {
|
||||||
streamChannel.loadChannelAtMessage(quotedMessageId);
|
streamChannel.loadChannelAtMessage(quotedMessageId).then((_) {
|
||||||
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
|
if (messages.map((e) => e.id).contains(quotedMessageId)) {
|
||||||
|
scrollToIndex();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
showInChannelIndicator: widget.parentMessage == null,
|
showInChannelIndicator: widget.parentMessage == null,
|
||||||
|
|||||||
+13
-14
@@ -287,11 +287,10 @@ class _MessageWidgetState extends State<MessageWidget> {
|
|||||||
widget.message.attachments?.any((element) => element.type == 'file') ==
|
widget.message.attachments?.any((element) => element.type == 'file') ==
|
||||||
true;
|
true;
|
||||||
|
|
||||||
final isMyMessage =
|
return Material(
|
||||||
widget.message.user.id == StreamChat.of(context).user.id;
|
type: MaterialType.transparency,
|
||||||
|
child: Portal(
|
||||||
return Portal(
|
child: InkWell(
|
||||||
child: GestureDetector(
|
|
||||||
onLongPress: () => onLongPress(context),
|
onLongPress: () => onLongPress(context),
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: widget.padding ?? EdgeInsets.all(8),
|
padding: widget.padding ?? EdgeInsets.all(8),
|
||||||
@@ -363,14 +362,16 @@ class _MessageWidgetState extends State<MessageWidget> {
|
|||||||
reverse: widget.reverse,
|
reverse: widget.reverse,
|
||||||
borderRadiusGeometry: widget
|
borderRadiusGeometry: widget
|
||||||
.borderRadiusGeometry,
|
.borderRadiusGeometry,
|
||||||
borderSide: widget.borderSide,
|
borderSide:
|
||||||
|
widget.borderSide,
|
||||||
shape: widget.shape,
|
shape: widget.shape,
|
||||||
messageTheme:
|
messageTheme:
|
||||||
widget.messageTheme,
|
widget.messageTheme,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
: Material(
|
: Card(
|
||||||
clipBehavior: Clip.antiAlias,
|
clipBehavior: Clip.antiAlias,
|
||||||
|
elevation: 0.0,
|
||||||
shape: widget.shape ??
|
shape: widget.shape ??
|
||||||
RoundedRectangleBorder(
|
RoundedRectangleBorder(
|
||||||
side: isOnlyEmoji
|
side: isOnlyEmoji
|
||||||
@@ -399,9 +400,6 @@ class _MessageWidgetState extends State<MessageWidget> {
|
|||||||
BorderRadius.zero,
|
BorderRadius.zero,
|
||||||
),
|
),
|
||||||
color: _getBackgroundColor(),
|
color: _getBackgroundColor(),
|
||||||
child: InkWell(
|
|
||||||
onLongPress: () =>
|
|
||||||
onLongPress(context),
|
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: EdgeInsets.all(
|
padding: EdgeInsets.all(
|
||||||
hasFiles ? 2.0 : 0.0),
|
hasFiles ? 2.0 : 0.0),
|
||||||
@@ -413,8 +411,7 @@ class _MessageWidgetState extends State<MessageWidget> {
|
|||||||
MainAxisSize.min,
|
MainAxisSize.min,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
if (_hasQuotedMessage)
|
if (_hasQuotedMessage)
|
||||||
_buildQuotedMessage(
|
_buildQuotedMessage(),
|
||||||
isMyMessage),
|
|
||||||
..._parseAttachments(
|
..._parseAttachments(
|
||||||
context),
|
context),
|
||||||
if (widget.message.text
|
if (widget.message.text
|
||||||
@@ -428,7 +425,6 @@ class _MessageWidgetState extends State<MessageWidget> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
|
||||||
if (widget.showReactionPickerIndicator)
|
if (widget.showReactionPickerIndicator)
|
||||||
Positioned(
|
Positioned(
|
||||||
right: 0,
|
right: 0,
|
||||||
@@ -477,10 +473,13 @@ class _MessageWidgetState extends State<MessageWidget> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildQuotedMessage(bool isMyMessage) {
|
Widget _buildQuotedMessage() {
|
||||||
|
final isMyMessage =
|
||||||
|
widget.message.user.id == StreamChat.of(context).user.id;
|
||||||
return QuotedMessageWidget(
|
return QuotedMessageWidget(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
if (widget.onQuotedMessageTap != null) {
|
if (widget.onQuotedMessageTap != null) {
|
||||||
|
|||||||
Reference in New Issue
Block a user