Merge branch 'main' into feature-updateVideoDetailStructure

This commit is contained in:
guozhigq
2024-05-22 00:02:30 +08:00
6 changed files with 50 additions and 13 deletions

View File

@ -20,11 +20,13 @@ import 'network_img_layer.dart';
class VideoCardV extends StatelessWidget {
final dynamic videoItem;
final int crossAxisCount;
final Function? blockUserCb;
const VideoCardV({
Key? key,
required this.videoItem,
required this.crossAxisCount,
this.blockUserCb,
}) : super(key: key);
bool isStringNumeric(String str) {
@ -157,7 +159,11 @@ class VideoCardV extends StatelessWidget {
);
}),
),
VideoContent(videoItem: videoItem, crossAxisCount: crossAxisCount)
VideoContent(
videoItem: videoItem,
crossAxisCount: crossAxisCount,
blockUserCb: blockUserCb,
)
],
),
);
@ -167,9 +173,14 @@ class VideoCardV extends StatelessWidget {
class VideoContent extends StatelessWidget {
final dynamic videoItem;
final int crossAxisCount;
const VideoContent(
{Key? key, required this.videoItem, required this.crossAxisCount})
: super(key: key);
final Function? blockUserCb;
const VideoContent({
Key? key,
required this.videoItem,
required this.crossAxisCount,
this.blockUserCb,
}) : super(key: key);
Widget _buildBadge(String text, String type, [double fs = 12]) {
return PBadge(
@ -241,7 +252,10 @@ class VideoContent extends StatelessWidget {
useRootNavigator: true,
isScrollControlled: true,
builder: (context) {
return MorePanel(videoItem: videoItem);
return MorePanel(
videoItem: videoItem,
blockUserCb: blockUserCb,
);
},
);
},
@ -297,11 +311,17 @@ class VideoStat extends StatelessWidget {
class MorePanel extends StatelessWidget {
final dynamic videoItem;
const MorePanel({super.key, required this.videoItem});
final Function? blockUserCb;
const MorePanel({
super.key,
required this.videoItem,
this.blockUserCb,
});
Future<dynamic> menuActionHandler(String type) async {
switch (type) {
case 'block':
Get.back();
blockUser();
break;
case 'watchLater':
@ -338,7 +358,10 @@ class MorePanel extends StatelessWidget {
reSrc: 11,
);
SmartDialog.dismiss();
SmartDialog.showToast(res['msg'] ?? '成功');
if (res['status']) {
blockUserCb?.call(videoItem.owner.mid);
}
SmartDialog.showToast(res['msg']);
},
child: const Text('确认'),
)

View File

@ -387,9 +387,15 @@ class VideoHttp {
'csrf': await Request.getCsrf(),
});
if (res.data['code'] == 0) {
return {'status': true, 'data': res.data['data']};
if (act == 5) {
List<int> blackMidsList =
setting.get(SettingBoxKey.blackMidsList, defaultValue: [-1]);
blackMidsList.add(mid);
setting.put(SettingBoxKey.blackMidsList, blackMidsList);
}
return {'status': true, 'data': res.data['data'], 'msg': '成功'};
} else {
return {'status': false, 'data': []};
return {'status': false, 'data': [], 'msg': res.data['message']};
}
}

View File

@ -1,4 +1,5 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:get/get.dart';
import 'package:hive/hive.dart';
import 'package:pilipala/http/video.dart';
@ -106,4 +107,10 @@ class RcmdController extends GetxController {
duration: const Duration(milliseconds: 500), curve: Curves.easeInOut);
}
}
void blockUserCb(mid) {
videoList.removeWhere((e) => e.owner.mid == mid);
videoList.refresh();
SmartDialog.showToast('已移除相关视频');
}
}

View File

@ -146,6 +146,7 @@ class _RcmdPageState extends State<RcmdPage>
? VideoCardV(
videoItem: videoList[index],
crossAxisCount: crossAxisCount,
blockUserCb: (mid) => ctr.blockUserCb(mid),
)
: const VideoCardVSkeleton();
},

View File

@ -233,7 +233,7 @@ class VideoDetailController extends GetxController
audio,
seekToTime,
duration,
bool autoplay = true,
bool? autoplay,
}) async {
/// 设置/恢复 屏幕亮度
if (brightness != null) {
@ -266,7 +266,7 @@ class VideoDetailController extends GetxController
cid: cid.value,
enableHeart: enableHeart,
isFirstTime: isFirstTime,
autoplay: autoplay,
autoplay: autoplay ?? autoPlay.value,
);
/// 开启自动全屏时在player初始化完成后立即传入headerControl

View File

@ -176,7 +176,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
/// 未开启自动播放时触发播放
Future<void> handlePlay() async {
await vdCtr.playerInit();
await vdCtr.playerInit(autoplay: true);
plPlayerController = vdCtr.plPlayerController;
plPlayerController!.addStatusLister(playerListener);
vdCtr.autoPlay.value = true;
@ -266,7 +266,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
}
vdCtr.isFirstTime = false;
final bool autoplay = autoPlayEnable;
vdCtr.playerInit(autoplay: autoplay);
vdCtr.playerInit();
/// 未开启自动播放时,未播放跳转下一页返回/播放后跳转下一页返回
vdCtr.autoPlay.value = !vdCtr.isShowCover.value;