opt: reply item

This commit is contained in:
bggRGjQaUbCoE
2024-10-11 20:03:16 +08:00
parent d4c2dffcc1
commit ba7d937932
5 changed files with 48 additions and 37 deletions

View File

@@ -41,6 +41,7 @@
## feat ## feat
- [x] 评论楼中楼按热度/时间排序
- [x] 评论点踩 - [x] 评论点踩
- [x] 显示ops专栏 - [x] 显示ops专栏
- [x] 私信发图 - [x] 私信发图

View File

@@ -15,6 +15,7 @@ class GrpcClient {
port: 443, port: 443,
options: const ChannelOptions( options: const ChannelOptions(
credentials: ChannelCredentials.secure(), credentials: ChannelCredentials.secure(),
connectionTimeout: Duration(seconds: 10),
), ),
); );
} }

View File

@@ -29,6 +29,7 @@ class VideoReplyController extends ReplyController {
CursorReply? cursor; CursorReply? cursor;
Mode mode = Mode.MAIN_LIST_HOT; Mode mode = Mode.MAIN_LIST_HOT;
bool hasUpTop = false;
@override @override
Future onRefresh() { Future onRefresh() {
@@ -65,6 +66,10 @@ class VideoReplyController extends ReplyController {
MainListReply replies = response.response; MainListReply replies = response.response;
if (cursor == null) { if (cursor == null) {
count.value = replies.subjectControl.count.toInt(); count.value = replies.subjectControl.count.toInt();
hasUpTop = replies.hasUpTop();
if (replies.hasUpTop()) {
replies.replies.insert(0, replies.upTop);
}
} }
cursor = replies.cursor; cursor = replies.cursor;
// replies.replies.clear(); // replies.replies.clear();

View File

@@ -225,6 +225,7 @@ class _VideoReplyPanelState extends State<VideoReplyPanel>
return ReplyItemGrpc( return ReplyItemGrpc(
replyItem: loadingState.response.replies[index], replyItem: loadingState.response.replies[index],
showReplyRow: true, showReplyRow: true,
isTop: _videoReplyController.hasUpTop && index == 0,
replyLevel: replyLevel, replyLevel: replyLevel,
replyReply: widget.replyReply, replyReply: widget.replyReply,
replyType: ReplyType.video, replyType: ReplyType.video,

View File

@@ -35,6 +35,7 @@ class ReplyItemGrpc extends StatelessWidget {
this.onReply, this.onReply,
this.onDelete, this.onDelete,
this.upMid, this.upMid,
this.isTop = false,
}); });
final ReplyInfo replyItem; final ReplyInfo replyItem;
final String? replyLevel; final String? replyLevel;
@@ -45,6 +46,7 @@ class ReplyItemGrpc extends StatelessWidget {
final Function()? onReply; final Function()? onReply;
final Function(dynamic rpid, dynamic frpid)? onDelete; final Function(dynamic rpid, dynamic frpid)? onDelete;
final dynamic upMid; final dynamic upMid;
final bool isTop;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@@ -60,11 +62,12 @@ class ReplyItemGrpc extends StatelessWidget {
onLongPress: () { onLongPress: () {
feedBack(); feedBack();
// showDialog( // showDialog(
// context: Get.context!, // context: Get.context!,
// builder: (_) => AlertDialog( // builder: (_) => AlertDialog(
// content: // content: SelectableText(
// SelectableText(jsonEncode(replyItem.toProto3Json())), // jsonEncode(replyItem.replyControl.toProto3Json())),
// )); // ),
// );
showModalBottomSheet( showModalBottomSheet(
context: context, context: context,
useRootNavigator: true, useRootNavigator: true,
@@ -259,7 +262,7 @@ class ReplyItemGrpc extends StatelessWidget {
var textPainter = TextPainter( var textPainter = TextPainter(
text: TextSpan(text: text), text: TextSpan(text: text),
maxLines: 6, maxLines: 6,
// replyItem.content!.isText! && replyLevel == '1' ? 6 : 999, // replyItem.content!.isText! && replyLevel == '1' ? 6 : null,
textDirection: Directionality.of(context), textDirection: Directionality.of(context),
)..layout(maxWidth: constraints.maxWidth); )..layout(maxWidth: constraints.maxWidth);
bool didExceedMaxLines = textPainter.didExceedMaxLines; bool didExceedMaxLines = textPainter.didExceedMaxLines;
@@ -272,20 +275,20 @@ class ReplyItemGrpc extends StatelessWidget {
Theme.of(context).textTheme.bodyMedium!.fontSize), Theme.of(context).textTheme.bodyMedium!.fontSize),
TextSpan( TextSpan(
children: [ children: [
// if (replyItem.isTop!) ...[ if (isTop) ...[
// const WidgetSpan( const WidgetSpan(
// alignment: PlaceholderAlignment.top, alignment: PlaceholderAlignment.top,
// child: PBadge( child: PBadge(
// text: 'TOP', text: 'TOP',
// size: 'small', size: 'small',
// stack: 'normal', stack: 'normal',
// type: 'line', type: 'line',
// fs: 9, fs: 9,
// semanticsLabel: '置顶', semanticsLabel: '置顶',
// ), ),
// ), ),
// const TextSpan(text: ' '), const TextSpan(text: ' '),
// ], ],
buildContent( buildContent(
context, context,
replyItem, replyItem,
@@ -318,6 +321,7 @@ class ReplyItemGrpc extends StatelessWidget {
Padding( Padding(
padding: const EdgeInsets.only(top: 5, bottom: 12), padding: const EdgeInsets.only(top: 5, bottom: 12),
child: ReplyItemRow( child: ReplyItemRow(
upMid: upMid,
replies: replyItem.replies, replies: replyItem.replies,
replyControl: replyItem.replyControl, replyControl: replyItem.replyControl,
// f_rpid: replyItem.rpid, // f_rpid: replyItem.rpid,
@@ -424,8 +428,7 @@ class ReplyItemRow extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final int extraRow = // replyControl?.isShow == true || final bool extraRow = replyControl.subReplyEntryText.isNotEmpty;
(replyControl.subReplyEntryText.isNotEmpty && replies.isEmpty) ? 1 : 0;
return Container( return Container(
margin: const EdgeInsets.only(left: 42, right: 4, top: 0), margin: const EdgeInsets.only(left: 42, right: 4, top: 0),
child: Material( child: Material(
@@ -459,9 +462,9 @@ class ReplyItemRow extends StatelessWidget {
width: double.infinity, width: double.infinity,
padding: EdgeInsets.fromLTRB( padding: EdgeInsets.fromLTRB(
8, 8,
i == 0 && (extraRow == 1 || replies.length > 1) ? 8 : 4, i == 0 && (extraRow || replies.length > 1) ? 8 : 4,
8, 8,
i == 0 && (extraRow == 1 || replies.length > 1) ? 4 : 6, i == 0 && (extraRow || replies.length > 1) ? 4 : 6,
), ),
child: Semantics( child: Semantics(
label: label:
@@ -538,7 +541,7 @@ class ReplyItemRow extends StatelessWidget {
), ),
) )
], ],
if (extraRow == 1) if (extraRow)
InkWell( InkWell(
// 一楼点击【共xx条回复】展开评论详情 // 一楼点击【共xx条回复】展开评论详情
onTap: () => replyReply!(replyItem), onTap: () => replyReply!(replyItem),
@@ -1012,18 +1015,18 @@ class MorePanel extends StatelessWidget {
break; break;
case 'copyFreedom': case 'copyFreedom':
Get.back(); Get.back();
showDialog( // showDialog(
context: Get.context!, // context: Get.context!,
builder: (context) { // builder: (context) {
return Dialog( // return Dialog(
child: Padding( // child: Padding(
padding: // padding:
const EdgeInsets.symmetric(horizontal: 20, vertical: 16), // const EdgeInsets.symmetric(horizontal: 20, vertical: 16),
child: SelectableText(message), // child: SelectableText(message),
), // ),
); // );
}, // },
); // );
break; break;
// case 'block': // case 'block':
// SmartDialog.showToast('加入黑名单'); // SmartDialog.showToast('加入黑名单');