opt: pages

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2024-11-21 18:06:33 +08:00
parent 5b2a4fa681
commit c5f5c00d37
66 changed files with 1504 additions and 1534 deletions

View File

@@ -699,7 +699,10 @@ class VideoIntroController extends GetxController
late RelatedController relatedCtr;
try {
relatedCtr = Get.find<RelatedController>(tag: heroTag);
if (relatedCtr.loadingState.value is Empty) {
if (relatedCtr.loadingState.value is! Success) {
return false;
}
if ((relatedCtr.loadingState.value as Success).response.isEmpty == true) {
SmartDialog.showToast('暂无相关视频,停止连播');
return false;
}

View File

@@ -101,7 +101,7 @@ class _CreateFavPageState extends State<CreateFavPage> {
slivers: [
HttpError(
errMsg: _errMsg,
fn: _getFolderInfo,
callback: _getFolderInfo,
),
],
),

View File

@@ -147,7 +147,7 @@ class _FavPanelState extends State<FavPanel> {
slivers: [
HttpError(
errMsg: data['msg'],
fn: () => setState(() {
callback: () => setState(() {
_futureBuilderFuture =
widget.ctr!.queryVideoInFolder();
}),

View File

@@ -144,7 +144,7 @@ class _GroupPanelState extends State<GroupPanel> {
slivers: [
HttpError(
errMsg: data['msg'],
fn: () => setState(() {}),
callback: () => setState(() {}),
),
],
);

View File

@@ -43,54 +43,58 @@ class _RelatedVideoPanelState extends State<RelatedVideoPanel>
}
Widget _buildBody(LoadingState loadingState) {
return loadingState is Success
? SliverGrid(
gridDelegate: SliverGridDelegateWithExtentAndRatio(
mainAxisSpacing: StyleString.safeSpace,
crossAxisSpacing: StyleString.safeSpace,
maxCrossAxisExtent: Grid.maxRowWidth * 2,
childAspectRatio: StyleString.aspectRatio * 2.4,
mainAxisExtent: 0),
delegate: SliverChildBuilderDelegate((context, index) {
if (index == loadingState.response.length) {
return SizedBox(height: MediaQuery.of(context).padding.bottom);
} else {
return Material(
child: VideoCardH(
videoItem: loadingState.response[index],
showPubdate: true,
longPress: () {
_relatedController.popupDialog.add(
_createPopupDialog(loadingState.response[index]));
Overlay.of(context)
.insert(_relatedController.popupDialog.last!);
},
longPressEnd: _relatedController.removePopupDialog,
),
);
}
}, childCount: loadingState.response.length + 1),
)
: loadingState is Error
? HttpError(
errMsg: '出错了',
fn: _relatedController.onReload,
)
: loadingState is Empty
? const SliverToBoxAdapter(child: SizedBox.shrink())
: SliverGrid(
gridDelegate: SliverGridDelegateWithExtentAndRatio(
mainAxisSpacing: StyleString.safeSpace,
crossAxisSpacing: StyleString.safeSpace,
maxCrossAxisExtent: Grid.maxRowWidth * 2,
childAspectRatio: StyleString.aspectRatio * 2.4,
mainAxisExtent: 0),
delegate: SliverChildBuilderDelegate(
(context, index) {
return const VideoCardHSkeleton();
return switch (loadingState) {
Loading() => SliverGrid(
gridDelegate: SliverGridDelegateWithExtentAndRatio(
mainAxisSpacing: StyleString.safeSpace,
crossAxisSpacing: StyleString.safeSpace,
maxCrossAxisExtent: Grid.maxRowWidth * 2,
childAspectRatio: StyleString.aspectRatio * 2.4,
mainAxisExtent: 0),
delegate: SliverChildBuilderDelegate(
(context, index) {
return const VideoCardHSkeleton();
},
childCount: 5,
),
),
Success() => (loadingState.response as List?)?.isNotEmpty == true
? SliverGrid(
gridDelegate: SliverGridDelegateWithExtentAndRatio(
mainAxisSpacing: StyleString.safeSpace,
crossAxisSpacing: StyleString.safeSpace,
maxCrossAxisExtent: Grid.maxRowWidth * 2,
childAspectRatio: StyleString.aspectRatio * 2.4,
mainAxisExtent: 0),
delegate: SliverChildBuilderDelegate((context, index) {
if (index == loadingState.response.length) {
return SizedBox(
height: MediaQuery.of(context).padding.bottom);
} else {
return Material(
child: VideoCardH(
videoItem: loadingState.response[index],
showPubdate: true,
longPress: () {
_relatedController.popupDialog.add(
_createPopupDialog(loadingState.response[index]));
Overlay.of(context)
.insert(_relatedController.popupDialog.last!);
},
childCount: 5,
longPressEnd: _relatedController.removePopupDialog,
),
);
}
}, childCount: loadingState.response.length + 1),
)
: HttpError(
callback: _relatedController.onReload,
),
Error() => HttpError(
errMsg: loadingState.errMsg,
callback: _relatedController.onReload,
),
LoadingState() => throw UnimplementedError(),
};
}
}

View File

@@ -200,63 +200,68 @@ class _VideoReplyPanelState extends State<VideoReplyPanel>
}
Widget _buildBody(LoadingState loadingState) {
return loadingState is Success
? SliverList(
delegate: SliverChildBuilderDelegate(
(BuildContext context, index) {
double bottom = MediaQuery.of(context).padding.bottom;
if (index == loadingState.response.replies.length) {
return Container(
padding: EdgeInsets.only(bottom: bottom),
height: bottom + 100,
child: Center(
child: Obx(
() => Text(
_videoReplyController.noMore.value,
style: TextStyle(
fontSize: 12,
color: Theme.of(context).colorScheme.outline,
return switch (loadingState) {
Loading() => SliverList(
delegate: SliverChildBuilderDelegate(
(BuildContext context, index) {
return const VideoReplySkeleton();
},
childCount: 5,
),
),
Success() => (loadingState.response.replies as List?)?.isNotEmpty == true
? SliverList(
delegate: SliverChildBuilderDelegate(
(BuildContext context, index) {
double bottom = MediaQuery.of(context).padding.bottom;
if (index == loadingState.response.replies.length) {
return Container(
padding: EdgeInsets.only(bottom: bottom),
height: bottom + 100,
child: Center(
child: Obx(
() => Text(
_videoReplyController.noMore.value,
style: TextStyle(
fontSize: 12,
color: Theme.of(context).colorScheme.outline,
),
),
),
),
),
);
} else {
return ReplyItemGrpc(
replyItem: loadingState.response.replies[index],
showReplyRow: true,
replyLevel: replyLevel,
replyReply: widget.replyReply,
replyType: ReplyType.video,
onReply: () {
_videoReplyController.onReply(
context,
replyItem: loadingState.response.replies[index],
index: index,
);
},
onDelete: _videoReplyController.onMDelete,
isTop: _videoReplyController.hasUpTop && index == 0,
upMid: loadingState.response.subjectControl.upMid,
);
}
},
childCount: loadingState.response.replies.length + 1,
);
} else {
return ReplyItemGrpc(
replyItem: loadingState.response.replies[index],
showReplyRow: true,
replyLevel: replyLevel,
replyReply: widget.replyReply,
replyType: ReplyType.video,
onReply: () {
_videoReplyController.onReply(
context,
replyItem: loadingState.response.replies[index],
index: index,
);
},
onDelete: _videoReplyController.onMDelete,
isTop: _videoReplyController.hasUpTop && index == 0,
upMid: loadingState.response.subjectControl.upMid,
);
}
},
childCount: loadingState.response.replies.length + 1,
),
)
: HttpError(
callback: _videoReplyController.onReload,
),
)
: loadingState is Error
? HttpError(
errMsg: loadingState.errMsg,
fn: _videoReplyController.onReload,
)
: SliverList(
delegate: SliverChildBuilderDelegate(
(BuildContext context, index) {
return const VideoReplySkeleton();
},
childCount: 5,
),
);
Error() => HttpError(
errMsg: loadingState.errMsg,
callback: _videoReplyController.onReload,
),
LoadingState() => throw UnimplementedError(),
};
}
}

View File

@@ -146,10 +146,20 @@ class VideoReplyReplyController extends CommonController
}
upMid ??= replies.subjectControl.upMid.toInt();
cursor = replies.cursor;
if (currentPage != 1) {
List<ReplyInfo> list = loadingState.value is Success
? (loadingState.value as Success).response
: <ReplyInfo>[];
if (isDialogue) {
replies.replies.insertAll(0, list);
} else {
replies.root.replies.insertAll(0, list);
}
}
if (isDialogue) {
if (replies.replies.isNotEmpty) {
noMore.value = '加载中...';
if (replies.cursor.isEnd) {
if (replies.cursor.isEnd || count.value >= replies.replies.length) {
noMore.value = '没有更多了';
}
} else {
@@ -159,7 +169,8 @@ class VideoReplyReplyController extends CommonController
} else {
if (replies.root.replies.isNotEmpty) {
noMore.value = '加载中...';
if (replies.cursor.isEnd) {
if (replies.cursor.isEnd ||
count.value >= replies.root.replies.length) {
noMore.value = '没有更多了';
}
} else {
@@ -167,16 +178,6 @@ class VideoReplyReplyController extends CommonController
noMore.value = currentPage == 1 ? '还没有评论' : '没有更多了';
}
}
if (currentPage != 1) {
List<ReplyInfo> list = loadingState.value is Success
? (loadingState.value as Success).response
: <ReplyInfo>[];
if (isDialogue) {
replies.replies.insertAll(0, list);
} else {
replies.root.replies.insertAll(0, list);
}
}
if (isDialogue) {
loadingState.value = LoadingState.success(replies.replies);
} else {

View File

@@ -333,7 +333,7 @@ class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel> {
slivers: [
HttpError(
errMsg: loadingState.errMsg,
fn: _videoReplyReplyController.onReload,
callback: _videoReplyReplyController.onReload,
)
],
);