[MessageWidget] Fix widget gesture detector
Signed-off-by: Sahil Kumar <[email protected]>
This commit is contained in:
+81
-84
@@ -317,58 +317,64 @@ class _MessageWidgetState extends State<MessageWidget> {
|
|||||||
messageTheme: widget.messageTheme,
|
messageTheme: widget.messageTheme,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
: Material(
|
: GestureDetector(
|
||||||
clipBehavior: Clip.antiAlias,
|
onTap: () => retryMessage(context),
|
||||||
shape: widget.shape ??
|
onLongPress: () =>
|
||||||
RoundedRectangleBorder(
|
onLongPress(context),
|
||||||
side: isOnlyEmoji &&
|
child: Material(
|
||||||
!_hasReplyMessage
|
clipBehavior: Clip.antiAlias,
|
||||||
? BorderSide.none
|
shape: widget.shape ??
|
||||||
: widget.borderSide ??
|
RoundedRectangleBorder(
|
||||||
BorderSide(
|
side: isOnlyEmoji &&
|
||||||
color: Theme.of(context)
|
!_hasReplyMessage
|
||||||
.brightness ==
|
? BorderSide.none
|
||||||
Brightness
|
: widget.borderSide ??
|
||||||
.dark
|
BorderSide(
|
||||||
? Colors.white
|
color: Theme.of(context)
|
||||||
.withAlpha(24)
|
.brightness ==
|
||||||
: Colors.black
|
Brightness
|
||||||
.withAlpha(
|
.dark
|
||||||
24),
|
? Colors.white
|
||||||
),
|
.withAlpha(
|
||||||
borderRadius: widget
|
24)
|
||||||
.borderRadiusGeometry ??
|
: Colors.black
|
||||||
BorderRadius.zero,
|
.withAlpha(
|
||||||
|
24),
|
||||||
|
),
|
||||||
|
borderRadius: widget
|
||||||
|
.borderRadiusGeometry ??
|
||||||
|
BorderRadius.zero,
|
||||||
|
),
|
||||||
|
color: _getBackgroundColor(),
|
||||||
|
child: Padding(
|
||||||
|
padding: EdgeInsets.all(
|
||||||
|
hasFiles ? 2.0 : 0.0),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment:
|
||||||
|
CrossAxisAlignment.start,
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: <Widget>[
|
||||||
|
if (_hasReplyMessage)
|
||||||
|
ReplyMessageWidget(
|
||||||
|
message:
|
||||||
|
widget.replyMessage,
|
||||||
|
messageTheme: isMyMessage
|
||||||
|
? StreamChatTheme.of(
|
||||||
|
context)
|
||||||
|
.otherMessageTheme
|
||||||
|
: StreamChatTheme.of(
|
||||||
|
context)
|
||||||
|
.ownMessageTheme,
|
||||||
|
reverse: widget.reverse,
|
||||||
|
),
|
||||||
|
..._parseAttachments(context),
|
||||||
|
if (widget.message.text
|
||||||
|
.trim()
|
||||||
|
.isNotEmpty &&
|
||||||
|
!isGiphy)
|
||||||
|
_buildTextBubble(context),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
color: _getBackgroundColor(),
|
|
||||||
child: Padding(
|
|
||||||
padding: EdgeInsets.all(
|
|
||||||
hasFiles ? 2.0 : 0.0),
|
|
||||||
child: Column(
|
|
||||||
crossAxisAlignment:
|
|
||||||
CrossAxisAlignment.start,
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: <Widget>[
|
|
||||||
if (_hasReplyMessage)
|
|
||||||
ReplyMessageWidget(
|
|
||||||
message:
|
|
||||||
widget.replyMessage,
|
|
||||||
messageTheme: isMyMessage
|
|
||||||
? StreamChatTheme.of(
|
|
||||||
context)
|
|
||||||
.otherMessageTheme
|
|
||||||
: StreamChatTheme.of(
|
|
||||||
context)
|
|
||||||
.ownMessageTheme,
|
|
||||||
reverse: widget.reverse,
|
|
||||||
),
|
|
||||||
..._parseAttachments(context),
|
|
||||||
if (widget.message.text
|
|
||||||
.trim()
|
|
||||||
.isNotEmpty &&
|
|
||||||
!isGiphy)
|
|
||||||
_buildTextBubble(context),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -706,33 +712,29 @@ class _MessageWidgetState extends State<MessageWidget> {
|
|||||||
}) {
|
}) {
|
||||||
final attachmentShape =
|
final attachmentShape =
|
||||||
widget.attachmentShape ?? widget.shape ?? _getDefaultShape(context);
|
widget.attachmentShape ?? widget.shape ?? _getDefaultShape(context);
|
||||||
return GestureDetector(
|
return Material(
|
||||||
onTap: () => retryMessage(context),
|
color: _getBackgroundColor(),
|
||||||
onLongPress: () => onLongPress(context),
|
clipBehavior: Clip.antiAlias,
|
||||||
child: Material(
|
shape: attachmentShape,
|
||||||
color: _getBackgroundColor(),
|
child: Padding(
|
||||||
clipBehavior: Clip.antiAlias,
|
padding: widget.attachmentPadding,
|
||||||
shape: attachmentShape,
|
child: Material(
|
||||||
child: Padding(
|
clipBehavior: Clip.hardEdge,
|
||||||
padding: widget.attachmentPadding,
|
shape: attachmentShape,
|
||||||
child: Material(
|
type: MaterialType.transparency,
|
||||||
clipBehavior: Clip.hardEdge,
|
child: Transform(
|
||||||
shape: attachmentShape,
|
transform: Matrix4.rotationY(widget.reverse ? pi : 0),
|
||||||
type: MaterialType.transparency,
|
alignment: Alignment.center,
|
||||||
child: Transform(
|
child: Column(
|
||||||
transform: Matrix4.rotationY(widget.reverse ? pi : 0),
|
mainAxisSize: MainAxisSize.min,
|
||||||
alignment: Alignment.center,
|
crossAxisAlignment: CrossAxisAlignment.end,
|
||||||
child: Column(
|
children: <Widget>[
|
||||||
mainAxisSize: MainAxisSize.min,
|
getFailedMessageWidget(
|
||||||
crossAxisAlignment: CrossAxisAlignment.end,
|
context,
|
||||||
children: <Widget>[
|
padding: const EdgeInsets.all(8.0),
|
||||||
getFailedMessageWidget(
|
),
|
||||||
context,
|
attachmentWidget,
|
||||||
padding: const EdgeInsets.all(8.0),
|
],
|
||||||
),
|
|
||||||
attachmentWidget,
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -862,7 +864,7 @@ class _MessageWidgetState extends State<MessageWidget> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildTextBubble(BuildContext context) {
|
Widget _buildTextBubble(BuildContext context) {
|
||||||
Widget child = Transform(
|
return Transform(
|
||||||
transform: Matrix4.rotationY(widget.reverse ? pi : 0),
|
transform: Matrix4.rotationY(widget.reverse ? pi : 0),
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
child: Column(
|
child: Column(
|
||||||
@@ -899,11 +901,6 @@ class _MessageWidgetState extends State<MessageWidget> {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
return GestureDetector(
|
|
||||||
onTap: () => retryMessage(context),
|
|
||||||
onLongPress: () => onLongPress(context),
|
|
||||||
child: child,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool get isOnlyEmoji =>
|
bool get isOnlyEmoji =>
|
||||||
|
|||||||
Reference in New Issue
Block a user