added new guide
This commit is contained in:
@@ -13,6 +13,21 @@ limited to fonts, colors, and shapes.
|
|||||||
|
|
||||||
This guide details how to customize the `MessageWidget` in the Stream Chat Flutter UI SDK.
|
This guide details how to customize the `MessageWidget` in the Stream Chat Flutter UI SDK.
|
||||||
|
|
||||||
|
### Building Custom Messages
|
||||||
|
|
||||||
|
This guide goes into detail about the ability to customize the `MessageWidget`. However, if you want
|
||||||
|
to customize the default `MessageWidget` in the `MessageListView` provided, you can use the `.copyWith()` method
|
||||||
|
provided inside the `messageBuilder` parameter of the `MessageListView` like this:
|
||||||
|
|
||||||
|
```dart
|
||||||
|
MessageListView(
|
||||||
|
messageBuilder: (context, details, messageList, defaultImpl) {
|
||||||
|
// Your implementation of the message here
|
||||||
|
// E.g: return Text(details.message.text ?? '');
|
||||||
|
},
|
||||||
|
),
|
||||||
|
```
|
||||||
|
|
||||||
### Theming
|
### Theming
|
||||||
|
|
||||||
You can customize the `MessageWidget` using the `StreamChatTheme` class, so that you can change the
|
You can customize the `MessageWidget` using the `StreamChatTheme` class, so that you can change the
|
||||||
@@ -35,8 +50,8 @@ StreamChatThemeData(
|
|||||||
|
|
||||||
/// Sets theme for user's messages
|
/// Sets theme for user's messages
|
||||||
ownMessageTheme: MessageThemeData(
|
ownMessageTheme: MessageThemeData(
|
||||||
messageBackgroundColor: colorTheme.textHighEmphasis,
|
messageBackgroundColor: colorTheme.textHighEmphasis,
|
||||||
),
|
),
|
||||||
|
|
||||||
/// Sets theme for received messages
|
/// Sets theme for received messages
|
||||||
otherMessageTheme: MessageThemeData(
|
otherMessageTheme: MessageThemeData(
|
||||||
@@ -48,6 +63,8 @@ StreamChatThemeData(
|
|||||||
)
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
#### Change message text style
|
#### Change message text style
|
||||||
|
|
||||||
The `MessageWidget` has multiple `Text` widgets that you can manipulate the styles of. The three main
|
The `MessageWidget` has multiple `Text` widgets that you can manipulate the styles of. The three main
|
||||||
@@ -62,6 +79,8 @@ MessageThemeData(
|
|||||||
)
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
#### Change avatar theme
|
#### Change avatar theme
|
||||||
|
|
||||||
You can change the attributes of the avatar (if displayed) using the `avatarTheme` property.
|
You can change the attributes of the avatar (if displayed) using the `avatarTheme` property.
|
||||||
@@ -74,6 +93,8 @@ MessageThemeData(
|
|||||||
)
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
#### Changing Reaction theme
|
#### Changing Reaction theme
|
||||||
|
|
||||||
You also customize the reactions attached to every message using the theme.
|
You also customize the reactions attached to every message using the theme.
|
||||||
@@ -86,6 +107,8 @@ MessageThemeData(
|
|||||||
),
|
),
|
||||||
```
|
```
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
### Changing Message Actions
|
### Changing Message Actions
|
||||||
|
|
||||||
When a message is long pressed, the `MessageActionsModal` is shown.
|
When a message is long pressed, the `MessageActionsModal` is shown.
|
||||||
@@ -95,21 +118,23 @@ The `MessageWidget` allows showing or hiding some options if you so choose.
|
|||||||
```dart
|
```dart
|
||||||
MessageWidget(
|
MessageWidget(
|
||||||
...
|
...
|
||||||
this.showUsername = true,
|
showUsername = true,
|
||||||
this.showTimestamp = true,
|
showTimestamp = true,
|
||||||
this.showReactions = true,
|
showReactions = true,
|
||||||
this.showDeleteMessage = true,
|
showDeleteMessage = true,
|
||||||
this.showEditMessage = true,
|
showEditMessage = true,
|
||||||
this.showReplyMessage = true,
|
showReplyMessage = true,
|
||||||
this.showThreadReplyMessage = true,
|
showThreadReplyMessage = true,
|
||||||
this.showResendMessage = true,
|
showResendMessage = true,
|
||||||
this.showCopyMessage = true,
|
showCopyMessage = true,
|
||||||
this.showFlagButton = true,
|
showFlagButton = true,
|
||||||
this.showPinButton = true,
|
showPinButton = true,
|
||||||
this.showPinHighlight = true,
|
showPinHighlight = true,
|
||||||
),
|
),
|
||||||
```
|
```
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
### Building attachments
|
### Building attachments
|
||||||
|
|
||||||
The `customAttachmentBuilder` property allows you to build any kind of attachment (inbuilt or custom)
|
The `customAttachmentBuilder` property allows you to build any kind of attachment (inbuilt or custom)
|
||||||
@@ -136,4 +161,22 @@ MessageListView(
|
|||||||
),
|
),
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Widget Builders
|
||||||
|
|
||||||
|
Some parameters allow you to construct your own widget in place of some elements in the `MessageWidget`.
|
||||||
|
|
||||||
|
These are:
|
||||||
|
* `userAvatarBuilder` : Allows user to substitute their own widget in place of the user avatar.
|
||||||
|
* `editMessageInputBuilder` : Allows user to substitute their own widget in place of the input in edit mode.
|
||||||
|
* `textBuilder` : Allows user to substitute their own widget in place of the text.
|
||||||
|
* `bottomRowBuilder` : Allows user to substitute their own widget in the bottom of the message when not deleted.
|
||||||
|
* `deletedBottomRowBuilder` : Allows user to substitute their own widget in the bottom of the message when deleted.
|
||||||
|
|
||||||
|
```dart
|
||||||
|
MessageWidget(
|
||||||
|
...
|
||||||
|
textBuilder: (context, message) {
|
||||||
|
// Add your own text implementation here.
|
||||||
|
},
|
||||||
|
),
|
||||||
|
```
|
||||||
|
|||||||
Reference in New Issue
Block a user