refactor reaction row
This commit is contained in:
+27
-22
@@ -487,8 +487,8 @@ class _MessageWidgetState extends State<MessageWidget>
|
|||||||
},
|
},
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: EdgeInsets.symmetric(
|
padding: EdgeInsets.symmetric(
|
||||||
vertical:
|
vertical: widget.message.reactionCounts?.isNotEmpty == true ? 4.0 : 0,
|
||||||
widget.message.reactionCounts?.isNotEmpty == true ? 4.0 : 0),
|
),
|
||||||
child: AnimatedContainer(
|
child: AnimatedContainer(
|
||||||
duration: Duration(milliseconds: 300),
|
duration: Duration(milliseconds: 300),
|
||||||
curve: Curves.decelerate,
|
curve: Curves.decelerate,
|
||||||
@@ -500,32 +500,37 @@ class _MessageWidgetState extends State<MessageWidget>
|
|||||||
borderRadius: BorderRadius.all(Radius.circular(14))),
|
borderRadius: BorderRadius.all(Radius.circular(14))),
|
||||||
child: (widget.message.reactionCounts != null &&
|
child: (widget.message.reactionCounts != null &&
|
||||||
widget.message.reactionCounts.isNotEmpty)
|
widget.message.reactionCounts.isNotEmpty)
|
||||||
? Row(
|
? _buildReactionRow()
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
|
||||||
children:
|
|
||||||
widget.message.reactionCounts.keys.map((reactionType) {
|
|
||||||
return Text(
|
|
||||||
reactionToEmoji[reactionType] ?? '?',
|
|
||||||
) as Widget; //TODO refactor
|
|
||||||
}).toList() +
|
|
||||||
[
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.only(left: 4.0),
|
|
||||||
child: Text(
|
|
||||||
widget.message.reactionCounts.values
|
|
||||||
.fold(0, (t, v) => v + t)
|
|
||||||
.toString(),
|
|
||||||
style: TextStyle(color: Colors.white),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
])
|
|
||||||
: SizedBox(),
|
: SizedBox(),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Row _buildReactionRow() {
|
||||||
|
List<Widget> children =
|
||||||
|
widget.message.reactionCounts.keys.map((reactionType) {
|
||||||
|
return Text(
|
||||||
|
reactionToEmoji[reactionType] ?? '?',
|
||||||
|
);
|
||||||
|
}).toList();
|
||||||
|
|
||||||
|
children.add(Padding(
|
||||||
|
padding: const EdgeInsets.only(left: 4.0),
|
||||||
|
child: Text(
|
||||||
|
widget.message.reactionCounts.values
|
||||||
|
.fold(0, (t, v) => v + t)
|
||||||
|
.toString(),
|
||||||
|
style: TextStyle(color: Colors.white),
|
||||||
|
),
|
||||||
|
));
|
||||||
|
return Row(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
children: children,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
final Map<String, String> reactionToEmoji = {
|
final Map<String, String> reactionToEmoji = {
|
||||||
'love': '❤️️',
|
'love': '❤️️',
|
||||||
'haha': '😂',
|
'haha': '😂',
|
||||||
|
|||||||
Reference in New Issue
Block a user