Skip to content

Commit 4c9b6ad

Browse files
refactor!: 🔨 Move currentUser into ChatController from ChatView widget and rename chatUsers to otherUsers (#190)
1 parent 34a29c8 commit 4c9b6ad

12 files changed

+176
-180
lines changed

CHANGELOG.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@
66
json serializable of models and added copyWith method (Message, Reaction and Reply Message).
77
* **Breaking**: [181](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/pull/181) Removed
88
deprecated field `showTypingIndicator` from ChatView.
9-
* **Breaking**: [187](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/pull/187) update sendBy
10-
parameter name of Message class to sentBy
9+
* **Breaking**: [188](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/pull/188) update
10+
sendBy parameter name of Message class to sentBy
11+
* **Breaking**: [190](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/pull/190) Move
12+
currentUser into ChatController from ChatView widget and rename chatUsers to otherUsers
1113
* **Feat**: [179](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/pull/179) Added reply
1214
suggestions functionality
1315
* **Feat**: [157](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/pull/157) Added onTap

README.md

Lines changed: 148 additions & 149 deletions
Original file line numberDiff line numberDiff line change
@@ -14,174 +14,174 @@ visit [Chat View Example](https://chat-view-8f1b5.web.app/#/).
1414
![The example app running in iOS](https://raw.githubusercontent.com/SimformSolutionsPvtLtd/flutter_chat_ui/main/preview/chatview.gif)
1515

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

19-
Before:
20-
```dart
21-
ChatView(
22-
showTypingIndicator:false,
23-
),
24-
```
18+
- Renamed `sendBy` field to `sentBy` in `Message` class.
2519

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

32-
ChatView(
33-
chatController: _chatController,
34-
),
35-
```
22+
- Moved `currentUser` field from `ChatView` widget to `ChatController` class
3623

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

39-
Updated `ChatUser`, `Message` and `ReplyMessage` Data Model's `fromJson` and `toJson` methods:
26+
Before:
27+
```dart
28+
ChatView(
29+
showTypingIndicator:false,
30+
),
31+
```
4032
41-
in `ChatUser.fromJson`:
33+
After:
34+
```dart
35+
/// use it with your [ChatController] instance.
36+
_chatContoller.setTypingIndicator = true; // for showing indicator
37+
_chatContoller.setTypingIndicator = false; // for hiding indicator
38+
```
4239
43-
Before:
44-
```dart
45-
ChatUser.fromJson(
46-
{
47-
...
48-
'imageType': ImageType.asset,
49-
...
50-
},
51-
),
52-
```
40+
- Updated `ChatUser`, `Message` and `ReplyMessage` Data Model's `fromJson` and `toJson` methods:
5341
54-
After:
55-
```dart
56-
ChatUser.fromJson(
57-
{
58-
...
59-
'imageType': 'asset',
60-
...
61-
},
62-
),
63-
```
42+
##### in `ChatUser.fromJson`:
6443
65-
in `ChatUser.toJson`:
44+
Before:
45+
```dart
46+
ChatUser.fromJson(
47+
{
48+
...
49+
'imageType': ImageType.asset,
50+
...
51+
},
52+
),
53+
```
6654
67-
Before:
68-
```dart
69-
{
70-
...
71-
imageType: ImageType.asset,
72-
...
73-
}
74-
```
55+
After:
56+
```dart
57+
ChatUser.fromJson(
58+
{
59+
...
60+
'imageType': 'asset',
61+
...
62+
},
63+
),
64+
```
7565
76-
After:
77-
```dart
78-
{
79-
...
80-
imageType: asset,
81-
...
82-
}
83-
```
66+
##### in `ChatUser.toJson`:
8467
85-
in `Message.fromJson`:
68+
Before:
69+
```dart
70+
{
71+
...
72+
imageType: ImageType.asset,
73+
...
74+
}
75+
```
8676
87-
Before:
88-
```dart
89-
Message.fromJson(
90-
{
91-
...
92-
'createdAt': DateTime.now(),
93-
'message_type': MessageType.text,
94-
'voice_message_duration': Duration(seconds: 5),
95-
...
96-
}
97-
)
98-
```
77+
After:
78+
```dart
79+
{
80+
...
81+
imageType: asset,
82+
...
83+
}
84+
```
9985
100-
After:
101-
```dart
102-
Message.fromJson(
103-
{
104-
...
105-
'createdAt': '2024-06-13T17:32:19.586412',
106-
'message_type': 'text',
107-
'voice_message_duration': '5000000',
108-
...
109-
}
110-
)
111-
```
86+
##### in `Message.fromJson`:
87+
88+
Before:
89+
```dart
90+
Message.fromJson(
91+
{
92+
...
93+
'createdAt': DateTime.now(),
94+
'message_type': MessageType.text,
95+
'voice_message_duration': Duration(seconds: 5),
96+
...
97+
}
98+
)
99+
```
112100
113-
in `Message.toJson`:
101+
After:
102+
```dart
103+
Message.fromJson(
104+
{
105+
...
106+
'createdAt': '2024-06-13T17:32:19.586412',
107+
'message_type': 'text',
108+
'voice_message_duration': '5000000',
109+
...
110+
}
111+
)
112+
```
114113
115-
Before:
116-
```dart
117-
{
118-
...
119-
createdAt: 2024-06-13 17:23:19.454789,
120-
message_type: MessageType.text,
121-
voice_message_duration: 0:00:05.000000,
122-
...
123-
}
124-
```
114+
##### in `Message.toJson`:
125115
126-
After:
127-
```dart
128-
{
129-
...
130-
createdAt: 2024-06-13T17:32:19.586412,
131-
message_type: text,
132-
voice_message_duration: 5000000,
133-
...
134-
}
135-
```
116+
Before:
117+
```dart
118+
{
119+
...
120+
createdAt: 2024-06-13 17:23:19.454789,
121+
message_type: MessageType.text,
122+
voice_message_duration: 0:00:05.000000,
123+
...
124+
}
125+
```
136126
137-
in `ReplyMessage.fromJson`:
127+
After:
128+
```dart
129+
{
130+
...
131+
createdAt: 2024-06-13T17:32:19.586412,
132+
message_type: text,
133+
voice_message_duration: 5000000,
134+
...
135+
}
136+
```
138137
139-
Before:
140-
```dart
141-
ReplyMessage.fromJson(
142-
{
143-
...
144-
'message_type': MessageType.text,
145-
'voiceMessageDuration': Duration(seconds: 5),
146-
...
147-
}
148-
)
149-
```
138+
##### in `ReplyMessage.fromJson`:
150139
151-
After:
152-
```dart
153-
ReplyMessage.fromJson(
154-
{
155-
...
156-
'message_type': 'text',
157-
'voiceMessageDuration': '5000000',
158-
...
159-
}
160-
)
161-
```
140+
Before:
141+
```dart
142+
ReplyMessage.fromJson(
143+
{
144+
...
145+
'message_type': MessageType.text,
146+
'voiceMessageDuration': Duration(seconds: 5),
147+
...
148+
}
149+
)
150+
```
162151
163-
in `ReplyMessage.toJson`:
152+
After:
153+
```dart
154+
ReplyMessage.fromJson(
155+
{
156+
...
157+
'message_type': 'text',
158+
'voiceMessageDuration': '5000000',
159+
...
160+
}
161+
)
162+
```
164163
165-
Before:
166-
```dart
167-
{
168-
...
169-
message_type: MessageType.text,
170-
voiceMessageDuration: 0:00:05.000000,
171-
...
172-
}
173-
```
164+
in `ReplyMessage.toJson`:
174165
175-
After:
176-
```dart
177-
{
178-
...
179-
message_type: text,
180-
voiceMessageDuration: 5000000,
181-
...
182-
}
183-
```
166+
Before:
167+
```dart
168+
{
169+
...
170+
message_type: MessageType.text,
171+
voiceMessageDuration: 0:00:05.000000,
172+
...
173+
}
174+
```
184175
176+
After:
177+
```dart
178+
{
179+
...
180+
message_type: text,
181+
voiceMessageDuration: 5000000,
182+
...
183+
}
184+
```
185185
186186
## Installing
187187
@@ -203,14 +203,14 @@ import 'package:chatview/chatview.dart';
203203
final chatController = ChatController(
204204
initialMessageList: messageList,
205205
scrollController: ScrollController(),
206-
chatUsers: [ChatUser(id: '2', name: 'Simform')],
206+
currentUser: ChatUser(id: '1', name: 'Flutter'),
207+
otherUsers: [ChatUser(id: '2', name: 'Simform')],
207208
);
208209
```
209210

210211
4. Adding a `ChatView` widget.
211212
```dart
212213
ChatView(
213-
currentUser: ChatUser(id: '1', name: 'Flutter'),
214214
chatController: chatController,
215215
onSendTap: onSendTap,
216216
chatViewState: ChatViewState.hasMessages, // Add this state once data is available.
@@ -960,7 +960,7 @@ _chatController.addReplySuggestions([
960960
```dart
961961
_chatController.removeReplySuggestions();
962962
```
963-
* Update Sugestions Config
963+
* Update suggestions Config
964964
```dart
965965
replySuggestionsConfig: ReplySuggestionsConfig(
966966
itemConfig: SuggestionItemConfig(
@@ -982,8 +982,8 @@ replySuggestionsConfig: ReplySuggestionsConfig(
982982
```
983983

984984
34. Added callback `messageSorter` to sort message in `ChatBackgroundConfiguration`.
985-
```dart
986985

986+
```dart
987987
ChatView(
988988
...
989989
chatBackgroundConfig: ChatBackgroundConfiguration(
@@ -997,7 +997,6 @@ ChatView(
997997
),
998998
```
999999

1000-
10011000
## How to use
10021001

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

0 commit comments

Comments
 (0)