opt view dyn reply

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-12-24 18:07:01 +08:00
parent fcf4e72d8e
commit 161bf2eedb
4 changed files with 31 additions and 6 deletions

View File

@@ -61,7 +61,8 @@ class ActionPanel extends StatelessWidget {
),
Expanded(
child: TextButton.icon(
onPressed: () => PageUtils.pushDynDetail(item, isPush: true),
onPressed: () =>
PageUtils.pushDynDetail(item, isPush: true, viewReply: true),
icon: Icon(
FontAwesomeIcons.comment,
size: 16,

View File

@@ -3,6 +3,8 @@ import 'package:PiliPlus/models/dynamics/result.dart';
import 'package:PiliPlus/pages/common/dyn/common_dyn_controller.dart';
import 'package:PiliPlus/utils/id_utils.dart';
import 'package:PiliPlus/utils/storage_pref.dart';
import 'package:flutter/material.dart' show GlobalKey, Scrollable;
import 'package:flutter/scheduler.dart' show SchedulerBinding;
import 'package:get/get.dart';
class DynamicDetailController extends CommonDynController {
@@ -17,12 +19,18 @@ class DynamicDetailController extends CommonDynController {
@override
dynamic get sourceId => replyType == 1 ? IdUtils.av2bv(oid) : oid;
GlobalKey? replyKey;
@override
void onInit() {
super.onInit();
dynItem = Get.arguments['item'];
var commentType = dynItem.basic?.commentType;
var commentIdStr = dynItem.basic?.commentIdStr;
final args = Get.arguments;
dynItem = args['item'];
if (args['viewReply'] ?? false) {
replyKey = GlobalKey();
}
final commentType = dynItem.basic?.commentType;
final commentIdStr = dynItem.basic?.commentIdStr;
if (commentType != null &&
commentType != 0 &&
commentIdStr != null &&
@@ -43,6 +51,17 @@ class DynamicDetailController extends CommonDynController {
void _init(String commentIdStr, int commentType) {
oid = int.parse(commentIdStr);
replyType = commentType;
queryData();
queryData().whenComplete(() {
if (replyKey != null && count.value > 0) {
SchedulerBinding.instance.addPostFrameCallback((_) {
if (replyKey?.currentContext != null) {
Scrollable.ensureVisible(
replyKey!.currentContext!,
duration: const Duration(milliseconds: 200),
);
}
});
}
});
}
}

View File

@@ -113,7 +113,10 @@ class _DynamicDetailPageState extends CommonDynPageState<DynamicDetailPage> {
),
),
buildReplyHeader(theme),
Obx(() => replyList(theme, controller.loadingState.value)),
Obx(
key: controller.replyKey,
() => replyList(theme, controller.loadingState.value),
),
],
),
);

View File

@@ -372,6 +372,7 @@ abstract final class PageUtils {
static Future<void> pushDynDetail(
DynamicItemModel item, {
bool isPush = false,
bool viewReply = false,
}) async {
feedBack();
@@ -389,6 +390,7 @@ abstract final class PageUtils {
'/dynamicDetail',
arguments: {
'item': item,
'viewReply': viewReply,
},
);
}