use MessageWidget.copyWith in reactions modal
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
import 'dart:ui';
|
import 'dart:ui';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:stream_chat_flutter/src/extension.dart';
|
|
||||||
import 'package:stream_chat_flutter/src/reaction_bubble.dart';
|
import 'package:stream_chat_flutter/src/reaction_bubble.dart';
|
||||||
import 'package:stream_chat_flutter/src/reaction_picker.dart';
|
import 'package:stream_chat_flutter/src/reaction_picker.dart';
|
||||||
import 'package:stream_chat_flutter/src/stream_chat.dart';
|
import 'package:stream_chat_flutter/src/stream_chat.dart';
|
||||||
@@ -15,17 +14,16 @@ class MessageReactionsModal extends StatelessWidget {
|
|||||||
const MessageReactionsModal({
|
const MessageReactionsModal({
|
||||||
Key? key,
|
Key? key,
|
||||||
required this.message,
|
required this.message,
|
||||||
|
required this.messageWidget,
|
||||||
required this.messageTheme,
|
required this.messageTheme,
|
||||||
this.showReactions = true,
|
this.showReactions = true,
|
||||||
this.messageShape,
|
|
||||||
this.attachmentShape,
|
|
||||||
this.reverse = false,
|
this.reverse = false,
|
||||||
this.showUserAvatar = DisplayWidget.show,
|
|
||||||
this.onUserAvatarTap,
|
this.onUserAvatarTap,
|
||||||
this.attachmentBorderRadiusGeometry,
|
|
||||||
this.textBuilder,
|
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
|
/// Widget that shows the message
|
||||||
|
final Widget messageWidget;
|
||||||
|
|
||||||
/// Message to display reactions of
|
/// Message to display reactions of
|
||||||
final Message message;
|
final Message message;
|
||||||
|
|
||||||
@@ -38,24 +36,9 @@ class MessageReactionsModal extends StatelessWidget {
|
|||||||
/// Flag to show reactions on message
|
/// Flag to show reactions on message
|
||||||
final bool showReactions;
|
final bool showReactions;
|
||||||
|
|
||||||
/// Enum to change user avatar config
|
|
||||||
final DisplayWidget showUserAvatar;
|
|
||||||
|
|
||||||
/// [ShapeBorder] to apply to message
|
|
||||||
final ShapeBorder? messageShape;
|
|
||||||
|
|
||||||
/// [ShapeBorder] to apply to attachment
|
|
||||||
final ShapeBorder? attachmentShape;
|
|
||||||
|
|
||||||
/// Callback when user avatar is tapped
|
/// Callback when user avatar is tapped
|
||||||
final void Function(User)? onUserAvatarTap;
|
final void Function(User)? onUserAvatarTap;
|
||||||
|
|
||||||
/// [BorderRadius] to apply to attachments
|
|
||||||
final BorderRadius? attachmentBorderRadiusGeometry;
|
|
||||||
|
|
||||||
/// Customize the MessageWidget textBuilder
|
|
||||||
final Widget Function(BuildContext context, Message message)? textBuilder;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final size = MediaQuery.of(context).size;
|
final size = MediaQuery.of(context).size;
|
||||||
@@ -77,8 +60,6 @@ class MessageReactionsModal extends StatelessWidget {
|
|||||||
final divFactor = message.attachments.isNotEmpty == true
|
final divFactor = message.attachments.isNotEmpty == true
|
||||||
? 1
|
? 1
|
||||||
: (roughSentenceSize == 0 ? 1 : (roughSentenceSize / roughMaxSize));
|
: (roughSentenceSize == 0 ? 1 : (roughSentenceSize / roughMaxSize));
|
||||||
final hasFileAttachment =
|
|
||||||
message.attachments.any((it) => it.type == 'file') == true;
|
|
||||||
|
|
||||||
final numberOfReactions = StreamChatTheme.of(context).reactionIcons.length;
|
final numberOfReactions = StreamChatTheme.of(context).reactionIcons.length;
|
||||||
final shiftFactor =
|
final shiftFactor =
|
||||||
@@ -110,38 +91,7 @@ class MessageReactionsModal extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
const SizedBox(height: 8),
|
const SizedBox(height: 8),
|
||||||
IgnorePointer(
|
IgnorePointer(
|
||||||
child: MessageWidget(
|
child: messageWidget,
|
||||||
key: const Key('MessageWidget'),
|
|
||||||
reverse: reverse,
|
|
||||||
message: message.copyWith(
|
|
||||||
text: message.text!.length > 200
|
|
||||||
? '${message.text!.substring(0, 200)}...'
|
|
||||||
: message.text,
|
|
||||||
),
|
|
||||||
messageTheme: messageTheme,
|
|
||||||
showReactions: false,
|
|
||||||
showUsername: false,
|
|
||||||
showUserAvatar: showUserAvatar,
|
|
||||||
showTimestamp: false,
|
|
||||||
translateUserAvatar: false,
|
|
||||||
showSendingIndicator: false,
|
|
||||||
shape: messageShape,
|
|
||||||
attachmentShape: attachmentShape,
|
|
||||||
padding: const EdgeInsets.all(0),
|
|
||||||
attachmentBorderRadiusGeometry: attachmentBorderRadiusGeometry
|
|
||||||
?.mirrorBorderIfReversed(reverse: !reverse),
|
|
||||||
attachmentPadding: EdgeInsets.all(
|
|
||||||
hasFileAttachment ? 4 : 2,
|
|
||||||
),
|
|
||||||
textPadding: EdgeInsets.symmetric(
|
|
||||||
vertical: 8,
|
|
||||||
horizontal: message.text!.isOnlyEmoji ? 0 : 16.0,
|
|
||||||
),
|
|
||||||
showReactionPickerIndicator: showReactions &&
|
|
||||||
(message.status == MessageSendingStatus.sent),
|
|
||||||
textBuilder: textBuilder,
|
|
||||||
showPinHighlight: false,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
if (message.latestReactions?.isNotEmpty == true) ...[
|
if (message.latestReactions?.isNotEmpty == true) ...[
|
||||||
const SizedBox(height: 8),
|
const SizedBox(height: 8),
|
||||||
|
|||||||
@@ -500,7 +500,7 @@ class MessageWidget extends StatefulWidget {
|
|||||||
showPinButton: showPinButton ?? this.showPinButton,
|
showPinButton: showPinButton ?? this.showPinButton,
|
||||||
showPinHighlight: showPinHighlight ?? this.showPinHighlight,
|
showPinHighlight: showPinHighlight ?? this.showPinHighlight,
|
||||||
customAttachmentBuilders:
|
customAttachmentBuilders:
|
||||||
customAttachmentBuilders ?? this.attachmentBuilders,
|
customAttachmentBuilders ?? attachmentBuilders,
|
||||||
translateUserAvatar: translateUserAvatar ?? this.translateUserAvatar,
|
translateUserAvatar: translateUserAvatar ?? this.translateUserAvatar,
|
||||||
onQuotedMessageTap: onQuotedMessageTap ?? this.onQuotedMessageTap,
|
onQuotedMessageTap: onQuotedMessageTap ?? this.onQuotedMessageTap,
|
||||||
onMessageTap: onMessageTap ?? this.onMessageTap,
|
onMessageTap: onMessageTap ?? this.onMessageTap,
|
||||||
@@ -1075,18 +1075,29 @@ class _MessageWidgetState extends State<MessageWidget>
|
|||||||
builder: (context) => StreamChannel(
|
builder: (context) => StreamChannel(
|
||||||
channel: channel,
|
channel: channel,
|
||||||
child: MessageReactionsModal(
|
child: MessageReactionsModal(
|
||||||
textBuilder: widget.textBuilder,
|
messageWidget: widget.copyWith(
|
||||||
attachmentBorderRadiusGeometry:
|
key: const Key('MessageWidget'),
|
||||||
widget.attachmentBorderRadiusGeometry as BorderRadius?,
|
message: widget.message.copyWith(
|
||||||
showUserAvatar:
|
text: widget.message.text!.length > 200
|
||||||
widget.message.user!.id == channel.client.state.user!.id
|
? '${widget.message.text!.substring(0, 200)}...'
|
||||||
? DisplayWidget.gone
|
: widget.message.text,
|
||||||
: DisplayWidget.show,
|
),
|
||||||
|
showReactions: false,
|
||||||
|
showUsername: false,
|
||||||
|
showTimestamp: false,
|
||||||
|
translateUserAvatar: false,
|
||||||
|
showSendingIndicator: false,
|
||||||
|
padding: const EdgeInsets.all(0),
|
||||||
|
showReactionPickerIndicator: widget.showReactions &&
|
||||||
|
(widget.message.status == MessageSendingStatus.sent),
|
||||||
|
showPinHighlight: false,
|
||||||
|
showUserAvatar:
|
||||||
|
widget.message.user!.id == channel.client.state.user!.id
|
||||||
|
? DisplayWidget.gone
|
||||||
|
: DisplayWidget.show,
|
||||||
|
),
|
||||||
onUserAvatarTap: widget.onUserAvatarTap,
|
onUserAvatarTap: widget.onUserAvatarTap,
|
||||||
messageTheme: widget.messageTheme,
|
messageTheme: widget.messageTheme,
|
||||||
messageShape: widget.shape ?? _getDefaultShape(context),
|
|
||||||
attachmentShape:
|
|
||||||
widget.attachmentShape ?? _getDefaultAttachmentShape(context),
|
|
||||||
reverse: widget.reverse,
|
reverse: widget.reverse,
|
||||||
message: widget.message,
|
message: widget.message,
|
||||||
showReactions: widget.showReactions,
|
showReactions: widget.showReactions,
|
||||||
|
|||||||
Reference in New Issue
Block a user