fix: parse live info

opt: items

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-04-30 13:01:47 +08:00
parent 77e4a30bc5
commit 23813eb224
9 changed files with 247 additions and 286 deletions

View File

@@ -31,12 +31,7 @@ class VideoCardHGrpc extends StatelessWidget {
final int aid = videoItem.smallCoverV5.base.args.aid.toInt();
String type = 'video';
final String heroTag = Utils.makeHeroTag(aid);
return Stack(
clipBehavior: Clip.none,
children: [
Semantics(
excludeSemantics: true,
child: InkWell(
return InkWell(
borderRadius: BorderRadius.circular(12),
onLongPress: () => imageSaveDialog(
title: videoItem.smallCoverV5.base.title,
@@ -62,8 +57,8 @@ class VideoCardHGrpc extends StatelessWidget {
AspectRatio(
aspectRatio: StyleString.aspectRatio,
child: LayoutBuilder(
builder: (BuildContext context,
BoxConstraints boxConstraints) {
builder:
(BuildContext context, BoxConstraints boxConstraints) {
final double maxWidth = boxConstraints.maxWidth;
final double maxHeight = boxConstraints.maxHeight;
return Stack(
@@ -77,8 +72,7 @@ class VideoCardHGrpc extends StatelessWidget {
height: maxHeight,
),
),
if (videoItem
.smallCoverV5.coverRightText1.isNotEmpty)
if (videoItem.smallCoverV5.coverRightText1.isNotEmpty)
PBadge(
text: Utils.timeFormat(
videoItem.smallCoverV5.coverRightText1),
@@ -104,9 +98,6 @@ class VideoCardHGrpc extends StatelessWidget {
);
},
),
),
),
],
);
}

View File

@@ -55,12 +55,7 @@ class VideoCardVMemberHome extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Stack(
clipBehavior: Clip.none,
children: [
Semantics(
excludeSemantics: true,
child: Card(
return Card(
clipBehavior: Clip.hardEdge,
margin: EdgeInsets.zero,
child: InkWell(
@@ -103,9 +98,6 @@ class VideoCardVMemberHome extends StatelessWidget {
],
),
),
),
),
],
);
}
}

View File

@@ -16,11 +16,16 @@ class RoomInfoH5Model {
Map? blockInfo;
RoomInfoH5Model.fromJson(Map<String, dynamic> json) {
roomInfo = RoomInfo.fromJson(json['room_info']);
anchorInfo = AnchorInfo.fromJson(json['anchor_info']);
roomInfo =
json['room_info'] == null ? null : RoomInfo.fromJson(json['room_info']);
anchorInfo = json['anchor_info'] == null
? null
: AnchorInfo.fromJson(json['anchor_info']);
isRoomFeed = json['is_room_feed'];
watchedShow = json['watched_show'];
likeInfoV3 = LikeInfoV3.fromJson(json['like_info_v3']);
likeInfoV3 = json['like_info_v3'] == null
? null
: LikeInfoV3.fromJson(json['like_info_v3']);
blockInfo = json['block_info'];
}
}
@@ -82,15 +87,18 @@ class RoomInfo {
class AnchorInfo {
AnchorInfo({
this.baseInfo,
this.relationInfo,
// this.relationInfo,
});
BaseInfo? baseInfo;
RelationInfo? relationInfo;
// RelationInfo? relationInfo;
AnchorInfo.fromJson(Map<String, dynamic> json) {
baseInfo = BaseInfo.fromJson(json['base_info']);
relationInfo = RelationInfo.fromJson(json['relation_info']);
baseInfo =
json['base_info'] == null ? null : BaseInfo.fromJson(json['base_info']);
// relationInfo = json['relation_info'] == null
// ? null
// : RelationInfo.fromJson(json['relation_info']);
}
}

View File

@@ -43,20 +43,13 @@ class BangumiCardVMemberHome extends StatelessWidget {
child: AspectRatio(
aspectRatio: 0.75,
child: LayoutBuilder(builder: (context, boxConstraints) {
final double maxWidth = boxConstraints.maxWidth;
final double maxHeight = boxConstraints.maxHeight;
return Stack(
clipBehavior: Clip.none,
children: [
Hero(
return Hero(
tag: heroTag,
child: NetworkImgLayer(
src: bangumiItem.cover,
width: maxWidth,
height: maxHeight,
width: boxConstraints.maxWidth,
height: boxConstraints.maxHeight,
),
),
],
);
}),
),

View File

@@ -30,7 +30,7 @@ class LiveRoomController extends GetxController {
RxBool volumeOff = false.obs;
PlPlayerController plPlayerController =
PlPlayerController.getInstance(videoType: 'live');
Rx<RoomInfoH5Model> roomInfoH5 = RoomInfoH5Model().obs;
Rx<RoomInfoH5Model?> roomInfoH5 = Rx<RoomInfoH5Model?>(null);
RxList<dynamic> messages = [].obs;
RxBool disableAutoScroll = false.obs;
@@ -50,6 +50,7 @@ class LiveRoomController extends GetxController {
void onInit() {
super.onInit();
roomId = int.parse(Get.parameters['roomid']!);
queryLiveInfoH5();
if (Accounts.main.isLogin && !MineController.anonymity.value) {
VideoHttp.roomEntryAction(roomId: roomId);
}
@@ -131,7 +132,6 @@ class LiveRoomController extends GetxController {
heroTag,
);
}
return res;
}
LiveMessageStream? msgStream;

View File

@@ -2,6 +2,7 @@ import 'dart:async';
import 'dart:io';
import 'dart:ui';
import 'package:PiliPlus/models/live/room_info_h5.dart';
import 'package:PiliPlus/pages/live_room/send_dm_panel.dart';
import 'package:PiliPlus/pages/live_room/widgets/chat.dart';
import 'package:PiliPlus/pages/live_room/widgets/header_control.dart';
@@ -36,7 +37,6 @@ class _LiveRoomPageState extends State<LiveRoomPage>
late final int _roomId;
late final LiveRoomController _liveRoomController;
late final PlPlayerController plPlayerController;
late Future? _futureBuilder;
late Future? _futureBuilderFuture;
bool get isFullScreen => plPlayerController.isFullScreen.value;
@@ -113,7 +113,6 @@ class _LiveRoomPageState extends State<LiveRoomPage>
}
void videoSourceInit() {
_futureBuilder = _liveRoomController.queryLiveInfoH5();
plPlayerController = _liveRoomController.plPlayerController;
}
@@ -222,14 +221,14 @@ class _LiveRoomPageState extends State<LiveRoomPage>
: Positioned.fill(
child: Opacity(
opacity: 0.6,
child: _liveRoomController.roomInfoH5.value.roomInfo
child: _liveRoomController.roomInfoH5.value?.roomInfo
?.appBackground?.isNotEmpty ==
true
? CachedNetworkImage(
fit: BoxFit.cover,
width: Get.width,
height: Get.height,
imageUrl: _liveRoomController.roomInfoH5.value
imageUrl: _liveRoomController.roomInfoH5.value!
.roomInfo!.appBackground!.http2https,
)
: Image.asset(
@@ -367,21 +366,16 @@ class _LiveRoomPageState extends State<LiveRoomPage>
foregroundColor: Colors.white,
toolbarHeight: isFullScreen ? 0 : null,
titleTextStyle: TextStyle(color: Colors.white),
title: FutureBuilder(
future: _futureBuilder,
builder: (context, snapshot) {
if (snapshot.data == null) {
return const SizedBox.shrink();
}
Map data = snapshot.data as Map;
if (data['status']) {
return Obx(
() => Row(
title: Obx(
() {
return _liveRoomController.roomInfoH5.value == null
? const SizedBox.shrink()
: Row(
children: [
GestureDetector(
onTap: () {
dynamic uid =
_liveRoomController.roomInfoH5.value.roomInfo?.uid;
dynamic uid = _liveRoomController
.roomInfoH5.value!.roomInfo?.uid;
Get.toNamed(
'/member?mid=$uid',
arguments: {
@@ -394,7 +388,7 @@ class _LiveRoomPageState extends State<LiveRoomPage>
height: 34,
type: 'avatar',
src: _liveRoomController
.roomInfoH5.value.anchorInfo!.baseInfo!.face,
.roomInfoH5.value!.anchorInfo!.baseInfo!.face,
),
),
const SizedBox(width: 10),
@@ -403,14 +397,15 @@ class _LiveRoomPageState extends State<LiveRoomPage>
children: [
Text(
_liveRoomController
.roomInfoH5.value.anchorInfo!.baseInfo!.uname!,
.roomInfoH5.value!.anchorInfo!.baseInfo!.uname!,
style: const TextStyle(fontSize: 14),
),
const SizedBox(height: 1),
if (_liveRoomController.roomInfoH5.value.watchedShow !=
if (_liveRoomController
.roomInfoH5.value!.watchedShow !=
null)
Text(
_liveRoomController.roomInfoH5.value
_liveRoomController.roomInfoH5.value!
.watchedShow!['text_large'] ??
'',
style: const TextStyle(fontSize: 12),
@@ -418,11 +413,7 @@ class _LiveRoomPageState extends State<LiveRoomPage>
],
),
],
),
);
} else {
return const SizedBox.shrink();
}
},
),
actions: [
@@ -452,27 +443,24 @@ class _LiveRoomPageState extends State<LiveRoomPage>
],
),
),
if (_liveRoomController.roomInfoH5.value != null)
PopupMenuItem(
onTap: () {
try {
RoomInfoH5Model roomInfo =
_liveRoomController.roomInfoH5.value!;
PageUtils.pmShare(
this.context,
content: {
"cover": _liveRoomController
.roomInfoH5.value.roomInfo!.cover!,
"cover": roomInfo.roomInfo!.cover!,
"sourceID": _liveRoomController.roomId.toString(),
"title": _liveRoomController
.roomInfoH5.value.roomInfo!.title!,
"title": roomInfo.roomInfo!.title!,
"url":
"https://live.bilibili.com/${_liveRoomController.roomId}",
"authorID": _liveRoomController
.roomInfoH5.value.roomInfo!.uid
.toString(),
"authorID": roomInfo.roomInfo!.uid.toString(),
"source": "直播",
"desc": _liveRoomController
.roomInfoH5.value.roomInfo!.title!,
"author": _liveRoomController
.roomInfoH5.value.anchorInfo!.baseInfo!.uname,
"desc": roomInfo.roomInfo!.title!,
"author": roomInfo.anchorInfo!.baseInfo!.uname,
},
);
} catch (e) {

View File

@@ -45,15 +45,10 @@ class MemberFavItem extends StatelessWidget {
aspectRatio: StyleString.aspectRatio,
child: LayoutBuilder(
builder: (context, boxConstraints) {
return Stack(
clipBehavior: Clip.none,
children: [
NetworkImgLayer(
return NetworkImgLayer(
src: item['cover'],
width: boxConstraints.maxWidth,
height: boxConstraints.maxHeight,
),
],
);
},
),

View File

@@ -85,10 +85,7 @@ class SubVideoCardH extends StatelessWidget {
Widget videoContent(context) {
return Expanded(
child: Stack(
clipBehavior: Clip.none,
children: [
Column(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
@@ -128,8 +125,6 @@ class SubVideoCardH extends StatelessWidget {
),
],
),
],
),
);
}
}

View File

@@ -732,7 +732,6 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
return Stack(
fit: StackFit.passthrough,
key: _playerKey,
clipBehavior: Clip.none,
children: <Widget>[
Obx(
() => Video(