opt: 评论详情优先展示二级评论
This commit is contained in:
@ -106,7 +106,7 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
|
||||
}
|
||||
|
||||
// 查看二级评论
|
||||
void replyReply(replyItem) {
|
||||
void replyReply(replyItem, currentReply) {
|
||||
int oid = replyItem.oid;
|
||||
int rpid = replyItem.rpid!;
|
||||
Get.to(
|
||||
@ -324,8 +324,8 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
|
||||
replyItem: replyList[index],
|
||||
showReplyRow: true,
|
||||
replyLevel: '1',
|
||||
replyReply: (replyItem) =>
|
||||
replyReply(replyItem),
|
||||
replyReply: (replyItem, currentReply) =>
|
||||
replyReply(replyItem, currentReply),
|
||||
replyType: ReplyType.values[replyType],
|
||||
addReply: (replyItem) {
|
||||
replyList[index]
|
||||
|
@ -162,11 +162,11 @@ class VideoDetailController extends GetxController
|
||||
getSubtitle();
|
||||
}
|
||||
|
||||
showReplyReplyPanel() {
|
||||
showReplyReplyPanel(oid, fRpid, firstFloor, currentReply) {
|
||||
replyReplyBottomSheetCtr =
|
||||
scaffoldKey.currentState?.showBottomSheet((BuildContext context) {
|
||||
return VideoReplyReplyPanel(
|
||||
oid: oid.value,
|
||||
oid: oid,
|
||||
rpid: fRpid,
|
||||
closePanel: () => {
|
||||
fRpid = 0,
|
||||
@ -175,6 +175,7 @@ class VideoDetailController extends GetxController
|
||||
replyType: ReplyType.video,
|
||||
source: 'videoDetail',
|
||||
sheetHeight: sheetHeight.value,
|
||||
currentReply: currentReply,
|
||||
);
|
||||
});
|
||||
replyReplyBottomSheetCtr?.closed.then((value) {
|
||||
|
@ -110,14 +110,15 @@ class _VideoReplyPanelState extends State<VideoReplyPanel>
|
||||
}
|
||||
|
||||
// 展示二级回复
|
||||
void replyReply(replyItem) {
|
||||
void replyReply(replyItem, currentReply) {
|
||||
final VideoDetailController videoDetailCtr =
|
||||
Get.find<VideoDetailController>(tag: heroTag);
|
||||
if (replyItem != null) {
|
||||
videoDetailCtr.oid.value = replyItem.oid;
|
||||
videoDetailCtr.fRpid = replyItem.rpid!;
|
||||
videoDetailCtr.firstFloor = replyItem;
|
||||
videoDetailCtr.showReplyReplyPanel();
|
||||
videoDetailCtr.showReplyReplyPanel(
|
||||
replyItem.oid, replyItem.rpid!, replyItem, currentReply);
|
||||
}
|
||||
}
|
||||
|
||||
@ -228,8 +229,8 @@ class _VideoReplyPanelState extends State<VideoReplyPanel>
|
||||
.replyList[index],
|
||||
showReplyRow: true,
|
||||
replyLevel: replyLevel,
|
||||
replyReply: (replyItem) =>
|
||||
replyReply(replyItem),
|
||||
replyReply: (replyItem, currentReply) =>
|
||||
replyReply(replyItem, currentReply),
|
||||
replyType: ReplyType.video,
|
||||
);
|
||||
}
|
||||
|
@ -12,7 +12,6 @@ import 'package:pilipala/pages/preview/index.dart';
|
||||
import 'package:pilipala/pages/video/detail/index.dart';
|
||||
import 'package:pilipala/pages/video/detail/reply_new/index.dart';
|
||||
import 'package:pilipala/utils/feed_back.dart';
|
||||
import 'package:pilipala/utils/id_utils.dart';
|
||||
import 'package:pilipala/utils/storage.dart';
|
||||
import 'package:pilipala/utils/url_utils.dart';
|
||||
import 'package:pilipala/utils/utils.dart';
|
||||
@ -45,7 +44,7 @@ class ReplyItem extends StatelessWidget {
|
||||
onTap: () {
|
||||
feedBack();
|
||||
if (replyReply != null) {
|
||||
replyReply!(replyItem);
|
||||
replyReply!(replyItem, null);
|
||||
}
|
||||
},
|
||||
onLongPress: () {
|
||||
@ -59,28 +58,23 @@ class ReplyItem extends StatelessWidget {
|
||||
},
|
||||
);
|
||||
},
|
||||
child: Column(
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(12, 14, 8, 5),
|
||||
child: content(context),
|
||||
),
|
||||
Divider(
|
||||
indent: 55,
|
||||
endIndent: 15,
|
||||
height: 0.3,
|
||||
color: Theme.of(context)
|
||||
.colorScheme
|
||||
.onInverseSurface
|
||||
.withOpacity(0.5),
|
||||
)
|
||||
],
|
||||
child: Container(
|
||||
padding: const EdgeInsets.fromLTRB(12, 14, 8, 5),
|
||||
decoration: BoxDecoration(
|
||||
border: Border(
|
||||
bottom: BorderSide(
|
||||
width: 1,
|
||||
color:
|
||||
Theme.of(context).colorScheme.onInverseSurface.withOpacity(0.5),
|
||||
))),
|
||||
child: content(context),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget lfAvtar(BuildContext context, String heroTag) {
|
||||
ColorScheme colorScheme = Theme.of(context).colorScheme;
|
||||
return Stack(
|
||||
children: [
|
||||
Hero(
|
||||
@ -100,11 +94,11 @@ class ReplyItem extends StatelessWidget {
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(7),
|
||||
color: Theme.of(context).colorScheme.background,
|
||||
color: colorScheme.background,
|
||||
),
|
||||
child: Icon(
|
||||
Icons.offline_bolt,
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
color: colorScheme.primary,
|
||||
size: 16,
|
||||
),
|
||||
),
|
||||
@ -117,7 +111,7 @@ class ReplyItem extends StatelessWidget {
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(7),
|
||||
color: Theme.of(context).colorScheme.background,
|
||||
color: colorScheme.background,
|
||||
),
|
||||
child: Image.asset(
|
||||
'assets/images/big-vip.png',
|
||||
@ -131,6 +125,8 @@ class ReplyItem extends StatelessWidget {
|
||||
|
||||
Widget content(BuildContext context) {
|
||||
final String heroTag = Utils.makeHeroTag(replyItem!.mid);
|
||||
ColorScheme colorScheme = Theme.of(context).colorScheme;
|
||||
TextTheme textTheme = Theme.of(context).textTheme;
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
@ -160,16 +156,17 @@ class ReplyItem extends StatelessWidget {
|
||||
style: TextStyle(
|
||||
color: replyItem!.member!.vip!['vipStatus'] > 0
|
||||
? const Color.fromARGB(255, 251, 100, 163)
|
||||
: Theme.of(context).colorScheme.outline,
|
||||
: colorScheme.outline,
|
||||
fontSize: 13,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
Image.asset(
|
||||
'assets/images/lv/lv${replyItem!.member!.level}.png',
|
||||
height: 11,
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 6, right: 6),
|
||||
child: Image.asset(
|
||||
'assets/images/lv/lv${replyItem!.member!.level}.png',
|
||||
height: 11,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
if (replyItem!.isUp!)
|
||||
const PBadge(
|
||||
text: 'UP',
|
||||
@ -184,9 +181,8 @@ class ReplyItem extends StatelessWidget {
|
||||
Text(
|
||||
Utils.dateFormat(replyItem!.ctime),
|
||||
style: TextStyle(
|
||||
fontSize:
|
||||
Theme.of(context).textTheme.labelSmall!.fontSize,
|
||||
color: Theme.of(context).colorScheme.outline,
|
||||
fontSize: textTheme.labelSmall!.fontSize,
|
||||
color: colorScheme.outline,
|
||||
),
|
||||
),
|
||||
if (replyItem!.replyControl != null &&
|
||||
@ -194,11 +190,8 @@ class ReplyItem extends StatelessWidget {
|
||||
Text(
|
||||
' • ${replyItem!.replyControl!.location!}',
|
||||
style: TextStyle(
|
||||
fontSize: Theme.of(context)
|
||||
.textTheme
|
||||
.labelSmall!
|
||||
.fontSize,
|
||||
color: Theme.of(context).colorScheme.outline),
|
||||
fontSize: textTheme.labelSmall!.fontSize,
|
||||
color: colorScheme.outline),
|
||||
),
|
||||
],
|
||||
)
|
||||
@ -256,6 +249,8 @@ class ReplyItem extends StatelessWidget {
|
||||
|
||||
// 感谢、回复、复制
|
||||
Widget bottonAction(BuildContext context, replyControl) {
|
||||
ColorScheme colorScheme = Theme.of(context).colorScheme;
|
||||
TextTheme textTheme = Theme.of(context).textTheme;
|
||||
return Row(
|
||||
children: <Widget>[
|
||||
const SizedBox(width: 32),
|
||||
@ -287,15 +282,13 @@ class ReplyItem extends StatelessWidget {
|
||||
},
|
||||
child: Row(children: [
|
||||
Icon(Icons.reply,
|
||||
size: 18,
|
||||
color:
|
||||
Theme.of(context).colorScheme.outline.withOpacity(0.8)),
|
||||
size: 18, color: colorScheme.outline.withOpacity(0.8)),
|
||||
const SizedBox(width: 3),
|
||||
Text(
|
||||
'回复',
|
||||
style: TextStyle(
|
||||
fontSize: Theme.of(context).textTheme.labelMedium!.fontSize,
|
||||
color: Theme.of(context).colorScheme.outline,
|
||||
fontSize: textTheme.labelMedium!.fontSize,
|
||||
color: colorScheme.outline,
|
||||
),
|
||||
),
|
||||
]),
|
||||
@ -306,8 +299,8 @@ class ReplyItem extends StatelessWidget {
|
||||
Text(
|
||||
'up主觉得很赞',
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
fontSize: Theme.of(context).textTheme.labelMedium!.fontSize),
|
||||
color: colorScheme.primary,
|
||||
fontSize: textTheme.labelMedium!.fontSize),
|
||||
),
|
||||
const SizedBox(width: 2),
|
||||
],
|
||||
@ -316,8 +309,8 @@ class ReplyItem extends StatelessWidget {
|
||||
Text(
|
||||
'热评',
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
fontSize: Theme.of(context).textTheme.labelMedium!.fontSize),
|
||||
color: colorScheme.primary,
|
||||
fontSize: textTheme.labelMedium!.fontSize),
|
||||
),
|
||||
const Spacer(),
|
||||
ZanButton(replyItem: replyItem, replyType: replyType),
|
||||
@ -347,10 +340,13 @@ class ReplyItemRow extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
final bool isShow = replyControl!.isShow!;
|
||||
final int extraRow = replyControl != null && isShow ? 1 : 0;
|
||||
ColorScheme colorScheme = Theme.of(context).colorScheme;
|
||||
TextTheme textTheme = Theme.of(context).textTheme;
|
||||
|
||||
return Container(
|
||||
margin: const EdgeInsets.only(left: 42, right: 4, top: 0),
|
||||
child: Material(
|
||||
color: Theme.of(context).colorScheme.onInverseSurface,
|
||||
color: colorScheme.onInverseSurface,
|
||||
borderRadius: BorderRadius.circular(6),
|
||||
clipBehavior: Clip.hardEdge,
|
||||
animationDuration: Duration.zero,
|
||||
@ -361,7 +357,9 @@ class ReplyItemRow extends StatelessWidget {
|
||||
for (int i = 0; i < replies!.length; i++) ...[
|
||||
InkWell(
|
||||
// 一楼点击评论展开评论详情
|
||||
onTap: () => replyReply!(replyItem),
|
||||
// onTap: () {
|
||||
// replyReply?.call(replyItem, replies![i]);
|
||||
// },
|
||||
onLongPress: () {
|
||||
feedBack();
|
||||
showModalBottomSheet(
|
||||
@ -379,7 +377,7 @@ class ReplyItemRow extends StatelessWidget {
|
||||
8,
|
||||
i == 0 && (extraRow == 1 || replies!.length > 1) ? 8 : 5,
|
||||
8,
|
||||
i == 0 && (extraRow == 1 || replies!.length > 1) ? 5 : 6,
|
||||
6,
|
||||
),
|
||||
child: Text.rich(
|
||||
overflow: TextOverflow.ellipsis,
|
||||
@ -393,7 +391,7 @@ class ReplyItemRow extends StatelessWidget {
|
||||
.textTheme
|
||||
.titleSmall!
|
||||
.fontSize,
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
color: colorScheme.primary,
|
||||
),
|
||||
recognizer: TapGestureRecognizer()
|
||||
..onTap = () {
|
||||
@ -429,15 +427,14 @@ class ReplyItemRow extends StatelessWidget {
|
||||
if (extraRow == 1)
|
||||
InkWell(
|
||||
// 一楼点击【共xx条回复】展开评论详情
|
||||
onTap: () => replyReply!(replyItem),
|
||||
onTap: () => replyReply!(replyItem, null),
|
||||
child: Container(
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.fromLTRB(8, 5, 8, 8),
|
||||
child: Text.rich(
|
||||
TextSpan(
|
||||
style: TextStyle(
|
||||
fontSize:
|
||||
Theme.of(context).textTheme.labelMedium!.fontSize,
|
||||
fontSize: textTheme.labelMedium!.fontSize,
|
||||
),
|
||||
children: [
|
||||
if (replyControl!.upReply!)
|
||||
@ -445,7 +442,7 @@ class ReplyItemRow extends StatelessWidget {
|
||||
TextSpan(
|
||||
text: replyControl!.entryText!,
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
color: colorScheme.primary,
|
||||
),
|
||||
)
|
||||
],
|
||||
@ -464,6 +461,7 @@ InlineSpan buildContent(
|
||||
BuildContext context, replyItem, replyReply, fReplyItem) {
|
||||
final String routePath = Get.currentRoute;
|
||||
bool isVideoPage = routePath.startsWith('/video');
|
||||
ColorScheme colorScheme = Theme.of(context).colorScheme;
|
||||
|
||||
// replyItem 当前回复内容
|
||||
// replyReply 查看二楼回复(回复详情)回调
|
||||
@ -533,8 +531,10 @@ InlineSpan buildContent(
|
||||
TextSpan(
|
||||
text: str,
|
||||
recognizer: TapGestureRecognizer()
|
||||
..onTap = () =>
|
||||
replyReply?.call(replyItem.root == 0 ? replyItem : fReplyItem),
|
||||
..onTap = () => replyReply?.call(
|
||||
replyItem.root == 0 ? replyItem : fReplyItem,
|
||||
replyItem,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
@ -564,7 +564,7 @@ InlineSpan buildContent(
|
||||
TextSpan(
|
||||
text: matchStr,
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
color: colorScheme.primary,
|
||||
),
|
||||
recognizer: TapGestureRecognizer()
|
||||
..onTap = () {
|
||||
@ -584,7 +584,7 @@ InlineSpan buildContent(
|
||||
text: ' $matchStr ',
|
||||
style: isVideoPage
|
||||
? TextStyle(
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
color: colorScheme.primary,
|
||||
)
|
||||
: null,
|
||||
recognizer: TapGestureRecognizer()
|
||||
@ -624,14 +624,14 @@ InlineSpan buildContent(
|
||||
child: Image.network(
|
||||
content.jumpUrl[matchStr]['prefix_icon'],
|
||||
height: 19,
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
color: colorScheme.primary,
|
||||
),
|
||||
)
|
||||
],
|
||||
TextSpan(
|
||||
text: content.jumpUrl[matchStr]['title'],
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
color: colorScheme.primary,
|
||||
),
|
||||
recognizer: TapGestureRecognizer()
|
||||
..onTap = () async {
|
||||
@ -721,7 +721,7 @@ InlineSpan buildContent(
|
||||
TextSpan(
|
||||
text: matchStr,
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
color: colorScheme.primary,
|
||||
),
|
||||
recognizer: TapGestureRecognizer()
|
||||
..onTap = () {
|
||||
@ -747,7 +747,7 @@ InlineSpan buildContent(
|
||||
text: ' $matchStr ',
|
||||
style: isVideoPage
|
||||
? TextStyle(
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
color: colorScheme.primary,
|
||||
)
|
||||
: null,
|
||||
recognizer: TapGestureRecognizer()
|
||||
@ -786,14 +786,14 @@ InlineSpan buildContent(
|
||||
child: Image.network(
|
||||
content.jumpUrl[patternStr]['prefix_icon'],
|
||||
height: 19,
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
color: colorScheme.primary,
|
||||
),
|
||||
)
|
||||
],
|
||||
TextSpan(
|
||||
text: content.jumpUrl[patternStr]['title'],
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
color: colorScheme.primary,
|
||||
),
|
||||
recognizer: TapGestureRecognizer()
|
||||
..onTap = () {
|
||||
@ -997,7 +997,8 @@ class MorePanel extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Color errorColor = Theme.of(context).colorScheme.error;
|
||||
ColorScheme colorScheme = Theme.of(context).colorScheme;
|
||||
TextTheme textTheme = Theme.of(context).textTheme;
|
||||
return Container(
|
||||
padding: EdgeInsets.only(bottom: MediaQuery.of(context).padding.bottom),
|
||||
child: Column(
|
||||
@ -1013,7 +1014,7 @@ class MorePanel extends StatelessWidget {
|
||||
width: 32,
|
||||
height: 3,
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).colorScheme.outline,
|
||||
color: colorScheme.outline,
|
||||
borderRadius: const BorderRadius.all(Radius.circular(3))),
|
||||
),
|
||||
),
|
||||
@ -1023,13 +1024,13 @@ class MorePanel extends StatelessWidget {
|
||||
onTap: () async => await menuActionHandler('copyAll'),
|
||||
minLeadingWidth: 0,
|
||||
leading: const Icon(Icons.copy_all_outlined, size: 19),
|
||||
title: Text('复制全部', style: Theme.of(context).textTheme.titleSmall),
|
||||
title: Text('复制全部', style: 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),
|
||||
title: Text('自由复制', style: textTheme.titleSmall),
|
||||
),
|
||||
// ListTile(
|
||||
// onTap: () async => await menuActionHandler('block'),
|
||||
|
@ -26,7 +26,7 @@ class VideoReplyReplyController extends GetxController {
|
||||
currentPage = 0;
|
||||
}
|
||||
|
||||
Future queryReplyList({type = 'init'}) async {
|
||||
Future queryReplyList({type = 'init', currentReply}) async {
|
||||
if (type == 'init') {
|
||||
currentPage = 0;
|
||||
}
|
||||
@ -63,6 +63,14 @@ class VideoReplyReplyController extends GetxController {
|
||||
// res['data'].replies.addAll(replyList);
|
||||
}
|
||||
}
|
||||
if (replyList.isNotEmpty && currentReply != null) {
|
||||
int indexToRemove =
|
||||
replyList.indexWhere((item) => currentReply.rpid == item.rpid);
|
||||
// 如果找到了指定ID的项,则移除
|
||||
if (indexToRemove != -1) {
|
||||
replyList.removeAt(indexToRemove);
|
||||
}
|
||||
}
|
||||
isLoadingMore = false;
|
||||
return res;
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ class VideoReplyReplyPanel extends StatefulWidget {
|
||||
this.source,
|
||||
this.replyType,
|
||||
this.sheetHeight,
|
||||
this.currentReply,
|
||||
super.key,
|
||||
});
|
||||
final int? oid;
|
||||
@ -29,6 +30,7 @@ class VideoReplyReplyPanel extends StatefulWidget {
|
||||
final String? source;
|
||||
final ReplyType? replyType;
|
||||
final double? sheetHeight;
|
||||
final dynamic currentReply;
|
||||
|
||||
@override
|
||||
State<VideoReplyReplyPanel> createState() => _VideoReplyReplyPanelState();
|
||||
@ -63,7 +65,9 @@ class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel> {
|
||||
},
|
||||
);
|
||||
|
||||
_futureBuilderFuture = _videoReplyReplyController.queryReplyList();
|
||||
_futureBuilderFuture = _videoReplyReplyController.queryReplyList(
|
||||
currentReply: widget.currentReply,
|
||||
);
|
||||
}
|
||||
|
||||
void replyReply(replyItem) {}
|
||||
@ -107,7 +111,9 @@ class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel> {
|
||||
onRefresh: () async {
|
||||
setState(() {});
|
||||
_videoReplyReplyController.currentPage = 0;
|
||||
return await _videoReplyReplyController.queryReplyList();
|
||||
return await _videoReplyReplyController.queryReplyList(
|
||||
currentReply: widget.currentReply,
|
||||
);
|
||||
},
|
||||
child: CustomScrollView(
|
||||
controller: _videoReplyReplyController.scrollController,
|
||||
@ -140,6 +146,10 @@ class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel> {
|
||||
if (snapshot.connectionState == ConnectionState.done) {
|
||||
Map? data = snapshot.data;
|
||||
if (data != null && data['status']) {
|
||||
if (widget.currentReply != null) {
|
||||
_videoReplyReplyController.replyList
|
||||
.insert(0, widget.currentReply);
|
||||
}
|
||||
// 请求成功
|
||||
return Obx(
|
||||
() => SliverList(
|
||||
|
Reference in New Issue
Block a user