opt: live: show emoticon_unique

This commit is contained in:
bggRGjQaUbCoE
2024-11-04 11:08:50 +08:00
parent 42901b3c05
commit 2190336638
5 changed files with 89 additions and 29 deletions

View File

@@ -68,7 +68,7 @@ class MemberHttp {
String? accessKey = GStorage.localCache
.get(LocalCacheKey.accessKey, defaultValue: {})['value'];
Map<String, String> data = {
if (accessKey != null) 'access_key': accessKey,
if (accessKey?.isNotEmpty == true) 'access_key': accessKey!,
'appkey': Constants.appKey,
'build': '1462100',
'c_locale': 'zh_CN',
@@ -115,7 +115,7 @@ class MemberHttp {
String? accessKey = GStorage.localCache
.get(LocalCacheKey.accessKey, defaultValue: {})['value'];
Map<String, String> data = {
if (accessKey != null) 'access_key': accessKey,
if (accessKey?.isNotEmpty == true) 'access_key': accessKey!,
'appkey': Constants.appKey,
'build': '1462100',
'c_locale': 'zh_CN',
@@ -168,7 +168,7 @@ class MemberHttp {
String? accessKey = GStorage.localCache
.get(LocalCacheKey.accessKey, defaultValue: {})['value'];
Map<String, String> data = {
if (accessKey != null) 'access_key': accessKey,
if (accessKey?.isNotEmpty == true) 'access_key': accessKey!,
if (aid != null) 'aid': aid.toString(),
'appkey': Constants.appKey,
'build': '1462100',
@@ -230,7 +230,7 @@ class MemberHttp {
String? accessKey = GStorage.localCache
.get(LocalCacheKey.accessKey, defaultValue: {})['value'];
Map<String, String> data = {
if (accessKey != null) 'access_key': accessKey,
if (accessKey?.isNotEmpty == true) 'access_key': accessKey!,
'appkey': Constants.appKey,
'build': '1462100',
'c_locale': 'zh_CN',

View File

@@ -9,12 +9,14 @@ class RoomInfoModel {
int? liveStatus;
int? liveTime;
PlayurlInfo? playurlInfo;
bool? isPortrait;
RoomInfoModel.fromJson(Map<String, dynamic> json) {
roomId = json['room_id'];
liveStatus = json['live_status'];
liveTime = json['live_time'];
playurlInfo = PlayurlInfo.fromJson(json['playurl_info']);
isPortrait = json['is_portrait'];
}
}

View File

@@ -58,9 +58,12 @@ class LiveRoomController extends GetxController {
);
}
bool? isPortrait;
Future queryLiveInfo() async {
var res = await LiveHttp.liveRoomInfo(roomId: roomId, qn: 10000);
if (res['status']) {
isPortrait = res['data'].isPortrait;
List<CodecItem> codec =
res['data'].playurlInfo.playurl.stream.first.format.first.codec;
CodecItem item = codec.first;

View File

@@ -2,6 +2,7 @@ import 'dart:io';
import 'package:PiliPalaX/http/live.dart';
import 'package:PiliPalaX/pages/live_room/widgets/chat.dart';
import 'package:PiliPalaX/utils/utils.dart';
import 'package:floating/floating.dart';
import 'package:flutter/material.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
@@ -21,6 +22,7 @@ class LiveRoomPage extends StatefulWidget {
}
class _LiveRoomPageState extends State<LiveRoomPage> {
late final int _roomId;
final LiveRoomController _liveRoomController = Get.put(LiveRoomController());
PlPlayerController? plPlayerController;
late Future? _futureBuilder;
@@ -31,6 +33,7 @@ class _LiveRoomPageState extends State<LiveRoomPage> {
Floating? floating;
late final _isLogin = GStorage.userInfo.get('userInfoCache') != null;
late final _node = FocusNode();
late final _ctr = TextEditingController();
void playCallBack() {
@@ -40,6 +43,7 @@ class _LiveRoomPageState extends State<LiveRoomPage> {
@override
void initState() {
super.initState();
_roomId = int.parse(Get.parameters['roomid'] ?? '-1');
PlPlayerController.setPlayCallBack(playCallBack);
if (Platform.isAndroid) {
floating = Floating();
@@ -58,6 +62,7 @@ class _LiveRoomPageState extends State<LiveRoomPage> {
void dispose() {
PlPlayerController.setPlayCallBack(null);
floating?.dispose();
_node.dispose();
plPlayerController?.dispose();
_ctr.dispose();
super.dispose();
@@ -149,12 +154,25 @@ class _LiveRoomPageState extends State<LiveRoomPage> {
return Obx(
() => Row(
children: [
NetworkImgLayer(
GestureDetector(
onTap: () {
_node.unfocus();
dynamic uid = _liveRoomController
.roomInfoH5.value.roomInfo?.uid;
Get.toNamed(
'/member?mid=$uid',
arguments: {
'heroTag': Utils.makeHeroTag(uid),
},
);
},
child: NetworkImgLayer(
width: 34,
height: 34,
type: 'avatar',
src: _liveRoomController
.roomInfoH5.value.anchorInfo!.baseInfo!.face,
src: _liveRoomController.roomInfoH5.value
.anchorInfo!.baseInfo!.face,
),
),
const SizedBox(width: 10),
Column(
@@ -228,6 +246,10 @@ class _LiveRoomPageState extends State<LiveRoomPage> {
verticalScreenForTwoSeconds();
}
},
child: Listener(
onPointerDown: (_) {
_node.unfocus();
},
child: SizedBox(
width: Get.size.width,
height: MediaQuery.of(context).orientation ==
@@ -237,12 +259,18 @@ class _LiveRoomPageState extends State<LiveRoomPage> {
child: videoPlayerPanel,
),
),
),
Expanded(
child: Listener(
onPointerDown: (_) {
_node.unfocus();
},
child: LiveRoomChat(
roomId: int.parse(Get.parameters['roomid']!),
roomId: _roomId,
liveRoomController: _liveRoomController,
),
),
),
Container(
padding: EdgeInsets.only(
left: 16,
@@ -264,6 +292,7 @@ class _LiveRoomPageState extends State<LiveRoomPage> {
children: [
Expanded(
child: TextField(
focusNode: _node,
controller: _ctr,
textInputAction: TextInputAction.send,
onSubmitted: (value) {

View File

@@ -6,8 +6,11 @@ import 'package:PiliPalaX/models/live/danmu_info.dart';
import 'package:PiliPalaX/pages/live_room/controller.dart';
import 'package:PiliPalaX/services/loggeer.dart';
import 'package:PiliPalaX/tcp/live.dart';
import 'package:PiliPalaX/utils/utils.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:get/get.dart';
import '../../../utils/storage.dart';
@@ -72,6 +75,23 @@ class _LiveRoomChatState extends State<LiveRoomChat> {
color: Color(0xFFAAAAAA),
fontSize: 14,
),
recognizer: TapGestureRecognizer()
..onTap = () {
try {
dynamic uid =
widget.liveRoomController.messages[index]
['info'][0][15]['user']['uid'];
Get.toNamed(
'/member?mid=$uid',
arguments: {
'heroTag': Utils.makeHeroTag(uid),
},
);
} catch (err) {
print(err.toString());
// SmartDialog.showToast(err.toString());
}
},
),
_buildMsg(widget.liveRoomController.messages[index]),
],
@@ -153,9 +173,14 @@ class _LiveRoomChatState extends State<LiveRoomChat> {
TextSpan _buildMsg(obj) {
dynamic emots = jsonDecode(obj['info'][0][15]['extra'])['emots'];
if (emots != null) {
List list = emots.keys.map((e) {
return e.replaceAllMapped(
dynamic uemote = obj['info'][0][13];
List list = [
if (emots != null) emots.keys,
if (uemote is Map) uemote['emoticon_unique'].replaceFirst('upower_', '')
];
if (list.isNotEmpty) {
list = list.map((e) {
return e.toString().replaceAllMapped(
RegExp(r'\[(.*?)\]'),
(match) => r'\[' + match.group(1)! + r'\]',
);
@@ -166,13 +191,14 @@ class _LiveRoomChatState extends State<LiveRoomChat> {
regExp,
onMatch: (Match match) {
String key = match[0]!;
dynamic emote = emots?[key] ?? uemote;
spanChildren.add(WidgetSpan(
child: ExcludeSemantics(
child: NetworkImgLayer(
src: emots[key]['url'],
src: emote['url'],
type: 'emote',
width: emots[key]['width'].toDouble(),
height: emots[key]['height'].toDouble(),
width: emote['width'].toDouble(),
height: emote['height'].toDouble(),
semanticsLabel: key,
)),
));