feat: Nicer audio message design and send duration
This commit is contained in:
parent
015a12b04d
commit
b01d81ee30
3 changed files with 77 additions and 60 deletions
|
|
@ -356,22 +356,26 @@ class ChatController extends State<Chat> {
|
|||
|
||||
void voiceMessageAction() async {
|
||||
if (await Record().hasPermission() == false) return;
|
||||
final result = await showDialog<String>(
|
||||
final result = await showDialog<Map>(
|
||||
context: context,
|
||||
useRootNavigator: false,
|
||||
builder: (c) => const RecordingDialog(),
|
||||
);
|
||||
if (result == null) return;
|
||||
final audioFile = File(result);
|
||||
// as we already explicitly say send in the recording dialog,
|
||||
// we do not need the send file dialog anymore. We can just send this straight away.
|
||||
final audioFile = File(result['path']);
|
||||
final file = MatrixAudioFile(
|
||||
bytes: audioFile.readAsBytesSync(),
|
||||
name: audioFile.path,
|
||||
);
|
||||
await showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () => room.sendFileEvent(
|
||||
MatrixAudioFile(
|
||||
bytes: audioFile.readAsBytesSync(), name: audioFile.path),
|
||||
inReplyTo: replyEvent,
|
||||
),
|
||||
future: () =>
|
||||
room.sendFileEvent(file, inReplyTo: replyEvent, extraContent: {
|
||||
'info': {
|
||||
...file.info,
|
||||
'duration': result['duration'],
|
||||
}
|
||||
}),
|
||||
);
|
||||
setState(() {
|
||||
replyEvent = null;
|
||||
|
|
|
|||
|
|
@ -133,8 +133,10 @@ class _RecordingDialogState extends State<RecordingDialog> {
|
|||
onPressed: () async {
|
||||
_recorderSubscription?.cancel();
|
||||
await _audioRecorder.stop();
|
||||
Navigator.of(context, rootNavigator: false)
|
||||
.pop<String>(_recordedPath);
|
||||
Navigator.of(context, rootNavigator: false).pop<Map>({
|
||||
'path': _recordedPath,
|
||||
'duration': _duration.inMilliseconds,
|
||||
});
|
||||
},
|
||||
child: Text(L10n.of(context).send.toUpperCase()),
|
||||
),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue