mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
Merge remote-tracking branch 'upstream/main'
This commit is contained in:
@@ -18,6 +18,7 @@ import 'package:pilipala/utils/id_utils.dart';
|
||||
import 'package:pilipala/utils/storage.dart';
|
||||
import 'package:share_plus/share_plus.dart';
|
||||
|
||||
import '../related/index.dart';
|
||||
import 'widgets/group_panel.dart';
|
||||
|
||||
class VideoIntroController extends GetxController {
|
||||
@@ -478,11 +479,15 @@ class VideoIntroController extends GetxController {
|
||||
// 重新获取视频资源
|
||||
final VideoDetailController videoDetailCtr =
|
||||
Get.find<VideoDetailController>(tag: heroTag);
|
||||
final ReleatedController releatedCtr =
|
||||
Get.find<ReleatedController>(tag: heroTag);
|
||||
videoDetailCtr.bvid = bvid;
|
||||
videoDetailCtr.oid.value = aid;
|
||||
videoDetailCtr.cid.value = cid;
|
||||
videoDetailCtr.danmakuCid.value = cid;
|
||||
videoDetailCtr.queryVideoUrl();
|
||||
releatedCtr.bvid = bvid;
|
||||
releatedCtr.queryRelatedVideo();
|
||||
// 重新请求评论
|
||||
try {
|
||||
/// 未渲染回复组件时可能异常
|
||||
|
||||
@@ -1,14 +1,22 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:pilipala/http/video.dart';
|
||||
import '../../../../models/model_hot_video_item.dart';
|
||||
|
||||
class ReleatedController extends GetxController {
|
||||
// 视频aid
|
||||
String bvid = Get.parameters['bvid'] ?? "";
|
||||
// 推荐视频列表
|
||||
List relatedVideoList = [];
|
||||
RxList relatedVideoList = <HotVideoItemModel>[].obs;
|
||||
|
||||
OverlayEntry? popupDialog;
|
||||
|
||||
Future<dynamic> queryRelatedVideo() => VideoHttp.relatedVideoList(bvid: bvid);
|
||||
Future<dynamic> queryRelatedVideo() async {
|
||||
return VideoHttp.relatedVideoList(bvid: bvid).then((value) {
|
||||
if (value['status']) {
|
||||
relatedVideoList.value = value['data'];
|
||||
}
|
||||
return value;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,48 +7,73 @@ import 'package:pilipala/common/widgets/overlay_pop.dart';
|
||||
import 'package:pilipala/common/widgets/video_card_h.dart';
|
||||
import './controller.dart';
|
||||
|
||||
class RelatedVideoPanel extends StatelessWidget {
|
||||
final ReleatedController _releatedController =
|
||||
Get.put(ReleatedController(), tag: Get.arguments?['heroTag']);
|
||||
RelatedVideoPanel({super.key});
|
||||
class RelatedVideoPanel extends StatefulWidget {
|
||||
const RelatedVideoPanel({super.key});
|
||||
|
||||
@override
|
||||
State<RelatedVideoPanel> createState() => _RelatedVideoPanelState();
|
||||
}
|
||||
|
||||
class _RelatedVideoPanelState extends State<RelatedVideoPanel>
|
||||
with AutomaticKeepAliveClientMixin {
|
||||
late ReleatedController _releatedController;
|
||||
late Future _futureBuilder;
|
||||
|
||||
@override
|
||||
bool get wantKeepAlive => true;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_releatedController =
|
||||
Get.put(ReleatedController(), tag: Get.arguments?['heroTag']);
|
||||
_futureBuilder = _releatedController.queryRelatedVideo();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
super.build(context);
|
||||
return FutureBuilder(
|
||||
future: _releatedController.queryRelatedVideo(),
|
||||
future: _futureBuilder,
|
||||
builder: (BuildContext context, AsyncSnapshot snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.done) {
|
||||
if (snapshot.data == null) {
|
||||
return const SliverToBoxAdapter(child: SizedBox());
|
||||
}
|
||||
if (snapshot.data!['status']) {
|
||||
if (snapshot.data!['status'] && snapshot.data != null) {
|
||||
RxList relatedVideoList = _releatedController.relatedVideoList;
|
||||
// 请求成功
|
||||
return SliverList(
|
||||
return Obx(
|
||||
() => SliverList(
|
||||
delegate: SliverChildBuilderDelegate((context, index) {
|
||||
if (index == snapshot.data['data'].length) {
|
||||
return SizedBox(height: MediaQuery.of(context).padding.bottom);
|
||||
} else {
|
||||
return Material(
|
||||
child: VideoCardH(
|
||||
videoItem: snapshot.data['data'][index],
|
||||
showPubdate: true,
|
||||
longPress: () {
|
||||
try {
|
||||
_releatedController.popupDialog =
|
||||
_createPopupDialog(snapshot.data['data'][index]);
|
||||
Overlay.of(context)
|
||||
.insert(_releatedController.popupDialog!);
|
||||
} catch (err) {
|
||||
return {};
|
||||
}
|
||||
},
|
||||
longPressEnd: () {
|
||||
_releatedController.popupDialog?.remove();
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}, childCount: snapshot.data['data'].length + 1));
|
||||
if (index == relatedVideoList.length) {
|
||||
return SizedBox(
|
||||
height: MediaQuery.of(context).padding.bottom);
|
||||
} else {
|
||||
return Material(
|
||||
child: VideoCardH(
|
||||
videoItem: relatedVideoList[index],
|
||||
showPubdate: true,
|
||||
longPress: () {
|
||||
try {
|
||||
_releatedController.popupDialog =
|
||||
_createPopupDialog(_releatedController
|
||||
.relatedVideoList[index]);
|
||||
Overlay.of(context)
|
||||
.insert(_releatedController.popupDialog!);
|
||||
} catch (err) {
|
||||
return {};
|
||||
}
|
||||
},
|
||||
longPressEnd: () {
|
||||
_releatedController.popupDialog?.remove();
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}, childCount: relatedVideoList.length + 1),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
// 请求错误
|
||||
return HttpError(errMsg: '出错了', fn: () {});
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'package:flutter/gestures.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
@@ -46,6 +47,17 @@ class ReplyItem extends StatelessWidget {
|
||||
replyReply!(replyItem);
|
||||
}
|
||||
},
|
||||
onLongPress: () {
|
||||
feedBack();
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
useRootNavigator: true,
|
||||
isScrollControlled: true,
|
||||
builder: (context) {
|
||||
return MorePanel(item: replyItem);
|
||||
},
|
||||
);
|
||||
},
|
||||
child: Column(
|
||||
children: [
|
||||
Padding(
|
||||
@@ -121,98 +133,6 @@ class ReplyItem extends StatelessWidget {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
// 头像、昵称
|
||||
// SizedBox(
|
||||
// width: double.infinity,
|
||||
// child: Stack(
|
||||
// children: [
|
||||
// GestureDetector(
|
||||
// behavior: HitTestBehavior.opaque,
|
||||
// onTap: () {
|
||||
// feedBack();
|
||||
// Get.toNamed('/member?mid=${replyItem!.mid}', arguments: {
|
||||
// 'face': replyItem!.member!.avatar!,
|
||||
// 'heroTag': heroTag
|
||||
// });
|
||||
// },
|
||||
// child: Row(
|
||||
// crossAxisAlignment: CrossAxisAlignment.center,
|
||||
// mainAxisSize: MainAxisSize.min,
|
||||
// children: <Widget>[
|
||||
// lfAvtar(context, heroTag),
|
||||
// const SizedBox(width: 12),
|
||||
// Text(
|
||||
// replyItem!.member!.uname!,
|
||||
// style: TextStyle(
|
||||
// color: replyItem!.member!.vip!['vipStatus'] > 0
|
||||
// ? const Color.fromARGB(255, 251, 100, 163)
|
||||
// : Theme.of(context).colorScheme.outline,
|
||||
// fontSize: 13,
|
||||
// ),
|
||||
// ),
|
||||
// const SizedBox(width: 6),
|
||||
// Image.asset(
|
||||
// 'assets/images/lv/lv${replyItem!.member!.level}.png',
|
||||
// height: 11,
|
||||
// ),
|
||||
// const SizedBox(width: 6),
|
||||
// if (replyItem!.isUp!)
|
||||
// const PBadge(
|
||||
// text: 'UP',
|
||||
// size: 'small',
|
||||
// stack: 'normal',
|
||||
// fs: 9,
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// Positioned(
|
||||
// top: 0,
|
||||
// left: 0,
|
||||
// right: 0,
|
||||
// child: Container(
|
||||
// width: double.infinity,
|
||||
// height: 45,
|
||||
// decoration: BoxDecoration(
|
||||
// image: replyItem!.member!.userSailing!.cardbg != null
|
||||
// ? DecorationImage(
|
||||
// alignment: Alignment.centerRight,
|
||||
// fit: BoxFit.fitHeight,
|
||||
// image: NetworkImage(
|
||||
// replyItem!.member!.userSailing!.cardbg!['image'],
|
||||
// ),
|
||||
// )
|
||||
// : null,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// if (replyItem!.member!.userSailing!.cardbg != null &&
|
||||
// replyItem!.member!.userSailing!.cardbg!['fan']['number'] > 0)
|
||||
// Positioned(
|
||||
// top: 10,
|
||||
// left: Get.size.width / 7 * 5.8,
|
||||
// child: DefaultTextStyle(
|
||||
// style: TextStyle(
|
||||
// fontFamily: 'fansCard',
|
||||
// fontSize: 9,
|
||||
// color: Theme.of(context).colorScheme.primary,
|
||||
// ),
|
||||
// child: Column(
|
||||
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||
// mainAxisAlignment: MainAxisAlignment.center,
|
||||
// children: [
|
||||
// const Text('NO.'),
|
||||
// Text(
|
||||
// replyItem!.member!.userSailing!.cardbg!['fan']
|
||||
// ['num_desc'],
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
/// fix Stack内GestureDetector onTap无效
|
||||
GestureDetector(
|
||||
behavior: HitTestBehavior.opaque,
|
||||
@@ -289,30 +209,26 @@ class ReplyItem extends StatelessWidget {
|
||||
// title
|
||||
Container(
|
||||
margin: const EdgeInsets.only(top: 10, left: 45, right: 6, bottom: 4),
|
||||
child: SelectableRegion(
|
||||
focusNode: FocusNode(),
|
||||
selectionControls: MaterialTextSelectionControls(),
|
||||
child: Text.rich(
|
||||
style: const TextStyle(height: 1.75),
|
||||
maxLines:
|
||||
replyItem!.content!.isText! && replyLevel == '1' ? 3 : 999,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
TextSpan(
|
||||
children: [
|
||||
if (replyItem!.isTop!)
|
||||
const WidgetSpan(
|
||||
alignment: PlaceholderAlignment.top,
|
||||
child: PBadge(
|
||||
text: 'TOP',
|
||||
size: 'small',
|
||||
stack: 'normal',
|
||||
type: 'line',
|
||||
fs: 9,
|
||||
),
|
||||
child: Text.rich(
|
||||
style: const TextStyle(height: 1.75),
|
||||
maxLines:
|
||||
replyItem!.content!.isText! && replyLevel == '1' ? 3 : 999,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
TextSpan(
|
||||
children: [
|
||||
if (replyItem!.isTop!)
|
||||
const WidgetSpan(
|
||||
alignment: PlaceholderAlignment.top,
|
||||
child: PBadge(
|
||||
text: 'TOP',
|
||||
size: 'small',
|
||||
stack: 'normal',
|
||||
type: 'line',
|
||||
fs: 9,
|
||||
),
|
||||
buildContent(context, replyItem!, replyReply, null),
|
||||
],
|
||||
),
|
||||
),
|
||||
buildContent(context, replyItem!, replyReply, null),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -445,6 +361,17 @@ class ReplyItemRow extends StatelessWidget {
|
||||
InkWell(
|
||||
// 一楼点击评论展开评论详情
|
||||
onTap: () => replyReply!(replyItem),
|
||||
onLongPress: () {
|
||||
feedBack();
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
useRootNavigator: true,
|
||||
isScrollControlled: true,
|
||||
builder: (context) {
|
||||
return MorePanel(item: replies![i]);
|
||||
},
|
||||
);
|
||||
},
|
||||
child: Container(
|
||||
width: double.infinity,
|
||||
padding: EdgeInsets.fromLTRB(
|
||||
@@ -636,8 +563,8 @@ InlineSpan buildContent(
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
} else if (RegExp(r'^\b(?:\d+[::])?[0-5]?[0-9][::][0-5]?[0-9]\b$').hasMatch(matchStr)) {
|
||||
} else if (RegExp(r'^\b(?:\d+[::])?[0-5]?[0-9][::][0-5]?[0-9]\b$')
|
||||
.hasMatch(matchStr)) {
|
||||
matchStr = matchStr.replaceAll(':', ':');
|
||||
spanChilds.add(
|
||||
TextSpan(
|
||||
@@ -955,3 +882,100 @@ InlineSpan buildContent(
|
||||
// spanChilds.add(TextSpan(text: matchMember));
|
||||
return TextSpan(children: spanChilds);
|
||||
}
|
||||
|
||||
class MorePanel extends StatelessWidget {
|
||||
final dynamic item;
|
||||
const MorePanel({super.key, required this.item});
|
||||
|
||||
Future<dynamic> menuActionHandler(String type) async {
|
||||
String message = item.content.message ?? item.content;
|
||||
switch (type) {
|
||||
case 'copyAll':
|
||||
await Clipboard.setData(ClipboardData(text: message));
|
||||
SmartDialog.showToast('已复制');
|
||||
Get.back();
|
||||
break;
|
||||
case 'copyFreedom':
|
||||
Get.back();
|
||||
showDialog(
|
||||
context: Get.context!,
|
||||
builder: (context) {
|
||||
return AlertDialog(
|
||||
title: const Text('自由复制'),
|
||||
content: SelectableText(message),
|
||||
);
|
||||
},
|
||||
);
|
||||
break;
|
||||
// case 'block':
|
||||
// SmartDialog.showToast('加入黑名单');
|
||||
// break;
|
||||
// case 'report':
|
||||
// SmartDialog.showToast('举报');
|
||||
// break;
|
||||
// case 'delete':
|
||||
// SmartDialog.showToast('删除');
|
||||
// break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Color errorColor = Theme.of(context).colorScheme.error;
|
||||
return Container(
|
||||
padding: EdgeInsets.only(bottom: MediaQuery.of(context).padding.bottom),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
InkWell(
|
||||
onTap: () => Get.back(),
|
||||
child: Container(
|
||||
height: 35,
|
||||
padding: const EdgeInsets.only(bottom: 2),
|
||||
child: Center(
|
||||
child: Container(
|
||||
width: 32,
|
||||
height: 3,
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).colorScheme.outline,
|
||||
borderRadius: const BorderRadius.all(Radius.circular(3))),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
onTap: () async => await menuActionHandler('copyAll'),
|
||||
minLeadingWidth: 0,
|
||||
leading: const Icon(Icons.copy_all_outlined, size: 19),
|
||||
title: Text('复制全部', style: Theme.of(context).textTheme.titleSmall),
|
||||
),
|
||||
ListTile(
|
||||
onTap: () async => await menuActionHandler('copyFreedom'),
|
||||
minLeadingWidth: 0,
|
||||
leading: const Icon(Icons.copy_outlined, size: 19),
|
||||
title: Text('自由复制', style: Theme.of(context).textTheme.titleSmall),
|
||||
),
|
||||
// ListTile(
|
||||
// onTap: () async => await menuActionHandler('block'),
|
||||
// minLeadingWidth: 0,
|
||||
// leading: Icon(Icons.block_outlined, color: errorColor),
|
||||
// title: Text('加入黑名单', style: TextStyle(color: errorColor)),
|
||||
// ),
|
||||
// ListTile(
|
||||
// onTap: () async => await menuActionHandler('report'),
|
||||
// minLeadingWidth: 0,
|
||||
// leading: Icon(Icons.report_outlined, color: errorColor),
|
||||
// title: Text('举报', style: TextStyle(color: errorColor)),
|
||||
// ),
|
||||
// ListTile(
|
||||
// onTap: () async => await menuActionHandler('del'),
|
||||
// minLeadingWidth: 0,
|
||||
// leading: Icon(Icons.delete_outline, color: errorColor),
|
||||
// title: Text('删除', style: TextStyle(color: errorColor)),
|
||||
// ),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user