diff --git a/lib/pages/member_video/controller.dart b/lib/pages/member_video/controller.dart index 8e11a6d5..bf508311 100644 --- a/lib/pages/member_video/controller.dart +++ b/lib/pages/member_video/controller.dart @@ -39,13 +39,13 @@ class MemberVideoCtr String? firstAid; String? lastAid; String? fromViewAid; - bool? isLocating; + Rx isLocating = Rx(null); bool? isLoadPrevious; bool? hasPrev; @override Future onRefresh() async { - if (isLocating == true) { + if (isLocating.value == true) { if (hasPrev == true) { isLoadPrevious = true; await queryData(); @@ -127,12 +127,12 @@ class MemberVideoCtr next: next, seasonId: seasonId, seriesId: seriesId, - includeCursor: isLocating == true && page == 0 ? true : null, + includeCursor: isLocating.value == true && page == 0 ? true : null, ); void queryBySort() { if (type == ContributeType.video) { - isLocating = null; + isLocating.value = null; order.value = order.value == 'pubdate' ? 'click' : 'pubdate'; } else { sort.value = sort.value == 'desc' ? 'asc' : 'desc'; @@ -221,7 +221,7 @@ class MemberVideoCtr @override Future onReload() { - isLocating = null; + isLocating.value = null; return super.onReload(); } } diff --git a/lib/pages/member_video/view.dart b/lib/pages/member_video/view.dart index 003f9ac8..265e8aa5 100644 --- a/lib/pages/member_video/view.dart +++ b/lib/pages/member_video/view.dart @@ -63,7 +63,7 @@ class _MemberVideoState extends State onRefresh: _controller.onRefresh, child: CustomScrollView( // physics: PositionRetainedScrollPhysics( - // shouldRetain: _controller.isLocating == true, + // shouldRetain: _controller.isLocating.value == true, // parent: const ClampingScrollPhysics(), // ), slivers: [ @@ -78,26 +78,29 @@ class _MemberVideoState extends State ), ), if (widget.type == ContributeType.video && - _controller.fromViewAid?.isNotEmpty == true && - _controller.isLocating != true) - Positioned( - right: 15, - bottom: 15, - child: SafeArea( - top: false, - left: false, - child: FloatingActionButton.extended( - onPressed: () { - _controller - ..isLocating = true - ..lastAid = _controller.fromViewAid - ..page = 0 - ..loadingState.value = LoadingState.loading() - ..queryData(); - }, - label: const Text('定位至上次观看'), - ), - ), + _controller.fromViewAid?.isNotEmpty == true) + Obx( + () => _controller.isLocating.value != true + ? Positioned( + right: 15, + bottom: 15, + child: SafeArea( + top: false, + left: false, + child: FloatingActionButton.extended( + onPressed: () { + _controller + ..isLocating.value = true + ..lastAid = _controller.fromViewAid + ..page = 0 + ..loadingState.value = LoadingState.loading() + ..queryData(); + }, + label: const Text('定位至上次观看'), + ), + ), + ) + : const SizedBox.shrink(), ), ], );