diff --git a/lib/common/widgets/dialog/report_member.dart b/lib/common/widgets/dialog/report_member.dart index 2918b1fa2..d2a6a8acb 100644 --- a/lib/common/widgets/dialog/report_member.dart +++ b/lib/common/widgets/dialog/report_member.dart @@ -146,21 +146,16 @@ Future showMemberReportDialog( ), ), TextButton( - onPressed: () async { + onPressed: () { if (reason.isEmpty) { SmartDialog.showToast('至少选择一项作为举报内容'); } else { Get.back(); - final result = await MemberHttp.reportMember( + MemberHttp.reportMember( mid, reason: reason.join(','), reasonV2: reasonV2 != null ? reasonV2! + 1 : null, ); - if (result['msg'] is String && result['msg'].isNotEmpty) { - SmartDialog.showToast(result['msg']); - } else { - SmartDialog.showToast('举报失败'); - } } }, child: const Text('确定'), diff --git a/lib/common/widgets/image/image_save.dart b/lib/common/widgets/image/image_save.dart index bfec997f5..3b3dc1129 100644 --- a/lib/common/widgets/image/image_save.dart +++ b/lib/common/widgets/image/image_save.dart @@ -18,21 +18,8 @@ void imageSaveDialog({ SmartDialog.show( animationType: SmartAnimationType.centerScale_otherSlide, builder: (context) { + const iconSize = 20.0; final theme = Theme.of(context); - - Widget iconBtn({ - String? tooltip, - required Icon icon, - required VoidCallback? onPressed, - }) { - return iconButton( - icon: icon, - iconSize: 20, - tooltip: tooltip, - onPressed: onPressed, - ); - } - return Container( width: imgWidth, margin: const EdgeInsets.symmetric(horizontal: StyleString.safeSpace), @@ -94,19 +81,19 @@ void imageSaveDialog({ else const Spacer(), if (aid != null || bvid != null) - iconBtn( + iconButton( + iconSize: iconSize, tooltip: '稍后再看', onPressed: () => { SmartDialog.dismiss(), - UserHttp.toViewLater(aid: aid, bvid: bvid).then( - (res) => SmartDialog.showToast(res['msg']), - ), + UserHttp.toViewLater(aid: aid, bvid: bvid), }, icon: const Icon(Icons.watch_later_outlined), ), if (cover != null && cover.isNotEmpty) ...[ if (PlatformUtils.isMobile) - iconBtn( + iconButton( + iconSize: iconSize, tooltip: '分享', onPressed: () { SmartDialog.dismiss(); @@ -114,7 +101,8 @@ void imageSaveDialog({ }, icon: const Icon(Icons.share), ), - iconBtn( + iconButton( + iconSize: iconSize, tooltip: '保存封面图', onPressed: () async { bool saveStatus = await ImageUtils.downloadImg([cover]); diff --git a/lib/common/widgets/interactiveviewer_gallery/interactiveviewer_gallery.dart b/lib/common/widgets/interactiveviewer_gallery/interactiveviewer_gallery.dart index 06613ee12..f83f74a7b 100644 --- a/lib/common/widgets/interactiveviewer_gallery/interactiveviewer_gallery.dart +++ b/lib/common/widgets/interactiveviewer_gallery/interactiveviewer_gallery.dart @@ -327,9 +327,9 @@ class _InteractiveviewerGalleryState extends State child: Hero( tag: item.url, child: switch (item.sourceType) { - SourceType.fileImage => Image( + SourceType.fileImage => Image.file( + File(item.url), filterQuality: FilterQuality.low, - image: FileImage(File(item.url)), ), SourceType.networkImage => CachedNetworkImage( fadeInDuration: Duration.zero, diff --git a/lib/common/widgets/video_popup_menu.dart b/lib/common/widgets/video_popup_menu.dart index 5e969f9aa..be7b7e5a5 100644 --- a/lib/common/widgets/video_popup_menu.dart +++ b/lib/common/widgets/video_popup_menu.dart @@ -70,12 +70,7 @@ class VideoPopupMenu extends StatelessWidget { _VideoCustomAction( '稍后再看', const Icon(MdiIcons.clockTimeEightOutline, size: 16), - () async { - final res = await UserHttp.toViewLater( - bvid: videoItem.bvid, - ); - SmartDialog.showToast(res['msg']); - }, + () => UserHttp.toViewLater(bvid: videoItem.bvid), ), if (videoItem.cid != null && Pref.enableAi) _VideoCustomAction( diff --git a/lib/http/dynamics.dart b/lib/http/dynamics.dart index a54fe50a3..8a8caa618 100644 --- a/lib/http/dynamics.dart +++ b/lib/http/dynamics.dart @@ -173,8 +173,8 @@ abstract final class DynamicsHttp { queryParameters: { 'platform': 'web', 'csrf': Accounts.main.csrf, - 'x-bili-device-req-json': {"platform": "web", "device": "pc"}, - 'x-bili-web-req-json': {"spm_id": "333.999"}, + 'x-bili-device-req-json': '{"platform": "web", "device": "pc"}', + 'x-bili-web-req-json': '{"spm_id": "333.999"}', }, data: { "dyn_req": { diff --git a/lib/http/fav.dart b/lib/http/fav.dart index 4b9fb29bb..348a3adff 100644 --- a/lib/http/fav.dart +++ b/lib/http/fav.dart @@ -673,7 +673,7 @@ abstract final class FavHttp { } } - static Future copyOrMoveFav({ + static Future> copyOrMoveFav({ required bool isCopy, required bool isFav, required dynamic srcMediaId, diff --git a/lib/http/live.dart b/lib/http/live.dart index 22daae26d..f1d0afeb9 100644 --- a/lib/http/live.dart +++ b/lib/http/live.dart @@ -10,6 +10,7 @@ import 'package:PiliPlus/models/common/live/live_search_type.dart'; import 'package:PiliPlus/models_new/live/live_area_list/area_item.dart'; import 'package:PiliPlus/models_new/live/live_area_list/area_list.dart'; import 'package:PiliPlus/models_new/live/live_contribution_rank/data.dart'; +import 'package:PiliPlus/models_new/live/live_danmaku/danmaku_msg.dart'; import 'package:PiliPlus/models_new/live/live_dm_block/data.dart'; import 'package:PiliPlus/models_new/live/live_dm_block/shield_info.dart'; import 'package:PiliPlus/models_new/live/live_dm_block/shield_user_list.dart'; @@ -122,7 +123,9 @@ abstract final class LiveHttp { } } - static Future liveRoomDanmaPrefetch({required Object roomId}) async { + static Future?>> liveRoomDmPrefetch({ + required Object roomId, + }) async { final res = await Request().get( Api.liveRoomDmPrefetch, queryParameters: {'roomid': roomId}, @@ -134,9 +137,17 @@ abstract final class LiveHttp { ), ); if (res.data['code'] == 0) { - return {'status': true, 'data': res.data['data']?['room']}; + try { + return Success( + (res.data['data']?['room'] as List?) + ?.map((e) => DanmakuMsg.fromPrefetch(e)) + .toList(), + ); + } catch (e) { + return Error(e.toString()); + } } else { - return {'status': false, 'msg': res.data['message']}; + return Error(res.data['message']); } } diff --git a/lib/http/member.dart b/lib/http/member.dart index 573dfaf1f..f722abdcd 100644 --- a/lib/http/member.dart +++ b/lib/http/member.dart @@ -29,9 +29,10 @@ import 'package:PiliPlus/utils/app_sign.dart'; import 'package:PiliPlus/utils/utils.dart'; import 'package:PiliPlus/utils/wbi_sign.dart'; import 'package:dio/dio.dart'; +import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; abstract final class MemberHttp { - static Future reportMember( + static Future reportMember( dynamic mid, { String? reason, int? reasonV2, @@ -46,10 +47,11 @@ abstract final class MemberHttp { }, options: Options(contentType: Headers.formUrlEncodedContentType), ); - return { - 'status': res.data['status'], - 'msg': res.data['message'] ?? res.data['data'], - }; + if (res.data['status'] == true) { + SmartDialog.showToast('举报成功'); + } else { + SmartDialog.showToast('举报失败'); + } } static Future> spaceArticle({ @@ -205,48 +207,48 @@ abstract final class MemberHttp { } } - static Future spaceStory({ - required Object mid, - required Object aid, - required Object beforeSize, - required Object afterSize, - required Object cid, - required Object contain, - required Object index, - }) async { - final params = { - 'aid': aid, - 'before_size': beforeSize, - 'after_size': afterSize, - 'cid': cid, - 'contain': contain, - 'index': index, - 'build': 8430300, - 'version': '8.43.0', - 'c_locale': 'zh_CN', - 'channel': 'master', - 'mobi_app': 'android', - 'platform': 'android', - 's_locale': 'zh_CN', - 'statistics': Constants.statisticsApp, - 'vmid': mid, - }; - final res = await Request().get( - Api.spaceStory, - queryParameters: params, - options: Options( - headers: { - 'bili-http-engine': 'cronet', - 'user-agent': Constants.userAgentApp, - }, - ), - ); - if (res.data['code'] == 0) { - return Success(res.data['data']); - } else { - return Error(res.data['message']); - } - } + // static Future spaceStory({ + // required Object mid, + // required Object aid, + // required Object beforeSize, + // required Object afterSize, + // required Object cid, + // required Object contain, + // required Object index, + // }) async { + // final params = { + // 'aid': aid, + // 'before_size': beforeSize, + // 'after_size': afterSize, + // 'cid': cid, + // 'contain': contain, + // 'index': index, + // 'build': 8430300, + // 'version': '8.43.0', + // 'c_locale': 'zh_CN', + // 'channel': 'master', + // 'mobi_app': 'android', + // 'platform': 'android', + // 's_locale': 'zh_CN', + // 'statistics': Constants.statisticsApp, + // 'vmid': mid, + // }; + // final res = await Request().get( + // Api.spaceStory, + // queryParameters: params, + // options: Options( + // headers: { + // 'bili-http-engine': 'cronet', + // 'user-agent': Constants.userAgentApp, + // }, + // ), + // ); + // if (res.data['code'] == 0) { + // return Success(res.data['data']); + // } else { + // return Error(res.data['message']); + // } + // } static Future> space({ int? mid, @@ -315,15 +317,15 @@ abstract final class MemberHttp { } } - static Future memberStat({int? mid}) async { + static Future> memberStat({int? mid}) async { final res = await Request().get( Api.userStat, queryParameters: {'vmid': mid}, ); if (res.data['code'] == 0) { - return {'status': true, 'data': res.data['data']}; + return Success(res.data['data']); } else { - return {'status': false, 'msg': res.data['message']}; + return Error(res.data['message']); } } @@ -632,15 +634,15 @@ abstract final class MemberHttp { } // 获取up播放数、点赞数 - static Future memberView({required int mid}) async { + static Future> memberView({required int mid}) async { final res = await Request().get( Api.getMemberViewApi, queryParameters: {'mid': mid}, ); if (res.data['code'] == 0) { - return {'status': true, 'data': res.data['data']}; + return Success(res.data['data']); } else { - return {'status': false, 'msg': res.data['message']}; + return Error(res.data['message']); } } diff --git a/lib/http/msg.dart b/lib/http/msg.dart index 6e155d22f..67186a632 100644 --- a/lib/http/msg.dart +++ b/lib/http/msg.dart @@ -152,7 +152,7 @@ abstract final class MsgHttp { } } - static Future uploadImage({ + static Future> uploadImage({ required dynamic path, required String bucket, required String dir, @@ -167,15 +167,9 @@ abstract final class MsgHttp { }), ); if (res.data['code'] == 0) { - return { - 'status': true, - 'data': res.data['data'], - }; + return Success(res.data['data']); } else { - return { - 'status': false, - 'msg': res.data['message'], - }; + return Error(res.data['message']); } } diff --git a/lib/http/pgc.dart b/lib/http/pgc.dart index d7ec6c889..7ed6ae3f0 100644 --- a/lib/http/pgc.dart +++ b/lib/http/pgc.dart @@ -243,15 +243,15 @@ abstract final class PgcHttp { } } - static Future seasonStatus(Object seasonId) async { + static Future> seasonStatus(Object seasonId) async { final res = await Request().get( Api.seasonStatus, queryParameters: {'season_id': seasonId}, ); if (res.data['code'] == 0) { - return {'status': true, 'data': res.data['result']}; + return Success(res.data['result']); } else { - return {'status': false, 'msg': res.data['message']}; + return Error(res.data['message']); } } } diff --git a/lib/http/search.dart b/lib/http/search.dart index 78bc31ec3..cbcf752ca 100644 --- a/lib/http/search.dart +++ b/lib/http/search.dart @@ -230,19 +230,19 @@ abstract final class SearchHttp { } } - static Future episodeInfo({dynamic epId}) async { - final res = await Request().get( - Api.episodeInfo, - queryParameters: { - 'ep_id': ?epId, - }, - ); - if (res.data['code'] == 0) { - return Success(res.data['data']); - } else { - return Error(res.data['message']); - } - } + // static Future episodeInfo({dynamic epId}) async { + // final res = await Request().get( + // Api.episodeInfo, + // queryParameters: { + // 'ep_id': ?epId, + // }, + // ); + // if (res.data['code'] == 0) { + // return Success(res.data['data']); + // } else { + // return Error(res.data['message']); + // } + // } static Future> searchTrending({ int limit = 30, diff --git a/lib/http/user.dart b/lib/http/user.dart index 716b294bc..a22331252 100644 --- a/lib/http/user.dart +++ b/lib/http/user.dart @@ -19,19 +19,20 @@ import 'package:PiliPlus/utils/app_sign.dart'; import 'package:PiliPlus/utils/global_data.dart'; import 'package:PiliPlus/utils/wbi_sign.dart'; import 'package:dio/dio.dart'; +import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; abstract final class UserHttp { - static Future userStat({required int mid}) async { - final res = await Request().get( - Api.userStat, - queryParameters: {'vmid': mid}, - ); - if (res.data['code'] == 0) { - return {'status': true, 'data': res.data['data']}; - } else { - return {'status': false}; - } - } + // static Future userStat({required int mid}) async { + // final res = await Request().get( + // Api.userStat, + // queryParameters: {'vmid': mid}, + // ); + // if (res.data['code'] == 0) { + // return {'status': true, 'data': res.data['data']}; + // } else { + // return {'status': false}; + // } + // } static Future> userInfo() async { final res = await Request().get(Api.userInfo); @@ -164,7 +165,7 @@ abstract final class UserHttp { } // 稍后再看 - static Future toViewLater({ + static Future> toViewLater({ String? bvid, Object? aid, }) async { @@ -179,14 +180,16 @@ abstract final class UserHttp { options: Options(contentType: Headers.formUrlEncodedContentType), ); if (res.data['code'] == 0) { - return {'status': true, 'msg': 'yeah!稍后再看'}; + SmartDialog.showToast('yeah!稍后再看'); + return const Success(null); } else { - return {'status': false, 'msg': res.data['message']}; + SmartDialog.showToast(res.data['message'].toString()); + return const Error(null); } } // 移除已观看 - static Future toViewDel({required String aids}) async { + static Future> toViewDel({required String aids}) async { final Map params = { 'csrf': Accounts.main.csrf, 'resources': aids, @@ -197,9 +200,11 @@ abstract final class UserHttp { options: Options(contentType: Headers.formUrlEncodedContentType), ); if (res.data['code'] == 0) { - return {'status': true, 'msg': 'yeah!成功移除'}; + SmartDialog.showToast('yeah!成功移除'); + return const Success(null); } else { - return {'status': false, 'msg': res.data['message']}; + SmartDialog.showToast(res.data['message'].toString()); + return const Error(null); } } @@ -264,7 +269,7 @@ abstract final class UserHttp { } } - static Future hasFollow(int mid) async { + static Future> hasFollow(int mid) async { final res = await Request().get( Api.relation, queryParameters: { @@ -272,9 +277,9 @@ abstract final class UserHttp { }, ); if (res.data['code'] == 0) { - return {'status': true, 'data': res.data['data']}; + return Success(res.data['data']); } else { - return {'status': false, 'msg': res.data['message']}; + return Error(res.data['message']); } } diff --git a/lib/http/validate.dart b/lib/http/validate.dart index 9f03a80c7..590a3a97c 100644 --- a/lib/http/validate.dart +++ b/lib/http/validate.dart @@ -1,10 +1,11 @@ import 'package:PiliPlus/http/api.dart'; import 'package:PiliPlus/http/init.dart'; +import 'package:PiliPlus/http/loading_state.dart'; import 'package:PiliPlus/utils/accounts.dart'; import 'package:dio/dio.dart'; abstract final class ValidateHttp { - static Future gaiaVgateRegister(String vVoucher) async { + static Future> gaiaVgateRegister(String vVoucher) async { final res = await Request().post( Api.gaiaVgateRegister, queryParameters: { @@ -18,13 +19,13 @@ abstract final class ValidateHttp { ), ); if (res.data['code'] == 0) { - return {'status': true, 'data': res.data['data']}; + return Success(res.data['data']); } else { - return {'status': false, 'msg': res.data['message']}; + return Error(res.data['message']); } } - static Future gaiaVgateValidate({ + static Future> gaiaVgateValidate({ required dynamic challenge, required dynamic seccode, required dynamic token, @@ -43,9 +44,9 @@ abstract final class ValidateHttp { }, ); if (res.data['code'] == 0) { - return {'status': true, 'data': res.data['data']}; + return Success(res.data['data']); } else { - return {'status': false, 'msg': res.data['message']}; + return Error(res.data['message']); } } } diff --git a/lib/http/video.dart b/lib/http/video.dart index 9d94879c9..cc5e04d9f 100644 --- a/lib/http/video.dart +++ b/lib/http/video.dart @@ -42,7 +42,7 @@ abstract final class VideoHttp { static bool enableFilter = zoneRegExp.pattern.isNotEmpty; // 首页推荐视频 - static Future rcmdVideoList({ + static Future>> rcmdVideoList({ required int ps, required int freshIdx, }) async { @@ -78,7 +78,9 @@ abstract final class VideoHttp { } // 添加额外的loginState变量模拟未登录状态 - static Future rcmdVideoListApp({required int freshIdx}) async { + static Future>> rcmdVideoListApp({ + required int freshIdx, + }) async { final params = { 'build': 2001100, 'c_locale': 'zh_CN', @@ -532,7 +534,7 @@ abstract final class VideoHttp { // parent num 父评论rpid 非必要 二级评论同根评论id 大于二级评论为要回复的评论id // message str 发送评论内容 必要 最大1000字符 // plat num 发送平台标识 非必要 1:web端 2:安卓客户端 3:ios客户端 4:wp客户端 - static Future replyAdd({ + static Future> replyAdd({ required int type, required int oid, required String message, @@ -542,9 +544,6 @@ abstract final class VideoHttp { bool syncToDynamic = false, Map? atNameToMid, }) async { - if (message == '') { - return {'status': false, 'msg': '请输入评论内容'}; - } final data = { 'type': type, 'oid': oid, @@ -563,9 +562,9 @@ abstract final class VideoHttp { options: Options(contentType: Headers.formUrlEncodedContentType), ); if (res.data['code'] == 0) { - return {'status': true, 'data': res.data['data']}; + return Success(res.data['data']); } else { - return {'status': false, 'msg': res.data['message']}; + return Error(res.data['message']); } } @@ -923,7 +922,7 @@ abstract final class VideoHttp { } // pgc 排行 - static Future pgcRankList({ + static Future?>> pgcRankList({ int day = 3, required int seasonType, }) async { @@ -946,7 +945,7 @@ abstract final class VideoHttp { } // pgc season 排行 - static Future pgcSeasonRankList({ + static Future?>> pgcSeasonRankList({ int day = 3, required int seasonType, }) async { diff --git a/lib/pages/about/view.dart b/lib/pages/about/view.dart index 9a034bdbf..28797c5f5 100644 --- a/lib/pages/about/view.dart +++ b/lib/pages/about/view.dart @@ -65,6 +65,24 @@ class _AboutPageState extends State { ); } + void _showDialog() => showDialog( + context: context, + builder: (context) { + return AlertDialog( + constraints: StyleString.dialogFixedConstraints, + content: TextField( + autofocus: true, + onSubmitted: (value) { + Get.back(); + if (value.isNotEmpty) { + PageUtils.handleWebview(value, inApp: true); + } + }, + ), + ); + }, + ); + @override Widget build(BuildContext context) { final theme = Theme.of(context); @@ -88,25 +106,10 @@ class _AboutPageState extends State { _pressCount++; if (_pressCount == 5) { _pressCount = 0; - showDialog( - context: context, - builder: (context) { - return AlertDialog( - constraints: StyleString.dialogFixedConstraints, - content: TextField( - autofocus: true, - onSubmitted: (value) { - Get.back(); - if (value.isNotEmpty) { - PageUtils.handleWebview(value, inApp: true); - } - }, - ), - ); - }, - ); + _showDialog(); } }, + onSecondaryTap: PlatformUtils.isDesktop ? _showDialog : null, child: ExcludeSemantics( child: Image.asset( width: 150, diff --git a/lib/pages/common/common_intro_controller.dart b/lib/pages/common/common_intro_controller.dart index fc61f9cb3..c486743b4 100644 --- a/lib/pages/common/common_intro_controller.dart +++ b/lib/pages/common/common_intro_controller.dart @@ -152,8 +152,7 @@ abstract class CommonIntroController extends GetxController final res = await (hasLater.value ? UserHttp.toViewDel(aids: IdUtils.bv2av(bvid).toString()) : UserHttp.toViewLater(bvid: bvid)); - if (res['status']) hasLater.value = !hasLater.value; - SmartDialog.showToast(res['msg']); + if (res.isSuccess) hasLater.value = !hasLater.value; } } diff --git a/lib/pages/dynamics/widgets/author_panel.dart b/lib/pages/dynamics/widgets/author_panel.dart index 8f16e3c6b..2991fc6d2 100644 --- a/lib/pages/dynamics/widgets/author_panel.dart +++ b/lib/pages/dynamics/widgets/author_panel.dart @@ -303,14 +303,9 @@ class AuthorPanel extends StatelessWidget { ), if (bvid != null) ListTile( - onTap: () async { + onTap: () { Get.back(); - try { - final res = await UserHttp.toViewLater(bvid: bvid); - SmartDialog.showToast(res['msg']); - } catch (err) { - SmartDialog.showToast('出错了:${err.toString()}'); - } + UserHttp.toViewLater(bvid: bvid); }, minLeadingWidth: 0, leading: const Icon(Icons.watch_later_outlined, size: 19), diff --git a/lib/pages/fav_create/view.dart b/lib/pages/fav_create/view.dart index 439afabe3..7e5abe933 100644 --- a/lib/pages/fav_create/view.dart +++ b/lib/pages/fav_create/view.dart @@ -154,11 +154,11 @@ class _CreateFavPageState extends State { dir: 'cover', ).then((res) { if (context.mounted) { - if (res['status']) { - _cover = res['data']['location']; + if (res case Success(:final response)) { + _cover = response['location']; (context as Element).markNeedsBuild(); } else { - SmartDialog.showToast(res['msg']); + res.toast(); } } if (PlatformUtils.isMobile) { diff --git a/lib/pages/history/widgets/item.dart b/lib/pages/history/widgets/item.dart index 2de6b6ef2..7e2411a47 100644 --- a/lib/pages/history/widgets/item.dart +++ b/lib/pages/history/widgets/item.dart @@ -218,12 +218,8 @@ class HistoryItem extends StatelessWidget { business != 'live' && business?.contains('article') != true) PopupMenuItem( - onTap: () async { - final res = await UserHttp.toViewLater( - bvid: item.history.bvid, - ); - SmartDialog.showToast(res['msg']); - }, + onTap: () => + UserHttp.toViewLater(bvid: item.history.bvid), height: 38, child: const Row( children: [ diff --git a/lib/pages/later/controller.dart b/lib/pages/later/controller.dart index 3104eae17..e5bdcc1ee 100644 --- a/lib/pages/later/controller.dart +++ b/lib/pages/later/controller.dart @@ -36,12 +36,11 @@ mixin BaseLaterController final res = await UserHttp.toViewDel( aids: removeList.map((item) => item.aid).join(','), ); - if (res['status']) { + if (res.isSuccess) { updateCount?.call(removeList.length); afterDelete(removeList); } SmartDialog.dismiss(); - SmartDialog.showToast(res['msg']); }, ); } @@ -70,13 +69,12 @@ mixin BaseLaterController onPressed: () async { Get.back(); final res = await UserHttp.toViewDel(aids: aid.toString()); - if (res['status']) { + if (res.isSuccess) { loadingState ..value.data!.removeAt(index) ..refresh(); updateCount?.call(1); } - SmartDialog.showToast(res['msg']); }, child: const Text('确认移除'), ), diff --git a/lib/pages/live_room/controller.dart b/lib/pages/live_room/controller.dart index a1845b706..df4315229 100644 --- a/lib/pages/live_room/controller.dart +++ b/lib/pages/live_room/controller.dart @@ -331,15 +331,11 @@ class LiveRoomController extends GetxController { @pragma('vm:notify-debugger-on-exception') Future prefetch() async { - final res = await LiveHttp.liveRoomDanmaPrefetch(roomId: roomId); - if (res['status']) { - if (res['data'] case List list) { - try { - messages.addAll( - list.cast>().map(DanmakuMsg.fromPrefetch), - ); - scrollToBottom(); - } catch (_) {} + final res = await LiveHttp.liveRoomDmPrefetch(roomId: roomId); + if (res case Success(:final response)) { + if (response != null && response.isNotEmpty) { + messages.addAll(response); + scrollToBottom(); } } } diff --git a/lib/pages/setting/models/style_settings.dart b/lib/pages/setting/models/style_settings.dart index b38c3aa12..aed333286 100644 --- a/lib/pages/setting/models/style_settings.dart +++ b/lib/pages/setting/models/style_settings.dart @@ -776,13 +776,13 @@ void _showQualityDialog({ }); } -const _minUiScale = 0.5; -const _maxUiScale = 2.0; - void _showUiScaleDialog( BuildContext context, VoidCallback setState, ) { + const minUiScale = 0.5; + const maxUiScale = 2.0; + double uiScale = Pref.uiScale; final textController = TextEditingController( text: uiScale.toStringAsFixed(2), @@ -804,10 +804,10 @@ void _showUiScaleDialog( Slider( padding: .zero, value: uiScale, - min: _minUiScale, - max: _maxUiScale, + min: minUiScale, + max: maxUiScale, secondaryTrackValue: 1.0, - divisions: ((_maxUiScale - _minUiScale) * 20).toInt(), + divisions: ((maxUiScale - minUiScale) * 20).toInt(), label: textController.text, onChanged: (value) => setDialogState(() { uiScale = value.toPrecision(2); @@ -831,8 +831,8 @@ void _showUiScaleDialog( onChanged: (value) { final parsed = double.tryParse(value); if (parsed != null && - parsed >= _minUiScale && - parsed <= _maxUiScale) { + parsed >= minUiScale && + parsed <= maxUiScale) { setDialogState(() { uiScale = parsed; }); diff --git a/lib/pages/video/controller.dart b/lib/pages/video/controller.dart index 443ac79bb..3f33cdff8 100644 --- a/lib/pages/video/controller.dart +++ b/lib/pages/video/controller.dart @@ -435,10 +435,9 @@ class VideoDetailController extends GetxController final res = await UserHttp.toViewDel( aids: item.aid.toString(), ); - if (res['status']) { + if (res.isSuccess) { mediaList.removeAt(index); } - SmartDialog.showToast(res['msg']); } else { final res = await FavHttp.favVideo( resources: '${item.aid}:${item.type}', diff --git a/lib/pages/video/introduction/pgc/controller.dart b/lib/pages/video/introduction/pgc/controller.dart index 36c1be338..cc59db5f9 100644 --- a/lib/pages/video/introduction/pgc/controller.dart +++ b/lib/pages/video/introduction/pgc/controller.dart @@ -480,10 +480,9 @@ class PgcIntroController extends CommonIntroController { // }); final res = await PgcHttp.seasonStatus(seasonId!); - if (res['status']) { - final Map data = res['data']; - isFollowed.value = data['follow'] == 1; - followStatus.value = data['follow_status']; + if (res case Success(:final response)) { + isFollowed.value = response['follow'] == 1; + followStatus.value = response['follow_status']; } } diff --git a/lib/pages/video/introduction/ugc/controller.dart b/lib/pages/video/introduction/ugc/controller.dart index f0c030e0f..998f7bd9b 100644 --- a/lib/pages/video/introduction/ugc/controller.dart +++ b/lib/pages/video/introduction/ugc/controller.dart @@ -408,11 +408,10 @@ class UgcIntroController extends CommonIntroController with ReloadMixin { if (videoDetail.owner == null || videoDetail.staff?.isNotEmpty == true) { return; } - final result = await UserHttp.hasFollow(videoDetail.owner!.mid!); - if (result['status']) { - Map data = result['data']; - if (data['special'] == 1) data['attribute'] = -10; - followStatus.value = data; + final res = await UserHttp.hasFollow(videoDetail.owner!.mid!); + if (res case Success(:final response)) { + if (response['special'] == 1) response['attribute'] = -10; + followStatus.value = response; } } diff --git a/lib/pages/video/member/controller.dart b/lib/pages/video/member/controller.dart index f8ecef20a..93e589f81 100644 --- a/lib/pages/video/member/controller.dart +++ b/lib/pages/video/member/controller.dart @@ -37,8 +37,8 @@ class HorizontalMemberPageController Future getMemberStat() async { final res = await MemberHttp.memberStat(mid: mid); - if (res['status']) { - userStat.addAll(res['data']); + if (res case Success(:final response)) { + userStat.addAll(response); } } @@ -47,8 +47,8 @@ class HorizontalMemberPageController return; } final res = await MemberHttp.memberView(mid: mid); - if (res['status']) { - userStat.addAll(res['data']); + if (res case Success(:final response)) { + userStat.addAll(response); } } diff --git a/lib/pages/video/reply_new/view.dart b/lib/pages/video/reply_new/view.dart index 9c6058157..cd227be92 100644 --- a/lib/pages/video/reply_new/view.dart +++ b/lib/pages/video/reply_new/view.dart @@ -9,6 +9,7 @@ import 'package:PiliPlus/common/widgets/flutter/text_field/text_field.dart'; import 'package:PiliPlus/common/widgets/view_safe_area.dart'; import 'package:PiliPlus/grpc/bilibili/main/community/reply/v1.pb.dart' show ReplyInfo; +import 'package:PiliPlus/http/loading_state.dart'; import 'package:PiliPlus/http/video.dart'; import 'package:PiliPlus/main.dart'; import 'package:PiliPlus/models/common/publish_panel_type.dart'; @@ -416,7 +417,7 @@ class _ReplyPageState extends CommonRichTextPubPageState { } } String message = editController.rawText; - final result = await VideoHttp.replyAdd( + final res = await VideoHttp.replyAdd( type: widget.replyType, oid: widget.oid, root: widget.root, @@ -428,12 +429,12 @@ class _ReplyPageState extends CommonRichTextPubPageState { pictures: pictures, syncToDynamic: _syncToDynamic.value, ); - if (result['status']) { + if (res case Success(:final response)) { hasPub = true; - SmartDialog.showToast(result['data']['success_toast']); - Get.back(result: result['data']['reply']); + SmartDialog.showToast(response['success_toast']); + Get.back(result: response['reply']); } else { - SmartDialog.showToast(result['msg']); + res.toast(); } } } diff --git a/lib/pages/whisper_detail/widget/chat_item.dart b/lib/pages/whisper_detail/widget/chat_item.dart index f8c72957f..c485ba19a 100644 --- a/lib/pages/whisper_detail/widget/chat_item.dart +++ b/lib/pages/whisper_detail/widget/chat_item.dart @@ -211,7 +211,7 @@ class ChatItem extends StatelessWidget { }, child: NetworkImgLayer( width: 220, - height: 220 * 9 / 16, + height: 123.75, src: content['cover'], ), ), @@ -259,7 +259,7 @@ class ChatItem extends StatelessWidget { for (final i in content['image_urls']) NetworkImgLayer( width: 130, - height: 130 * 9 / 16, + height: 73.125, src: i, ), ], @@ -348,7 +348,7 @@ class ChatItem extends StatelessWidget { children: [ NetworkImgLayer( width: 130, - height: 130 * 9 / 16, + height: 73.125, src: i['cover_url'], ), Expanded( @@ -544,7 +544,7 @@ class ChatItem extends StatelessWidget { onTap: onTap, child: NetworkImgLayer( width: 220, - height: 220 * 9 / 16, + height: 123.75, src: content['thumb'], ), ), diff --git a/lib/utils/request_utils.dart b/lib/utils/request_utils.dart index 944f7ae92..12b46cb4d 100644 --- a/lib/utils/request_utils.dart +++ b/lib/utils/request_utils.dart @@ -121,11 +121,11 @@ abstract final class RequestUtils { } } else { if (followStatus?['tag'] == null) { - Map result = await UserHttp.hasFollow(mid); - if (result['status']) { - followStatus = result['data']; + final res = await UserHttp.hasFollow(mid); + if (res case Success(:final response)) { + followStatus = response; } else { - SmartDialog.showToast(result['msg']); + res.toast(); return; } } @@ -494,12 +494,12 @@ abstract final class RequestUtils { } final res = await ValidateHttp.gaiaVgateRegister(vVoucher); - if (!res['status']) { - SmartDialog.showToast("${res['msg']}"); + if (!res.isSuccess) { + res.toast(); return; } - final resData = res['data']; + final resData = res.data; if (resData == null) { SmartDialog.showToast("null data"); return; @@ -507,10 +507,10 @@ abstract final class RequestUtils { CaptchaDataModel captchaData = CaptchaDataModel(); - final geetest = resData?['geetest']; + final geetest = resData['geetest']; String? gt = geetest?['gt']; String? challenge = geetest?['challenge']; - captchaData.token = resData?['token']; + captchaData.token = resData['token']; bool isGeeArgumentValid() { return gt?.isNotEmpty == true && @@ -530,9 +530,9 @@ abstract final class RequestUtils { token: captchaData.token, validate: captchaData.validate, ); - if (res['status']) { - if (res['data']?['is_valid'] == 1) { - final griskId = res['data']?['grisk_id']; + if (res case Success(:final response)) { + if (response?['is_valid'] == 1) { + final griskId = response?['grisk_id']; if (griskId != null) { onSuccess(griskId); } @@ -540,7 +540,7 @@ abstract final class RequestUtils { SmartDialog.showToast('invalid'); } } else { - SmartDialog.showToast(res['msg']); + res.toast(); } }