Call records

This commit is contained in:
LittleSheep 2024-06-28 04:34:35 +08:00
parent ec14d1e3b3
commit 459469998b
3 changed files with 35 additions and 3 deletions

View File

@ -168,6 +168,8 @@ class SolianMessages extends Translations {
'messageUnsyncCaption': '@count message(s) still in un-synced.', 'messageUnsyncCaption': '@count message(s) still in un-synced.',
'messageEditDesc': 'Edited message @id', 'messageEditDesc': 'Edited message @id',
'messageDeleteDesc': 'Deleted message @id', 'messageDeleteDesc': 'Deleted message @id',
'messageCallStartDesc': '@user starts a call',
'messageCallEndDesc': 'Call last for @duration',
'messageTypeUnsupported': 'Unsupported Message: @type', 'messageTypeUnsupported': 'Unsupported Message: @type',
'messageInputPlaceholder': 'Message @channel', 'messageInputPlaceholder': 'Message @channel',
'messageActionList': 'Actions of Message', 'messageActionList': 'Actions of Message',
@ -385,6 +387,8 @@ class SolianMessages extends Translations {
'messageDecoding': '解码信息中…', 'messageDecoding': '解码信息中…',
'messageEditDesc': '修改了消息 @id', 'messageEditDesc': '修改了消息 @id',
'messageDeleteDesc': '删除了消息 @id', 'messageDeleteDesc': '删除了消息 @id',
'messageCallStartDesc': '@user 发起了一次童话',
'messageCallEndDesc': '通话持续了 @duration',
'messageTypeUnsupported': '不支持的消息类型 @type', 'messageTypeUnsupported': '不支持的消息类型 @type',
'messageActionList': '消息的操作', 'messageActionList': '消息的操作',
'messageDeletionConfirm': '确认删除消息', 'messageDeletionConfirm': '确认删除消息',

View File

@ -1,5 +1,3 @@
import 'dart:math';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
@ -30,6 +28,14 @@ class ChatEvent extends StatelessWidget {
this.chatController, this.chatController,
}); });
String _formatDuration(Duration duration) {
String negativeSign = duration.isNegative ? '-' : '';
String twoDigits(int n) => n.toString().padLeft(2, '0');
String twoDigitMinutes = twoDigits(duration.inMinutes.remainder(60).abs());
String twoDigitSeconds = twoDigits(duration.inSeconds.remainder(60).abs());
return '$negativeSign${twoDigits(duration.inHours)}:$twoDigitMinutes:$twoDigitSeconds';
}
Widget buildQuote() { Widget buildQuote() {
return FutureBuilder( return FutureBuilder(
future: chatController!.getEvent( future: chatController!.getEvent(
@ -75,6 +81,27 @@ class ChatEvent extends StatelessWidget {
isHasMerged: isHasMerged, isHasMerged: isHasMerged,
isQuote: isQuote, isQuote: isQuote,
); );
case 'calls.start':
return ChatEventMessageActionLog(
icon: const Icon(Icons.call_made, size: 16),
text: 'messageCallStartDesc'
.trParams({'user': '@${item.sender.account.name}'}),
isMerged: isMerged,
isHasMerged: isHasMerged,
isQuote: isQuote,
);
case 'calls.end':
return ChatEventMessageActionLog(
icon: const Icon(Icons.call_received, size: 16),
text: 'messageCallEndDesc'.trParams({
'duration': _formatDuration(
Duration(milliseconds: item.body['last']),
),
}),
isMerged: isMerged,
isHasMerged: isHasMerged,
isQuote: isQuote,
);
case 'system.changes': case 'system.changes':
return ChatEventMessageActionLog( return ChatEventMessageActionLog(
icon: const Icon(Icons.manage_history, size: 16), icon: const Icon(Icons.manage_history, size: 16),

View File

@ -65,8 +65,9 @@ class _ChatMessageInputState extends State<ChatMessageInput> {
// TODO Deal with the @ ping (query uid with username), and then add into related_user and replace the @ with internal link in body // TODO Deal with the @ ping (query uid with username), and then add into related_user and replace the @ with internal link in body
const uuid = Uuid();
final payload = { final payload = {
'uuid': const Uuid().v4(), 'uuid': uuid.v4(),
'type': _editTo == null ? 'messages.new' : 'messages.edit', 'type': _editTo == null ? 'messages.new' : 'messages.edit',
'body': { 'body': {
'text': _textController.value.text, 'text': _textController.value.text,