Skip to content

Commit

Permalink
doc: separate out readme content
Browse files Browse the repository at this point in the history
  • Loading branch information
apurva010 committed Jul 15, 2024
1 parent 2c70e16 commit c79c400
Show file tree
Hide file tree
Showing 7 changed files with 1,000 additions and 0 deletions.
12 changes: 12 additions & 0 deletions doc/contributors.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
## Main Contributors

<table>
<tr>
<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>
<td align="center"><a href="https://github.com/aditya-chavda"><img src="https://avatars.githubusercontent.com/u/41247722?v=4" width="100px;" alt=""/><br /><sub><b>Aditya Chavda</b></sub></a></td>
</tr>
</table>
<br/>
5 changes: 5 additions & 0 deletions doc/how_to_use.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## 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.

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.
68 changes: 68 additions & 0 deletions doc/installation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
## Installing

1. Add dependency to `pubspec.yaml`

```dart
dependencies:
chatview: <latest-version>
```
*Get the latest version in the 'Installing' tab on [pub.dev](https://pub.dev/packages/chatview)*

2. Import the package
```dart
import 'package:chatview/chatview.dart';
```

3. Adding a chat controller.
```dart
final chatController = ChatController(
initialMessageList: messageList,
scrollController: ScrollController(),
currentUser: ChatUser(id: '1', name: 'Flutter'),
otherUsers: [ChatUser(id: '2', name: 'Simform')],
);
```

4. Adding a `ChatView` widget.
```dart
ChatView(
chatController: chatController,
onSendTap: onSendTap,
chatViewState: ChatViewState.hasMessages, // Add this state once data is available.
)
```

5. Adding a messageList with `Message` class.
```dart
List<Message> messageList = [
Message(
id: '1',
message: "Hi",
createdAt: createdAt,
sentBy: userId,
),
Message(
id: '2',
message: "Hello",
createdAt: createdAt,
sentBy: userId,
),
];
```

6. Adding a `onSendTap`.
```dart
void onSendTap(String message, ReplyMessage replyMessage, MessageType messageType){
final message = Message(
id: '3',
message: "How are you",
createdAt: DateTime.now(),
senBy: currentUser.id,
replyMessage: replyMessage,
messageType: messageType,
);
chatController.addMessage(message);
}
```

Note: you can evaluate message type from `messageType` parameter, based on that you can perform operations.
171 changes: 171 additions & 0 deletions doc/migration_guide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
## Migration guide for release 2.0.0

- Renamed `sendBy` field to `sentBy` in `Message` class.

- Renamed `chatUsers` field to `otherUsers` in `ChatController` class.

- Moved `currentUser` field from `ChatView` widget to `ChatController` class

- Updated `id` value in `copyWith` method of `Message` to have correct value.

- Removed `showTypingIndicator` field from `ChatView` and replaced it with `ChatController.showTypingIndicator`.

Before:
```dart
ChatView(
showTypingIndicator:false,
),
```
After:
```dart
/// use it with your [ChatController] instance.
_chatContoller.setTypingIndicator = true; // for showing indicator
_chatContoller.setTypingIndicator = false; // for hiding indicator
```
- Updated `ChatUser`, `Message` and `ReplyMessage` Data Model's `fromJson` and `toJson` methods:
##### in `ChatUser.fromJson`:
Before:
```dart
ChatUser.fromJson(
{
...
'imageType': ImageType.asset,
...
},
),
```
After:
```dart
ChatUser.fromJson(
{
...
'imageType': 'asset',
...
},
),
```
##### in `ChatUser.toJson`:
Before:
```dart
{
...
imageType: ImageType.asset,
...
}
```
After:
```dart
{
...
imageType: asset,
...
}
```
##### in `Message.fromJson`:
Before:
```dart
Message.fromJson(
{
...
'createdAt': DateTime.now(),
'message_type': MessageType.text,
'voice_message_duration': Duration(seconds: 5),
...
}
)
```
After:
```dart
Message.fromJson(
{
...
'createdAt': '2024-06-13T17:32:19.586412',
'message_type': 'text',
'voice_message_duration': '5000000',
...
}
)
```
##### in `Message.toJson`:
Before:
```dart
{
...
createdAt: 2024-06-13 17:23:19.454789,
message_type: MessageType.text,
voice_message_duration: 0:00:05.000000,
...
}
```
After:
```dart
{
...
createdAt: 2024-06-13T17:32:19.586412,
message_type: text,
voice_message_duration: 5000000,
...
}
```
##### in `ReplyMessage.fromJson`:
Before:
```dart
ReplyMessage.fromJson(
{
...
'message_type': MessageType.text,
'voiceMessageDuration': Duration(seconds: 5),
...
}
)
```
After:
```dart
ReplyMessage.fromJson(
{
...
'message_type': 'text',
'voiceMessageDuration': '5000000',
...
}
)
```
in `ReplyMessage.toJson`:
Before:
```dart
{
...
message_type: MessageType.text,
voiceMessageDuration: 0:00:05.000000,
...
}
```
After:
```dart
{
...
message_type: text,
voiceMessageDuration: 5000000,
...
}
```
Loading

0 comments on commit c79c400

Please sign in to comment.