mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-06-01 16:48:16 +08:00
tweaks (#1187)
* opt: marquee * fix: bangumi seek * opt: post panel * opt: remove deprecated code * opt: singleton dynController * fix: music scheme * feat: MemberVideo jump keep position * tweak
This commit is contained in:
committed by
GitHub
parent
e8a674ca2a
commit
172389b12b
@@ -40,18 +40,19 @@ class MemberVideoCtr
|
||||
String? firstAid;
|
||||
String? lastAid;
|
||||
String? fromViewAid;
|
||||
Rx<bool?> isLocating = Rx<bool?>(null);
|
||||
bool? isLoadPrevious;
|
||||
RxBool isLocating = false.obs;
|
||||
bool isLoadPrevious = false;
|
||||
bool? hasPrev;
|
||||
|
||||
@override
|
||||
Future<void> onRefresh() async {
|
||||
if (isLocating.value == true) {
|
||||
if (isLocating.value) {
|
||||
if (hasPrev == true) {
|
||||
isLoadPrevious = true;
|
||||
await queryData();
|
||||
}
|
||||
} else {
|
||||
isLoadPrevious = false;
|
||||
firstAid = null;
|
||||
lastAid = null;
|
||||
next = null;
|
||||
@@ -76,15 +77,15 @@ class MemberVideoCtr
|
||||
bool isRefresh,
|
||||
Success<SpaceArchiveData> response,
|
||||
) {
|
||||
SpaceArchiveData data = response.response;
|
||||
final data = response.response;
|
||||
episodicButton
|
||||
..value = data.episodicButton ?? EpisodicButton()
|
||||
..refresh();
|
||||
next = data.next;
|
||||
if (page == 0 || isLoadPrevious == true) {
|
||||
if (page == 0 || isLoadPrevious) {
|
||||
hasPrev = data.hasPrev;
|
||||
}
|
||||
if (page == 0 || isLoadPrevious != true) {
|
||||
if (page == 0 || !isLoadPrevious) {
|
||||
if ((type == ContributeType.video
|
||||
? data.hasNext == false
|
||||
: data.next == 0) ||
|
||||
@@ -97,7 +98,7 @@ class MemberVideoCtr
|
||||
: (data.count ?? -1);
|
||||
if (page != 0 && loadingState.value.isSuccess) {
|
||||
data.item ??= <SpaceArchiveItem>[];
|
||||
if (isLoadPrevious == true) {
|
||||
if (isLoadPrevious) {
|
||||
data.item!.addAll(loadingState.value.data!);
|
||||
} else {
|
||||
data.item!.insertAll(0, loadingState.value.data!);
|
||||
@@ -105,7 +106,6 @@ class MemberVideoCtr
|
||||
}
|
||||
firstAid = data.item?.firstOrNull?.param;
|
||||
lastAid = data.item?.lastOrNull?.param;
|
||||
isLoadPrevious = null;
|
||||
loadingState.value = Success(data.item);
|
||||
return true;
|
||||
}
|
||||
@@ -116,13 +116,13 @@ class MemberVideoCtr
|
||||
type: type,
|
||||
mid: mid,
|
||||
aid: type == ContributeType.video
|
||||
? isLoadPrevious == true
|
||||
? isLoadPrevious
|
||||
? firstAid
|
||||
: lastAid
|
||||
: null,
|
||||
order: type == ContributeType.video ? order.value : null,
|
||||
sort: type == ContributeType.video
|
||||
? isLoadPrevious == true
|
||||
? isLoadPrevious
|
||||
? 'asc'
|
||||
: null
|
||||
: sort.value,
|
||||
@@ -130,12 +130,12 @@ class MemberVideoCtr
|
||||
next: next,
|
||||
seasonId: seasonId,
|
||||
seriesId: seriesId,
|
||||
includeCursor: isLocating.value == true && page == 0 ? true : null,
|
||||
includeCursor: isLocating.value && page == 0,
|
||||
);
|
||||
|
||||
void queryBySort() {
|
||||
if (type == ContributeType.video) {
|
||||
isLocating.value = null;
|
||||
isLocating.value = false;
|
||||
order.value = order.value == 'pubdate' ? 'click' : 'pubdate';
|
||||
} else {
|
||||
sort.value = sort.value == 'desc' ? 'asc' : 'desc';
|
||||
@@ -223,7 +223,7 @@ class MemberVideoCtr
|
||||
@override
|
||||
Future<void> onReload() {
|
||||
reload = true;
|
||||
isLocating.value = null;
|
||||
isLocating.value = false;
|
||||
return super.onReload();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import 'package:PiliPlus/pages/member_video/controller.dart';
|
||||
import 'package:PiliPlus/pages/member_video/widgets/video_card_h_member_video.dart';
|
||||
import 'package:PiliPlus/utils/grid.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/scheduler.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
class MemberVideo extends StatefulWidget {
|
||||
@@ -59,8 +60,25 @@ class _MemberVideoState extends State<MemberVideo>
|
||||
super.build(context);
|
||||
final theme = Theme.of(context);
|
||||
final padding = MediaQuery.viewPaddingOf(context);
|
||||
Widget child = refreshIndicator(
|
||||
onRefresh: _controller.onRefresh,
|
||||
final child = refreshIndicator(
|
||||
onRefresh: () async {
|
||||
final count = _controller.loadingState.value.dataOrNull?.length;
|
||||
await _controller.onRefresh();
|
||||
if (_controller.isLoadPrevious) {
|
||||
if (mounted) {
|
||||
final newCount = _controller.loadingState.value.dataOrNull?.length;
|
||||
if (count != null && newCount != null && newCount > count) {
|
||||
SchedulerBinding.instance.addPostFrameCallback((_) {
|
||||
PrimaryScrollController.of(this.context).jumpTo(
|
||||
gridDelegate.layoutCache!
|
||||
.getGeometryForChildIndex(newCount - count)
|
||||
.scrollOffset,
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
child: CustomScrollView(
|
||||
physics: ReloadScrollPhysics(controller: _controller),
|
||||
slivers: [
|
||||
@@ -80,23 +98,21 @@ class _MemberVideoState extends State<MemberVideo>
|
||||
children: [
|
||||
child,
|
||||
Obx(
|
||||
() => _controller.isLocating.value != true
|
||||
() => !_controller.isLocating.value
|
||||
? Positioned(
|
||||
right: 15 + padding.right,
|
||||
bottom: 15 + padding.bottom,
|
||||
child: FloatingActionButton.extended(
|
||||
onPressed: () {
|
||||
final fromViewAid = _controller.fromViewAid;
|
||||
_controller
|
||||
..isLocating.value = true
|
||||
..lastAid = fromViewAid;
|
||||
final locatedIndex = _controller
|
||||
.loadingState
|
||||
.value
|
||||
.dataOrNull
|
||||
?.indexWhere((i) => i.param == fromViewAid);
|
||||
if (locatedIndex == null || locatedIndex == -1) {
|
||||
_controller.isLocating.value = true;
|
||||
final locatedIndex =
|
||||
_controller.loadingState.value.dataOrNull
|
||||
?.indexWhere((i) => i.param == fromViewAid) ??
|
||||
-1;
|
||||
if (locatedIndex == -1) {
|
||||
_controller
|
||||
..lastAid = fromViewAid
|
||||
..reload = true
|
||||
..page = 0
|
||||
..loadingState.value = LoadingState.loading()
|
||||
|
||||
Reference in New Issue
Block a user