opt: viewpoints page

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-03-09 10:04:18 +08:00
parent 0408b27ca5
commit 847ac80d5f
5 changed files with 99 additions and 103 deletions

View File

@@ -23,12 +23,10 @@ class AtMeController extends CommonController {
cursor = data.cursor?.id ?? -1;
cursorTime = data.cursor?.time ?? -1;
if (currentPage != 1 && loadingState.value is Success) {
loadingState.value = LoadingState.success(
(loadingState.value as Success).response as List
..addAll(data.items ?? <AtMeItems>[]));
} else {
loadingState.value = LoadingState.success(data.items);
data.items ??= <AtMeItems>[];
data.items!.insertAll(0, (loadingState.value as Success).response);
}
loadingState.value = LoadingState.success(data.items);
return true;
}

View File

@@ -27,14 +27,13 @@ class LikeMeController extends CommonController {
List<LikeMeItems> latest = data.latest?.items ?? [];
List<LikeMeItems> total = data.total?.items ?? [];
if (currentPage != 1 && loadingState.value is Success) {
loadingState.value = LoadingState.success((loadingState.value as Success)
.response as Pair<List<LikeMeItems>, List<LikeMeItems>>
..first.addAll(latest)
..second.addAll(total));
} else {
Pair<List<LikeMeItems>, List<LikeMeItems>> pair =
(loadingState.value as Success).response;
latest.insertAll(0, pair.first);
total.insertAll(0, pair.second);
}
loadingState.value =
LoadingState.success(Pair(first: latest, second: total));
}
return true;
}

View File

@@ -23,12 +23,10 @@ class ReplyMeController extends CommonController {
cursor = data.cursor?.id ?? -1;
cursorTime = data.cursor?.time ?? -1;
if (currentPage != 1 && loadingState.value is Success) {
loadingState.value = LoadingState.success(
(loadingState.value as Success).response as List
..addAll(data.items ?? <ReplyMeItems>[]));
} else {
loadingState.value = LoadingState.success(data.items);
data.items ??= <ReplyMeItems>[];
data.items!.insertAll(0, (loadingState.value as Success).response);
}
loadingState.value = LoadingState.success(data.items);
return true;
}

View File

@@ -17,18 +17,20 @@ class SysMsgController extends CommonController {
@override
List? handleListResponse(List currentList, List dataList) {
if (cursor == -1) {
msgSysUpdateCursor(dataList.first.cursor!);
msgSysUpdateCursor(dataList.firstOrNull?.cursor);
}
cursor = dataList.last.cursor ?? -1;
cursor = dataList.lastOrNull?.cursor ?? -1;
if (isEnd.not && dataList.length + 1 < pageSize) {
isEnd = true;
}
return null;
}
Future msgSysUpdateCursor(int cursor) async {
Future msgSysUpdateCursor(int? cursor) async {
if (cursor != null) {
MsgHttp.msgSysUpdateCursor(cursor);
}
}
@override
Future onRefresh() {

View File

@@ -39,6 +39,7 @@ class _ViewPointsPageState
automaticallyImplyLeading: false,
titleSpacing: 16,
title: const Text('分段信息'),
toolbarHeight: 45,
actions: [
Text(
'分段进度条',
@@ -73,27 +74,25 @@ class _ViewPointsPageState
),
const SizedBox(width: 16),
],
bottom: PreferredSize(
preferredSize: Size.fromHeight(1),
child: Divider(
height: 1,
color: Theme.of(context).dividerColor.withOpacity(0.1),
),
),
),
body: enableSlide ? slideList() : buildList,
);
@override
Widget get buildList => ListView(
Widget get buildList => ListView.separated(
controller: ScrollController(),
physics: const AlwaysScrollableScrollPhysics(),
padding:
EdgeInsets.only(bottom: MediaQuery.paddingOf(context).bottom + 80),
children: [
...List.generate(
videoDetailController.viewPointList.length * 2 - 1,
(rawIndex) {
if (rawIndex % 2 == 1) {
return Divider(
height: 1,
color: Theme.of(context).dividerColor.withOpacity(0.1),
);
}
int index = rawIndex ~/ 2;
itemCount: videoDetailController.viewPointList.length,
itemBuilder: (context, index) {
Segment segment = videoDetailController.viewPointList[index];
if (currentIndex == -1 &&
segment.from != null &&
@@ -101,8 +100,7 @@ class _ViewPointsPageState
if (videoDetailController
.plPlayerController.positionSeconds.value >=
segment.from! &&
videoDetailController
.plPlayerController.positionSeconds.value <
videoDetailController.plPlayerController.positionSeconds.value <
segment.to!) {
currentIndex = index;
}
@@ -135,8 +133,7 @@ class _ViewPointsPageState
builder: (context, constraints) => NetworkImgLayer(
radius: 6,
src: segment.url,
width:
constraints.maxHeight * StyleString.aspectRatio,
width: constraints.maxHeight * StyleString.aspectRatio,
height: constraints.maxHeight,
),
),
@@ -163,7 +160,9 @@ class _ViewPointsPageState
),
);
},
separatorBuilder: (context, index) => Divider(
height: 1,
color: Theme.of(context).dividerColor.withOpacity(0.1),
),
],
);
}