[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,
|
||||||
|
|||||||
+154
-155
@@ -287,121 +287,119 @@ 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),
|
child: Transform(
|
||||||
child: Transform(
|
alignment: Alignment.center,
|
||||||
alignment: Alignment.center,
|
transform: Matrix4.rotationY(widget.reverse ? pi : 0),
|
||||||
transform: Matrix4.rotationY(widget.reverse ? pi : 0),
|
child: FractionallySizedBox(
|
||||||
child: FractionallySizedBox(
|
alignment: Alignment.centerLeft,
|
||||||
alignment: Alignment.centerLeft,
|
widthFactor: 0.75,
|
||||||
widthFactor: 0.75,
|
child: Column(
|
||||||
child: Column(
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
mainAxisSize: MainAxisSize.min,
|
||||||
mainAxisSize: MainAxisSize.min,
|
children: <Widget>[
|
||||||
children: <Widget>[
|
Stack(
|
||||||
Stack(
|
clipBehavior: Clip.none,
|
||||||
clipBehavior: Clip.none,
|
alignment: AlignmentDirectional.bottomStart,
|
||||||
alignment: AlignmentDirectional.bottomStart,
|
children: [
|
||||||
children: [
|
Column(
|
||||||
Column(
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
mainAxisSize: MainAxisSize.min,
|
||||||
mainAxisSize: MainAxisSize.min,
|
children: [
|
||||||
children: [
|
Row(
|
||||||
Row(
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.end,
|
||||||
crossAxisAlignment: CrossAxisAlignment.end,
|
mainAxisSize: MainAxisSize.min,
|
||||||
mainAxisSize: MainAxisSize.min,
|
children: <Widget>[
|
||||||
children: <Widget>[
|
if (widget.showUserAvatar == DisplayWidget.show)
|
||||||
if (widget.showUserAvatar == DisplayWidget.show)
|
_buildUserAvatar(),
|
||||||
_buildUserAvatar(),
|
SizedBox(width: 6),
|
||||||
SizedBox(width: 6),
|
if (widget.showUserAvatar == DisplayWidget.hide)
|
||||||
if (widget.showUserAvatar == DisplayWidget.hide)
|
SizedBox(
|
||||||
SizedBox(
|
width: widget.messageTheme.avatarTheme
|
||||||
width: widget.messageTheme.avatarTheme
|
.constraints.maxWidth +
|
||||||
.constraints.maxWidth +
|
8,
|
||||||
8,
|
|
||||||
),
|
|
||||||
Flexible(
|
|
||||||
child: PortalEntry(
|
|
||||||
portal: Container(
|
|
||||||
transform:
|
|
||||||
Matrix4.translationValues(-16, 2, 0),
|
|
||||||
child: _buildReactionIndicator(context),
|
|
||||||
constraints:
|
|
||||||
BoxConstraints(maxWidth: 22 * 6.0),
|
|
||||||
),
|
),
|
||||||
portalAnchor: Alignment(-1.0, -1.0),
|
Flexible(
|
||||||
childAnchor: Alignment(1, -1.0),
|
child: PortalEntry(
|
||||||
child: Stack(
|
portal: Container(
|
||||||
clipBehavior: Clip.none,
|
transform:
|
||||||
children: [
|
Matrix4.translationValues(-16, 2, 0),
|
||||||
Padding(
|
child: _buildReactionIndicator(context),
|
||||||
padding: widget.showReactions
|
constraints:
|
||||||
? EdgeInsets.only(
|
BoxConstraints(maxWidth: 22 * 6.0),
|
||||||
top: widget
|
),
|
||||||
.message
|
portalAnchor: Alignment(-1.0, -1.0),
|
||||||
.reactionCounts
|
childAnchor: Alignment(1, -1.0),
|
||||||
?.isNotEmpty ==
|
child: Stack(
|
||||||
true
|
clipBehavior: Clip.none,
|
||||||
? 18
|
children: [
|
||||||
: 0,
|
Padding(
|
||||||
)
|
padding: widget.showReactions
|
||||||
: EdgeInsets.zero,
|
? EdgeInsets.only(
|
||||||
child: (widget.message.isDeleted &&
|
top: widget
|
||||||
!isFailedState)
|
.message
|
||||||
? Transform(
|
.reactionCounts
|
||||||
alignment: Alignment.center,
|
?.isNotEmpty ==
|
||||||
transform: Matrix4.rotationY(
|
true
|
||||||
widget.reverse ? pi : 0),
|
? 18
|
||||||
child: DeletedMessage(
|
: 0,
|
||||||
reverse: widget.reverse,
|
)
|
||||||
borderRadiusGeometry: widget
|
: EdgeInsets.zero,
|
||||||
.borderRadiusGeometry,
|
child: (widget.message.isDeleted &&
|
||||||
borderSide: widget.borderSide,
|
!isFailedState)
|
||||||
shape: widget.shape,
|
? Transform(
|
||||||
messageTheme:
|
alignment: Alignment.center,
|
||||||
widget.messageTheme,
|
transform: Matrix4.rotationY(
|
||||||
),
|
widget.reverse ? pi : 0),
|
||||||
)
|
child: DeletedMessage(
|
||||||
: Material(
|
reverse: widget.reverse,
|
||||||
clipBehavior: Clip.antiAlias,
|
borderRadiusGeometry: widget
|
||||||
shape: widget.shape ??
|
.borderRadiusGeometry,
|
||||||
RoundedRectangleBorder(
|
borderSide:
|
||||||
side: isOnlyEmoji
|
widget.borderSide,
|
||||||
? BorderSide.none
|
shape: widget.shape,
|
||||||
: widget.borderSide ??
|
messageTheme:
|
||||||
BorderSide(
|
widget.messageTheme,
|
||||||
color: Theme.of(context)
|
),
|
||||||
.brightness ==
|
)
|
||||||
Brightness
|
: Card(
|
||||||
.dark
|
clipBehavior: Clip.antiAlias,
|
||||||
? StreamChatTheme.of(
|
elevation: 0.0,
|
||||||
context)
|
shape: widget.shape ??
|
||||||
.colorTheme
|
RoundedRectangleBorder(
|
||||||
.white
|
side: isOnlyEmoji
|
||||||
.withAlpha(
|
? BorderSide.none
|
||||||
24)
|
: widget.borderSide ??
|
||||||
: StreamChatTheme.of(
|
BorderSide(
|
||||||
context)
|
color: Theme.of(context)
|
||||||
.colorTheme
|
.brightness ==
|
||||||
.black
|
Brightness
|
||||||
.withAlpha(
|
.dark
|
||||||
24),
|
? StreamChatTheme.of(
|
||||||
),
|
context)
|
||||||
borderRadius: widget
|
.colorTheme
|
||||||
.borderRadiusGeometry ??
|
.white
|
||||||
BorderRadius.zero,
|
.withAlpha(
|
||||||
),
|
24)
|
||||||
color: _getBackgroundColor(),
|
: StreamChatTheme.of(
|
||||||
child: InkWell(
|
context)
|
||||||
onLongPress: () =>
|
.colorTheme
|
||||||
onLongPress(context),
|
.black
|
||||||
|
.withAlpha(
|
||||||
|
24),
|
||||||
|
),
|
||||||
|
borderRadius: widget
|
||||||
|
.borderRadiusGeometry ??
|
||||||
|
BorderRadius.zero,
|
||||||
|
),
|
||||||
|
color: _getBackgroundColor(),
|
||||||
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
|
||||||
@@ -427,51 +424,51 @@ class _MessageWidgetState extends State<MessageWidget> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
if (widget.showReactionPickerIndicator)
|
||||||
if (widget.showReactionPickerIndicator)
|
Positioned(
|
||||||
Positioned(
|
right: 0,
|
||||||
right: 0,
|
top: -6,
|
||||||
top: -6,
|
child: Transform(
|
||||||
child: Transform(
|
transform: Matrix4.rotationY(
|
||||||
transform: Matrix4.rotationY(
|
widget.reverse ? pi : 0),
|
||||||
widget.reverse ? pi : 0),
|
child: CustomPaint(
|
||||||
child: CustomPaint(
|
painter: ReactionBubblePainter(
|
||||||
painter: ReactionBubblePainter(
|
widget.messageTheme
|
||||||
widget.messageTheme
|
.reactionsBackgroundColor,
|
||||||
.reactionsBackgroundColor,
|
widget.messageTheme
|
||||||
widget.messageTheme
|
.reactionsBorderColor,
|
||||||
.reactionsBorderColor,
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
],
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
],
|
|
||||||
),
|
|
||||||
if (showBottomRow) SizedBox(height: 20.0),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
if (showBottomRow) _buildBottomRow(leftPadding),
|
|
||||||
if (isFailedState)
|
|
||||||
Positioned(
|
|
||||||
left: widget.reverse ? -3 : null,
|
|
||||||
right: widget.reverse ? null : -9,
|
|
||||||
bottom: showBottomRow ? 20 : 0,
|
|
||||||
child: Container(
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: Colors.white,
|
|
||||||
shape: BoxShape.circle,
|
|
||||||
),
|
),
|
||||||
child: StreamSvgIcon.error(size: 20),
|
if (showBottomRow) SizedBox(height: 20.0),
|
||||||
),
|
],
|
||||||
),
|
),
|
||||||
],
|
if (showBottomRow) _buildBottomRow(leftPadding),
|
||||||
),
|
if (isFailedState)
|
||||||
],
|
Positioned(
|
||||||
|
left: widget.reverse ? -3 : null,
|
||||||
|
right: widget.reverse ? null : -9,
|
||||||
|
bottom: showBottomRow ? 20 : 0,
|
||||||
|
child: Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.white,
|
||||||
|
shape: BoxShape.circle,
|
||||||
|
),
|
||||||
|
child: StreamSvgIcon.error(size: 20),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -480,7 +477,9 @@ 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