feat: Nicer record voice message UI with pause function
This commit is contained in:
parent
4482b37feb
commit
e86deb99c9
6 changed files with 631 additions and 557 deletions
|
|
@ -12,7 +12,6 @@ import 'package:emoji_picker_flutter/emoji_picker_flutter.dart';
|
|||
import 'package:go_router/go_router.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
import 'package:matrix/matrix.dart';
|
||||
import 'package:record/record.dart';
|
||||
import 'package:scroll_to_index/scroll_to_index.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:universal_html/html.dart' as html;
|
||||
|
|
@ -23,7 +22,6 @@ import 'package:fluffychat/config/themes.dart';
|
|||
import 'package:fluffychat/l10n/l10n.dart';
|
||||
import 'package:fluffychat/pages/chat/chat_view.dart';
|
||||
import 'package:fluffychat/pages/chat/event_info_dialog.dart';
|
||||
import 'package:fluffychat/pages/chat/recording_dialog.dart';
|
||||
import 'package:fluffychat/pages/chat_details/chat_details.dart';
|
||||
import 'package:fluffychat/utils/error_reporter.dart';
|
||||
import 'package:fluffychat/utils/file_selector.dart';
|
||||
|
|
@ -648,31 +646,14 @@ class ChatController extends State<ChatPageWithRoom>
|
|||
);
|
||||
}
|
||||
|
||||
void voiceMessageAction() async {
|
||||
room.client.getConfig(); // Preload server file configuration.
|
||||
|
||||
Future<void> onVoiceMessageSend(
|
||||
String path,
|
||||
int duration,
|
||||
List<int> waveform,
|
||||
String? fileName,
|
||||
) async {
|
||||
final scaffoldMessenger = ScaffoldMessenger.of(context);
|
||||
if (PlatformInfos.isAndroid) {
|
||||
final info = await DeviceInfoPlugin().androidInfo;
|
||||
if (info.version.sdkInt < 19) {
|
||||
showOkAlertDialog(
|
||||
context: context,
|
||||
title: L10n.of(context).unsupportedAndroidVersion,
|
||||
message: L10n.of(context).unsupportedAndroidVersionLong,
|
||||
okLabel: L10n.of(context).close,
|
||||
);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (await AudioRecorder().hasPermission() == false) return;
|
||||
final result = await showDialog<RecordingResult>(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (c) => const RecordingDialog(),
|
||||
);
|
||||
if (result == null) return;
|
||||
final audioFile = XFile(result.path);
|
||||
final audioFile = XFile(path);
|
||||
|
||||
final bytesResult = await showFutureLoadingDialog(
|
||||
context: context,
|
||||
|
|
@ -683,7 +664,7 @@ class ChatController extends State<ChatPageWithRoom>
|
|||
|
||||
final file = MatrixAudioFile(
|
||||
bytes: bytes,
|
||||
name: result.fileName ?? audioFile.path,
|
||||
name: fileName ?? audioFile.path,
|
||||
);
|
||||
|
||||
await room.sendFileEvent(
|
||||
|
|
@ -692,12 +673,12 @@ class ChatController extends State<ChatPageWithRoom>
|
|||
extraContent: {
|
||||
'info': {
|
||||
...file.info,
|
||||
'duration': result.duration,
|
||||
'duration': duration,
|
||||
},
|
||||
'org.matrix.msc3245.voice': {},
|
||||
'org.matrix.msc1767.audio': {
|
||||
'duration': result.duration,
|
||||
'waveform': result.waveform,
|
||||
'duration': duration,
|
||||
'waveform': waveform,
|
||||
},
|
||||
},
|
||||
).catchError((e) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue