feat: 点击tab返回顶部
This commit is contained in:
@ -109,6 +109,7 @@ class VideoDetailController extends GetxController
|
||||
].obs;
|
||||
RxDouble sheetHeight = 0.0.obs;
|
||||
RxString archiveSourceType = 'dash'.obs;
|
||||
ScrollController? replyScrillController;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
@ -551,4 +552,15 @@ class VideoDetailController extends GetxController
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -19,12 +19,14 @@ class VideoReplyPanel extends StatefulWidget {
|
||||
final int? oid;
|
||||
final int rpid;
|
||||
final String? replyLevel;
|
||||
final Function(ScrollController)? onControllerCreated;
|
||||
|
||||
const VideoReplyPanel({
|
||||
this.bvid,
|
||||
this.oid,
|
||||
this.rpid = 0,
|
||||
this.replyLevel,
|
||||
this.onControllerCreated,
|
||||
super.key,
|
||||
});
|
||||
|
||||
@ -68,6 +70,7 @@ class _VideoReplyPanelState extends State<VideoReplyPanel>
|
||||
|
||||
_futureBuilderFuture = _videoReplyController.queryReplyList();
|
||||
scrollController = ScrollController();
|
||||
widget.onControllerCreated?.call(scrollController);
|
||||
fabAnimationCtr.forward();
|
||||
scrollListener();
|
||||
}
|
||||
|
@ -387,6 +387,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
||||
dividerColor: Colors.transparent,
|
||||
tabs:
|
||||
vdCtr.tabs.map((String name) => Tab(text: name)).toList(),
|
||||
onTap: (index) => vdCtr.onTapTabbar(index),
|
||||
),
|
||||
),
|
||||
),
|
||||
@ -683,6 +684,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
||||
() => VideoReplyPanel(
|
||||
bvid: vdCtr.bvid,
|
||||
oid: vdCtr.oid.value,
|
||||
onControllerCreated: vdCtr.onControllerCreated,
|
||||
),
|
||||
)
|
||||
],
|
||||
|
Reference in New Issue
Block a user