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

refactor!: 🔨 Move currentUser into ChatController from ChatView widget and rename chatUsers to otherUsers #190

Merged
merged 1 commit into from
Jun 18, 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
6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
json serializable of models and added copyWith method (Message, Reaction and Reply Message).
* **Breaking**: [181](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/pull/181) Removed
deprecated field `showTypingIndicator` from ChatView.
* **Breaking**: [187](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/pull/187) update sendBy
parameter name of Message class to sentBy
* **Breaking**: [188](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/pull/188) update
sendBy parameter name of Message class to sentBy
* **Breaking**: [190](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/pull/190) Move
currentUser into ChatController from ChatView widget and rename chatUsers to otherUsers
* **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
Expand Down
297 changes: 148 additions & 149 deletions README.md
aditya-css marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -14,174 +14,174 @@ visit [Chat View Example](https://chat-view-8f1b5.web.app/#/).
![The example app running in iOS](https://raw.githubusercontent.com/SimformSolutionsPvtLtd/flutter_chat_ui/main/preview/chatview.gif)

## Migration guide for release 2.0.0
Removed `showTypingIndicator` field from `ChatView` and replaced it with `ChatController.showTypingIndicator`.

Before:
```dart
ChatView(
showTypingIndicator:false,
),
```
- Renamed `sendBy` field to `sentBy` in `Message` class.

After:
```dart
/// use it with your [ChatController] instance.
_chatContoller.setTypingIndicator = true; // for showing indicator
_chatContoller.setTypingIndicator = false; // for hiding indicator
- Renamed `chatUsers` field to `otherUsers` in `ChatController` class.

ChatView(
chatController: _chatController,
),
```
- Moved `currentUser` field from `ChatView` widget to `ChatController` class

Renamed `sendBy` field to `sentBy` in `Message` class.
- Removed `showTypingIndicator` field from `ChatView` and replaced it with `ChatController.showTypingIndicator`.

Updated `ChatUser`, `Message` and `ReplyMessage` Data Model's `fromJson` and `toJson` methods:
Before:
```dart
ChatView(
showTypingIndicator:false,
),
```

in `ChatUser.fromJson`:
After:
```dart
/// use it with your [ChatController] instance.
_chatContoller.setTypingIndicator = true; // for showing indicator
_chatContoller.setTypingIndicator = false; // for hiding indicator
```

Before:
```dart
ChatUser.fromJson(
{
...
'imageType': ImageType.asset,
...
},
),
```
- Updated `ChatUser`, `Message` and `ReplyMessage` Data Model's `fromJson` and `toJson` methods:

After:
```dart
ChatUser.fromJson(
{
...
'imageType': 'asset',
...
},
),
```
##### in `ChatUser.fromJson`:

in `ChatUser.toJson`:
Before:
```dart
ChatUser.fromJson(
{
...
'imageType': ImageType.asset,
...
},
),
```

Before:
```dart
{
...
imageType: ImageType.asset,
...
}
```
After:
```dart
ChatUser.fromJson(
{
...
'imageType': 'asset',
...
},
),
```

After:
```dart
{
...
imageType: asset,
...
}
```
##### in `ChatUser.toJson`:

in `Message.fromJson`:
Before:
```dart
{
...
imageType: ImageType.asset,
...
}
```

Before:
```dart
Message.fromJson(
{
...
'createdAt': DateTime.now(),
'message_type': MessageType.text,
'voice_message_duration': Duration(seconds: 5),
...
}
)
```
After:
```dart
{
...
imageType: asset,
...
}
```

After:
```dart
Message.fromJson(
{
...
'createdAt': '2024-06-13T17:32:19.586412',
'message_type': 'text',
'voice_message_duration': '5000000',
...
}
)
```
##### in `Message.fromJson`:

Before:
```dart
Message.fromJson(
{
...
'createdAt': DateTime.now(),
'message_type': MessageType.text,
'voice_message_duration': Duration(seconds: 5),
...
}
)
```

in `Message.toJson`:
After:
```dart
Message.fromJson(
{
...
'createdAt': '2024-06-13T17:32:19.586412',
'message_type': 'text',
'voice_message_duration': '5000000',
...
}
)
```

Before:
```dart
{
...
createdAt: 2024-06-13 17:23:19.454789,
message_type: MessageType.text,
voice_message_duration: 0:00:05.000000,
...
}
```
##### in `Message.toJson`:

After:
```dart
{
...
createdAt: 2024-06-13T17:32:19.586412,
message_type: text,
voice_message_duration: 5000000,
...
}
```
Before:
```dart
{
...
createdAt: 2024-06-13 17:23:19.454789,
message_type: MessageType.text,
voice_message_duration: 0:00:05.000000,
...
}
```

in `ReplyMessage.fromJson`:
After:
```dart
{
...
createdAt: 2024-06-13T17:32:19.586412,
message_type: text,
voice_message_duration: 5000000,
...
}
```

Before:
```dart
ReplyMessage.fromJson(
{
...
'message_type': MessageType.text,
'voiceMessageDuration': Duration(seconds: 5),
...
}
)
```
##### in `ReplyMessage.fromJson`:

After:
```dart
ReplyMessage.fromJson(
{
...
'message_type': 'text',
'voiceMessageDuration': '5000000',
...
}
)
```
Before:
```dart
ReplyMessage.fromJson(
{
...
'message_type': MessageType.text,
'voiceMessageDuration': Duration(seconds: 5),
...
}
)
```

in `ReplyMessage.toJson`:
After:
```dart
ReplyMessage.fromJson(
{
...
'message_type': 'text',
'voiceMessageDuration': '5000000',
...
}
)
```

Before:
```dart
{
...
message_type: MessageType.text,
voiceMessageDuration: 0:00:05.000000,
...
}
```
in `ReplyMessage.toJson`:

After:
```dart
{
...
message_type: text,
voiceMessageDuration: 5000000,
...
}
```
Before:
```dart
{
...
message_type: MessageType.text,
voiceMessageDuration: 0:00:05.000000,
...
}
```

After:
```dart
{
...
message_type: text,
voiceMessageDuration: 5000000,
...
}
```

## Installing

Expand All @@ -203,14 +203,14 @@ import 'package:chatview/chatview.dart';
final chatController = ChatController(
initialMessageList: messageList,
scrollController: ScrollController(),
chatUsers: [ChatUser(id: '2', name: 'Simform')],
currentUser: ChatUser(id: '1', name: 'Flutter'),
otherUsers: [ChatUser(id: '2', name: 'Simform')],
);
```

4. Adding a `ChatView` widget.
```dart
ChatView(
currentUser: ChatUser(id: '1', name: 'Flutter'),
chatController: chatController,
onSendTap: onSendTap,
chatViewState: ChatViewState.hasMessages, // Add this state once data is available.
Expand Down Expand Up @@ -960,7 +960,7 @@ _chatController.addReplySuggestions([
```dart
_chatController.removeReplySuggestions();
```
* Update Sugestions Config
* Update suggestions Config
```dart
replySuggestionsConfig: ReplySuggestionsConfig(
itemConfig: SuggestionItemConfig(
Expand All @@ -982,8 +982,8 @@ replySuggestionsConfig: ReplySuggestionsConfig(
```

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

```dart
ChatView(
...
chatBackgroundConfig: ChatBackgroundConfiguration(
Expand All @@ -997,7 +997,6 @@ 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.
Expand Down
Loading