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 e83e1a9
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## [1.4.0] (UnReleased)

* **Fix**: Reaction widget gets cutOff when it width is greater then message width/Screen width.

## [1.3.1]

* **Feat**: [105](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/pull/105) Allow user
Expand Down
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
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: chatview
description: A Flutter package that allows you to integrate Chat View with highly customization options.
version: 1.3.1
version: 1.4.0
issue_tracker: https://github.com/SimformSolutionsPvtLtd/flutter_chatview/issues
repository: https://github.com/SimformSolutionsPvtLtd/flutter_chatview

Expand Down

0 comments on commit e83e1a9

Please sign in to comment.