mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-07-20 10:30:13 +08:00
opt: common ctr
opt: state Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -1092,7 +1092,7 @@ class VideoDetailController extends GetxController
|
||||
subType: videoType == SearchType.media_bangumi ? subType : null,
|
||||
callback: () {
|
||||
if (videoState.value is! Success) {
|
||||
videoState.value = LoadingState.success(null);
|
||||
videoState.value = Success(null);
|
||||
}
|
||||
setSubtitle(vttSubtitlesIndex.value);
|
||||
},
|
||||
@@ -1186,7 +1186,7 @@ class VideoDetailController extends GetxController
|
||||
SmartDialog.showToast('视频资源不存在');
|
||||
autoPlay.value = false;
|
||||
isShowCover.value = true;
|
||||
videoState.value = LoadingState.error('视频资源不存在');
|
||||
videoState.value = Error('视频资源不存在');
|
||||
if (plPlayerController.isFullScreen.value) {
|
||||
plPlayerController.toggleFullScreen(false);
|
||||
}
|
||||
@@ -1297,7 +1297,7 @@ class VideoDetailController extends GetxController
|
||||
} else {
|
||||
autoPlay.value = false;
|
||||
isShowCover.value = true;
|
||||
videoState.value = LoadingState.error(result['msg']);
|
||||
videoState.value = Error(result['msg']);
|
||||
if (plPlayerController.isFullScreen.value) {
|
||||
plPlayerController.toggleFullScreen(false);
|
||||
}
|
||||
|
||||
@@ -87,19 +87,19 @@ class _BangumiIntroPanelState extends State<BangumiIntroPanel>
|
||||
showEpisodes: widget.showEpisodes,
|
||||
showIntroDetail: () {},
|
||||
),
|
||||
Success() => BangumiInfo(
|
||||
Success(:var response) => BangumiInfo(
|
||||
heroTag: widget.heroTag,
|
||||
isLoading: false,
|
||||
bangumiDetail: loadingState.response,
|
||||
bangumiDetail: response,
|
||||
cid: cid,
|
||||
showEpisodes: widget.showEpisodes,
|
||||
showIntroDetail: () => widget.showIntroDetail(
|
||||
loadingState.response,
|
||||
response,
|
||||
bangumiIntroController.videoTags,
|
||||
),
|
||||
),
|
||||
Error() => HttpError(
|
||||
errMsg: loadingState.errMsg,
|
||||
Error(:var errMsg) => HttpError(
|
||||
errMsg: errMsg,
|
||||
onReload: bangumiIntroController.onReload,
|
||||
),
|
||||
};
|
||||
|
||||
@@ -12,6 +12,8 @@ class HorizontalMemberPageController extends CommonDataController {
|
||||
|
||||
dynamic mid;
|
||||
|
||||
int currentPage = 0;
|
||||
|
||||
Rx<LoadingState<MemberInfoModel>> userState =
|
||||
LoadingState<MemberInfoModel>.loading().obs;
|
||||
RxMap userStat = {}.obs;
|
||||
@@ -19,7 +21,6 @@ class HorizontalMemberPageController extends CommonDataController {
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
currentPage = 0;
|
||||
getUserInfo();
|
||||
queryData();
|
||||
}
|
||||
@@ -27,10 +28,10 @@ class HorizontalMemberPageController extends CommonDataController {
|
||||
Future<void> getUserInfo() async {
|
||||
dynamic res = await MemberHttp.memberInfo(mid: mid);
|
||||
if (res['status']) {
|
||||
userState.value = LoadingState.success(res['data']);
|
||||
userState.value = Success(res['data']);
|
||||
getMemberStat();
|
||||
} else {
|
||||
userState.value = LoadingState.error(res['msg']);
|
||||
userState.value = Error(res['msg']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,7 +70,7 @@ class HorizontalMemberPageController extends CommonDataController {
|
||||
}
|
||||
firstAid = data.item?.firstOrNull?.param;
|
||||
lastAid = data.item?.lastOrNull?.param;
|
||||
loadingState.value = LoadingState.success(data.item);
|
||||
loadingState.value = Success(data.item);
|
||||
isLoadPrevious = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ class _HorizontalMemberPageState extends State<HorizontalMemberPage> {
|
||||
Widget _buildUserPage(ThemeData theme, LoadingState userState) {
|
||||
return switch (userState) {
|
||||
Loading() => loadingWidget,
|
||||
Success() => Column(
|
||||
Success(:var response) => Column(
|
||||
children: [
|
||||
const SizedBox(height: 4),
|
||||
Row(
|
||||
@@ -103,7 +103,7 @@ class _HorizontalMemberPageState extends State<HorizontalMemberPage> {
|
||||
const SizedBox(width: 16),
|
||||
],
|
||||
),
|
||||
_buildUserInfo(theme, userState.response),
|
||||
_buildUserInfo(theme, response),
|
||||
const SizedBox(height: 5),
|
||||
Expanded(
|
||||
child: Obx(
|
||||
@@ -111,11 +111,12 @@ class _HorizontalMemberPageState extends State<HorizontalMemberPage> {
|
||||
),
|
||||
],
|
||||
),
|
||||
Error() => scrollErrorWidget(
|
||||
Error(:var errMsg) => scrollErrorWidget(
|
||||
controller: _controller.scrollController,
|
||||
errMsg: userState.errMsg,
|
||||
errMsg: errMsg,
|
||||
onReload: () {
|
||||
_controller.userState.value = LoadingState.loading();
|
||||
_controller.userState.value =
|
||||
LoadingState<MemberInfoModel>.loading();
|
||||
_controller.getUserInfo();
|
||||
},
|
||||
),
|
||||
@@ -178,7 +179,7 @@ class _HorizontalMemberPageState extends State<HorizontalMemberPage> {
|
||||
Widget _buildVideoList(ThemeData theme, LoadingState loadingState) {
|
||||
return switch (loadingState) {
|
||||
Loading() => loadingWidget,
|
||||
Success() => Material(
|
||||
Success(:var response) => Material(
|
||||
color: Colors.transparent,
|
||||
child: CustomScrollView(
|
||||
controller: _controller.scrollController,
|
||||
@@ -196,12 +197,10 @@ class _HorizontalMemberPageState extends State<HorizontalMemberPage> {
|
||||
gridDelegate: Grid.videoCardHDelegate(context),
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
(context, index) {
|
||||
if (index == loadingState.response.length - 1 &&
|
||||
_controller.hasNext) {
|
||||
if (index == response.length - 1 && _controller.hasNext) {
|
||||
_controller.onLoadMore();
|
||||
}
|
||||
final SpaceArchiveItem videoItem =
|
||||
loadingState.response[index];
|
||||
final SpaceArchiveItem videoItem = response[index];
|
||||
return VideoCardHMemberVideo(
|
||||
key: ValueKey('${videoItem.param}'),
|
||||
videoItem: videoItem,
|
||||
@@ -222,16 +221,16 @@ class _HorizontalMemberPageState extends State<HorizontalMemberPage> {
|
||||
},
|
||||
);
|
||||
},
|
||||
childCount: loadingState.response.length,
|
||||
childCount: response.length,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Error() => scrollErrorWidget(
|
||||
Error(:var errMsg) => scrollErrorWidget(
|
||||
controller: _controller.scrollController,
|
||||
errMsg: loadingState.errMsg,
|
||||
errMsg: errMsg,
|
||||
onReload: _controller.onReload,
|
||||
),
|
||||
};
|
||||
|
||||
@@ -39,6 +39,6 @@ class NoteListPageCtr extends CommonListController {
|
||||
Future<LoadingState> customGetData() => VideoHttp.getVideoNoteList(
|
||||
oid: oid,
|
||||
uperMid: upperMid,
|
||||
page: currentPage,
|
||||
page: page,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -148,7 +148,7 @@ class _NoteListPageState extends CommonSlidePageState<NoteListPage> {
|
||||
)
|
||||
],
|
||||
),
|
||||
Success() => loadingState.response?.isNotEmpty == true
|
||||
Success(:var response) => response?.isNotEmpty == true
|
||||
? refreshIndicator(
|
||||
onRefresh: _controller.onRefresh,
|
||||
child: CustomScrollView(
|
||||
@@ -157,13 +157,12 @@ class _NoteListPageState extends CommonSlidePageState<NoteListPage> {
|
||||
slivers: [
|
||||
SliverList.separated(
|
||||
itemBuilder: (context, index) {
|
||||
if (index == loadingState.response!.length - 1) {
|
||||
if (index == response.length - 1) {
|
||||
_controller.onLoadMore();
|
||||
}
|
||||
return _itemWidget(
|
||||
context, theme, loadingState.response![index]);
|
||||
return _itemWidget(context, theme, response[index]);
|
||||
},
|
||||
itemCount: loadingState.response!.length,
|
||||
itemCount: response!.length,
|
||||
separatorBuilder: (context, index) => Divider(
|
||||
height: 1,
|
||||
color: theme.colorScheme.outline.withOpacity(0.1),
|
||||
@@ -178,7 +177,7 @@ class _NoteListPageState extends CommonSlidePageState<NoteListPage> {
|
||||
),
|
||||
)
|
||||
: errWidget(),
|
||||
Error() => errWidget(loadingState.errMsg),
|
||||
Error(:var errMsg) => errWidget(errMsg),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -45,19 +45,22 @@ class _RelatedVideoPanelState extends State<RelatedVideoPanel>
|
||||
childCount: 5,
|
||||
),
|
||||
),
|
||||
Success() => loadingState.response?.isNotEmpty == true
|
||||
Success(:var response) => response?.isNotEmpty == true
|
||||
? SliverGrid(
|
||||
gridDelegate: Grid.videoCardHDelegate(context),
|
||||
delegate: SliverChildBuilderDelegate((context, index) {
|
||||
return VideoCardH(
|
||||
videoItem: loadingState.response![index],
|
||||
showPubdate: true,
|
||||
);
|
||||
}, childCount: loadingState.response!.length),
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
(context, index) {
|
||||
return VideoCardH(
|
||||
videoItem: response[index],
|
||||
showPubdate: true,
|
||||
);
|
||||
},
|
||||
childCount: response!.length,
|
||||
),
|
||||
)
|
||||
: const SliverToBoxAdapter(),
|
||||
Error() => HttpError(
|
||||
errMsg: loadingState.errMsg,
|
||||
Error(:var errMsg) => HttpError(
|
||||
errMsg: errMsg,
|
||||
onReload: _relatedController.onReload,
|
||||
),
|
||||
};
|
||||
|
||||
@@ -203,11 +203,11 @@ class _VideoReplyPanelState extends State<VideoReplyPanel>
|
||||
},
|
||||
itemCount: 5,
|
||||
),
|
||||
Success() => loadingState.response?.isNotEmpty == true
|
||||
Success(:var response) => response?.isNotEmpty == true
|
||||
? SliverList.builder(
|
||||
itemBuilder: (context, index) {
|
||||
double bottom = MediaQuery.of(context).padding.bottom;
|
||||
if (index == loadingState.response.length) {
|
||||
if (index == response.length) {
|
||||
_videoReplyController.onLoadMore();
|
||||
return Container(
|
||||
alignment: Alignment.center,
|
||||
@@ -216,7 +216,7 @@ class _VideoReplyPanelState extends State<VideoReplyPanel>
|
||||
child: Text(
|
||||
_videoReplyController.isEnd.not
|
||||
? '加载中...'
|
||||
: loadingState.response.isEmpty
|
||||
: response.isEmpty
|
||||
? '还没有评论'
|
||||
: '没有更多了',
|
||||
style: TextStyle(
|
||||
@@ -227,13 +227,13 @@ class _VideoReplyPanelState extends State<VideoReplyPanel>
|
||||
);
|
||||
} else {
|
||||
return ReplyItemGrpc(
|
||||
replyItem: loadingState.response[index],
|
||||
replyItem: response[index],
|
||||
replyLevel: widget.replyLevel,
|
||||
replyReply: widget.replyReply,
|
||||
onReply: () {
|
||||
_videoReplyController.onReply(
|
||||
context,
|
||||
replyItem: loadingState.response[index],
|
||||
replyItem: response[index],
|
||||
index: index,
|
||||
);
|
||||
},
|
||||
@@ -257,14 +257,14 @@ class _VideoReplyPanelState extends State<VideoReplyPanel>
|
||||
);
|
||||
}
|
||||
},
|
||||
itemCount: loadingState.response.length + 1,
|
||||
itemCount: response.length + 1,
|
||||
)
|
||||
: HttpError(
|
||||
errMsg: '还没有评论',
|
||||
onReload: _videoReplyController.onReload,
|
||||
),
|
||||
Error() => HttpError(
|
||||
errMsg: loadingState.errMsg,
|
||||
Error(:var errMsg) => HttpError(
|
||||
errMsg: errMsg,
|
||||
onReload: _videoReplyController.onReload,
|
||||
),
|
||||
};
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:PiliPlus/grpc/bilibili/main/community/reply/v1.pb.dart'
|
||||
show ReplyInfo;
|
||||
import 'package:PiliPlus/http/reply.dart';
|
||||
|
||||
@@ -402,8 +402,8 @@ class _VideoReplyReplyPanelState
|
||||
],
|
||||
),
|
||||
),
|
||||
Success() => () {
|
||||
if (index == loadingState.response.length) {
|
||||
Success(:var response) => () {
|
||||
if (index == response.length) {
|
||||
_videoReplyReplyController.onLoadMore();
|
||||
return Container(
|
||||
alignment: Alignment.center,
|
||||
@@ -413,7 +413,7 @@ class _VideoReplyReplyPanelState
|
||||
child: Text(
|
||||
_videoReplyReplyController.isEnd.not
|
||||
? '加载中...'
|
||||
: loadingState.response.isEmpty
|
||||
: response.isEmpty
|
||||
? '还没有评论'
|
||||
: '没有更多了',
|
||||
style: TextStyle(
|
||||
@@ -435,16 +435,16 @@ class _VideoReplyReplyPanelState
|
||||
return ColoredBox(
|
||||
color: colorAnimation!.value ??
|
||||
theme.colorScheme.onInverseSurface,
|
||||
child: _replyItem(loadingState.response[index], index),
|
||||
child: _replyItem(response[index], index),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
return _replyItem(loadingState.response[index], index);
|
||||
return _replyItem(response[index], index);
|
||||
}
|
||||
}(),
|
||||
Error() => errorWidget(
|
||||
errMsg: loadingState.errMsg,
|
||||
Error(:var errMsg) => errorWidget(
|
||||
errMsg: errMsg,
|
||||
onReload: _videoReplyReplyController.onReload,
|
||||
),
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user