Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: ✨ added reply suggestions functionality #184

Merged
merged 1 commit into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 33 additions & 31 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,47 +1,49 @@
## [2.0.0] (Unreleased)

* **Breaking**: [173](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/pull/173) Added
callback to sort message in chat.
* **Breaking**: [177](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/pull/177) Fixed
json serializable of models and added copyWith method (Message, Reaction and Reply Message).
* **Fix**: [182](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/issues/182) Fix
send message not working when user start texting after newLine.
* **Breaking**: [181](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/pull/181) Removed
deprecated field `showTypingIndicator` from ChatView.
* **Feat**: [179](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/pull/179) Added reply
suggestions functionality
* **Feat**: [157](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/pull/157) Added onTap
of reacted user from reacted user list.
* **Feat**: [156](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/pull/156) Added
default avatar, error builder for asset, network and base64 profile image and
cached_network_image for network images.
* **Breaking**: [173](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/pull/173) Added
callback to sort message in chat.
* **Fix**: [181](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/pull/181) Removed
deprecated field `showTypingIndicator` from ChatView.
* **Feat**: [121](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/pull/121) Added support
for configuring the audio recording quality.
* **Feat**: [93](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/issues/93) Added support
that provide date pattern to change chat separation.
* **Fix**: [139](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/issues/139) Added
support to customize view for the reply of any message.
* **Fix**: [174](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/issues/174) Fix
wrong username shown while replying to any messages.
* **Fix**: [134](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/issues/134)
Added a reply message view for custom message type.
* **Feat**: [157](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/pull/157)
Added onTap of reacted user from reacted user list.
* **Fix**: [174](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/issues/174) Fix wrong
username shown while replying to any messages.
* **Fix**: [134](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/issues/134) Added a
reply message view for custom message type.
* **Fix**: [137](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/issues/137) Added
support for cancel voice recording and field to provide cancel record icon.
* **Feat**: [93](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/issues/93) Added support
that provide date pattern to change chat separation.
* **Fix**: [142](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/issues/142) Added
field to provide base64 string data for profile picture.
* **Fix**: [165](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/issues/165) Fix issue
of user reaction callback provides incorrect message object when user react on any message
with double or from reaction sheet.
* **Fix**: [164](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/issues/164)
Add flag to enable/disable chat text field.
* **Feat**: [121](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/pull/121)Added support
for configuring the audio recording quality.
* **Fix**: [131](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/issues/131)
Fix unsupported operation while running on the web.
* **Fix**: [142](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/issues/142) Added field
to provide base64 string data for profile picture.
* **Fix**: [161](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/pull/161) Added field
to set top padding of chat text field.
* **Fix**: [165](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/issues/165) Fix issue of
user reaction callback provides incorrect message object when user react on any message with
double or from reaction sheet.
* **Fix**: [164](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/issues/164) Add flag to
enable/disable chat text field.
* **Fix**: [131](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/issues/131) Fix
unsupported operation while running on the web.
* **Fix**: [160](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/pull/160) Added
configuration for emoji picker sheet.
* **Fix**: [130](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/issues/130) Added
report button for receiver message and update onMoreTap, onReportTap callback.
* **Fix**: [126](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/issues/126) Added
flag to hide user name in chat.
* **Feat**: [161](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/pull/161) Added
field to set top padding of chat text field.
* **Fix**: [130](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/issues/130) Added report
button for receiver message and update onMoreTap, onReportTap callback.
* **Fix**: [126](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/issues/126) Added flag
to hide user name in chat.
* **Fix**: [182](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/issues/182) Fix
send message not working when user start texting after newLine.

## [1.3.1]

Expand Down
83 changes: 54 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
![Banner](https://raw.githubusercontent.com/SimformSolutionsPvtLtd/flutter_chat_ui/main/preview/banner.png)

# ChatView
[![chatview](https://img.shields.io/pub/v/chatview?label=chatview)](https://pub.dev/packages/chatview)
[![chatview](https://img.shields.io/pub/v/chatview?label=chatview)](https://pub.dev/packages/chatview)

A Flutter package that allows you to integrate Chat View with highly customization options such as one on one
chat, group chat, message reactions, reply messages, link preview and configurations for overall view.
Expand Down Expand Up @@ -34,7 +34,7 @@ ChatView(
),
```

## Installing
## Installing

1. Add dependency to `pubspec.yaml`

Expand Down Expand Up @@ -434,7 +434,7 @@ ChatView(
```

17. Callback when a user starts/stops typing in `TextFieldConfiguration`

```dart
ChatView(
...
Expand All @@ -459,7 +459,7 @@ ChatView(
```

18. Passing customReceipts builder or handling stuffs related receipts see `ReceiptsWidgetConfig` in outgoingChatBubbleConfig.

```dart
ChatView(
...
Expand Down Expand Up @@ -492,18 +492,7 @@ ChatView(
)
```

19. Added field `chatTextFieldTopPadding` to set top padding of chat text field.

```dart
ChatView(
...
chatTextFieldTopPadding: 10,
...

)
```

20. Flag `enableOtherUserName` to hide user name in chat.
19. Flag `enableOtherUserName` to hide user name in chat.

```dart
ChatView(
Expand All @@ -516,7 +505,7 @@ ChatView(
)
```

21. Added report button for receiver message and update `onMoreTap` and `onReportTap` callbacks.
20. Added report button for receiver message and update `onMoreTap` and `onReportTap` callbacks.

```dart
ChatView(
Expand All @@ -533,7 +522,7 @@ ChatView(
)
```

22. Added `emojiPickerSheetConfig` for configuration of emoji picker sheet.
21. Added `emojiPickerSheetConfig` for configuration of emoji picker sheet.

```dart
ChatView(
Expand All @@ -554,7 +543,7 @@ ChatView(
)
```

23. Configure the styling & audio recording quality using `VoiceRecordingConfiguration` in sendMessageConfig.
22. Configure the styling & audio recording quality using `VoiceRecordingConfiguration` in sendMessageConfig.

```dart
ChatView(
Expand All @@ -579,7 +568,7 @@ ChatView(
)
```

24. Added `enabled` to enable/disable chat text field.
23. Added `enabled` to enable/disable chat text field.

```dart
ChatView(
Expand All @@ -595,7 +584,7 @@ ChatView(

)
```
25. Added flag `isProfilePhotoInBase64` that defines whether provided image is url or base64 data.
24. Added flag `isProfilePhotoInBase64` that defines whether provided image is url or base64 data.

```dart
final chatController = ChatController(
Expand All @@ -621,7 +610,7 @@ ChatView(
)
```

26. Added `chatSeparatorDatePattern` in `DefaultGroupSeparatorConfiguration` to separate chats with provided pattern.
25. Added `chatSeparatorDatePattern` in `DefaultGroupSeparatorConfiguration` to separate chats with provided pattern.

```dart
ChatView(
Expand All @@ -637,7 +626,7 @@ ChatView(
)
```

27. Field `cancelRecordConfiguration` to provide an configuration to cancel voice record message.
26. Field `cancelRecordConfiguration` to provide an configuration to cancel voice record message.

```dart
ChatView(
Expand All @@ -660,7 +649,7 @@ ChatView(
)
```

28. Added callback of onTap on list of reacted users in reaction sheet `reactedUserCallback`.
27. Added callback of onTap on list of reacted users in reaction sheet `reactedUserCallback`.
```dart

ChatView(
Expand All @@ -680,7 +669,7 @@ ChatView(
),
```

29. Added a `customMessageReplyViewBuilder` to customize reply message view for custom type message.
28. Added a `customMessageReplyViewBuilder` to customize reply message view for custom type message.

```dart
ChatView(
Expand All @@ -702,7 +691,7 @@ ChatView(
)
```

30. Add default avatar for profile image `defaultAvatarImage`,
29. Add default avatar for profile image `defaultAvatarImage`,
error builder for asset and network profile image `assetImageErrorBuilder` `networkImageErrorBuilder`,
Enum `ImageType` to define image as asset, network or base64 data.
```dart
Expand All @@ -727,7 +716,7 @@ ChatView(
```


31. Added a `customMessageReplyViewBuilder` to customize reply message view for custom type message.
30. Added a `customMessageReplyViewBuilder` to customize reply message view for custom type message.

```dart
ChatView(
Expand Down Expand Up @@ -812,8 +801,42 @@ ChatView(
)
```

33. Reply Suggestions functionalities.

* Add reply suggestions
```dart
_chatController.addReplySuggestions([
SuggestionItemData(text: 'Thanks.'),
SuggestionItemData(text: 'Thank you very much.'),
SuggestionItemData(text: 'Great.')
]);
```
* Remove reply suggestions
```dart
_chatController.removeReplySuggestions();
```
* Update Sugestions Config
```dart
replySuggestionsConfig: ReplySuggestionsConfig(
itemConfig: SuggestionItemConfig(
decoration: BoxDecoration(),
textStyle: TextStyle(),
padding: EdgetInsets.all(8),
customItemBuilder: (index, suggestionItemData) => Container()
),
listConfig: SuggestionListConfig(
decoration: BoxDecoration(),
padding: EdgetInsets.all(8),
itemSeparatorWidth: 8,
axisAlignment: SuggestionListAlignment.left
)
onTap: (item) =>
_onSendTap(item.text, const ReplyMessage(), MessageType.text),
autoDismissOnSelection: true
),
```

33. Added callback `messageSorter` to sort message in `ChatBackgroundConfiguration`.
34. Added callback `messageSorter` to sort message in `ChatBackgroundConfiguration`.
```dart

ChatView(
Expand All @@ -832,7 +855,7 @@ ChatView(

## How to use

Check out [blog](https://medium.com/simform-engineering/chatview-a-cutting-edge-chat-ui-solution-7367b1f9d772) for better understanding and basic implementation.
Check out [blog](https://medium.com/simform-engineering/chatview-a-cutting-edge-chat-ui-solution-7367b1f9d772) for better understanding and basic implementation.

Also, for whole example, check out the **example** app in the [example](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/tree/main/example) directory or the 'Example' tab on pub.dartlang.org for a more complete example.

Expand All @@ -844,6 +867,8 @@ Also, for whole example, check out the **example** app in the [example](https://
<td align="center"><a href="https://github.com/vatsaltanna"><img src="https://avatars.githubusercontent.com/u/25323183?s=100" width="100px;" alt=""/><br /><sub><b>Vatsal Tanna</b></sub></a></td>
<td align="center"><a href="https://github.com/DhvanitVaghani"><img src="https://avatars.githubusercontent.com/u/64645989?v=4" width="100px;" alt=""/><br /><sub><b>Dhvanit Vaghani</b></sub></a></td>
<td align="center"><a href="https://github.com/Ujas-Majithiya"><img src="https://avatars.githubusercontent.com/u/56400956?v=4" width="100px;" alt=""/><br /><sub><b>Ujas Majithiya</b></sub></a></td>
<td align="center"><a href="https://github.com/apurva780"><img src="https://avatars.githubusercontent.com/u/65003381?v=4" width="100px;" alt=""/><br /><sub><b>Apurva Kanthraviya</b></sub></a></td>

</tr>
</table>
<br/>
Expand Down
44 changes: 42 additions & 2 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,23 @@ class _ChatScreenState extends State<ChatScreen> {
_chatController.setTypingIndicator = !_chatController.showTypingIndicator;
}

void receiveMessage() async {
_chatController.addMessage(
Message(
id: DateTime.now().toString(),
message: 'I will schedule the meeting.',
createdAt: DateTime.now(),
sendBy: '2',
),
);
await Future.delayed(const Duration(milliseconds: 500));
_chatController.addReplySuggestions([
const SuggestionItemData(text: 'Thanks.'),
const SuggestionItemData(text: 'Thank you very much.'),
const SuggestionItemData(text: 'Great.')
]);
}

@override
Widget build(BuildContext context) {
return Scaffold(
Expand Down Expand Up @@ -125,6 +142,14 @@ class _ChatScreenState extends State<ChatScreen> {
color: theme.themeIconColor,
),
),
IconButton(
tooltip: 'Simulate Message receive',
onPressed: receiveMessage,
icon: Icon(
Icons.supervised_user_circle,
color: theme.themeIconColor,
),
),
],
),
chatBackgroundConfig: ChatBackgroundConfiguration(
Expand Down Expand Up @@ -266,6 +291,22 @@ class _ChatScreenState extends State<ChatScreen> {
swipeToReplyConfig: SwipeToReplyConfiguration(
replyIconColor: theme.swipeToReplyIconColor,
),
replySuggestionsConfig: ReplySuggestionsConfig(
itemConfig: SuggestionItemConfig(
decoration: BoxDecoration(
color: theme.textFieldBackgroundColor,
borderRadius: BorderRadius.circular(8),
border: Border.all(
color: theme.outgoingChatBubbleColor ?? Colors.white,
),
),
textStyle: TextStyle(
color: isDarkTheme ? Colors.white : Colors.black,
),
),
onTap: (item) =>
_onSendTap(item.text, const ReplyMessage(), MessageType.text),
),
),
);
}
Expand All @@ -275,10 +316,9 @@ class _ChatScreenState extends State<ChatScreen> {
ReplyMessage replyMessage,
MessageType messageType,
) {
final id = int.parse(Data.messageList.last.id) + 1;
_chatController.addMessage(
Message(
id: id.toString(),
id: DateTime.now().toString(),
createdAt: DateTime.now(),
message: message,
sendBy: currentUser.id,
Expand Down
Loading