mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-04-22 03:31:09 +08:00
live dm action
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -8,6 +8,7 @@ import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/http/video.dart';
|
||||
import 'package:PiliPlus/models/common/super_chat_type.dart';
|
||||
import 'package:PiliPlus/models/common/video/live_quality.dart';
|
||||
import 'package:PiliPlus/models/model_owner.dart';
|
||||
import 'package:PiliPlus/models_new/live/live_danmaku/danmaku_msg.dart';
|
||||
import 'package:PiliPlus/models_new/live/live_danmaku/live_emote.dart';
|
||||
import 'package:PiliPlus/models_new/live/live_dm_info/data.dart';
|
||||
@@ -441,6 +442,22 @@ class LiveRoomController extends GetxController {
|
||||
if (first[13] case Map<String, dynamic> map) {
|
||||
uemote = BaseEmote.fromJson(map);
|
||||
}
|
||||
final checkInfo = info[9];
|
||||
final liveExtra = LiveDanmaku(
|
||||
id: extra['id_str'],
|
||||
mid: uid,
|
||||
dmType: extra['dm_type'],
|
||||
ts: checkInfo['ts'],
|
||||
ct: checkInfo['ct'],
|
||||
);
|
||||
Owner? reply;
|
||||
final replyMid = extra['reply_mid'];
|
||||
if (replyMid != null && replyMid != 0) {
|
||||
reply = Owner(
|
||||
mid: replyMid,
|
||||
name: extra['reply_uname'],
|
||||
);
|
||||
}
|
||||
messages.add(
|
||||
DanmakuMsg(
|
||||
name: name,
|
||||
@@ -450,11 +467,12 @@ class LiveRoomController extends GetxController {
|
||||
(k, v) => MapEntry(k, BaseEmote.fromJson(v)),
|
||||
),
|
||||
uemote: uemote,
|
||||
extra: liveExtra,
|
||||
reply: reply,
|
||||
),
|
||||
);
|
||||
|
||||
if (plPlayerController.showDanmaku) {
|
||||
final checkInfo = info[9];
|
||||
danmakuController?.addDanmaku(
|
||||
DanmakuContentItem(
|
||||
msg,
|
||||
@@ -464,13 +482,7 @@ class LiveRoomController extends GetxController {
|
||||
type: DmUtils.getPosition(extra['mode']),
|
||||
// extra['send_from_me'] is invalid
|
||||
selfSend: isLogin && uid == mid,
|
||||
extra: LiveDanmaku(
|
||||
id: extra['id_str'],
|
||||
mid: uid,
|
||||
dmType: extra['dm_type'],
|
||||
ts: checkInfo['ts'],
|
||||
ct: checkInfo['ct'],
|
||||
),
|
||||
extra: liveExtra,
|
||||
),
|
||||
);
|
||||
if (!disableAutoScroll.value) {
|
||||
|
||||
@@ -160,11 +160,27 @@ class _ReplyPageState extends CommonRichTextPubPageState<LiveSendDmPanel> {
|
||||
int? dmType,
|
||||
emoticonOptions,
|
||||
}) async {
|
||||
int replyMid = 0;
|
||||
String replyDmid = '';
|
||||
if (message == null) {
|
||||
final buffer = StringBuffer();
|
||||
for (final e in editController.items) {
|
||||
if (e.type == .at) {
|
||||
replyMid = int.parse(e.rawText);
|
||||
replyDmid = e.id!;
|
||||
} else {
|
||||
buffer.write(e.rawText);
|
||||
}
|
||||
}
|
||||
message = buffer.toString();
|
||||
}
|
||||
final res = await LiveHttp.sendLiveMsg(
|
||||
roomId: liveRoomController.roomId,
|
||||
msg: message ?? editController.rawText,
|
||||
msg: message,
|
||||
dmType: dmType,
|
||||
emoticonOptions: emoticonOptions,
|
||||
replyMid: replyMid,
|
||||
replayDmid: replyDmid,
|
||||
);
|
||||
if (res.isSuccess) {
|
||||
hasPub = true;
|
||||
|
||||
@@ -4,6 +4,7 @@ import 'dart:ui';
|
||||
|
||||
import 'package:PiliPlus/common/widgets/button/icon_button.dart';
|
||||
import 'package:PiliPlus/common/widgets/custom_icon.dart';
|
||||
import 'package:PiliPlus/common/widgets/flutter/text_field/controller.dart';
|
||||
import 'package:PiliPlus/common/widgets/image/network_img_layer.dart';
|
||||
import 'package:PiliPlus/common/widgets/keep_alive_wrapper.dart';
|
||||
import 'package:PiliPlus/common/widgets/scroll_physics.dart';
|
||||
@@ -725,6 +726,16 @@ class _LiveRoomPageState extends State<LiveRoomPage>
|
||||
isPP: isPP,
|
||||
roomId: _liveRoomController.roomId,
|
||||
liveRoomController: _liveRoomController,
|
||||
onAtUser: (item) => _liveRoomController
|
||||
..savedDanmaku = [
|
||||
RichTextItem.fromStart(
|
||||
'@${item.name} ',
|
||||
rawText: item.uid.toString(),
|
||||
type: .at,
|
||||
id: item.extra.id.toString(),
|
||||
),
|
||||
]
|
||||
..onSendDanmaku(),
|
||||
);
|
||||
return Padding(
|
||||
padding: EdgeInsets.only(bottom: 12, top: isPortrait ? 12 : 0),
|
||||
|
||||
@@ -1,12 +1,17 @@
|
||||
import 'package:PiliPlus/common/widgets/image/network_img_layer.dart';
|
||||
import 'package:PiliPlus/http/live.dart';
|
||||
import 'package:PiliPlus/models/common/image_type.dart';
|
||||
import 'package:PiliPlus/models_new/live/live_danmaku/danmaku_msg.dart';
|
||||
import 'package:PiliPlus/models_new/live/live_superchat/item.dart';
|
||||
import 'package:PiliPlus/pages/live_room/controller.dart';
|
||||
import 'package:PiliPlus/pages/video/widgets/header_control.dart';
|
||||
import 'package:PiliPlus/utils/accounts.dart';
|
||||
import 'package:PiliPlus/utils/extension/theme_ext.dart';
|
||||
import 'package:PiliPlus/utils/utils.dart';
|
||||
import 'package:flutter/foundation.dart' show kDebugMode;
|
||||
import 'package:flutter/gestures.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
class LiveRoomChatPanel extends StatelessWidget {
|
||||
@@ -14,12 +19,15 @@ class LiveRoomChatPanel extends StatelessWidget {
|
||||
super.key,
|
||||
required this.roomId,
|
||||
required this.liveRoomController,
|
||||
this.isPP = false,
|
||||
required this.isPP,
|
||||
required this.onAtUser,
|
||||
});
|
||||
|
||||
final int roomId;
|
||||
final LiveRoomController liveRoomController;
|
||||
final bool isPP;
|
||||
final ValueChanged<DanmakuMsg> onAtUser;
|
||||
|
||||
bool get disableAutoScroll => liveRoomController.disableAutoScroll.value;
|
||||
|
||||
@override
|
||||
@@ -31,6 +39,10 @@ class LiveRoomChatPanel extends StatelessWidget {
|
||||
? Colors.white.withValues(alpha: 0.9)
|
||||
: Colors.white.withValues(alpha: 0.6);
|
||||
late final devicePixelRatio = MediaQuery.devicePixelRatioOf(context);
|
||||
late final colorScheme = ColorScheme.of(context);
|
||||
late final primary = colorScheme.isDark
|
||||
? colorScheme.primary
|
||||
: colorScheme.inversePrimary;
|
||||
return Stack(
|
||||
children: [
|
||||
Obx(
|
||||
@@ -67,8 +79,16 @@ class LiveRoomChatPanel extends StatelessWidget {
|
||||
? null
|
||||
: (TapGestureRecognizer()
|
||||
..onTap = () =>
|
||||
Get.toNamed('/member?mid=${item.uid}')),
|
||||
_showMsgDialog(context, item)),
|
||||
),
|
||||
if (item.reply case final reply?)
|
||||
TextSpan(
|
||||
text: '@${reply.name} ',
|
||||
style: TextStyle(color: primary, fontSize: 14),
|
||||
recognizer: TapGestureRecognizer()
|
||||
..onTap = () =>
|
||||
Get.toNamed('/member?mid=${reply.mid}'),
|
||||
),
|
||||
_buildMsg(devicePixelRatio, item),
|
||||
],
|
||||
),
|
||||
@@ -252,4 +272,83 @@ class LiveRoomChatPanel extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void _showMsgDialog(BuildContext context, DanmakuMsg item) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => SimpleDialog(
|
||||
clipBehavior: .hardEdge,
|
||||
contentPadding: const .symmetric(vertical: 12),
|
||||
constraints: const BoxConstraints(minWidth: 280, maxWidth: 320),
|
||||
title: Column(
|
||||
spacing: 4,
|
||||
mainAxisSize: .min,
|
||||
crossAxisAlignment: .start,
|
||||
children: [
|
||||
Text(
|
||||
item.name,
|
||||
style: const TextStyle(fontSize: 15),
|
||||
),
|
||||
Text(
|
||||
item.text,
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: ColorScheme.of(context).outline,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
children: [
|
||||
ListTile(
|
||||
dense: true,
|
||||
onTap: () {
|
||||
Get
|
||||
..back()
|
||||
..toNamed('/member?mid=${item.uid}');
|
||||
},
|
||||
title: const Text('去TA的个人空间', style: TextStyle(fontSize: 14)),
|
||||
),
|
||||
ListTile(
|
||||
dense: true,
|
||||
onTap: () {
|
||||
Get.back();
|
||||
onAtUser(item);
|
||||
},
|
||||
title: const Text('@TA', style: TextStyle(fontSize: 14)),
|
||||
),
|
||||
ListTile(
|
||||
dense: true,
|
||||
title: const Text('屏蔽发送者', style: TextStyle(fontSize: 14)),
|
||||
onTap: () async {
|
||||
Get.back();
|
||||
if (!Accounts.main.isLogin) return;
|
||||
final res = await LiveHttp.liveShieldUser(
|
||||
uid: item.uid,
|
||||
roomid: roomId,
|
||||
type: 1,
|
||||
);
|
||||
if (res.isSuccess) {
|
||||
SmartDialog.showToast('屏蔽成功');
|
||||
} else {
|
||||
res.toast();
|
||||
}
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
dense: true,
|
||||
title: const Text('举报选中弹幕', style: TextStyle(fontSize: 14)),
|
||||
onTap: () {
|
||||
Get.back();
|
||||
HeaderControl.reportLiveDanmaku(
|
||||
context,
|
||||
roomId: roomId,
|
||||
msg: item.text,
|
||||
extra: item.extra,
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user