refactor reaction row
This commit is contained in:
+20
-15
@@ -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,17 +500,22 @@ 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,
|
: SizedBox(),
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
),
|
||||||
children:
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Row _buildReactionRow() {
|
||||||
|
List<Widget> children =
|
||||||
widget.message.reactionCounts.keys.map((reactionType) {
|
widget.message.reactionCounts.keys.map((reactionType) {
|
||||||
return Text(
|
return Text(
|
||||||
reactionToEmoji[reactionType] ?? '?',
|
reactionToEmoji[reactionType] ?? '?',
|
||||||
) as Widget; //TODO refactor
|
);
|
||||||
}).toList() +
|
}).toList();
|
||||||
[
|
|
||||||
Padding(
|
children.add(Padding(
|
||||||
padding: const EdgeInsets.only(left: 4.0),
|
padding: const EdgeInsets.only(left: 4.0),
|
||||||
child: Text(
|
child: Text(
|
||||||
widget.message.reactionCounts.values
|
widget.message.reactionCounts.values
|
||||||
@@ -518,11 +523,11 @@ class _MessageWidgetState extends State<MessageWidget>
|
|||||||
.toString(),
|
.toString(),
|
||||||
style: TextStyle(color: Colors.white),
|
style: TextStyle(color: Colors.white),
|
||||||
),
|
),
|
||||||
)
|
));
|
||||||
])
|
return Row(
|
||||||
: SizedBox(),
|
mainAxisSize: MainAxisSize.min,
|
||||||
),
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
),
|
children: children,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user