lint changes message
This commit is contained in:
@@ -15,17 +15,17 @@ import 'package:stream_chat_flutter/src/quoted_message_widget.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/url_attachment.dart';
|
import 'package:stream_chat_flutter/src/url_attachment.dart';
|
||||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||||
|
import 'package:stream_chat_flutter/src/image_group.dart';
|
||||||
|
import 'package:stream_chat_flutter/src/extension.dart';
|
||||||
|
|
||||||
import 'attachment/attachment.dart';
|
/// Widget builder for building attachments
|
||||||
import 'extension.dart';
|
|
||||||
import 'image_group.dart';
|
|
||||||
import 'message_text.dart';
|
|
||||||
|
|
||||||
typedef AttachmentBuilder = Widget Function(
|
typedef AttachmentBuilder = Widget Function(
|
||||||
BuildContext,
|
BuildContext,
|
||||||
Message,
|
Message,
|
||||||
List<Attachment>,
|
List<Attachment>,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/// Callback for when quoted message is tapped
|
||||||
typedef OnQuotedMessageTap = void Function(String?);
|
typedef OnQuotedMessageTap = void Function(String?);
|
||||||
|
|
||||||
/// The display behaviour of a widget
|
/// The display behaviour of a widget
|
||||||
@@ -45,119 +45,13 @@ enum DisplayWidget {
|
|||||||
///
|
///
|
||||||
/// It shows a message with reactions, replies and user avatar.
|
/// It shows a message with reactions, replies and user avatar.
|
||||||
///
|
///
|
||||||
/// Usually you don't use this widget as it's the default message widget used by [MessageListView].
|
/// Usually you don't use this widget as it's the default message widget used by
|
||||||
|
/// [MessageListView].
|
||||||
///
|
///
|
||||||
/// The widget components render the ui based on the first ancestor of type [StreamChatTheme].
|
/// The widget components render the ui based on the first ancestor of type
|
||||||
|
/// [StreamChatTheme].
|
||||||
/// Modify it to change the widget appearance.
|
/// Modify it to change the widget appearance.
|
||||||
class MessageWidget extends StatefulWidget {
|
class MessageWidget extends StatefulWidget {
|
||||||
/// Function called on mention tap
|
|
||||||
final void Function(User)? onMentionTap;
|
|
||||||
|
|
||||||
/// The function called when tapping on replies
|
|
||||||
final void Function(Message)? onThreadTap;
|
|
||||||
final void Function(Message)? onReplyTap;
|
|
||||||
final Widget Function(BuildContext, Message)? editMessageInputBuilder;
|
|
||||||
final Widget Function(BuildContext, Message)? textBuilder;
|
|
||||||
|
|
||||||
/// Function called on long press
|
|
||||||
final void Function(BuildContext, Message)? onMessageActions;
|
|
||||||
|
|
||||||
/// The message
|
|
||||||
final Message message;
|
|
||||||
|
|
||||||
/// The message theme
|
|
||||||
final MessageTheme messageTheme;
|
|
||||||
|
|
||||||
/// If true the widget will be mirrored
|
|
||||||
final bool reverse;
|
|
||||||
|
|
||||||
/// The shape of the message text
|
|
||||||
final ShapeBorder? shape;
|
|
||||||
|
|
||||||
/// The shape of an attachment
|
|
||||||
final ShapeBorder? attachmentShape;
|
|
||||||
|
|
||||||
/// The borderside of the message text
|
|
||||||
final BorderSide? borderSide;
|
|
||||||
|
|
||||||
/// The borderside of an attachment
|
|
||||||
final BorderSide? attachmentBorderSide;
|
|
||||||
|
|
||||||
/// The border radius of the message text
|
|
||||||
final BorderRadiusGeometry? borderRadiusGeometry;
|
|
||||||
|
|
||||||
/// The border radius of an attachment
|
|
||||||
final BorderRadiusGeometry? attachmentBorderRadiusGeometry;
|
|
||||||
|
|
||||||
/// The padding of the widget
|
|
||||||
final EdgeInsetsGeometry? padding;
|
|
||||||
|
|
||||||
/// The internal padding of the message text
|
|
||||||
final EdgeInsets textPadding;
|
|
||||||
|
|
||||||
/// The internal padding of an attachment
|
|
||||||
final EdgeInsetsGeometry attachmentPadding;
|
|
||||||
|
|
||||||
/// It controls the display behaviour of the user avatar
|
|
||||||
final DisplayWidget showUserAvatar;
|
|
||||||
|
|
||||||
/// It controls the display behaviour of the sending indicator
|
|
||||||
final bool showSendingIndicator;
|
|
||||||
|
|
||||||
/// If true the widget will show the reactions
|
|
||||||
final bool showReactions;
|
|
||||||
|
|
||||||
final bool allRead;
|
|
||||||
|
|
||||||
/// If true the widget will show the thread reply indicator
|
|
||||||
final bool showThreadReplyIndicator;
|
|
||||||
|
|
||||||
/// If true the widget will show the show in channel indicator
|
|
||||||
final bool showInChannelIndicator;
|
|
||||||
|
|
||||||
/// The function called when tapping on UserAvatar
|
|
||||||
final void Function(User)? onUserAvatarTap;
|
|
||||||
|
|
||||||
/// The function called when tapping on a link
|
|
||||||
final void Function(String)? onLinkTap;
|
|
||||||
|
|
||||||
/// Used in [MessageReactionsModal] and [MessageActionsModal]
|
|
||||||
final bool showReactionPickerIndicator;
|
|
||||||
|
|
||||||
final List<Read>? readList;
|
|
||||||
|
|
||||||
final ShowMessageCallback? onShowMessage;
|
|
||||||
final ValueChanged<ReturnActionType>? onReturnAction;
|
|
||||||
|
|
||||||
/// If true show the users username next to the timestamp of the message
|
|
||||||
final bool showUsername;
|
|
||||||
final bool showTimestamp;
|
|
||||||
|
|
||||||
final bool showReplyMessage;
|
|
||||||
final bool showThreadReplyMessage;
|
|
||||||
final bool showEditMessage;
|
|
||||||
final bool showCopyMessage;
|
|
||||||
final bool showDeleteMessage;
|
|
||||||
final bool showResendMessage;
|
|
||||||
|
|
||||||
final bool showFlagButton;
|
|
||||||
final Map<String, AttachmentBuilder> attachmentBuilders;
|
|
||||||
|
|
||||||
/// Center user avatar with bottom of the message
|
|
||||||
final bool translateUserAvatar;
|
|
||||||
|
|
||||||
/// Function called when quotedMessage is tapped
|
|
||||||
final OnQuotedMessageTap? onQuotedMessageTap;
|
|
||||||
|
|
||||||
/// Function called when message is tapped
|
|
||||||
final void Function(Message)? onMessageTap;
|
|
||||||
|
|
||||||
/// List of custom actions shown on message long tap
|
|
||||||
final List<MessageAction> customActions;
|
|
||||||
|
|
||||||
// Customize onTap on attachment
|
|
||||||
final void Function(Message message, Attachment attachment)? onAttachmentTap;
|
|
||||||
|
|
||||||
///
|
///
|
||||||
MessageWidget({
|
MessageWidget({
|
||||||
Key? key,
|
Key? key,
|
||||||
@@ -273,24 +167,24 @@ class MessageWidget extends StatefulWidget {
|
|||||||
return wrapAttachmentWidget(
|
return wrapAttachmentWidget(
|
||||||
context,
|
context,
|
||||||
Column(
|
Column(
|
||||||
children: attachments.map((attachment) {
|
children: attachments
|
||||||
return VideoAttachment(
|
.map((attachment) => VideoAttachment(
|
||||||
attachment: attachment,
|
attachment: attachment,
|
||||||
messageTheme: messageTheme,
|
messageTheme: messageTheme,
|
||||||
size: Size(
|
size: Size(
|
||||||
MediaQuery.of(context).size.width * 0.8,
|
MediaQuery.of(context).size.width * 0.8,
|
||||||
MediaQuery.of(context).size.height * 0.3,
|
MediaQuery.of(context).size.height * 0.3,
|
||||||
),
|
),
|
||||||
message: message,
|
message: message,
|
||||||
onShowMessage: onShowMessage,
|
onShowMessage: onShowMessage,
|
||||||
onReturnAction: onReturnAction,
|
onReturnAction: onReturnAction,
|
||||||
onAttachmentTap: onAttachmentTap != null
|
onAttachmentTap: onAttachmentTap != null
|
||||||
? () {
|
? () {
|
||||||
onAttachmentTap(message, attachment);
|
onAttachmentTap(message, attachment);
|
||||||
}
|
}
|
||||||
: null,
|
: null,
|
||||||
);
|
))
|
||||||
}).toList(),
|
.toList(),
|
||||||
),
|
),
|
||||||
border,
|
border,
|
||||||
reverse,
|
reverse,
|
||||||
@@ -306,18 +200,18 @@ class MessageWidget extends StatefulWidget {
|
|||||||
return wrapAttachmentWidget(
|
return wrapAttachmentWidget(
|
||||||
context,
|
context,
|
||||||
Column(
|
Column(
|
||||||
children: attachments.map((attachment) {
|
children: attachments
|
||||||
return GiphyAttachment(
|
.map((attachment) => GiphyAttachment(
|
||||||
attachment: attachment,
|
attachment: attachment,
|
||||||
message: message,
|
message: message,
|
||||||
size: Size(
|
size: Size(
|
||||||
MediaQuery.of(context).size.width * 0.8,
|
MediaQuery.of(context).size.width * 0.8,
|
||||||
MediaQuery.of(context).size.height * 0.3,
|
MediaQuery.of(context).size.height * 0.3,
|
||||||
),
|
),
|
||||||
onShowMessage: onShowMessage,
|
onShowMessage: onShowMessage,
|
||||||
onReturnAction: onReturnAction,
|
onReturnAction: onReturnAction,
|
||||||
);
|
))
|
||||||
}).toList(),
|
.toList(),
|
||||||
),
|
),
|
||||||
border,
|
border,
|
||||||
reverse,
|
reverse,
|
||||||
@@ -336,23 +230,21 @@ class MessageWidget extends StatefulWidget {
|
|||||||
|
|
||||||
return Column(
|
return Column(
|
||||||
children: attachments
|
children: attachments
|
||||||
.map<Widget>((attachment) {
|
.map<Widget>((attachment) => wrapAttachmentWidget(
|
||||||
return wrapAttachmentWidget(
|
context,
|
||||||
context,
|
FileAttachment(
|
||||||
FileAttachment(
|
message: message,
|
||||||
message: message,
|
attachment: attachment,
|
||||||
attachment: attachment,
|
size: Size(
|
||||||
size: Size(
|
MediaQuery.of(context).size.width * 0.8,
|
||||||
MediaQuery.of(context).size.width * 0.8,
|
MediaQuery.of(context).size.height * 0.3,
|
||||||
MediaQuery.of(context).size.height * 0.3,
|
),
|
||||||
),
|
),
|
||||||
),
|
border,
|
||||||
border,
|
reverse,
|
||||||
reverse,
|
attachmentBorderRadiusGeometry as BorderRadius? ??
|
||||||
attachmentBorderRadiusGeometry as BorderRadius? ??
|
BorderRadius.zero,
|
||||||
BorderRadius.zero,
|
))
|
||||||
);
|
|
||||||
})
|
|
||||||
.insertBetween(SizedBox(
|
.insertBetween(SizedBox(
|
||||||
height: attachmentPadding.vertical / 2,
|
height: attachmentPadding.vertical / 2,
|
||||||
))
|
))
|
||||||
@@ -362,6 +254,141 @@ class MessageWidget extends StatefulWidget {
|
|||||||
}..addAll(customAttachmentBuilders ?? {}),
|
}..addAll(customAttachmentBuilders ?? {}),
|
||||||
super(key: key);
|
super(key: key);
|
||||||
|
|
||||||
|
/// Function called on mention tap
|
||||||
|
final void Function(User)? onMentionTap;
|
||||||
|
|
||||||
|
/// The function called when tapping on threads
|
||||||
|
final void Function(Message)? onThreadTap;
|
||||||
|
|
||||||
|
/// The function called when tapping on replies
|
||||||
|
final void Function(Message)? onReplyTap;
|
||||||
|
|
||||||
|
/// Widget builder for edit message layout
|
||||||
|
final Widget Function(BuildContext, Message)? editMessageInputBuilder;
|
||||||
|
|
||||||
|
/// Widget builder for building text
|
||||||
|
final Widget Function(BuildContext, Message)? textBuilder;
|
||||||
|
|
||||||
|
/// Function called on long press
|
||||||
|
final void Function(BuildContext, Message)? onMessageActions;
|
||||||
|
|
||||||
|
/// The message
|
||||||
|
final Message message;
|
||||||
|
|
||||||
|
/// The message theme
|
||||||
|
final MessageTheme messageTheme;
|
||||||
|
|
||||||
|
/// If true the widget will be mirrored
|
||||||
|
final bool reverse;
|
||||||
|
|
||||||
|
/// The shape of the message text
|
||||||
|
final ShapeBorder? shape;
|
||||||
|
|
||||||
|
/// The shape of an attachment
|
||||||
|
final ShapeBorder? attachmentShape;
|
||||||
|
|
||||||
|
/// The borderside of the message text
|
||||||
|
final BorderSide? borderSide;
|
||||||
|
|
||||||
|
/// The borderside of an attachment
|
||||||
|
final BorderSide? attachmentBorderSide;
|
||||||
|
|
||||||
|
/// The border radius of the message text
|
||||||
|
final BorderRadiusGeometry? borderRadiusGeometry;
|
||||||
|
|
||||||
|
/// The border radius of an attachment
|
||||||
|
final BorderRadiusGeometry? attachmentBorderRadiusGeometry;
|
||||||
|
|
||||||
|
/// The padding of the widget
|
||||||
|
final EdgeInsetsGeometry? padding;
|
||||||
|
|
||||||
|
/// The internal padding of the message text
|
||||||
|
final EdgeInsets textPadding;
|
||||||
|
|
||||||
|
/// The internal padding of an attachment
|
||||||
|
final EdgeInsetsGeometry attachmentPadding;
|
||||||
|
|
||||||
|
/// It controls the display behaviour of the user avatar
|
||||||
|
final DisplayWidget showUserAvatar;
|
||||||
|
|
||||||
|
/// It controls the display behaviour of the sending indicator
|
||||||
|
final bool showSendingIndicator;
|
||||||
|
|
||||||
|
/// If true the widget will show the reactions
|
||||||
|
final bool showReactions;
|
||||||
|
|
||||||
|
///
|
||||||
|
final bool allRead;
|
||||||
|
|
||||||
|
/// If true the widget will show the thread reply indicator
|
||||||
|
final bool showThreadReplyIndicator;
|
||||||
|
|
||||||
|
/// If true the widget will show the show in channel indicator
|
||||||
|
final bool showInChannelIndicator;
|
||||||
|
|
||||||
|
/// The function called when tapping on UserAvatar
|
||||||
|
final void Function(User)? onUserAvatarTap;
|
||||||
|
|
||||||
|
/// The function called when tapping on a link
|
||||||
|
final void Function(String)? onLinkTap;
|
||||||
|
|
||||||
|
/// Used in [MessageReactionsModal] and [MessageActionsModal]
|
||||||
|
final bool showReactionPickerIndicator;
|
||||||
|
|
||||||
|
/// List of users who read
|
||||||
|
final List<Read>? readList;
|
||||||
|
|
||||||
|
/// Callback when show message is tapped
|
||||||
|
final ShowMessageCallback? onShowMessage;
|
||||||
|
|
||||||
|
/// Handle return actions like reply message
|
||||||
|
final ValueChanged<ReturnActionType>? onReturnAction;
|
||||||
|
|
||||||
|
/// If true show the users username next to the timestamp of the message
|
||||||
|
final bool showUsername;
|
||||||
|
|
||||||
|
/// Show message timestamp
|
||||||
|
final bool showTimestamp;
|
||||||
|
|
||||||
|
/// Show reply action
|
||||||
|
final bool showReplyMessage;
|
||||||
|
|
||||||
|
/// Show thread reply action
|
||||||
|
final bool showThreadReplyMessage;
|
||||||
|
|
||||||
|
/// Show edit action
|
||||||
|
final bool showEditMessage;
|
||||||
|
|
||||||
|
/// Show copy action
|
||||||
|
final bool showCopyMessage;
|
||||||
|
|
||||||
|
/// Show delete action
|
||||||
|
final bool showDeleteMessage;
|
||||||
|
|
||||||
|
/// Show resend action
|
||||||
|
final bool showResendMessage;
|
||||||
|
|
||||||
|
/// Show flag action
|
||||||
|
final bool showFlagButton;
|
||||||
|
|
||||||
|
/// Builder for respective attachment types
|
||||||
|
final Map<String, AttachmentBuilder> attachmentBuilders;
|
||||||
|
|
||||||
|
/// Center user avatar with bottom of the message
|
||||||
|
final bool translateUserAvatar;
|
||||||
|
|
||||||
|
/// Function called when quotedMessage is tapped
|
||||||
|
final OnQuotedMessageTap? onQuotedMessageTap;
|
||||||
|
|
||||||
|
/// Function called when message is tapped
|
||||||
|
final void Function(Message)? onMessageTap;
|
||||||
|
|
||||||
|
/// List of custom actions shown on message long tap
|
||||||
|
final List<MessageAction> customActions;
|
||||||
|
|
||||||
|
/// Customize onTap on attachment
|
||||||
|
final void Function(Message message, Attachment attachment)? onAttachmentTap;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_MessageWidgetState createState() => _MessageWidgetState();
|
_MessageWidgetState createState() => _MessageWidgetState();
|
||||||
}
|
}
|
||||||
@@ -437,7 +464,7 @@ class _MessageWidgetState extends State<MessageWidget>
|
|||||||
? null
|
? null
|
||||||
: () => onLongPress(context),
|
: () => onLongPress(context),
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: widget.padding ?? EdgeInsets.all(8),
|
padding: widget.padding ?? const 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),
|
||||||
@@ -464,7 +491,7 @@ class _MessageWidgetState extends State<MessageWidget>
|
|||||||
DisplayWidget.show &&
|
DisplayWidget.show &&
|
||||||
widget.message.user != null) ...[
|
widget.message.user != null) ...[
|
||||||
_buildUserAvatar(),
|
_buildUserAvatar(),
|
||||||
SizedBox(width: 4),
|
const SizedBox(width: 4),
|
||||||
],
|
],
|
||||||
if (widget.showUserAvatar == DisplayWidget.hide)
|
if (widget.showUserAvatar == DisplayWidget.hide)
|
||||||
SizedBox(width: avatarWidth + 4),
|
SizedBox(width: avatarWidth + 4),
|
||||||
@@ -473,12 +500,12 @@ class _MessageWidgetState extends State<MessageWidget>
|
|||||||
portal: Container(
|
portal: Container(
|
||||||
transform:
|
transform:
|
||||||
Matrix4.translationValues(-12, 0, 0),
|
Matrix4.translationValues(-12, 0, 0),
|
||||||
constraints:
|
constraints: const BoxConstraints(
|
||||||
BoxConstraints(maxWidth: 22 * 6.0),
|
maxWidth: 22 * 6.0),
|
||||||
child: _buildReactionIndicator(context),
|
child: _buildReactionIndicator(context),
|
||||||
),
|
),
|
||||||
portalAnchor: Alignment(-1, -1),
|
portalAnchor: const Alignment(-1, -1),
|
||||||
childAnchor: Alignment(1, -1),
|
childAnchor: const Alignment(1, -1),
|
||||||
child: Stack(
|
child: Stack(
|
||||||
clipBehavior: Clip.none,
|
clipBehavior: Clip.none,
|
||||||
children: [
|
children: [
|
||||||
@@ -501,15 +528,18 @@ class _MessageWidgetState extends State<MessageWidget>
|
|||||||
transform: Matrix4.rotationY(
|
transform: Matrix4.rotationY(
|
||||||
widget.reverse ? pi : 0),
|
widget.reverse ? pi : 0),
|
||||||
child: Container(
|
child: Container(
|
||||||
|
// ignore: lines_longer_than_80_chars
|
||||||
margin: EdgeInsets.symmetric(
|
margin: EdgeInsets.symmetric(
|
||||||
horizontal:
|
horizontal:
|
||||||
|
// ignore: lines_longer_than_80_chars
|
||||||
widget.showUserAvatar ==
|
widget.showUserAvatar ==
|
||||||
DisplayWidget
|
// ignore: lines_longer_than_80_chars
|
||||||
.gone
|
DisplayWidget.gone
|
||||||
? 0
|
? 0
|
||||||
: 4.0),
|
: 4.0),
|
||||||
child: DeletedMessage(
|
child: DeletedMessage(
|
||||||
reverse: widget.reverse,
|
reverse: widget.reverse,
|
||||||
|
// ignore: lines_longer_than_80_chars
|
||||||
borderRadiusGeometry: widget
|
borderRadiusGeometry: widget
|
||||||
.borderRadiusGeometry,
|
.borderRadiusGeometry,
|
||||||
borderSide:
|
borderSide:
|
||||||
@@ -527,6 +557,7 @@ class _MessageWidgetState extends State<MessageWidget>
|
|||||||
horizontal: (isFailedState
|
horizontal: (isFailedState
|
||||||
? 15.0
|
? 15.0
|
||||||
: 0.0) +
|
: 0.0) +
|
||||||
|
// ignore: lines_longer_than_80_chars
|
||||||
(widget.showUserAvatar ==
|
(widget.showUserAvatar ==
|
||||||
DisplayWidget
|
DisplayWidget
|
||||||
.gone
|
.gone
|
||||||
@@ -539,11 +570,14 @@ class _MessageWidgetState extends State<MessageWidget>
|
|||||||
.borderSide ??
|
.borderSide ??
|
||||||
BorderSide(
|
BorderSide(
|
||||||
color: widget
|
color: widget
|
||||||
|
// ignore: lines_longer_than_80_chars
|
||||||
.messageTheme
|
.messageTheme
|
||||||
|
// ignore: lines_longer_than_80_chars
|
||||||
.messageBorderColor ??
|
.messageBorderColor ??
|
||||||
Colors.grey,
|
Colors.grey,
|
||||||
),
|
),
|
||||||
borderRadius: widget
|
borderRadius: widget
|
||||||
|
// ignore: lines_longer_than_80_chars
|
||||||
.borderRadiusGeometry ??
|
.borderRadiusGeometry ??
|
||||||
BorderRadius.zero,
|
BorderRadius.zero,
|
||||||
),
|
),
|
||||||
@@ -648,7 +682,7 @@ class _MessageWidgetState extends State<MessageWidget>
|
|||||||
color: StreamChatTheme.of(context).colorTheme.grey,
|
color: StreamChatTheme.of(context).colorTheme.grey,
|
||||||
size: 16,
|
size: 16,
|
||||||
),
|
),
|
||||||
SizedBox(width: 8),
|
const SizedBox(width: 8),
|
||||||
Text(
|
Text(
|
||||||
'Only visible to you',
|
'Only visible to you',
|
||||||
style: StreamChatTheme.of(context)
|
style: StreamChatTheme.of(context)
|
||||||
@@ -672,6 +706,7 @@ class _MessageWidgetState extends State<MessageWidget>
|
|||||||
msg = '$replyCount Thread Replies';
|
msg = '$replyCount Thread Replies';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ignore: prefer_function_declarations_over_variables
|
||||||
final onThreadTap = () async {
|
final onThreadTap = () async {
|
||||||
try {
|
try {
|
||||||
var message = widget.message;
|
var message = widget.message;
|
||||||
@@ -683,6 +718,7 @@ class _MessageWidgetState extends State<MessageWidget>
|
|||||||
} catch (e, stk) {
|
} catch (e, stk) {
|
||||||
print(e);
|
print(e);
|
||||||
print(stk);
|
print(stk);
|
||||||
|
// ignore: avoid_returning_null_for_void
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -730,7 +766,7 @@ class _MessageWidgetState extends State<MessageWidget>
|
|||||||
((widget.messageTheme.replies?.fontSize ?? 1) / 2),
|
((widget.messageTheme.replies?.fontSize ?? 1) / 2),
|
||||||
),
|
),
|
||||||
child: CustomPaint(
|
child: CustomPaint(
|
||||||
size: Size(16, 32) * context.textScaleFactor,
|
size: const Size(16, 32) * context.textScaleFactor,
|
||||||
painter: _ThreadReplyPainter(
|
painter: _ThreadReplyPainter(
|
||||||
context: context,
|
context: context,
|
||||||
color: widget.messageTheme.messageBorderColor,
|
color: widget.messageTheme.messageBorderColor,
|
||||||
@@ -742,7 +778,7 @@ class _MessageWidgetState extends State<MessageWidget>
|
|||||||
Widget mappedChild = Transform(
|
Widget mappedChild = Transform(
|
||||||
transform: Matrix4.rotationY(widget.reverse ? pi : 0),
|
transform: Matrix4.rotationY(widget.reverse ? pi : 0),
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
child: Container(
|
child: SizedBox(
|
||||||
height: context.textScaleFactor * 14,
|
height: context.textScaleFactor * 14,
|
||||||
child: child,
|
child: child,
|
||||||
),
|
),
|
||||||
@@ -792,7 +828,7 @@ class _MessageWidgetState extends State<MessageWidget>
|
|||||||
padding: const EdgeInsets.all(1),
|
padding: const EdgeInsets.all(1),
|
||||||
child: UserAvatar(
|
child: UserAvatar(
|
||||||
user: user,
|
user: user,
|
||||||
constraints: BoxConstraints.loose(Size.fromRadius(7)),
|
constraints: BoxConstraints.loose(const Size.fromRadius(7)),
|
||||||
showOnlineStatus: false,
|
showOnlineStatus: false,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -816,7 +852,7 @@ class _MessageWidgetState extends State<MessageWidget>
|
|||||||
..sort((a, b) => a.user!.id == ownId ? 1 : -1);
|
..sort((a, b) => a.user!.id == ownId ? 1 : -1);
|
||||||
|
|
||||||
return AnimatedSwitcher(
|
return AnimatedSwitcher(
|
||||||
duration: Duration(milliseconds: 300),
|
duration: const Duration(milliseconds: 300),
|
||||||
child: (widget.showReactions &&
|
child: (widget.showReactions &&
|
||||||
(widget.message.reactionCounts?.isNotEmpty == true) &&
|
(widget.message.reactionCounts?.isNotEmpty == true) &&
|
||||||
!widget.message.isDeleted)
|
!widget.message.isDeleted)
|
||||||
@@ -835,7 +871,7 @@ class _MessageWidgetState extends State<MessageWidget>
|
|||||||
reactions: reactionsList,
|
reactions: reactionsList,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
: SizedBox(),
|
: const SizedBox(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -845,78 +881,75 @@ class _MessageWidgetState extends State<MessageWidget>
|
|||||||
showDialog(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
barrierColor: StreamChatTheme.of(context).colorTheme.overlay,
|
barrierColor: StreamChatTheme.of(context).colorTheme.overlay,
|
||||||
builder: (context) {
|
builder: (context) => StreamChannel(
|
||||||
return StreamChannel(
|
channel: channel,
|
||||||
channel: channel,
|
child: MessageActionsModal(
|
||||||
child: MessageActionsModal(
|
onCopyTap: (message) =>
|
||||||
onCopyTap: (message) =>
|
Clipboard.setData(ClipboardData(text: message.text)),
|
||||||
Clipboard.setData(ClipboardData(text: message.text)),
|
attachmentBorderRadiusGeometry:
|
||||||
attachmentBorderRadiusGeometry:
|
widget.attachmentBorderRadiusGeometry as BorderRadius?,
|
||||||
widget.attachmentBorderRadiusGeometry as BorderRadius?,
|
showUserAvatar:
|
||||||
showUserAvatar:
|
widget.message.user!.id == channel.client.state.user!.id
|
||||||
widget.message.user!.id == channel.client.state.user!.id
|
? DisplayWidget.gone
|
||||||
? DisplayWidget.gone
|
: DisplayWidget.show,
|
||||||
: DisplayWidget.show,
|
messageTheme: widget.messageTheme,
|
||||||
messageTheme: widget.messageTheme,
|
messageShape: widget.shape ?? _getDefaultShape(context),
|
||||||
messageShape: widget.shape ?? _getDefaultShape(context),
|
attachmentShape: widget.attachmentShape ??
|
||||||
attachmentShape:
|
_getDefaultAttachmentShape(context),
|
||||||
widget.attachmentShape ?? _getDefaultAttachmentShape(context),
|
reverse: widget.reverse,
|
||||||
reverse: widget.reverse,
|
showDeleteMessage: widget.showDeleteMessage || isDeleteFailed,
|
||||||
showDeleteMessage: widget.showDeleteMessage || isDeleteFailed,
|
message: widget.message,
|
||||||
message: widget.message,
|
editMessageInputBuilder: widget.editMessageInputBuilder,
|
||||||
editMessageInputBuilder: widget.editMessageInputBuilder,
|
onReplyTap: widget.onReplyTap,
|
||||||
onReplyTap: widget.onReplyTap,
|
onThreadReplyTap: widget.onThreadTap,
|
||||||
onThreadReplyTap: widget.onThreadTap,
|
showResendMessage: widget.showResendMessage &&
|
||||||
showResendMessage:
|
(isSendFailed || isUpdateFailed),
|
||||||
widget.showResendMessage && (isSendFailed || isUpdateFailed),
|
showCopyMessage: widget.showCopyMessage &&
|
||||||
showCopyMessage: widget.showCopyMessage &&
|
!isFailedState &&
|
||||||
!isFailedState &&
|
widget.message.text?.trim().isNotEmpty == true,
|
||||||
widget.message.text?.trim().isNotEmpty == true,
|
showEditMessage: widget.showEditMessage &&
|
||||||
showEditMessage: widget.showEditMessage &&
|
!isDeleteFailed &&
|
||||||
!isDeleteFailed &&
|
widget.message.attachments
|
||||||
widget.message.attachments
|
.any((element) => element.type == 'giphy') !=
|
||||||
.any((element) => element.type == 'giphy') !=
|
true,
|
||||||
true,
|
showReactions: widget.showReactions,
|
||||||
showReactions: widget.showReactions,
|
showReplyMessage: widget.showReplyMessage &&
|
||||||
showReplyMessage: widget.showReplyMessage &&
|
!isFailedState &&
|
||||||
!isFailedState &&
|
widget.onReplyTap != null,
|
||||||
widget.onReplyTap != null,
|
showThreadReplyMessage: widget.showThreadReplyMessage &&
|
||||||
showThreadReplyMessage: widget.showThreadReplyMessage &&
|
!isFailedState &&
|
||||||
!isFailedState &&
|
widget.onThreadTap != null,
|
||||||
widget.onThreadTap != null,
|
showFlagButton: widget.showFlagButton,
|
||||||
showFlagButton: widget.showFlagButton,
|
customActions: widget.customActions,
|
||||||
customActions: widget.customActions,
|
),
|
||||||
),
|
));
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void _showMessageReactionsModalBottomSheet(BuildContext context) {
|
void _showMessageReactionsModalBottomSheet(BuildContext context) {
|
||||||
final channel = StreamChannel.of(context).channel;
|
final channel = StreamChannel.of(context).channel;
|
||||||
showDialog(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
barrierColor: StreamChatTheme.of(context).colorTheme.overlay,
|
barrierColor: StreamChatTheme.of(context).colorTheme.overlay,
|
||||||
builder: (context) {
|
builder: (context) => StreamChannel(
|
||||||
return StreamChannel(
|
channel: channel,
|
||||||
channel: channel,
|
child: MessageReactionsModal(
|
||||||
child: MessageReactionsModal(
|
attachmentBorderRadiusGeometry:
|
||||||
attachmentBorderRadiusGeometry:
|
widget.attachmentBorderRadiusGeometry as BorderRadius?,
|
||||||
widget.attachmentBorderRadiusGeometry as BorderRadius?,
|
showUserAvatar:
|
||||||
showUserAvatar:
|
widget.message.user!.id == channel.client.state.user!.id
|
||||||
widget.message.user!.id == channel.client.state.user!.id
|
? DisplayWidget.gone
|
||||||
? DisplayWidget.gone
|
: DisplayWidget.show,
|
||||||
: DisplayWidget.show,
|
onUserAvatarTap: widget.onUserAvatarTap,
|
||||||
onUserAvatarTap: widget.onUserAvatarTap,
|
messageTheme: widget.messageTheme,
|
||||||
messageTheme: widget.messageTheme,
|
messageShape: widget.shape ?? _getDefaultShape(context),
|
||||||
messageShape: widget.shape ?? _getDefaultShape(context),
|
attachmentShape:
|
||||||
attachmentShape:
|
widget.attachmentShape ?? _getDefaultAttachmentShape(context),
|
||||||
widget.attachmentShape ?? _getDefaultAttachmentShape(context),
|
reverse: widget.reverse,
|
||||||
reverse: widget.reverse,
|
message: widget.message,
|
||||||
message: widget.message,
|
showReactions: widget.showReactions,
|
||||||
showReactions: widget.showReactions,
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ShapeBorder _getDefaultAttachmentShape(BuildContext context) {
|
ShapeBorder _getDefaultAttachmentShape(BuildContext context) {
|
||||||
@@ -933,15 +966,13 @@ class _MessageWidgetState extends State<MessageWidget>
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
ShapeBorder _getDefaultShape(BuildContext context) {
|
ShapeBorder _getDefaultShape(BuildContext context) => RoundedRectangleBorder(
|
||||||
return RoundedRectangleBorder(
|
side: widget.borderSide ??
|
||||||
side: widget.borderSide ??
|
BorderSide(
|
||||||
BorderSide(
|
color: StreamChatTheme.of(context).colorTheme.greyWhisper,
|
||||||
color: StreamChatTheme.of(context).colorTheme.greyWhisper,
|
),
|
||||||
),
|
borderRadius: widget.borderRadiusGeometry ?? BorderRadius.zero,
|
||||||
borderRadius: widget.borderRadiusGeometry ?? BorderRadius.zero,
|
);
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget _parseAttachments() {
|
Widget _parseAttachments() {
|
||||||
final attachmentGroups = <String, List<Attachment>>{};
|
final attachmentGroups = <String, List<Attachment>>{};
|
||||||
@@ -1003,9 +1034,8 @@ class _MessageWidgetState extends State<MessageWidget>
|
|||||||
(message.status == MessageSendingStatus.sending ||
|
(message.status == MessageSendingStatus.sending ||
|
||||||
message.status == MessageSendingStatus.updating)) {
|
message.status == MessageSendingStatus.updating)) {
|
||||||
final totalAttachments = message.attachments.length;
|
final totalAttachments = message.attachments.length;
|
||||||
final uploadRemaining = message.attachments.where((it) {
|
final uploadRemaining =
|
||||||
return !it.uploadState.isSuccess;
|
message.attachments.where((it) => !it.uploadState.isSuccess).length;
|
||||||
}).length;
|
|
||||||
if (uploadRemaining == 0) {
|
if (uploadRemaining == 0) {
|
||||||
return StreamSvgIcon.check(
|
return StreamSvgIcon.check(
|
||||||
size: style!.fontSize,
|
size: style!.fontSize,
|
||||||
@@ -1033,7 +1063,7 @@ class _MessageWidgetState extends State<MessageWidget>
|
|||||||
color: StreamChatTheme.of(context).colorTheme.accentBlue,
|
color: StreamChatTheme.of(context).colorTheme.accentBlue,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
SizedBox(width: 2),
|
const SizedBox(width: 2),
|
||||||
child,
|
child,
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
@@ -1064,7 +1094,7 @@ class _MessageWidgetState extends State<MessageWidget>
|
|||||||
);
|
);
|
||||||
|
|
||||||
Widget _buildTextBubble() {
|
Widget _buildTextBubble() {
|
||||||
if (widget.message.text!.trim().isEmpty) return Offstage();
|
if (widget.message.text!.trim().isEmpty) return const Offstage();
|
||||||
return Transform(
|
return Transform(
|
||||||
transform: Matrix4.rotationY(widget.reverse ? pi : 0),
|
transform: Matrix4.rotationY(widget.reverse ? pi : 0),
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
@@ -1135,11 +1165,11 @@ class _MessageWidgetState extends State<MessageWidget>
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _ThreadReplyPainter extends CustomPainter {
|
class _ThreadReplyPainter extends CustomPainter {
|
||||||
|
const _ThreadReplyPainter({this.context, required this.color});
|
||||||
|
|
||||||
final Color? color;
|
final Color? color;
|
||||||
final BuildContext? context;
|
final BuildContext? context;
|
||||||
|
|
||||||
const _ThreadReplyPainter({this.context, required this.color});
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void paint(Canvas canvas, Size size) {
|
void paint(Canvas canvas, Size size) {
|
||||||
final paint = Paint()
|
final paint = Paint()
|
||||||
|
|||||||
Reference in New Issue
Block a user