Browse Source

feat(call): 更新通话状态并优化表情和录音功能

- 在通话控制器中添加 calling 状态更新逻辑
- 调整表情配置将笑脸表情排列到前面
- 在语音输入组件中添加 60 秒最大录音时长限制
- 优化通话页面余额显示逻辑基于通话时长判断
- 修复语音输入时间格式化显示问题
master
Jolie 2 months ago
parent
commit
a2047d064b
4 changed files with 46 additions and 16 deletions
  1. 18
      lib/config/emoji_config.dart
  2. 11
      lib/controller/message/call_controller.dart
  3. 11
      lib/pages/message/video_call_page.dart
  4. 22
      lib/widget/message/voice_input_view.dart

18
lib/config/emoji_config.dart

@ -28,27 +28,31 @@ class EmojiItem {
class EmojiConfig {
static const String basePath = 'assets/images/emoji/';
///
///
static const List<EmojiItem> allEmojis = [
//
EmojiItem(id: '19', name: '开心', path: '${basePath}emoji_19.png'),
EmojiItem(id: '06', name: '吐舌笑', path: '${basePath}emoji_06.png'),
EmojiItem(id: '11', name: '墨镜笑', path: '${basePath}emoji_11.png'),
EmojiItem(id: '14', name: '奸笑', path: '${basePath}emoji_14.png'),
EmojiItem(id: '17', name: '尴尬笑', path: '${basePath}emoji_17.png'),
EmojiItem(id: '47', name: '猫咪笑', path: '${basePath}emoji_47.png'),
EmojiItem(id: '54', name: '笑哭', path: '${basePath}emoji_54.png'),
//
EmojiItem(id: '01', name: '不爽', path: '${basePath}emoji_01.png'),
EmojiItem(id: '02', name: '不自在', path: '${basePath}emoji_02.png'),
EmojiItem(id: '03', name: '兴奋', path: '${basePath}emoji_03.png'),
EmojiItem(id: '04', name: '叹气', path: '${basePath}emoji_04.png'),
EmojiItem(id: '05', name: '吃惊', path: '${basePath}emoji_05.png'),
EmojiItem(id: '06', name: '吐舌笑', path: '${basePath}emoji_06.png'),
EmojiItem(id: '07', name: '吐舌头', path: '${basePath}emoji_07.png'),
EmojiItem(id: '08', name: '哭泣', path: '${basePath}emoji_08.png'),
EmojiItem(id: '09', name: '困了', path: '${basePath}emoji_09.png'),
EmojiItem(id: '10', name: '困惑', path: '${basePath}emoji_10.png'),
EmojiItem(id: '11', name: '墨镜笑', path: '${basePath}emoji_11.png'),
EmojiItem(id: '12', name: '大哭', path: '${basePath}emoji_12.png'),
EmojiItem(id: '13', name: '失望', path: '${basePath}emoji_13.png'),
EmojiItem(id: '14', name: '奸笑', path: '${basePath}emoji_14.png'),
EmojiItem(id: '15', name: '害羞', path: '${basePath}emoji_15.png'),
EmojiItem(id: '16', name: '尴尬', path: '${basePath}emoji_16.png'),
EmojiItem(id: '17', name: '尴尬笑', path: '${basePath}emoji_17.png'),
EmojiItem(id: '18', name: '尴尬露齿', path: '${basePath}emoji_18.png'),
EmojiItem(id: '19', name: '开心', path: '${basePath}emoji_19.png'),
EmojiItem(id: '20', name: '恶心', path: '${basePath}emoji_20.png'),
EmojiItem(id: '21', name: '惊恐', path: '${basePath}emoji_21.png'),
EmojiItem(id: '22', name: '惊讶', path: '${basePath}emoji_22.png'),
@ -76,14 +80,12 @@ class EmojiConfig {
EmojiItem(id: '44', name: '火冒三丈', path: '${basePath}emoji_44.png'),
EmojiItem(id: '45', name: '焦虑', path: '${basePath}emoji_45.png'),
EmojiItem(id: '46', name: '狡猾', path: '${basePath}emoji_46.png'),
EmojiItem(id: '47', name: '猫咪笑', path: '${basePath}emoji_47.png'),
EmojiItem(id: '48', name: '生气', path: '${basePath}emoji_48.png'),
EmojiItem(id: '49', name: '生气皱眉', path: '${basePath}emoji_49.png'),
EmojiItem(id: '50', name: '疑问', path: '${basePath}emoji_50.png'),
EmojiItem(id: '51', name: '眨眼害羞', path: '${basePath}emoji_51.png'),
EmojiItem(id: '52', name: '眨眼飞吻', path: '${basePath}emoji_52.png'),
EmojiItem(id: '53', name: '禁言', path: '${basePath}emoji_53.png'),
EmojiItem(id: '54', name: '笑哭', path: '${basePath}emoji_54.png'),
EmojiItem(id: '55', name: '翻白眼', path: '${basePath}emoji_55.png'),
EmojiItem(id: '56', name: '翻白眼叹气', path: '${basePath}emoji_56.png'),
EmojiItem(id: '57', name: '翻白眼无奈', path: '${basePath}emoji_57.png'),

11
lib/controller/message/call_controller.dart

@ -1005,6 +1005,17 @@ class CallController extends GetxController {
_callChannelId = channelId;
}
// calling
// CallSession status final
final updatedSession = CallSession(
targetUserId: callSession.targetUserId,
callType: callSession.callType,
status: CallStatus.calling, //
isInitiator: callSession.isInitiator,
startTime: callSession.startTime,
);
currentCall.value = updatedSession;
// 1
//
if (_consumeTimer == null) {

11
lib/pages/message/video_call_page.dart

@ -576,19 +576,22 @@ class _VideoCallPageState extends State<VideoCallPage> {
Obx(() {
final callSession = _callController.currentCall.value;
final consumeData = _callController.consumeResponse.value;
final callDuration = _callController.callDurationSeconds.value;
// waitCalling
final isCalling = callSession?.status == CallStatus.waitCalling;
// 0
final isCallConnected = callSession != null && callDuration > 0;
//
final isFree = consumeData?.isFree == true;
if (isCalling || isFree) {
//
if (!isCallConnected || isFree) {
return const SizedBox.shrink();
}
final availableBalance = consumeData?.availableBalance ?? 0;
final unitSellingBalance = consumeData?.unitSellingBalance ?? 0;
if (availableBalance <= 0 && unitSellingBalance <= 0) {
return SizedBox();
return const SizedBox.shrink();
}
return Center(
child: Text(

22
lib/widget/message/voice_input_view.dart

@ -27,6 +27,9 @@ class _VoiceInputViewState extends State<VoiceInputView> {
bool _isCanceling = false;
Offset _panStartPosition = Offset.zero;
String? _recordingPath;
//
static const int maxRecordingDuration = 60;
@override
void dispose() {
@ -48,8 +51,10 @@ class _VoiceInputViewState extends State<VoiceInputView> {
//
String _formatTime(int seconds) {
final minutes = seconds ~/ 60;
final secs = seconds % 60;
// 60
final displaySeconds = seconds.clamp(0, maxRecordingDuration);
final minutes = displaySeconds ~/ 60;
final secs = displaySeconds % 60;
return '$minutes:${secs.toString().padLeft(2, '0')}';
}
@ -87,6 +92,15 @@ class _VoiceInputViewState extends State<VoiceInputView> {
timer.cancel();
return;
}
//
if (_seconds >= maxRecordingDuration) {
// 60
timer.cancel();
_stopRecording(cancel: false);
return;
}
setState(() {
_seconds++;
});
@ -104,8 +118,8 @@ class _VoiceInputViewState extends State<VoiceInputView> {
if (_isRecording) {
try {
//
final finalSeconds = _seconds;
// 60
final finalSeconds = _seconds.clamp(0, maxRecordingDuration);
final finalPath = _recordingPath;
await _audioRecorder.stop();

Loading…
Cancel
Save