Skip to content

Commit

Permalink
fix:🐛Reaction widget gets cutOff when it width is greater then messag…
Browse files Browse the repository at this point in the history
…e width.
  • Loading branch information
jaiminrana05 committed Sep 29, 2023
1 parent 31eedc2 commit 5e37239
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
1 change: 1 addition & 0 deletions lib/src/models/message_reaction_configuration.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import 'package:flutter/material.dart';

class MessageReactionConfiguration {
/// Used for giving size of reaction on message.
/// Will apply only for one-one chat.
final double? reactionSize;

/// Used for giving margin of reaction on message.
Expand Down
17 changes: 14 additions & 3 deletions lib/src/widgets/reaction_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,10 @@ class _ReactionWidgetState extends State<ReactionWidget> {

@override
Widget build(BuildContext context) {
//// Convert into set to remove reduntant values
//// Convert into set to remove redundant values
final reactionsSet = widget.reaction.reactions.toSet();
final isGroupChat = widget.reaction.reactedUserIds.length > 2;

return Positioned(
bottom: 0,
right: widget.isMessageBySender && needToExtend ? 0 : null,
Expand Down Expand Up @@ -103,12 +105,18 @@ class _ReactionWidgetState extends State<ReactionWidget> {
child: Row(
children: [
Text(
reactionsSet.join(' '),
isGroupChat
? reactionsSet.take(3).join(' ')
: reactionsSet.join(' '),
style: TextStyle(
fontSize: messageReactionConfig?.reactionSize ?? 13,
fontSize: isGroupChat
? messageReactionConfig?.reactionSize ?? 13
: 13,
),
),
if ((chatController?.chatUsers.length ?? 0) > 1) ...[
/// when reaction user length is 3 or <3 && they all have
/// reacted with the same reaction this condition will be true
if (!(widget.reaction.reactedUserIds.length > 3) &&
!(reactionsSet.length > 1))
...List.generate(
Expand All @@ -124,6 +132,9 @@ class _ReactionWidgetState extends State<ReactionWidget> {
messageReactionConfig?.profileCircleRadius,
),
),

/// ReactionUser length > 3 && all have reacted with the same
/// reaction then this condition will be executed
if (widget.reaction.reactedUserIds.length > 3 &&
!(reactionsSet.length > 1))
Padding(
Expand Down

0 comments on commit 5e37239

Please sign in to comment.