fix reaction ui
This commit is contained in:
+40
-40
@@ -156,7 +156,7 @@ class _MessageWidgetState extends State<MessageWidget>
|
|||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Column(
|
Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
attachmentWidget,
|
attachmentWidget,
|
||||||
attachment.title != null
|
attachment.title != null
|
||||||
@@ -224,17 +224,33 @@ class _MessageWidgetState extends State<MessageWidget>
|
|||||||
|
|
||||||
if (widget.message.text.trim().isNotEmpty) {
|
if (widget.message.text.trim().isNotEmpty) {
|
||||||
final topPadding =
|
final topPadding =
|
||||||
widget.message.reactionCounts?.isNotEmpty == true ? 36.0 : 0.0;
|
widget.message.reactionCounts?.isNotEmpty == true ? 2.0 : 0.0;
|
||||||
column.children.add(Stack(
|
column.children.addAll(
|
||||||
|
<Widget>[
|
||||||
|
Align(
|
||||||
|
child: _buildReactions(isMyMessage),
|
||||||
|
alignment:
|
||||||
|
isMyMessage ? Alignment.centerLeft : Alignment.centerRight,
|
||||||
|
),
|
||||||
|
Stack(
|
||||||
overflow: Overflow.visible,
|
overflow: Overflow.visible,
|
||||||
alignment: Alignment.centerRight,
|
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Positioned(
|
widget.message.reactionCounts?.isNotEmpty == true
|
||||||
left: isMyMessage ? 0 : null,
|
? Positioned(
|
||||||
right: !isMyMessage ? 0 : null,
|
left: isMyMessage ? 8 : null,
|
||||||
top: 0,
|
right: !isMyMessage ? 8 : null,
|
||||||
child: _buildReactions(isMyMessage)),
|
top: -4,
|
||||||
AnimatedContainer(
|
child: CustomPaint(
|
||||||
|
painter: ReactionBubblePainter(),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: SizedBox(),
|
||||||
|
Padding(
|
||||||
|
padding: EdgeInsets.only(
|
||||||
|
right: isMyMessage ? 0.0 : 8.0,
|
||||||
|
left: isMyMessage ? 8.0 : 0.0,
|
||||||
|
),
|
||||||
|
child: AnimatedContainer(
|
||||||
duration: Duration(milliseconds: 300),
|
duration: Duration(milliseconds: 300),
|
||||||
margin: EdgeInsets.only(
|
margin: EdgeInsets.only(
|
||||||
top: nOfAttachmentWidgets > 0 ? (topPadding) : (topPadding),
|
top: nOfAttachmentWidgets > 0 ? (topPadding) : (topPadding),
|
||||||
@@ -251,12 +267,15 @@ class _MessageWidgetState extends State<MessageWidget>
|
|||||||
styleSheet: MarkdownStyleSheet.fromTheme(Theme.of(context)),
|
styleSheet: MarkdownStyleSheet.fromTheme(Theme.of(context)),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
));
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
child: column,
|
child: IntrinsicWidth(child: column),
|
||||||
onLongPress: () {
|
onLongPress: () {
|
||||||
_showMessageBottomSheet(context);
|
_showMessageBottomSheet(context);
|
||||||
});
|
});
|
||||||
@@ -307,32 +326,15 @@ class _MessageWidgetState extends State<MessageWidget>
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildReactions(bool isMyMessage) {
|
Widget _buildReactions(bool isMyMessage) {
|
||||||
return Padding(
|
return GestureDetector(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 2.0),
|
|
||||||
child: GestureDetector(
|
|
||||||
onTap: () {
|
onTap: () {
|
||||||
_showMessageBottomSheet(context);
|
_showMessageBottomSheet(context);
|
||||||
},
|
},
|
||||||
child: Stack(
|
child: Padding(
|
||||||
overflow: Overflow.visible,
|
padding: const EdgeInsets.symmetric(vertical: 2.0),
|
||||||
children: <Widget>[
|
child: AnimatedContainer(
|
||||||
widget.message.reactionCounts?.isNotEmpty == true
|
duration: Duration(milliseconds: 300),
|
||||||
? Positioned(
|
curve: Curves.decelerate,
|
||||||
left: isMyMessage ? 0 : null,
|
|
||||||
right: !isMyMessage ? 0 : null,
|
|
||||||
bottom: 2,
|
|
||||||
child: CustomPaint(
|
|
||||||
painter: ReactionBubblePainter(),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
: SizedBox(),
|
|
||||||
Container(
|
|
||||||
transform: Matrix4.translationValues(
|
|
||||||
((widget.message.reactionCounts?.length ?? 0) * 10) *
|
|
||||||
(isMyMessage ? -1.0 : 1.0),
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
),
|
|
||||||
padding: widget.message.reactionCounts?.isNotEmpty == true
|
padding: widget.message.reactionCounts?.isNotEmpty == true
|
||||||
? const EdgeInsets.all(8)
|
? const EdgeInsets.all(8)
|
||||||
: EdgeInsets.zero,
|
: EdgeInsets.zero,
|
||||||
@@ -342,10 +344,10 @@ class _MessageWidgetState extends State<MessageWidget>
|
|||||||
child: (widget.message.reactionCounts != null &&
|
child: (widget.message.reactionCounts != null &&
|
||||||
widget.message.reactionCounts.isNotEmpty)
|
widget.message.reactionCounts.isNotEmpty)
|
||||||
? Row(
|
? Row(
|
||||||
mainAxisSize: MainAxisSize.max,
|
mainAxisSize: MainAxisSize.min,
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
children: widget.message.reactionCounts.keys
|
children:
|
||||||
.map((reactionType) {
|
widget.message.reactionCounts.keys.map((reactionType) {
|
||||||
return Text(
|
return Text(
|
||||||
reactionToEmoji[reactionType] ?? '?',
|
reactionToEmoji[reactionType] ?? '?',
|
||||||
) as Widget; //TODO refactor
|
) as Widget; //TODO refactor
|
||||||
@@ -361,8 +363,6 @@ class _MessageWidgetState extends State<MessageWidget>
|
|||||||
)))
|
)))
|
||||||
: SizedBox(),
|
: SizedBox(),
|
||||||
),
|
),
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user