Skip to content
Draft
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
39 changes: 39 additions & 0 deletions doc/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,39 @@ void onSendTap(String message, ReplyMessage replyMessage, MessageType messageTyp

> Note: You can evaluate message type from the 'messageType' parameter and perform operations accordingly.

## Voice Message Duration

For voice messages, you can display the duration by passing the `voiceMessageDuration` parameter when creating a message:

```dart
final voiceMessage = Message(
id: '4',
message: '/path/to/audio/file.m4a',
createdAt: DateTime.now(),
sentBy: currentUser.id,
messageType: MessageType.voice,
voiceMessageDuration: Duration(seconds: 15), // Display duration in voice message bubble
);

chatController.addMessage(voiceMessage);
```

The duration will be automatically displayed in the voice message bubble using the HH:MM:SS format. You can customize the text style using the `VoiceMessageConfiguration`:

```dart
ChatView(
// ...
sendMessageConfig: SendMessageConfiguration(
voiceMessageConfig: VoiceMessageConfiguration(
durationTextStyle: TextStyle(
fontSize: 12,
color: Colors.white,
),
),
),
)
```

# ChatView - Advanced Usage

ChatView offers extensive customization options to tailor the chat UI to your specific needs.
Expand Down Expand Up @@ -798,6 +831,12 @@ ChatView(
// - Multiple audios can be played simultaneously.
// - Starting recording will not affect any currently playing audio.
playerMode: PlayerMode.single,

// Customize the text style for voice message duration display
durationTextStyle: TextStyle(
fontSize: 12,
color: Colors.white,
),
)
),
// ...
Expand Down
4 changes: 4 additions & 0 deletions lib/src/models/config_models/voice_message_configuration.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class VoiceMessageConfiguration {
this.waveformPadding,
this.enableSeekGesture = true,
this.playerMode = PlayerMode.multi,
this.durationTextStyle,
});

/// Applies style to waveform.
Expand Down Expand Up @@ -100,4 +101,7 @@ class VoiceMessageConfiguration {
/// - Multiple audios can be played simultaneously.
/// - Note: Starting recording will not affect any currently playing audio.
final PlayerMode playerMode;

/// TextStyle for voice message duration text.
final TextStyle? durationTextStyle;
}
12 changes: 12 additions & 0 deletions lib/src/widgets/voice_message_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,18 @@ class _VoiceMessageViewState extends State<VoiceMessageView> {
const Duration(milliseconds: 500),
enableSeekGesture: widget.config?.enableSeekGesture ?? true,
),
if (widget.message.voiceMessageDuration != null)
Padding(
padding: const EdgeInsets.only(right: 8),
child: Text(
widget.message.voiceMessageDuration!.toHHMMSS(),
style: widget.config?.durationTextStyle ??
const TextStyle(
fontSize: 12,
color: Colors.white,
),
),
),
],
),
),
Expand Down