feat: 点击tab返回顶部

This commit is contained in:
guozhigq
2024-06-20 23:38:49 +08:00
parent 9917506b5d
commit 7706c919e9
3 changed files with 17 additions and 0 deletions

View File

@ -109,6 +109,7 @@ class VideoDetailController extends GetxController
].obs; ].obs;
RxDouble sheetHeight = 0.0.obs; RxDouble sheetHeight = 0.0.obs;
RxString archiveSourceType = 'dash'.obs; RxString archiveSourceType = 'dash'.obs;
ScrollController? replyScrillController;
@override @override
void onInit() { void onInit() {
@ -551,4 +552,15 @@ class VideoDetailController extends GetxController
cover.value = videoItem['pic'] = pic; cover.value = videoItem['pic'] = pic;
} }
} }
void onControllerCreated(ScrollController controller) {
replyScrillController = controller;
}
void onTapTabbar(int index) {
if (index == 1 && tabCtr.index == 1) {
replyScrillController?.animateTo(0,
duration: const Duration(milliseconds: 300), curve: Curves.ease);
}
}
} }

View File

@ -19,12 +19,14 @@ class VideoReplyPanel extends StatefulWidget {
final int? oid; final int? oid;
final int rpid; final int rpid;
final String? replyLevel; final String? replyLevel;
final Function(ScrollController)? onControllerCreated;
const VideoReplyPanel({ const VideoReplyPanel({
this.bvid, this.bvid,
this.oid, this.oid,
this.rpid = 0, this.rpid = 0,
this.replyLevel, this.replyLevel,
this.onControllerCreated,
super.key, super.key,
}); });
@ -68,6 +70,7 @@ class _VideoReplyPanelState extends State<VideoReplyPanel>
_futureBuilderFuture = _videoReplyController.queryReplyList(); _futureBuilderFuture = _videoReplyController.queryReplyList();
scrollController = ScrollController(); scrollController = ScrollController();
widget.onControllerCreated?.call(scrollController);
fabAnimationCtr.forward(); fabAnimationCtr.forward();
scrollListener(); scrollListener();
} }

View File

@ -387,6 +387,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
dividerColor: Colors.transparent, dividerColor: Colors.transparent,
tabs: tabs:
vdCtr.tabs.map((String name) => Tab(text: name)).toList(), vdCtr.tabs.map((String name) => Tab(text: name)).toList(),
onTap: (index) => vdCtr.onTapTabbar(index),
), ),
), ),
), ),
@ -683,6 +684,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
() => VideoReplyPanel( () => VideoReplyPanel(
bvid: vdCtr.bvid, bvid: vdCtr.bvid,
oid: vdCtr.oid.value, oid: vdCtr.oid.value,
onControllerCreated: vdCtr.onControllerCreated,
), ),
) )
], ],