From 294ea9e1b7f567be7c5812c93b7c8bf6325302be Mon Sep 17 00:00:00 2001 From: guozhigq Date: Sat, 2 Nov 2024 22:24:59 +0800 Subject: [PATCH 01/27] feat: video tags --- lib/http/api.dart | 3 + lib/http/video.dart | 16 +++++ lib/models/video/tags.dart | 17 +++++ .../video/detail/introduction/controller.dart | 11 +++ lib/pages/video/detail/introduction/view.dart | 5 +- .../introduction/widgets/intro_detail.dart | 72 +++++++++++++++---- 6 files changed, 111 insertions(+), 13 deletions(-) create mode 100644 lib/models/video/tags.dart diff --git a/lib/http/api.dart b/lib/http/api.dart index 078e615e..edd39e30 100644 --- a/lib/http/api.dart +++ b/lib/http/api.dart @@ -609,4 +609,7 @@ class Api { /// @我的 static const String messageAtAPi = '/x/msgfeed/at?'; + + /// 视频标签 + static const String videoTag = '/x/tag/archive/tags'; } diff --git a/lib/http/video.dart b/lib/http/video.dart index eeef5751..6cf0e495 100644 --- a/lib/http/video.dart +++ b/lib/http/video.dart @@ -2,6 +2,7 @@ import 'dart:convert'; import 'dart:developer'; import 'package:dio/dio.dart'; import 'package:hive/hive.dart'; +import 'package:pilipala/models/video/tags.dart'; import '../common/constants.dart'; import '../models/common/reply_type.dart'; import '../models/home/rcmd/result.dart'; @@ -559,4 +560,19 @@ class VideoHttp { final List body = res.data['body']; return {'content': content, 'body': body}; } + + // 获取视频标签 + static Future getVideoTag({required String bvid}) async { + var res = await Request().get(Api.videoTag, data: {'bvid': bvid}); + if (res.data['code'] == 0) { + return { + 'status': true, + 'data': res.data['data'].map((e) { + return VideoTagItem.fromJson(e); + }).toList() + }; + } else { + return {'status': false, 'data': [], 'msg': res.data['message']}; + } + } } diff --git a/lib/models/video/tags.dart b/lib/models/video/tags.dart new file mode 100644 index 00000000..f01f85ba --- /dev/null +++ b/lib/models/video/tags.dart @@ -0,0 +1,17 @@ +class VideoTagItem { + String? tagName; + int? tagId; + int? tagType; + + VideoTagItem({ + this.tagName, + this.tagId, + this.tagType, + }); + + VideoTagItem.fromJson(Map json) { + tagName = json['tag_name']; + tagId = json['tag_id']; + tagType = json['type']; + } +} diff --git a/lib/pages/video/detail/introduction/controller.dart b/lib/pages/video/detail/introduction/controller.dart index e78d8121..42ae9027 100644 --- a/lib/pages/video/detail/introduction/controller.dart +++ b/lib/pages/video/detail/introduction/controller.dart @@ -10,6 +10,7 @@ import 'package:pilipala/http/user.dart'; import 'package:pilipala/http/video.dart'; import 'package:pilipala/models/user/fav_folder.dart'; import 'package:pilipala/models/video/ai.dart'; +import 'package:pilipala/models/video/tags.dart'; import 'package:pilipala/models/video_detail_res.dart'; import 'package:pilipala/pages/video/detail/controller.dart'; import 'package:pilipala/pages/video/detail/reply/index.dart'; @@ -52,6 +53,7 @@ class VideoIntroController extends GetxController { RxInt lastPlayCid = 0.obs; var userInfo; + RxList videoTags = [].obs; // 同时观看 bool isShowOnlineTotal = false; @@ -81,6 +83,7 @@ class VideoIntroController extends GetxController { } enableRelatedVideo = setting.get(SettingBoxKey.enableRelatedVideo, defaultValue: true); + queryVideoTag(); } // 获取视频简介&分p @@ -678,4 +681,12 @@ class VideoIntroController extends GetxController { }, ); } + + // 获取视频标签 + void queryVideoTag() async { + var result = await VideoHttp.getVideoTag(bvid: bvid); + if (result['status']) { + videoTags.value = result['data']; + } + } } diff --git a/lib/pages/video/detail/introduction/view.dart b/lib/pages/video/detail/introduction/view.dart index 80176a7b..8a9b068a 100644 --- a/lib/pages/video/detail/introduction/view.dart +++ b/lib/pages/video/detail/introduction/view.dart @@ -387,7 +387,10 @@ class _VideoInfoState extends State with TickerProviderStateMixin { ExpandablePanel( controller: _expandableCtr, collapsed: const SizedBox(height: 0), - expanded: IntroDetail(videoDetail: widget.videoDetail!), + expanded: IntroDetail( + videoDetail: widget.videoDetail!, + videoTags: videoIntroController.videoTags, + ), theme: const ExpandableThemeData( animationDuration: Duration(milliseconds: 300), scrollAnimationDuration: Duration(milliseconds: 300), diff --git a/lib/pages/video/detail/introduction/widgets/intro_detail.dart b/lib/pages/video/detail/introduction/widgets/intro_detail.dart index c74558a0..c00db644 100644 --- a/lib/pages/video/detail/introduction/widgets/intro_detail.dart +++ b/lib/pages/video/detail/introduction/widgets/intro_detail.dart @@ -4,6 +4,7 @@ import 'package:flutter/services.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:get/get.dart'; import 'package:pilipala/http/constants.dart'; +import 'package:pilipala/models/video/tags.dart'; import 'package:pilipala/utils/feed_back.dart'; import 'package:pilipala/utils/utils.dart'; @@ -11,13 +12,15 @@ class IntroDetail extends StatelessWidget { const IntroDetail({ super.key, this.videoDetail, + this.videoTags, }); + final dynamic videoDetail; + final RxList? videoTags; @override Widget build(BuildContext context) { TextStyle textStyle = TextStyle( - fontSize: 14, color: Theme.of(context).colorScheme.primary, ); return SizedBox( @@ -59,19 +62,26 @@ class IntroDetail extends StatelessWidget { ) ], ), - const SizedBox(height: 4), - SelectableRegion( - focusNode: FocusNode(), - selectionControls: MaterialTextSelectionControls(), - child: Text.rich( - style: const TextStyle(height: 1.4), - TextSpan( - children: [ - buildContent(context, videoDetail!), - ], + if (videoDetail!.descV2.isNotEmpty) ...[ + const SizedBox(height: 4), + SelectableRegion( + focusNode: FocusNode(), + selectionControls: MaterialTextSelectionControls(), + child: Text.rich( + style: TextStyle( + height: 1.4, color: Theme.of(context).colorScheme.outline), + TextSpan( + children: [ + buildContent(context, videoDetail!), + ], + ), ), ), - ), + ], + const SizedBox(height: 8), + Obx(() => null != videoTags && videoTags!.isNotEmpty + ? _buildTags(context, videoTags) + : const SizedBox.shrink()), ], ), ); @@ -152,4 +162,42 @@ class IntroDetail extends StatelessWidget { }); return TextSpan(children: spanChilds); } + + Widget _buildTags(BuildContext context, List? videoTags) { + final ColorScheme colorScheme = Theme.of(context).colorScheme; + return Wrap( + spacing: 6, + runSpacing: 6, + direction: Axis.horizontal, + textDirection: TextDirection.ltr, + children: videoTags!.map((tag) { + return InkWell( + onTap: () { + Get.toNamed( + '/tag', + arguments: { + 'tagId': tag.tagId, + 'tagName': tag.tagName, + }, + ); + }, + borderRadius: BorderRadius.circular(20), + child: Container( + decoration: BoxDecoration( + color: colorScheme.surfaceVariant.withOpacity(0.5), + borderRadius: BorderRadius.circular(20), + ), + padding: const EdgeInsets.symmetric(vertical: 5, horizontal: 10), + child: Text( + tag.tagName!, + style: TextStyle( + fontSize: 12, + color: colorScheme.onSurfaceVariant, + ), + ), + ), + ); + }).toList(), + ); + } } From 44ef189f326fd644fd67d68a197320d6f399d455 Mon Sep 17 00:00:00 2001 From: guozhigq Date: Sun, 10 Nov 2024 22:51:36 +0800 Subject: [PATCH 02/27] opt: layout --- lib/common/pages_bottom_sheet.dart | 222 ++++++++++++++++++----------- 1 file changed, 137 insertions(+), 85 deletions(-) diff --git a/lib/common/pages_bottom_sheet.dart b/lib/common/pages_bottom_sheet.dart index 1e88e863..dd8c5490 100644 --- a/lib/common/pages_bottom_sheet.dart +++ b/lib/common/pages_bottom_sheet.dart @@ -105,7 +105,8 @@ class _PagesBottomSheetState extends State List? _listScrollControllerList; final String heroTag = Get.arguments['heroTag']; VideoDetailController? _videoDetailController; - late RxInt isSubscribe = (-1).obs; + RxInt isSubscribe = (-1).obs; + bool isVisible = false; @override void initState() { @@ -224,6 +225,13 @@ class _PagesBottomSheetState extends State } } + // 更改展开状态 + void _changeVisible() { + setState(() { + isVisible = !isVisible; + }); + } + @override void dispose() { try { @@ -255,7 +263,9 @@ class _PagesBottomSheetState extends State UgcSeasonBuild( ugcSeason: widget.ugcSeason!, isSubscribe: isSubscribe, + isVisible: isVisible, changeFucCall: _changeSubscribeStatus, + changeVisible: _changeVisible, ), ], Expanded( @@ -325,19 +335,23 @@ class _PagesBottomSheetState extends State Widget buildTabBar() { return Column( children: [ - TabBar( - controller: tabController, - isScrollable: true, - indicatorSize: TabBarIndicatorSize.label, - tabAlignment: TabAlignment.start, - splashBorderRadius: BorderRadius.circular(4), - tabs: [ - ...widget.ugcSeason!.sections!.map((SectionItem section) { - return Tab( - text: section.title, - ); - }).toList() - ], + // 背景色 + Container( + color: Theme.of(context).colorScheme.surface, + child: TabBar( + controller: tabController, + isScrollable: true, + indicatorSize: TabBarIndicatorSize.label, + tabAlignment: TabAlignment.start, + splashBorderRadius: BorderRadius.circular(4), + tabs: [ + ...widget.ugcSeason!.sections!.map((SectionItem section) { + return Tab( + text: section.title, + ); + }).toList() + ], + ), ), Expanded( child: TabBarView( @@ -678,95 +692,133 @@ class EpisodeGridItem extends StatelessWidget { class UgcSeasonBuild extends StatelessWidget { final UgcSeason ugcSeason; final RxInt isSubscribe; + final bool isVisible; final Function changeFucCall; + final Function changeVisible; const UgcSeasonBuild({ Key? key, required this.ugcSeason, required this.isSubscribe, + required this.isVisible, required this.changeFucCall, + required this.changeVisible, }) : super(key: key); @override Widget build(BuildContext context) { - final ThemeData t = Theme.of(context); - final Color outline = t.colorScheme.outline; - return Container( - padding: const EdgeInsets.fromLTRB(12, 0, 12, 0), - color: Theme.of(context).colorScheme.surface, - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Divider( - height: 1, - thickness: 1, - color: Theme.of(context).dividerColor.withOpacity(0.1), - ), - const SizedBox(height: 10), - Text( - '合集:${ugcSeason.title}', - style: Theme.of(context).textTheme.titleMedium, - overflow: TextOverflow.ellipsis, - ), - if (ugcSeason.intro != null && ugcSeason.intro != '') ...[ - const SizedBox(height: 4), - Row( + final ThemeData theme = Theme.of(context); + final Color outline = theme.colorScheme.outline; + final Color surface = theme.colorScheme.surface; + final Color primary = theme.colorScheme.primary; + final Color onPrimary = theme.colorScheme.onPrimary; + final Color onInverseSurface = theme.colorScheme.onInverseSurface; + final TextStyle titleMedium = theme.textTheme.titleMedium!; + final TextStyle labelMedium = theme.textTheme.labelMedium!; + final Color dividerColor = theme.dividerColor.withOpacity(0.1); + + return isVisible + ? Container( + padding: const EdgeInsets.fromLTRB(12, 0, 12, 0), + color: surface, + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, children: [ - Expanded( - child: Text(ugcSeason.intro ?? '', - style: TextStyle( - color: Theme.of(context).colorScheme.outline)), - ), - Obx( - () => isSubscribe.value == -1 - ? const SizedBox(height: 32) - : SizedBox( - height: 32, - child: FilledButton.tonal( - onPressed: () => changeFucCall.call(), - style: TextButton.styleFrom( - padding: const EdgeInsets.only( - left: 8, - right: 8, + Divider(height: 1, thickness: 1, color: dividerColor), + const SizedBox(height: 10), + Row( + children: [ + Expanded( + child: Text( + '合集:${ugcSeason.title}', + style: titleMedium, + maxLines: 2, + overflow: TextOverflow.ellipsis, + ), + ), + const SizedBox(width: 10), + Obx( + () => isSubscribe.value == -1 + ? const SizedBox(height: 32) + : SizedBox( + height: 32, + child: FilledButton.tonal( + onPressed: () => changeFucCall.call(), + style: TextButton.styleFrom( + padding: + const EdgeInsets.only(left: 8, right: 8), + foregroundColor: isSubscribe.value == 1 + ? outline + : onPrimary, + backgroundColor: isSubscribe.value == 1 + ? onInverseSurface + : primary, + ), + child: + Text(isSubscribe.value == 1 ? '已订阅' : '订阅'), ), - foregroundColor: isSubscribe.value == 1 - ? outline - : t.colorScheme.onPrimary, - backgroundColor: isSubscribe.value == 1 - ? t.colorScheme.onInverseSurface - : t.colorScheme.primary, // 设置按钮背景色 ), - child: Text(isSubscribe.value == 1 ? '已订阅' : '订阅'), - ), - ), + ), + ], ), - const SizedBox(width: 6), + if (ugcSeason.intro != null && ugcSeason.intro != '') ...[ + const SizedBox(height: 4), + Text( + ugcSeason.intro!, + style: TextStyle(color: outline, fontSize: 12), + ), + ], + const SizedBox(height: 4), + Text.rich( + TextSpan( + style: TextStyle( + fontSize: labelMedium.fontSize, color: outline), + children: [ + TextSpan( + text: '${Utils.numFormat(ugcSeason.stat!.view)}播放'), + const TextSpan(text: ' · '), + TextSpan( + text: + '${Utils.numFormat(ugcSeason.stat!.danmaku)}弹幕'), + ], + ), + ), + const SizedBox(height: 14), + Align( + alignment: Alignment.center, + child: Material( + color: surface, + child: InkWell( + onTap: () => changeVisible.call(), + child: Padding( + padding: const EdgeInsets.symmetric( + vertical: 10, horizontal: 0), + child: Text( + '收起简介', + style: TextStyle(color: primary, fontSize: 12), + ), + ), + ), + ), + ), + Divider(height: 1, thickness: 1, color: dividerColor), ], ), - ], - const SizedBox(height: 4), - Text.rich( - TextSpan( - style: TextStyle( - fontSize: Theme.of(context).textTheme.labelMedium!.fontSize, - color: Theme.of(context).colorScheme.outline, + ) + : Align( + alignment: Alignment.center, + child: InkWell( + onTap: () => changeVisible.call(), + child: Padding( + padding: + const EdgeInsets.symmetric(vertical: 10, horizontal: 0), + child: Text( + '展开简介', + style: TextStyle(color: primary, fontSize: 12), + ), ), - children: [ - TextSpan(text: '${Utils.numFormat(ugcSeason.stat!.view)}播放'), - const TextSpan(text: ' · '), - TextSpan(text: '${Utils.numFormat(ugcSeason.stat!.danmaku)}弹幕'), - ], ), - ), - const SizedBox(height: 14), - Divider( - height: 1, - thickness: 1, - color: Theme.of(context).dividerColor.withOpacity(0.1), - ), - ], - ), - ); + ); } } From 17fddb2a16a04b65db54cd7d12fcce557382a6be Mon Sep 17 00:00:00 2001 From: guozhigq Date: Mon, 11 Nov 2024 09:18:05 +0800 Subject: [PATCH 03/27] fix: typo --- lib/common/widgets/custom_toast.dart | 2 +- lib/common/widgets/network_img_layer.dart | 2 +- lib/http/init.dart | 8 ++++---- lib/http/member.dart | 4 ++-- lib/http/search.dart | 2 +- lib/http/video.dart | 6 +++--- lib/main.dart | 4 ++-- lib/models/video/reply/member.dart | 2 +- lib/pages/bangumi/controller.dart | 2 +- lib/pages/bangumi/introduction/controller.dart | 2 +- lib/pages/bangumi/introduction/view.dart | 2 +- .../bangumi/introduction/widgets/intro_detail.dart | 2 +- lib/pages/bangumi/widgets/bangumi_panel.dart | 2 +- lib/pages/blacklist/index.dart | 2 +- lib/pages/danmaku/view.dart | 2 +- lib/pages/dynamics/controller.dart | 4 ++-- lib/pages/dynamics/detail/controller.dart | 10 +++++----- lib/pages/dynamics/view.dart | 2 +- lib/pages/fan/controller.dart | 2 +- lib/pages/fav/controller.dart | 2 +- lib/pages/follow/controller.dart | 2 +- lib/pages/history/controller.dart | 4 ++-- lib/pages/home/controller.dart | 6 +++--- lib/pages/home/widgets/app_bar.dart | 2 +- lib/pages/html/controller.dart | 2 +- lib/pages/later/controller.dart | 2 +- lib/pages/live/controller.dart | 2 +- lib/pages/live_follow/controller.dart | 2 +- lib/pages/live_room/controller.dart | 2 +- lib/pages/live_room/widgets/bottom_control.dart | 2 +- lib/pages/main/controller.dart | 4 ++-- lib/pages/main/view.dart | 6 +++--- lib/pages/member/controller.dart | 2 +- lib/pages/mine/controller.dart | 4 ++-- lib/pages/mine_edit/controller.dart | 2 +- lib/pages/rank/controller.dart | 2 +- lib/pages/rcmd/controller.dart | 2 +- lib/pages/search/controller.dart | 4 ++-- lib/pages/setting/controller.dart | 6 +++--- lib/pages/setting/extra_setting.dart | 4 ++-- lib/pages/setting/pages/action_menu_set.dart | 2 +- lib/pages/setting/pages/color_select.dart | 2 +- lib/pages/setting/pages/display_mode.dart | 2 +- lib/pages/setting/pages/font_size_select.dart | 2 +- lib/pages/setting/pages/home_tabbar_set.dart | 2 +- lib/pages/setting/pages/navigation_bar_set.dart | 2 +- lib/pages/setting/pages/play_gesture_set.dart | 2 +- lib/pages/setting/pages/play_speed_set.dart | 4 ++-- lib/pages/setting/play_setting.dart | 2 +- lib/pages/setting/privacy_setting.dart | 2 +- lib/pages/setting/recommend_setting.dart | 13 ++++++------- lib/pages/setting/style_setting.dart | 2 +- lib/pages/setting/widgets/select_item.dart | 2 +- lib/pages/setting/widgets/switch_item.dart | 2 +- lib/pages/subscription/controller.dart | 2 +- lib/pages/video/detail/controller.dart | 6 +++--- lib/pages/video/detail/introduction/controller.dart | 2 +- lib/pages/video/detail/introduction/view.dart | 4 ++-- .../detail/introduction/widgets/fav_panel.dart | 2 +- .../detail/introduction/widgets/group_panel.dart | 2 +- lib/pages/video/detail/reply/controller.dart | 10 +++++----- .../video/detail/reply/widgets/reply_item.dart | 2 +- lib/pages/video/detail/reply_reply/view.dart | 2 +- lib/pages/video/detail/view.dart | 4 ++-- lib/pages/video/detail/widgets/header_control.dart | 4 ++-- lib/pages/whisper_detail/controller.dart | 2 +- lib/pages/whisper_detail/view.dart | 2 +- lib/pages/whisper_detail/widget/chat_item.dart | 3 +-- lib/plugin/pl_player/controller.dart | 6 +++--- lib/plugin/pl_player/view.dart | 2 +- lib/router/app_pages.dart | 2 +- lib/services/audio_handler.dart | 2 +- lib/services/disable_battery_opt.dart | 8 ++++---- lib/utils/data.dart | 4 ++-- lib/utils/feed_back.dart | 2 +- lib/utils/global_data_cache.dart | 8 ++++---- lib/utils/login.dart | 2 +- lib/utils/recommend_filter.dart | 2 +- lib/utils/storage.dart | 2 +- lib/utils/wbi_sign.dart | 2 +- 80 files changed, 127 insertions(+), 129 deletions(-) diff --git a/lib/common/widgets/custom_toast.dart b/lib/common/widgets/custom_toast.dart index f732fd85..93695e0d 100644 --- a/lib/common/widgets/custom_toast.dart +++ b/lib/common/widgets/custom_toast.dart @@ -2,7 +2,7 @@ import 'package:flutter/material.dart'; import 'package:hive/hive.dart'; import 'package:pilipala/utils/storage.dart'; -Box setting = GStrorage.setting; +Box setting = GStorage.setting; class CustomToast extends StatelessWidget { const CustomToast({super.key, required this.msg}); diff --git a/lib/common/widgets/network_img_layer.dart b/lib/common/widgets/network_img_layer.dart index d5903b71..4980e2fc 100644 --- a/lib/common/widgets/network_img_layer.dart +++ b/lib/common/widgets/network_img_layer.dart @@ -6,7 +6,7 @@ import 'package:pilipala/utils/global_data_cache.dart'; import '../../utils/storage.dart'; import '../constants.dart'; -Box setting = GStrorage.setting; +Box setting = GStorage.setting; class NetworkImgLayer extends StatelessWidget { const NetworkImgLayer({ diff --git a/lib/http/init.dart b/lib/http/init.dart index 3117666e..7eb15644 100644 --- a/lib/http/init.dart +++ b/lib/http/init.dart @@ -21,8 +21,8 @@ class Request { static late CookieManager cookieManager; static late final Dio dio; factory Request() => _instance; - Box setting = GStrorage.setting; - static Box localCache = GStrorage.localCache; + Box setting = GStorage.setting; + static Box localCache = GStorage.localCache; late bool enableSystemProxy; late String systemProxyHost; late String systemProxyPort; @@ -32,8 +32,8 @@ class Request { /// 设置cookie static setCookie() async { - Box userInfoCache = GStrorage.userInfo; - Box setting = GStrorage.setting; + Box userInfoCache = GStorage.userInfo; + Box setting = GStorage.setting; final String cookiePath = await Utils.getCookiePath(); final PersistCookieJar cookieJar = PersistCookieJar( ignoreExpires: true, diff --git a/lib/http/member.dart b/lib/http/member.dart index fc99c987..53e14eae 100644 --- a/lib/http/member.dart +++ b/lib/http/member.dart @@ -470,8 +470,8 @@ class MemberHttp { SmartDialog.dismiss(); if (res.data['code'] == 0) { String accessKey = res.data['data']['access_token']; - Box localCache = GStrorage.localCache; - Box userInfoCache = GStrorage.userInfo; + Box localCache = GStorage.localCache; + Box userInfoCache = GStorage.userInfo; var userInfo = userInfoCache.get('userInfoCache'); localCache.put( LocalCacheKey.accessKey, {'mid': userInfo.mid, 'value': accessKey}); diff --git a/lib/http/search.dart b/lib/http/search.dart index 00e51497..a61ff406 100644 --- a/lib/http/search.dart +++ b/lib/http/search.dart @@ -11,7 +11,7 @@ import '../utils/storage.dart'; import 'index.dart'; class SearchHttp { - static Box setting = GStrorage.setting; + static Box setting = GStorage.setting; static Future hotSearchList() async { var res = await Request().get(Api.hotSearchList); if (res.data is String) { diff --git a/lib/http/video.dart b/lib/http/video.dart index 8405abc1..03209ab7 100644 --- a/lib/http/video.dart +++ b/lib/http/video.dart @@ -24,11 +24,11 @@ import 'init.dart'; /// 返回{'status': bool, 'data': List} /// view层根据 status 判断渲染逻辑 class VideoHttp { - static Box localCache = GStrorage.localCache; - static Box setting = GStrorage.setting; + static Box localCache = GStorage.localCache; + static Box setting = GStorage.setting; static bool enableRcmdDynamic = setting.get(SettingBoxKey.enableRcmdDynamic, defaultValue: true); - static Box userInfoCache = GStrorage.userInfo; + static Box userInfoCache = GStorage.userInfo; // 首页推荐视频 static Future rcmdVideoList({required int ps, required int freshIdx}) async { diff --git a/lib/main.dart b/lib/main.dart index 3ac97b25..80dcf9f9 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -32,7 +32,7 @@ void main() async { MediaKit.ensureInitialized(); await SystemChrome.setPreferredOrientations( [DeviceOrientation.portraitUp, DeviceOrientation.portraitDown]); - await GStrorage.init(); + await GStorage.init(); clearLogs(); Request(); await Request.setCookie(); @@ -73,7 +73,7 @@ class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { - Box setting = GStrorage.setting; + Box setting = GStorage.setting; // 主题色 Color defaultColor = colorThemeTypes[setting.get(SettingBoxKey.customColor, defaultValue: 0)] diff --git a/lib/models/video/reply/member.dart b/lib/models/video/reply/member.dart index 0801d110..ad10c143 100644 --- a/lib/models/video/reply/member.dart +++ b/lib/models/video/reply/member.dart @@ -29,7 +29,7 @@ class ReplyMember { avatar = json['avatar']; level = json['level_info']['current_level']; pendant = Pendant.fromJson(json['pendant']); - officialVerify = json['officia_verify']; + officialVerify = json['official_verify']; vip = json['vip']; fansDetail = json['fans_detail']; userSailing = json['user_sailing'] != null diff --git a/lib/pages/bangumi/controller.dart b/lib/pages/bangumi/controller.dart index 29dd15d1..746808bf 100644 --- a/lib/pages/bangumi/controller.dart +++ b/lib/pages/bangumi/controller.dart @@ -12,7 +12,7 @@ class BangumiController extends GetxController { RxInt total = 0.obs; int _currentPage = 1; bool isLoadingMore = true; - Box userInfoCache = GStrorage.userInfo; + Box userInfoCache = GStorage.userInfo; RxBool userLogin = false.obs; late int mid; var userInfo; diff --git a/lib/pages/bangumi/introduction/controller.dart b/lib/pages/bangumi/introduction/controller.dart index dc173a57..cec5e3f6 100644 --- a/lib/pages/bangumi/introduction/controller.dart +++ b/lib/pages/bangumi/introduction/controller.dart @@ -48,7 +48,7 @@ class BangumiIntroController extends GetxController { RxBool hasCoin = false.obs; // 是否收藏 RxBool hasFav = false.obs; - Box userInfoCache = GStrorage.userInfo; + Box userInfoCache = GStorage.userInfo; bool userLogin = false; Rx favFolderData = FavFolderData().obs; List addMediaIdsNew = []; diff --git a/lib/pages/bangumi/introduction/view.dart b/lib/pages/bangumi/introduction/view.dart index 429b109a..3ad0625f 100644 --- a/lib/pages/bangumi/introduction/view.dart +++ b/lib/pages/bangumi/introduction/view.dart @@ -116,7 +116,7 @@ class _BangumiInfoState extends State { String heroTag = Get.arguments['heroTag']; late final BangumiIntroController bangumiIntroController; late final VideoDetailController videoDetailCtr; - Box localCache = GStrorage.localCache; + Box localCache = GStorage.localCache; late double sheetHeight; int? cid; bool isProcessing = false; diff --git a/lib/pages/bangumi/introduction/widgets/intro_detail.dart b/lib/pages/bangumi/introduction/widgets/intro_detail.dart index 409474a9..a4c469de 100644 --- a/lib/pages/bangumi/introduction/widgets/intro_detail.dart +++ b/lib/pages/bangumi/introduction/widgets/intro_detail.dart @@ -4,7 +4,7 @@ import 'package:pilipala/common/widgets/stat/danmu.dart'; import 'package:pilipala/common/widgets/stat/view.dart'; import 'package:pilipala/utils/storage.dart'; -Box localCache = GStrorage.localCache; +Box localCache = GStorage.localCache; late double sheetHeight; class IntroDetail extends StatelessWidget { diff --git a/lib/pages/bangumi/widgets/bangumi_panel.dart b/lib/pages/bangumi/widgets/bangumi_panel.dart index cdca500c..f6f1ff22 100644 --- a/lib/pages/bangumi/widgets/bangumi_panel.dart +++ b/lib/pages/bangumi/widgets/bangumi_panel.dart @@ -36,7 +36,7 @@ class BangumiPanel extends StatefulWidget { class _BangumiPanelState extends State { late RxInt currentIndex = (-1).obs; final ScrollController listViewScrollCtr = ScrollController(); - Box userInfoCache = GStrorage.userInfo; + Box userInfoCache = GStorage.userInfo; dynamic userInfo; // 默认未开通 int vipStatus = 0; diff --git a/lib/pages/blacklist/index.dart b/lib/pages/blacklist/index.dart index 0616c1dc..96eff255 100644 --- a/lib/pages/blacklist/index.dart +++ b/lib/pages/blacklist/index.dart @@ -22,7 +22,7 @@ class _BlackListPageState extends State { final ScrollController scrollController = ScrollController(); Future? _futureBuilderFuture; bool _isLoadingMore = false; - Box setting = GStrorage.setting; + Box setting = GStorage.setting; @override void initState() { diff --git a/lib/pages/danmaku/view.dart b/lib/pages/danmaku/view.dart index 3cf1ed8a..5209d437 100644 --- a/lib/pages/danmaku/view.dart +++ b/lib/pages/danmaku/view.dart @@ -32,7 +32,7 @@ class _PlDanmakuState extends State { late PlDanmakuController _plDanmakuController; DanmakuController? _controller; // bool danmuPlayStatus = true; - Box setting = GStrorage.setting; + Box setting = GStorage.setting; late bool enableShowDanmaku; late List blockTypes; late double showArea; diff --git a/lib/pages/dynamics/controller.dart b/lib/pages/dynamics/controller.dart index df5b154e..ff5c959a 100644 --- a/lib/pages/dynamics/controller.dart +++ b/lib/pages/dynamics/controller.dart @@ -50,11 +50,11 @@ class DynamicsController extends GetxController { ]; bool flag = false; RxInt initialValue = 0.obs; - Box userInfoCache = GStrorage.userInfo; + Box userInfoCache = GStorage.userInfo; RxBool userLogin = false.obs; var userInfo; RxBool isLoadingDynamic = false.obs; - Box setting = GStrorage.setting; + Box setting = GStorage.setting; @override void onInit() { diff --git a/lib/pages/dynamics/detail/controller.dart b/lib/pages/dynamics/detail/controller.dart index e7c179f3..88c11f1d 100644 --- a/lib/pages/dynamics/detail/controller.dart +++ b/lib/pages/dynamics/detail/controller.dart @@ -24,7 +24,7 @@ class DynamicDetailController extends GetxController { ReplySortType _sortType = ReplySortType.time; RxString sortTypeTitle = ReplySortType.time.titles.obs; RxString sortTypeLabel = ReplySortType.time.labels.obs; - Box setting = GStrorage.setting; + Box setting = GStorage.setting; RxInt replyReqCode = 200.obs; bool isEnd = false; @@ -37,13 +37,13 @@ class DynamicDetailController extends GetxController { acount.value = int.parse(item!.modules!.moduleStat!.comment!.count ?? '0'); } - int deaultReplySortIndex = + int defaultReplySortIndex = setting.get(SettingBoxKey.replySortType, defaultValue: 0); - if (deaultReplySortIndex == 2) { + if (defaultReplySortIndex == 2) { setting.put(SettingBoxKey.replySortType, 0); - deaultReplySortIndex = 0; + defaultReplySortIndex = 0; } - _sortType = ReplySortType.values[deaultReplySortIndex]; + _sortType = ReplySortType.values[defaultReplySortIndex]; sortTypeTitle.value = _sortType.titles; sortTypeLabel.value = _sortType.labels; } diff --git a/lib/pages/dynamics/view.dart b/lib/pages/dynamics/view.dart index ce3e1aaa..257ecd49 100644 --- a/lib/pages/dynamics/view.dart +++ b/lib/pages/dynamics/view.dart @@ -32,7 +32,7 @@ class _DynamicsPageState extends State final MineController mineController = Get.put(MineController()); late Future _futureBuilderFuture; late Future _futureBuilderFutureUp; - Box userInfoCache = GStrorage.userInfo; + Box userInfoCache = GStorage.userInfo; late ScrollController scrollController; @override diff --git a/lib/pages/fan/controller.dart b/lib/pages/fan/controller.dart index 6661d9fe..1a82b538 100644 --- a/lib/pages/fan/controller.dart +++ b/lib/pages/fan/controller.dart @@ -6,7 +6,7 @@ import 'package:pilipala/models/fans/result.dart'; import 'package:pilipala/utils/storage.dart'; class FansController extends GetxController { - Box userInfoCache = GStrorage.userInfo; + Box userInfoCache = GStorage.userInfo; int pn = 1; int ps = 20; int total = 0; diff --git a/lib/pages/fav/controller.dart b/lib/pages/fav/controller.dart index 5be46bf0..6ab36bfb 100644 --- a/lib/pages/fav/controller.dart +++ b/lib/pages/fav/controller.dart @@ -11,7 +11,7 @@ class FavController extends GetxController { final ScrollController scrollController = ScrollController(); Rx favFolderData = FavFolderData().obs; RxList favFolderList = [].obs; - Box userInfoCache = GStrorage.userInfo; + Box userInfoCache = GStorage.userInfo; UserInfoData? userInfo; int currentPage = 1; int pageSize = 60; diff --git a/lib/pages/follow/controller.dart b/lib/pages/follow/controller.dart index fe4b6100..e39eb3cd 100644 --- a/lib/pages/follow/controller.dart +++ b/lib/pages/follow/controller.dart @@ -11,7 +11,7 @@ import 'package:pilipala/utils/storage.dart'; /// 查看自己的关注时,可以查看分类 /// 查看其他人的关注时,只可以看全部 class FollowController extends GetxController with GetTickerProviderStateMixin { - Box userInfoCache = GStrorage.userInfo; + Box userInfoCache = GStorage.userInfo; int pn = 1; int ps = 20; int total = 0; diff --git a/lib/pages/history/controller.dart b/lib/pages/history/controller.dart index 64953e3b..7b366d10 100644 --- a/lib/pages/history/controller.dart +++ b/lib/pages/history/controller.dart @@ -12,11 +12,11 @@ class HistoryController extends GetxController { RxList historyList = [].obs; RxBool isLoadingMore = false.obs; RxBool pauseStatus = false.obs; - Box localCache = GStrorage.localCache; + Box localCache = GStorage.localCache; RxBool isLoading = false.obs; RxBool enableMultiple = false.obs; RxInt checkedCount = 0.obs; - Box userInfoCache = GStrorage.userInfo; + Box userInfoCache = GStorage.userInfo; UserInfoData? userInfo; @override diff --git a/lib/pages/home/controller.dart b/lib/pages/home/controller.dart index ea6e72ba..91f16c9f 100644 --- a/lib/pages/home/controller.dart +++ b/lib/pages/home/controller.dart @@ -14,12 +14,12 @@ class HomeController extends GetxController with GetTickerProviderStateMixin { late TabController tabController; late List tabsCtrList; late List tabsPageList; - Box userInfoCache = GStrorage.userInfo; - Box settingStorage = GStrorage.setting; + Box userInfoCache = GStorage.userInfo; + Box settingStorage = GStorage.setting; RxBool userLogin = false.obs; RxString userFace = ''.obs; var userInfo; - Box setting = GStrorage.setting; + Box setting = GStorage.setting; late final StreamController searchBarStream = StreamController.broadcast(); late bool hideSearchBar; diff --git a/lib/pages/home/widgets/app_bar.dart b/lib/pages/home/widgets/app_bar.dart index 35cb9d4e..4bf5200a 100644 --- a/lib/pages/home/widgets/app_bar.dart +++ b/lib/pages/home/widgets/app_bar.dart @@ -5,7 +5,7 @@ import 'package:hive/hive.dart'; import 'package:pilipala/common/widgets/network_img_layer.dart'; import 'package:pilipala/utils/storage.dart'; -Box userInfoCache = GStrorage.userInfo; +Box userInfoCache = GStorage.userInfo; class HomeAppBar extends StatelessWidget { const HomeAppBar({super.key}); diff --git a/lib/pages/html/controller.dart b/lib/pages/html/controller.dart index 7ba41966..2c45fbe6 100644 --- a/lib/pages/html/controller.dart +++ b/lib/pages/html/controller.dart @@ -25,7 +25,7 @@ class HtmlRenderController extends GetxController { ReplySortType _sortType = ReplySortType.time; RxString sortTypeTitle = ReplySortType.time.titles.obs; RxString sortTypeLabel = ReplySortType.time.labels.obs; - Box setting = GStrorage.setting; + Box setting = GStorage.setting; @override void onInit() { diff --git a/lib/pages/later/controller.dart b/lib/pages/later/controller.dart index e8170d0a..6cb8a3c0 100644 --- a/lib/pages/later/controller.dart +++ b/lib/pages/later/controller.dart @@ -13,7 +13,7 @@ class LaterController extends GetxController { RxList laterList = [].obs; int count = 0; RxBool isLoading = false.obs; - Box userInfoCache = GStrorage.userInfo; + Box userInfoCache = GStorage.userInfo; UserInfoData? userInfo; @override diff --git a/lib/pages/live/controller.dart b/lib/pages/live/controller.dart index 492024e5..a2434624 100644 --- a/lib/pages/live/controller.dart +++ b/lib/pages/live/controller.dart @@ -17,7 +17,7 @@ class LiveController extends GetxController { RxInt liveFollowingCount = 0.obs; bool flag = false; OverlayEntry? popupDialog; - Box setting = GStrorage.setting; + Box setting = GStorage.setting; @override void onInit() { diff --git a/lib/pages/live_follow/controller.dart b/lib/pages/live_follow/controller.dart index 65c99384..049da1f6 100644 --- a/lib/pages/live_follow/controller.dart +++ b/lib/pages/live_follow/controller.dart @@ -7,7 +7,7 @@ import 'package:pilipala/utils/storage.dart'; class LiveFollowController extends GetxController { RxInt crossAxisCount = 2.obs; - Box setting = GStrorage.setting; + Box setting = GStorage.setting; int _currentPage = 1; RxInt liveFollowingCount = 0.obs; RxList liveFollowingList = diff --git a/lib/pages/live_room/controller.dart b/lib/pages/live_room/controller.dart index 0d347bf2..a918ec7b 100644 --- a/lib/pages/live_room/controller.dart +++ b/lib/pages/live_room/controller.dart @@ -33,7 +33,7 @@ class LiveRoomController extends GetxController { int? tempCurrentQn; late List> acceptQnList; RxString currentQnDesc = ''.obs; - Box userInfoCache = GStrorage.userInfo; + Box userInfoCache = GStorage.userInfo; int userId = 0; PlSocket? plSocket; List danmuHostList = []; diff --git a/lib/pages/live_room/widgets/bottom_control.dart b/lib/pages/live_room/widgets/bottom_control.dart index 4dd7c538..aa3d51b8 100644 --- a/lib/pages/live_room/widgets/bottom_control.dart +++ b/lib/pages/live_room/widgets/bottom_control.dart @@ -35,7 +35,7 @@ class _BottomControlState extends State { TextStyle subTitleStyle = const TextStyle(fontSize: 12); TextStyle titleStyle = const TextStyle(fontSize: 14); Size get preferredSize => const Size(double.infinity, kToolbarHeight); - Box localCache = GStrorage.localCache; + Box localCache = GStorage.localCache; @override void initState() { diff --git a/lib/pages/main/controller.dart b/lib/pages/main/controller.dart index 37c8d174..3a3cc9eb 100644 --- a/lib/pages/main/controller.dart +++ b/lib/pages/main/controller.dart @@ -20,12 +20,12 @@ class MainController extends GetxController { late List navBarSort; final StreamController bottomBarStream = StreamController.broadcast(); - Box setting = GStrorage.setting; + Box setting = GStorage.setting; DateTime? _lastPressedAt; late bool hideTabBar; late PageController pageController; int selectedIndex = 0; - Box userInfoCache = GStrorage.userInfo; + Box userInfoCache = GStorage.userInfo; dynamic userInfo; RxBool userLogin = false.obs; late Rx dynamicBadgeType = DynamicBadgeMode.number.obs; diff --git a/lib/pages/main/view.dart b/lib/pages/main/view.dart index 82df1af9..01fae4bf 100644 --- a/lib/pages/main/view.dart +++ b/lib/pages/main/view.dart @@ -30,7 +30,7 @@ class _MainAppState extends State with SingleTickerProviderStateMixin { late MineController _mineController; int? _lastSelectTime; //上次点击时间 - Box setting = GStrorage.setting; + Box setting = GStorage.setting; late bool enableMYBar; @override @@ -113,14 +113,14 @@ class _MainAppState extends State with SingleTickerProviderStateMixin { @override void dispose() async { - await GStrorage.close(); + await GStorage.close(); EventBus().off(EventName.loginEvent); super.dispose(); } @override Widget build(BuildContext context) { - Box localCache = GStrorage.localCache; + Box localCache = GStorage.localCache; double statusBarHeight = MediaQuery.of(context).padding.top; double sheetHeight = MediaQuery.sizeOf(context).height - MediaQuery.of(context).padding.top - diff --git a/lib/pages/member/controller.dart b/lib/pages/member/controller.dart index b805b33d..6e66b5ed 100644 --- a/lib/pages/member/controller.dart +++ b/lib/pages/member/controller.dart @@ -18,7 +18,7 @@ class MemberController extends GetxController { late Map userStat; RxString face = ''.obs; String? heroTag; - Box userInfoCache = GStrorage.userInfo; + Box userInfoCache = GStorage.userInfo; late int ownerMid; // 投稿列表 RxList? archiveList = [].obs; diff --git a/lib/pages/mine/controller.dart b/lib/pages/mine/controller.dart index 24401711..6c7c0fda 100644 --- a/lib/pages/mine/controller.dart +++ b/lib/pages/mine/controller.dart @@ -17,8 +17,8 @@ class MineController extends GetxController { Rx userInfo = UserInfoData().obs; Rx themeType = ThemeType.system.obs; Rx favFolderData = FavFolderData().obs; - Box setting = GStrorage.setting; - Box userInfoCache = GStrorage.userInfo; + Box setting = GStorage.setting; + Box userInfoCache = GStorage.userInfo; List menuList = [ { 'icon': Icons.history, diff --git a/lib/pages/mine_edit/controller.dart b/lib/pages/mine_edit/controller.dart index 9bc43246..148aaccc 100644 --- a/lib/pages/mine_edit/controller.dart +++ b/lib/pages/mine_edit/controller.dart @@ -6,7 +6,7 @@ import 'package:pilipala/http/user.dart'; import 'package:pilipala/utils/storage.dart'; class MineEditController extends GetxController { - Box userInfoCache = GStrorage.userInfo; + Box userInfoCache = GStorage.userInfo; final formKey = GlobalKey(); final TextEditingController unameCtr = TextEditingController(); final TextEditingController useridCtr = TextEditingController(); diff --git a/lib/pages/rank/controller.dart b/lib/pages/rank/controller.dart index bb34b13f..ad986772 100644 --- a/lib/pages/rank/controller.dart +++ b/lib/pages/rank/controller.dart @@ -14,7 +14,7 @@ class RankController extends GetxController with GetTickerProviderStateMixin { late TabController tabController; late List tabsCtrList; late List tabsPageList; - Box setting = GStrorage.setting; + Box setting = GStorage.setting; late final StreamController searchBarStream = StreamController.broadcast(); diff --git a/lib/pages/rcmd/controller.dart b/lib/pages/rcmd/controller.dart index 2d606b12..464ab254 100644 --- a/lib/pages/rcmd/controller.dart +++ b/lib/pages/rcmd/controller.dart @@ -14,7 +14,7 @@ class RcmdController extends GetxController { // RxList webVideoList = [].obs; bool isLoadingMore = true; OverlayEntry? popupDialog; - Box setting = GStrorage.setting; + Box setting = GStorage.setting; RxInt crossAxisCount = 2.obs; late bool enableSaveLastData; late String defaultRcmdType = 'web'; diff --git a/lib/pages/search/controller.dart b/lib/pages/search/controller.dart index 8c478fd1..2da2acff 100644 --- a/lib/pages/search/controller.dart +++ b/lib/pages/search/controller.dart @@ -15,7 +15,7 @@ class SSearchController extends GetxController { RxString searchKeyWord = ''.obs; Rx controller = TextEditingController().obs; RxList hotSearchList = [].obs; - Box localCache = GStrorage.localCache; + Box localCache = GStorage.localCache; List historyCacheList = []; RxList historyList = [].obs; RxList searchSuggestList = [].obs; @@ -23,7 +23,7 @@ class SSearchController extends GetxController { Debouncer(delay: const Duration(milliseconds: 200)); // 设置延迟时间 String hintText = '搜索'; RxString defaultSearch = ''.obs; - Box setting = GStrorage.setting; + Box setting = GStorage.setting; bool enableHotKey = true; bool enableSearchSuggest = true; diff --git a/lib/pages/setting/controller.dart b/lib/pages/setting/controller.dart index 1fbd7efb..0e082152 100644 --- a/lib/pages/setting/controller.dart +++ b/lib/pages/setting/controller.dart @@ -13,9 +13,9 @@ import '../main/index.dart'; import 'widgets/select_dialog.dart'; class SettingController extends GetxController { - Box userInfoCache = GStrorage.userInfo; - Box setting = GStrorage.setting; - Box localCache = GStrorage.localCache; + Box userInfoCache = GStorage.userInfo; + Box setting = GStorage.setting; + Box localCache = GStorage.localCache; RxBool userLogin = false.obs; RxBool feedBackEnable = false.obs; diff --git a/lib/pages/setting/extra_setting.dart b/lib/pages/setting/extra_setting.dart index 5a7dadfb..44add757 100644 --- a/lib/pages/setting/extra_setting.dart +++ b/lib/pages/setting/extra_setting.dart @@ -19,8 +19,8 @@ class ExtraSetting extends StatefulWidget { } class _ExtraSettingState extends State { - Box setting = GStrorage.setting; - static Box localCache = GStrorage.localCache; + Box setting = GStorage.setting; + static Box localCache = GStorage.localCache; late dynamic defaultReplySort; late dynamic defaultDynamicType; late dynamic enableSystemProxy; diff --git a/lib/pages/setting/pages/action_menu_set.dart b/lib/pages/setting/pages/action_menu_set.dart index 3655df73..cbbd0e84 100644 --- a/lib/pages/setting/pages/action_menu_set.dart +++ b/lib/pages/setting/pages/action_menu_set.dart @@ -13,7 +13,7 @@ class ActionMenuSetPage extends StatefulWidget { } class _ActionMenuSetPageState extends State { - Box setting = GStrorage.setting; + Box setting = GStorage.setting; late List actionTypeSort; late List allLabels; diff --git a/lib/pages/setting/pages/color_select.dart b/lib/pages/setting/pages/color_select.dart index d0e34bcb..e144eb88 100644 --- a/lib/pages/setting/pages/color_select.dart +++ b/lib/pages/setting/pages/color_select.dart @@ -142,7 +142,7 @@ class _ColorSelectPageState extends State { } class ColorSelectController extends GetxController { - Box setting = GStrorage.setting; + Box setting = GStorage.setting; RxBool dynamicColor = true.obs; RxInt type = 0.obs; late final List> colorThemes; diff --git a/lib/pages/setting/pages/display_mode.dart b/lib/pages/setting/pages/display_mode.dart index 0dcf1958..180accb9 100644 --- a/lib/pages/setting/pages/display_mode.dart +++ b/lib/pages/setting/pages/display_mode.dart @@ -16,7 +16,7 @@ class _SetDiaplayModeState extends State { List modes = []; DisplayMode? active; DisplayMode? preferred; - Box setting = GStrorage.setting; + Box setting = GStorage.setting; final ValueNotifier page = ValueNotifier(0); late final PageController controller = PageController() diff --git a/lib/pages/setting/pages/font_size_select.dart b/lib/pages/setting/pages/font_size_select.dart index f5ca6be3..97c0c402 100644 --- a/lib/pages/setting/pages/font_size_select.dart +++ b/lib/pages/setting/pages/font_size_select.dart @@ -11,7 +11,7 @@ class FontSizeSelectPage extends StatefulWidget { } class _FontSizeSelectPageState extends State { - Box setting = GStrorage.setting; + Box setting = GStorage.setting; List list = [0.9, 0.95, 1.0, 1.05, 1.1, 1.15, 1.2, 1.25, 1.3]; late double minsize; late double maxSize; diff --git a/lib/pages/setting/pages/home_tabbar_set.dart b/lib/pages/setting/pages/home_tabbar_set.dart index 63e87d02..1550a3f2 100644 --- a/lib/pages/setting/pages/home_tabbar_set.dart +++ b/lib/pages/setting/pages/home_tabbar_set.dart @@ -12,7 +12,7 @@ class TabbarSetPage extends StatefulWidget { } class _TabbarSetPageState extends State { - Box settingStorage = GStrorage.setting; + Box settingStorage = GStorage.setting; late List defaultTabs; late List tabbarSort; diff --git a/lib/pages/setting/pages/navigation_bar_set.dart b/lib/pages/setting/pages/navigation_bar_set.dart index 49540163..24796451 100644 --- a/lib/pages/setting/pages/navigation_bar_set.dart +++ b/lib/pages/setting/pages/navigation_bar_set.dart @@ -13,7 +13,7 @@ class NavigationBarSetPage extends StatefulWidget { } class _NavigationbarSetPageState extends State { - Box settingStorage = GStrorage.setting; + Box settingStorage = GStorage.setting; late List defaultNavTabs; late List navBarSort; diff --git a/lib/pages/setting/pages/play_gesture_set.dart b/lib/pages/setting/pages/play_gesture_set.dart index 9659e58a..b901ade9 100644 --- a/lib/pages/setting/pages/play_gesture_set.dart +++ b/lib/pages/setting/pages/play_gesture_set.dart @@ -16,7 +16,7 @@ class PlayGesturePage extends StatefulWidget { } class _PlayGesturePageState extends State { - Box setting = GStrorage.setting; + Box setting = GStorage.setting; late int fullScreenGestureMode; @override diff --git a/lib/pages/setting/pages/play_speed_set.dart b/lib/pages/setting/pages/play_speed_set.dart index eb81f586..4636d579 100644 --- a/lib/pages/setting/pages/play_speed_set.dart +++ b/lib/pages/setting/pages/play_speed_set.dart @@ -14,8 +14,8 @@ class PlaySpeedPage extends StatefulWidget { } class _PlaySpeedPageState extends State { - Box videoStorage = GStrorage.video; - Box settingStorage = GStrorage.setting; + Box videoStorage = GStorage.video; + Box settingStorage = GStorage.setting; late double playSpeedDefault; late List playSpeedSystem; late double longPressSpeedDefault; diff --git a/lib/pages/setting/play_setting.dart b/lib/pages/setting/play_setting.dart index a3c75ab5..bcf071dd 100644 --- a/lib/pages/setting/play_setting.dart +++ b/lib/pages/setting/play_setting.dart @@ -23,7 +23,7 @@ class PlaySetting extends StatefulWidget { } class _PlaySettingState extends State { - Box setting = GStrorage.setting; + Box setting = GStorage.setting; late dynamic defaultVideoQa; late dynamic defaultLiveQa; late dynamic defaultAudioQa; diff --git a/lib/pages/setting/privacy_setting.dart b/lib/pages/setting/privacy_setting.dart index 07a02318..493795c2 100644 --- a/lib/pages/setting/privacy_setting.dart +++ b/lib/pages/setting/privacy_setting.dart @@ -14,7 +14,7 @@ class PrivacySetting extends StatefulWidget { class _PrivacySettingState extends State { bool userLogin = false; - Box userInfoCache = GStrorage.userInfo; + Box userInfoCache = GStorage.userInfo; var userInfo; @override diff --git a/lib/pages/setting/recommend_setting.dart b/lib/pages/setting/recommend_setting.dart index ab8ec063..91631db8 100644 --- a/lib/pages/setting/recommend_setting.dart +++ b/lib/pages/setting/recommend_setting.dart @@ -17,10 +17,10 @@ class RecommendSetting extends StatefulWidget { } class _RecommendSettingState extends State { - Box setting = GStrorage.setting; - static Box localCache = GStrorage.localCache; + Box setting = GStorage.setting; + static Box localCache = GStorage.localCache; late dynamic defaultRcmdType; - Box userInfoCache = GStrorage.userInfo; + Box userInfoCache = GStorage.userInfo; late dynamic userInfo; bool userLogin = false; late dynamic accessKeyInfo; @@ -247,10 +247,9 @@ class _RecommendSettingState extends State { '* 其它(如热门视频、手动搜索、链接跳转等)均不受过滤器影响。\n' '* 设定较严苛的条件可导致推荐项数锐减或多次请求,请酌情选择。\n' '* 后续可能会增加更多过滤条件,敬请期待。', - style: Theme.of(context) - .textTheme - .labelSmall! - .copyWith(color: Theme.of(context).colorScheme.outline.withOpacity(0.7)), + style: Theme.of(context).textTheme.labelSmall!.copyWith( + color: + Theme.of(context).colorScheme.outline.withOpacity(0.7)), ), ) ], diff --git a/lib/pages/setting/style_setting.dart b/lib/pages/setting/style_setting.dart index 930a6bde..a94cef29 100644 --- a/lib/pages/setting/style_setting.dart +++ b/lib/pages/setting/style_setting.dart @@ -28,7 +28,7 @@ class _StyleSettingState extends State { final ColorSelectController colorSelectController = Get.put(ColorSelectController()); - Box setting = GStrorage.setting; + Box setting = GStorage.setting; late int picQuality; late ThemeType _tempThemeValue; late dynamic defaultCustomRows; diff --git a/lib/pages/setting/widgets/select_item.dart b/lib/pages/setting/widgets/select_item.dart index a18754a1..8eeaad92 100644 --- a/lib/pages/setting/widgets/select_item.dart +++ b/lib/pages/setting/widgets/select_item.dart @@ -19,7 +19,7 @@ class SetSelectItem extends StatefulWidget { } class _SetSelectItemState extends State { - Box setting = GStrorage.setting; + Box setting = GStorage.setting; late dynamic currentVal; late int currentIndex; late List menus; diff --git a/lib/pages/setting/widgets/switch_item.dart b/lib/pages/setting/widgets/switch_item.dart index d0c2bbf2..9ccda6a7 100644 --- a/lib/pages/setting/widgets/switch_item.dart +++ b/lib/pages/setting/widgets/switch_item.dart @@ -28,7 +28,7 @@ class SetSwitchItem extends StatefulWidget { class _SetSwitchItemState extends State { // ignore: non_constant_identifier_names - Box Setting = GStrorage.setting; + Box Setting = GStorage.setting; late bool val; @override diff --git a/lib/pages/subscription/controller.dart b/lib/pages/subscription/controller.dart index b59a42f0..11fddf3f 100644 --- a/lib/pages/subscription/controller.dart +++ b/lib/pages/subscription/controller.dart @@ -11,7 +11,7 @@ import '../../models/user/sub_folder.dart'; class SubController extends GetxController { final ScrollController scrollController = ScrollController(); Rx subFolderData = SubFolderModelData().obs; - Box userInfoCache = GStrorage.userInfo; + Box userInfoCache = GStorage.userInfo; UserInfoData? userInfo; int currentPage = 1; int pageSize = 20; diff --git a/lib/pages/video/detail/controller.dart b/lib/pages/video/detail/controller.dart index 3fead9c7..53f7d019 100644 --- a/lib/pages/video/detail/controller.dart +++ b/lib/pages/video/detail/controller.dart @@ -68,9 +68,9 @@ class VideoDetailController extends GetxController RxBool enableHA = false.obs; /// 本地存储 - Box userInfoCache = GStrorage.userInfo; - Box localCache = GStrorage.localCache; - Box setting = GStrorage.setting; + Box userInfoCache = GStorage.userInfo; + Box localCache = GStorage.localCache; + Box setting = GStorage.setting; RxInt oid = 0.obs; // 评论id 请求楼中楼评论使用 diff --git a/lib/pages/video/detail/introduction/controller.dart b/lib/pages/video/detail/introduction/controller.dart index e78d8121..fd09fea6 100644 --- a/lib/pages/video/detail/introduction/controller.dart +++ b/lib/pages/video/detail/introduction/controller.dart @@ -41,7 +41,7 @@ class VideoIntroController extends GetxController { RxBool hasFav = false.obs; // 是否不喜欢 RxBool hasDisLike = false.obs; - Box userInfoCache = GStrorage.userInfo; + Box userInfoCache = GStorage.userInfo; bool userLogin = false; Rx favFolderData = FavFolderData().obs; List addMediaIdsNew = []; diff --git a/lib/pages/video/detail/introduction/view.dart b/lib/pages/video/detail/introduction/view.dart index 80176a7b..2ac4efff 100644 --- a/lib/pages/video/detail/introduction/view.dart +++ b/lib/pages/video/detail/introduction/view.dart @@ -137,8 +137,8 @@ class _VideoInfoState extends State with TickerProviderStateMixin { late String heroTag; late final VideoIntroController videoIntroController; late final VideoDetailController videoDetailCtr; - final Box localCache = GStrorage.localCache; - final Box setting = GStrorage.setting; + final Box localCache = GStorage.localCache; + final Box setting = GStorage.setting; late double sheetHeight; late final dynamic owner; late int mid; diff --git a/lib/pages/video/detail/introduction/widgets/fav_panel.dart b/lib/pages/video/detail/introduction/widgets/fav_panel.dart index fa043cb6..54fefe9d 100644 --- a/lib/pages/video/detail/introduction/widgets/fav_panel.dart +++ b/lib/pages/video/detail/introduction/widgets/fav_panel.dart @@ -16,7 +16,7 @@ class FavPanel extends StatefulWidget { } class _FavPanelState extends State { - final Box localCache = GStrorage.localCache; + final Box localCache = GStorage.localCache; late Future _futureBuilderFuture; @override diff --git a/lib/pages/video/detail/introduction/widgets/group_panel.dart b/lib/pages/video/detail/introduction/widgets/group_panel.dart index bafebf50..1292bcdc 100644 --- a/lib/pages/video/detail/introduction/widgets/group_panel.dart +++ b/lib/pages/video/detail/introduction/widgets/group_panel.dart @@ -18,7 +18,7 @@ class GroupPanel extends StatefulWidget { } class _GroupPanelState extends State { - final Box localCache = GStrorage.localCache; + final Box localCache = GStorage.localCache; late Future _futureBuilderFuture; late List tagsList; bool showDefault = true; diff --git a/lib/pages/video/detail/reply/controller.dart b/lib/pages/video/detail/reply/controller.dart index a5797c7b..ab4fc9e3 100644 --- a/lib/pages/video/detail/reply/controller.dart +++ b/lib/pages/video/detail/reply/controller.dart @@ -32,20 +32,20 @@ class VideoReplyController extends GetxController { RxString sortTypeTitle = ReplySortType.time.titles.obs; RxString sortTypeLabel = ReplySortType.time.labels.obs; - Box setting = GStrorage.setting; + Box setting = GStorage.setting; RxInt replyReqCode = 200.obs; bool isEnd = false; @override void onInit() { super.onInit(); - int deaultReplySortIndex = + int defaultReplySortIndex = setting.get(SettingBoxKey.replySortType, defaultValue: 0) as int; - if (deaultReplySortIndex == 2) { + if (defaultReplySortIndex == 2) { setting.put(SettingBoxKey.replySortType, 0); - deaultReplySortIndex = 0; + defaultReplySortIndex = 0; } - _sortType = ReplySortType.values[deaultReplySortIndex]; + _sortType = ReplySortType.values[defaultReplySortIndex]; sortTypeTitle.value = _sortType.titles; sortTypeLabel.value = _sortType.labels; } diff --git a/lib/pages/video/detail/reply/widgets/reply_item.dart b/lib/pages/video/detail/reply/widgets/reply_item.dart index 1fc45f12..84c0a62f 100644 --- a/lib/pages/video/detail/reply/widgets/reply_item.dart +++ b/lib/pages/video/detail/reply/widgets/reply_item.dart @@ -26,7 +26,7 @@ import 'package:pilipala/utils/utils.dart'; import 'reply_save.dart'; import 'zan.dart'; -Box setting = GStrorage.setting; +Box setting = GStorage.setting; class ReplyItem extends StatelessWidget { const ReplyItem({ diff --git a/lib/pages/video/detail/reply_reply/view.dart b/lib/pages/video/detail/reply_reply/view.dart index 8da8e535..592ea684 100644 --- a/lib/pages/video/detail/reply_reply/view.dart +++ b/lib/pages/video/detail/reply_reply/view.dart @@ -42,7 +42,7 @@ class VideoReplyReplyPanel extends StatefulWidget { class _VideoReplyReplyPanelState extends State { late VideoReplyReplyController _videoReplyReplyController; late AnimationController replyAnimationCtl; - final Box localCache = GStrorage.localCache; + final Box localCache = GStorage.localCache; Future? _futureBuilderFuture; late ScrollController scrollController; diff --git a/lib/pages/video/detail/view.dart b/lib/pages/video/detail/view.dart index a3c19661..775950f9 100644 --- a/lib/pages/video/detail/view.dart +++ b/lib/pages/video/detail/view.dart @@ -54,8 +54,8 @@ class _VideoDetailPageState extends State Rx playerStatus = PlayerStatus.playing.obs; double doubleOffset = 0; - final Box localCache = GStrorage.localCache; - final Box setting = GStrorage.setting; + final Box localCache = GStorage.localCache; + final Box setting = GStorage.setting; late double statusBarHeight; final double videoHeight = Get.size.width * 9 / 16; late Future _futureBuilderFuture; diff --git a/lib/pages/video/detail/widgets/header_control.dart b/lib/pages/video/detail/widgets/header_control.dart index b2bed21c..f2857398 100644 --- a/lib/pages/video/detail/widgets/header_control.dart +++ b/lib/pages/video/detail/widgets/header_control.dart @@ -52,8 +52,8 @@ class _HeaderControlState extends State { static const TextStyle subTitleStyle = TextStyle(fontSize: 12); static const TextStyle titleStyle = TextStyle(fontSize: 14); Size get preferredSize => const Size(double.infinity, kToolbarHeight); - final Box localCache = GStrorage.localCache; - final Box videoStorage = GStrorage.video; + final Box localCache = GStorage.localCache; + final Box videoStorage = GStorage.video; late List speedsList; double buttonSpace = 8; RxBool isFullScreen = false.obs; diff --git a/lib/pages/whisper_detail/controller.dart b/lib/pages/whisper_detail/controller.dart index ec828afb..54d6a2c4 100644 --- a/lib/pages/whisper_detail/controller.dart +++ b/lib/pages/whisper_detail/controller.dart @@ -20,7 +20,7 @@ class WhisperDetailController extends GetxController { //表情转换图片规则 RxList eInfos = [].obs; final TextEditingController replyContentController = TextEditingController(); - Box userInfoCache = GStrorage.userInfo; + Box userInfoCache = GStorage.userInfo; List emoteList = []; List picList = []; diff --git a/lib/pages/whisper_detail/view.dart b/lib/pages/whisper_detail/view.dart index 3ea59343..f79c241d 100644 --- a/lib/pages/whisper_detail/view.dart +++ b/lib/pages/whisper_detail/view.dart @@ -30,7 +30,7 @@ class _WhisperDetailPageState extends State late double emoteHeight = 230.0; double keyboardHeight = 0.0; // 键盘高度 RxString toolbarType = ''.obs; - Box userInfoCache = GStrorage.userInfo; + Box userInfoCache = GStorage.userInfo; @override void initState() { diff --git a/lib/pages/whisper_detail/widget/chat_item.dart b/lib/pages/whisper_detail/widget/chat_item.dart index 60a04f74..973dca5e 100644 --- a/lib/pages/whisper_detail/widget/chat_item.dart +++ b/lib/pages/whisper_detail/widget/chat_item.dart @@ -56,8 +56,7 @@ class ChatItem extends StatelessWidget { @override Widget build(BuildContext context) { - bool isOwner = - item.senderUid == GStrorage.userInfo.get('userInfoCache').mid; + bool isOwner = item.senderUid == GStorage.userInfo.get('userInfoCache').mid; bool isPic = item.msgType == MsgType.pic.value; // 图片 bool isText = item.msgType == MsgType.text.value; // 文本 diff --git a/lib/plugin/pl_player/controller.dart b/lib/plugin/pl_player/controller.dart index cd41df24..de4cd9df 100644 --- a/lib/plugin/pl_player/controller.dart +++ b/lib/plugin/pl_player/controller.dart @@ -27,9 +27,9 @@ import '../../models/video/subTitile/content.dart'; import '../../models/video/subTitile/result.dart'; // import 'package:wakelock_plus/wakelock_plus.dart'; -Box videoStorage = GStrorage.video; -Box setting = GStrorage.setting; -Box localCache = GStrorage.localCache; +Box videoStorage = GStorage.video; +Box setting = GStorage.setting; +Box localCache = GStorage.localCache; class PlPlayerController { Player? _videoPlayerController; diff --git a/lib/plugin/pl_player/view.dart b/lib/plugin/pl_player/view.dart index a88bc86f..990661bc 100644 --- a/lib/plugin/pl_player/view.dart +++ b/lib/plugin/pl_player/view.dart @@ -82,7 +82,7 @@ class _PLVideoPlayerState extends State final RxDouble _distance = 0.0.obs; final RxBool _volumeInterceptEventStream = false.obs; - Box setting = GStrorage.setting; + Box setting = GStorage.setting; late FullScreenMode mode; late int defaultBtmProgressBehavior; late bool enableQuickDouble; diff --git a/lib/router/app_pages.dart b/lib/router/app_pages.dart index 2d581293..31749764 100644 --- a/lib/router/app_pages.dart +++ b/lib/router/app_pages.dart @@ -66,7 +66,7 @@ import '../pages/whisper/index.dart'; import '../pages/whisper_detail/index.dart'; import '../utils/storage.dart'; -Box setting = GStrorage.setting; +Box setting = GStorage.setting; class Routes { static final List> getPages = [ diff --git a/lib/services/audio_handler.dart b/lib/services/audio_handler.dart index 853c58d0..7aa91eac 100644 --- a/lib/services/audio_handler.dart +++ b/lib/services/audio_handler.dart @@ -24,7 +24,7 @@ Future initAudioService() async { class VideoPlayerServiceHandler extends BaseAudioHandler with SeekHandler { static final List _item = []; - Box setting = GStrorage.setting; + Box setting = GStorage.setting; bool enableBackgroundPlay = false; PlPlayerController player = PlPlayerController(); diff --git a/lib/services/disable_battery_opt.dart b/lib/services/disable_battery_opt.dart index ae018977..d2de0bc3 100644 --- a/lib/services/disable_battery_opt.dart +++ b/lib/services/disable_battery_opt.dart @@ -9,7 +9,7 @@ void DisableBatteryOpt() async { } // 本地缓存中读取 是否禁用了电池优化 默认未禁用 bool isDisableBatteryOptLocal = - GStrorage.localCache.get('isDisableBatteryOptLocal', defaultValue: false); + GStorage.localCache.get('isDisableBatteryOptLocal', defaultValue: false); if (!isDisableBatteryOptLocal) { final isBatteryOptimizationDisabled = await DisableBatteryOptimization.isBatteryOptimizationDisabled; @@ -17,11 +17,11 @@ void DisableBatteryOpt() async { final hasDisabled = await DisableBatteryOptimization .showDisableBatteryOptimizationSettings(); // 设置为已禁用 - GStrorage.localCache.put('isDisableBatteryOptLocal', hasDisabled == true); + GStorage.localCache.put('isDisableBatteryOptLocal', hasDisabled == true); } } - bool isManufacturerBatteryOptimizationDisabled = GStrorage.localCache + bool isManufacturerBatteryOptimizationDisabled = GStorage.localCache .get('isManufacturerBatteryOptimizationDisabled', defaultValue: false); if (!isManufacturerBatteryOptimizationDisabled) { final isManBatteryOptimizationDisabled = await DisableBatteryOptimization @@ -33,7 +33,7 @@ void DisableBatteryOpt() async { "按照步骤操作以禁用电池优化,以保证应用在后台正常运行", ); // 设置为已禁用 - GStrorage.localCache.put( + GStorage.localCache.put( 'isManufacturerBatteryOptimizationDisabled', hasDisabled == true); } } diff --git a/lib/utils/data.dart b/lib/utils/data.dart index 7cf00bae..667a7e0d 100644 --- a/lib/utils/data.dart +++ b/lib/utils/data.dart @@ -9,8 +9,8 @@ class Data { } static Future historyStatus() async { - Box localCache = GStrorage.localCache; - Box userInfoCache = GStrorage.userInfo; + Box localCache = GStorage.localCache; + Box userInfoCache = GStorage.userInfo; if (userInfoCache.get('userInfoCache') == null) { return; } diff --git a/lib/utils/feed_back.dart b/lib/utils/feed_back.dart index b0f9f035..4a29af21 100644 --- a/lib/utils/feed_back.dart +++ b/lib/utils/feed_back.dart @@ -2,7 +2,7 @@ import 'package:flutter/services.dart'; import 'package:hive/hive.dart'; import 'storage.dart'; -Box setting = GStrorage.setting; +Box setting = GStorage.setting; void feedBack() { // 设置中是否开启 final bool enable = diff --git a/lib/utils/global_data_cache.dart b/lib/utils/global_data_cache.dart index 794d4737..3321c660 100644 --- a/lib/utils/global_data_cache.dart +++ b/lib/utils/global_data_cache.dart @@ -5,10 +5,10 @@ import 'package:pilipala/plugin/pl_player/models/play_speed.dart'; import 'package:pilipala/utils/storage.dart'; import '../models/common/index.dart'; -Box setting = GStrorage.setting; -Box localCache = GStrorage.localCache; -Box videoStorage = GStrorage.video; -Box userInfoCache = GStrorage.userInfo; +Box setting = GStorage.setting; +Box localCache = GStorage.localCache; +Box videoStorage = GStorage.video; +Box userInfoCache = GStorage.userInfo; class GlobalDataCache { late int imgQuality; diff --git a/lib/utils/login.dart b/lib/utils/login.dart index 07afd2dc..a2b36d02 100644 --- a/lib/utils/login.dart +++ b/lib/utils/login.dart @@ -71,7 +71,7 @@ class LoginUtils { if (result['status'] && result['data'].isLogin) { SmartDialog.showToast('登录成功'); try { - Box userInfoCache = GStrorage.userInfo; + Box userInfoCache = GStorage.userInfo; if (!userInfoCache.isOpen) { userInfoCache = await Hive.openBox('userInfo'); } diff --git a/lib/utils/recommend_filter.dart b/lib/utils/recommend_filter.dart index 113e2261..29907c63 100644 --- a/lib/utils/recommend_filter.dart +++ b/lib/utils/recommend_filter.dart @@ -13,7 +13,7 @@ class RecommendFilter { } static void update() { - var setting = GStrorage.setting; + var setting = GStorage.setting; // filterUnfollowedRatio = // setting.get(SettingBoxKey.filterUnfollowedRatio, defaultValue: 0); minDurationForRcmd = diff --git a/lib/utils/storage.dart b/lib/utils/storage.dart index ed14b8df..a5b36768 100644 --- a/lib/utils/storage.dart +++ b/lib/utils/storage.dart @@ -3,7 +3,7 @@ import 'package:hive_flutter/hive_flutter.dart'; import 'package:path_provider/path_provider.dart'; import 'package:pilipala/models/user/info.dart'; -class GStrorage { +class GStorage { static late final Box userInfo; static late final Box localCache; static late final Box setting; diff --git a/lib/utils/wbi_sign.dart b/lib/utils/wbi_sign.dart index 4f831f16..3dd72150 100644 --- a/lib/utils/wbi_sign.dart +++ b/lib/utils/wbi_sign.dart @@ -9,7 +9,7 @@ import '../http/index.dart'; import 'storage.dart'; class WbiSign { - static Box localCache = GStrorage.localCache; + static Box localCache = GStorage.localCache; final List mixinKeyEncTab = [ 46, 47, From 539e83fb94699d2c9efbd6b430e006f694c9b11b Mon Sep 17 00:00:00 2001 From: guozhigq Date: Tue, 12 Nov 2024 00:02:08 +0800 Subject: [PATCH 04/27] opt: replace gif --- lib/common/pages_bottom_sheet.dart | 2 +- lib/pages/member/widgets/profile.dart | 2 +- lib/pages/video/detail/introduction/widgets/page_panel.dart | 2 +- lib/pages/video/detail/introduction/widgets/season_panel.dart | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/common/pages_bottom_sheet.dart b/lib/common/pages_bottom_sheet.dart index d7872f13..a6e73ae2 100644 --- a/lib/common/pages_bottom_sheet.dart +++ b/lib/common/pages_bottom_sheet.dart @@ -295,7 +295,7 @@ class EpisodeListItem extends StatelessWidget { dense: false, leading: isCurrentIndex ? Image.asset( - 'assets/images/live.gif', + 'assets/images/live.png', color: primary, height: 12, ) diff --git a/lib/pages/member/widgets/profile.dart b/lib/pages/member/widgets/profile.dart index e06309d0..4ea267e5 100644 --- a/lib/pages/member/widgets/profile.dart +++ b/lib/pages/member/widgets/profile.dart @@ -122,7 +122,7 @@ class ProfilePanel extends StatelessWidget { ), child: Row(children: [ Image.asset( - 'assets/images/live.gif', + 'assets/images/live.png', height: 10, ), Text( diff --git a/lib/pages/video/detail/introduction/widgets/page_panel.dart b/lib/pages/video/detail/introduction/widgets/page_panel.dart index 81a22176..f75a6989 100644 --- a/lib/pages/video/detail/introduction/widgets/page_panel.dart +++ b/lib/pages/video/detail/introduction/widgets/page_panel.dart @@ -153,7 +153,7 @@ class _PagesPanelState extends State { children: [ if (isCurrentIndex) ...[ Image.asset( - 'assets/images/live.gif', + 'assets/images/live.png', color: Theme.of(context).colorScheme.primary, height: 12, ), diff --git a/lib/pages/video/detail/introduction/widgets/season_panel.dart b/lib/pages/video/detail/introduction/widgets/season_panel.dart index f26885a7..7161bc92 100644 --- a/lib/pages/video/detail/introduction/widgets/season_panel.dart +++ b/lib/pages/video/detail/introduction/widgets/season_panel.dart @@ -84,7 +84,7 @@ class _SeasonPanelState extends State { dense: false, leading: isCurrentIndex ? Image.asset( - 'assets/images/live.gif', + 'assets/images/live.png', color: primary, height: 12, ) @@ -140,7 +140,7 @@ class _SeasonPanelState extends State { ), const SizedBox(width: 15), Image.asset( - 'assets/images/live.gif', + 'assets/images/live.png', color: Theme.of(context).colorScheme.primary, height: 12, ), From 3ee5e7acfc5946abb447383bccad913dfb738839 Mon Sep 17 00:00:00 2001 From: guozhigq Date: Tue, 12 Nov 2024 14:15:26 +0800 Subject: [PATCH 05/27] mod --- lib/utils/login.dart | 3 --- 1 file changed, 3 deletions(-) diff --git a/lib/utils/login.dart b/lib/utils/login.dart index 26950382..9dde1cb1 100644 --- a/lib/utils/login.dart +++ b/lib/utils/login.dart @@ -18,9 +18,6 @@ import 'package:pilipala/utils/storage.dart'; import 'package:uuid/uuid.dart'; class LoginUtils { - static Box userInfoCache = GStrorage.userInfo; - static Box localCache = GStrorage.localCache; - static Future refreshLoginStatus(bool status) async { try { // 更改我的页面登录状态 From 9f9a5683221dea37fa3b2a76a000e354e4ca9fa5 Mon Sep 17 00:00:00 2001 From: guozhigq Date: Wed, 13 Nov 2024 00:27:47 +0800 Subject: [PATCH 06/27] fix: cv load failed --- lib/http/init.dart | 7 +++++++ lib/http/read.dart | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/http/init.dart b/lib/http/init.dart index 7eb15644..e820102a 100644 --- a/lib/http/init.dart +++ b/lib/http/init.dart @@ -217,6 +217,13 @@ class Request { if (extra['ua'] != null) { options.headers = {'user-agent': headerUa(type: extra['ua'])}; } + if (extra['opus-goback'] != null) { + if (extra['opus-goback'] != null) { + String cookieHeader = dio.options.headers['cookie']; + options.headers!['cookie'] = + '$cookieHeader; opus-goback = ${extra['opus-goback']}'; + } + } } options.responseType = resType; diff --git a/lib/http/read.dart b/lib/http/read.dart index 68e72e59..5ea33519 100644 --- a/lib/http/read.dart +++ b/lib/http/read.dart @@ -1,4 +1,5 @@ import 'dart:convert'; +import 'package:dio/dio.dart'; import 'package:html/parser.dart'; import 'package:pilipala/models/read/opus.dart'; import 'package:pilipala/models/read/read.dart'; @@ -64,7 +65,7 @@ class ReadHttp { static Future parseArticleCv({required String id}) async { var res = await Request().get( 'https://www.bilibili.com/read/cv$id', - extra: {'ua': 'pc'}, + extra: {'ua': 'pc', 'opus-goback': '1'}, ); String scriptContent = extractScriptContents(parse(res.data).body!.outerHtml)[0]; From 57407c943fcb3e9efdeeb807301af242f122818e Mon Sep 17 00:00:00 2001 From: guozhigq Date: Wed, 13 Nov 2024 00:54:49 +0800 Subject: [PATCH 07/27] opt: request get options --- lib/http/danmaku.dart | 4 +++- lib/http/init.dart | 16 ++-------------- lib/http/read.dart | 7 ++++++- 3 files changed, 11 insertions(+), 16 deletions(-) diff --git a/lib/http/danmaku.dart b/lib/http/danmaku.dart index 2ed2a415..7b4283ae 100644 --- a/lib/http/danmaku.dart +++ b/lib/http/danmaku.dart @@ -17,7 +17,9 @@ class DanmakaHttp { var response = await Request().get( Api.webDanmaku, data: params, - extra: {'resType': ResponseType.bytes}, + options: Options( + responseType: ResponseType.bytes, + ), ); return DmSegMobileReply.fromBuffer(response.data); } diff --git a/lib/http/init.dart b/lib/http/init.dart index e820102a..0868570f 100644 --- a/lib/http/init.dart +++ b/lib/http/init.dart @@ -209,24 +209,12 @@ class Request { */ get(url, {data, Options? options, cancelToken, extra}) async { Response response; - options ??= Options(); // 如果 options 为 null,则初始化一个新的 Options 对象 - ResponseType resType = ResponseType.json; - if (extra != null) { - resType = extra['resType'] ?? ResponseType.json; if (extra['ua'] != null) { - options.headers = {'user-agent': headerUa(type: extra['ua'])}; - } - if (extra['opus-goback'] != null) { - if (extra['opus-goback'] != null) { - String cookieHeader = dio.options.headers['cookie']; - options.headers!['cookie'] = - '$cookieHeader; opus-goback = ${extra['opus-goback']}'; - } + options ??= Options(); + options.headers!['user-agent'] = headerUa(type: extra['ua']); } } - options.responseType = resType; - try { response = await dio.get( url, diff --git a/lib/http/read.dart b/lib/http/read.dart index 5ea33519..f2542936 100644 --- a/lib/http/read.dart +++ b/lib/http/read.dart @@ -65,7 +65,12 @@ class ReadHttp { static Future parseArticleCv({required String id}) async { var res = await Request().get( 'https://www.bilibili.com/read/cv$id', - extra: {'ua': 'pc', 'opus-goback': '1'}, + extra: {'ua': 'pc'}, + options: Options( + headers: { + 'cookie': 'opus-goback=1', + }, + ), ); String scriptContent = extractScriptContents(parse(res.data).body!.outerHtml)[0]; From 000963063982637e07cba976abbcb5a05a7f0e69 Mon Sep 17 00:00:00 2001 From: guozhigq Date: Wed, 13 Nov 2024 23:59:31 +0800 Subject: [PATCH 08/27] opt: reply del --- lib/pages/video/detail/reply/controller.dart | 20 ++++++++++++++++ lib/pages/video/detail/reply/view.dart | 7 +++--- .../detail/reply/widgets/reply_item.dart | 24 +++++++++++++++---- .../video/detail/reply_reply/controller.dart | 10 ++++++++ lib/pages/video/detail/reply_reply/view.dart | 1 + 5 files changed, 54 insertions(+), 8 deletions(-) diff --git a/lib/pages/video/detail/reply/controller.dart b/lib/pages/video/detail/reply/controller.dart index ab4fc9e3..91aa4fd6 100644 --- a/lib/pages/video/detail/reply/controller.dart +++ b/lib/pages/video/detail/reply/controller.dart @@ -132,4 +132,24 @@ class VideoReplyController extends GetxController { queryReplyList(type: 'init'); }); } + + // 移除评论 + Future removeReply(int? rpid, int? frpid) async { + // 移除一楼评论 + if (rpid != null) { + replyList.removeWhere((item) { + return item.rpid == rpid; + }); + } + // 移除二楼评论 + if (frpid != 0 && frpid != null) { + replyList.value = replyList.map((item) { + if (item.rpid! == frpid) { + return item..replies!.removeWhere((reply) => reply.rpid == rpid); + } else { + return item; + } + }).toList(); + } + } } diff --git a/lib/pages/video/detail/reply/view.dart b/lib/pages/video/detail/reply/view.dart index 54372c5e..28d36979 100644 --- a/lib/pages/video/detail/reply/view.dart +++ b/lib/pages/video/detail/reply/view.dart @@ -242,10 +242,9 @@ class _VideoReplyPanelState extends State .replyList[index], showReplyRow: true, replyLevel: replyLevel, - replyReply: (replyItem, currentReply, - loadMore) => - replyReply(replyItem, currentReply, - loadMore), + replyReply: replyReply, + onDelete: + _videoReplyController.removeReply, replyType: ReplyType.video, ); } diff --git a/lib/pages/video/detail/reply/widgets/reply_item.dart b/lib/pages/video/detail/reply/widgets/reply_item.dart index 84c0a62f..76a25331 100644 --- a/lib/pages/video/detail/reply/widgets/reply_item.dart +++ b/lib/pages/video/detail/reply/widgets/reply_item.dart @@ -37,6 +37,7 @@ class ReplyItem extends StatelessWidget { this.replyReply, this.replyType, this.replySave = false, + this.onDelete, super.key, }); final ReplyItemModel? replyItem; @@ -46,6 +47,7 @@ class ReplyItem extends StatelessWidget { final Function? replyReply; final ReplyType? replyType; final bool replySave; + final Function(int? rpid, int? frpid)? onDelete; @override Widget build(BuildContext context) { @@ -75,6 +77,7 @@ class ReplyItem extends StatelessWidget { item: replyItem, mainFloor: true, isOwner: isOwner, + onDelete: onDelete, ); }, ); @@ -275,6 +278,7 @@ class ReplyItem extends StatelessWidget { // f_rpid: replyItem!.rpid, replyItem: replyItem, replyReply: replyReply, + onDelete: onDelete, ), ), ], @@ -371,15 +375,15 @@ class ReplyItemRow extends StatelessWidget { super.key, this.replies, this.replyControl, - // this.f_rpid, this.replyItem, this.replyReply, + this.onDelete, }); final List? replies; ReplyControl? replyControl; - // int? f_rpid; ReplyItemModel? replyItem; Function? replyReply; + final Function(int? rpid, int? frpid)? onDelete; @override Widget build(BuildContext context) { @@ -410,12 +414,18 @@ class ReplyItemRow extends StatelessWidget { }, onLongPress: () { feedBack(); + final bool isOwner = int.parse(replyItem!.member!.mid!) == + (GlobalDataCache().userInfo?.mid ?? -1); showModalBottomSheet( context: context, useRootNavigator: true, isScrollControlled: true, builder: (context) { - return MorePanel(item: replies![i]); + return MorePanel( + item: replies![i], + isOwner: isOwner, + onDelete: onDelete, + ); }, ); }, @@ -1019,11 +1029,13 @@ class MorePanel extends StatelessWidget { final dynamic item; final bool mainFloor; final bool isOwner; + final Function(int? rpid, int? frpid)? onDelete; const MorePanel({ super.key, required this.item, this.mainFloor = false, this.isOwner = false, + this.onDelete, }); Future menuActionHandler(String type) async { @@ -1077,13 +1089,17 @@ class MorePanel extends StatelessWidget { TextButton( onPressed: () async { Get.back(); + print('item.rpid: ${item.rpid}'); + onDelete?.call(item.rpid!, item.root); + return; var result = await ReplyHttp.replyDel( type: item.type!, oid: item.oid!, rpid: item.rpid!, ); if (result['status']) { - SmartDialog.showToast('评论删除成功,需手动刷新'); + // SmartDialog.showToast('评论删除成功,需手动刷新'); + onDelete?.call(item.rpid!, item.root); Get.back(); } else { SmartDialog.showToast(result['msg']); diff --git a/lib/pages/video/detail/reply_reply/controller.dart b/lib/pages/video/detail/reply_reply/controller.dart index d0f67b80..2795b7a9 100644 --- a/lib/pages/video/detail/reply_reply/controller.dart +++ b/lib/pages/video/detail/reply_reply/controller.dart @@ -84,6 +84,16 @@ class VideoReplyReplyController extends GetxController { return res; } + // 移除评论 + Future removeReply(int? rpid, int? frpid) async { + // 移除一楼评论 + if (rpid != null) { + replyList.removeWhere((item) { + return item.rpid == rpid; + }); + } + } + @override void onClose() { currentPage = 0; diff --git a/lib/pages/video/detail/reply_reply/view.dart b/lib/pages/video/detail/reply_reply/view.dart index 592ea684..aaa84fe6 100644 --- a/lib/pages/video/detail/reply_reply/view.dart +++ b/lib/pages/video/detail/reply_reply/view.dart @@ -118,6 +118,7 @@ class _VideoReplyReplyPanelState extends State { }, replyType: widget.replyType, replyReply: (replyItem) => replyReply(replyItem), + onDelete: _videoReplyReplyController.removeReply, ); } From b93a3d08ccc5750b42414eeeb1e86a986fab8874 Mon Sep 17 00:00:00 2001 From: guozhigq Date: Thu, 14 Nov 2024 00:19:05 +0800 Subject: [PATCH 09/27] opt: reply del --- lib/models/video/reply/item.dart | 6 ++++++ lib/pages/dynamics/detail/controller.dart | 11 +++++++++++ lib/pages/dynamics/detail/view.dart | 2 ++ lib/pages/video/detail/reply/controller.dart | 10 +++++++++- lib/pages/video/detail/reply/widgets/reply_item.dart | 6 +----- 5 files changed, 29 insertions(+), 6 deletions(-) diff --git a/lib/models/video/reply/item.dart b/lib/models/video/reply/item.dart index 1fa05bec..44a87af9 100644 --- a/lib/models/video/reply/item.dart +++ b/lib/models/video/reply/item.dart @@ -125,6 +125,7 @@ class ReplyControl { this.upLike, this.isShow, this.entryText, + this.entryTextNum, this.titleText, this.time, this.location, @@ -135,6 +136,7 @@ class ReplyControl { bool? upLike; bool? isShow; String? entryText; + int? entryTextNum; String? titleText; String? time; String? location; @@ -155,6 +157,10 @@ class ReplyControl { } entryText = json['sub_reply_entry_text']; + // 正则匹配 + entryTextNum = json['sub_reply_entry_text'] != null + ? int.parse(RegExp(r"\d+").stringMatch(json['sub_reply_entry_text']!)!) + : 0; titleText = json['sub_reply_title_text']; time = json['time_desc']; location = json['location'] != null ? json['location'].split(':')[1] : ''; diff --git a/lib/pages/dynamics/detail/controller.dart b/lib/pages/dynamics/detail/controller.dart index 88c11f1d..a5f04bbe 100644 --- a/lib/pages/dynamics/detail/controller.dart +++ b/lib/pages/dynamics/detail/controller.dart @@ -123,4 +123,15 @@ class DynamicDetailController extends GetxController { Future onLoad() async { queryReplyList(reqType: 'onLoad'); } + + Future removeReply(int? rpid, int? frpid) async { + // 移除一楼评论 + if (rpid != null) { + replyList.removeWhere((item) { + return item.rpid == rpid; + }); + } + + /// TODO 移除二楼评论 + } } diff --git a/lib/pages/dynamics/detail/view.dart b/lib/pages/dynamics/detail/view.dart index e80befec..9958a13b 100644 --- a/lib/pages/dynamics/detail/view.dart +++ b/lib/pages/dynamics/detail/view.dart @@ -335,6 +335,8 @@ class _DynamicDetailPageState extends State .replies! .add(replyItem); }, + onDelete: + _dynamicDetailController.removeReply, ); } }, diff --git a/lib/pages/video/detail/reply/controller.dart b/lib/pages/video/detail/reply/controller.dart index 91aa4fd6..4af59b9d 100644 --- a/lib/pages/video/detail/reply/controller.dart +++ b/lib/pages/video/detail/reply/controller.dart @@ -145,7 +145,15 @@ class VideoReplyController extends GetxController { if (frpid != 0 && frpid != null) { replyList.value = replyList.map((item) { if (item.rpid! == frpid) { - return item..replies!.removeWhere((reply) => reply.rpid == rpid); + item.replies!.removeWhere((reply) => reply.rpid == rpid); + // 【共xx条回复】 + if (item.replyControl != null && + item.replyControl!.entryTextNum! >= 1) { + item.replyControl!.entryTextNum = + item.replyControl!.entryTextNum! - 1; + item.rcount = item.replyControl!.entryTextNum; + } + return item; } else { return item; } diff --git a/lib/pages/video/detail/reply/widgets/reply_item.dart b/lib/pages/video/detail/reply/widgets/reply_item.dart index 76a25331..5d31858f 100644 --- a/lib/pages/video/detail/reply/widgets/reply_item.dart +++ b/lib/pages/video/detail/reply/widgets/reply_item.dart @@ -503,7 +503,7 @@ class ReplyItemRow extends StatelessWidget { if (replyControl!.upReply!) const TextSpan(text: 'up主等人 '), TextSpan( - text: replyControl!.entryText!, + text: '查看${replyControl!.entryTextNum}条回复', style: TextStyle( color: colorScheme.primary, ), @@ -1089,16 +1089,12 @@ class MorePanel extends StatelessWidget { TextButton( onPressed: () async { Get.back(); - print('item.rpid: ${item.rpid}'); - onDelete?.call(item.rpid!, item.root); - return; var result = await ReplyHttp.replyDel( type: item.type!, oid: item.oid!, rpid: item.rpid!, ); if (result['status']) { - // SmartDialog.showToast('评论删除成功,需手动刷新'); onDelete?.call(item.rpid!, item.root); Get.back(); } else { From acdc347a7f900abe8af55a87e1a324ca8e61f3c7 Mon Sep 17 00:00:00 2001 From: guozhigq Date: Thu, 14 Nov 2024 00:33:41 +0800 Subject: [PATCH 10/27] mod: tag click push --- .../detail/introduction/widgets/intro_detail.dart | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/lib/pages/video/detail/introduction/widgets/intro_detail.dart b/lib/pages/video/detail/introduction/widgets/intro_detail.dart index c00db644..7387f29f 100644 --- a/lib/pages/video/detail/introduction/widgets/intro_detail.dart +++ b/lib/pages/video/detail/introduction/widgets/intro_detail.dart @@ -173,21 +173,15 @@ class IntroDetail extends StatelessWidget { children: videoTags!.map((tag) { return InkWell( onTap: () { - Get.toNamed( - '/tag', - arguments: { - 'tagId': tag.tagId, - 'tagName': tag.tagName, - }, - ); + Get.toNamed('/searchResult', parameters: {'keyword': tag.tagName!}); }, - borderRadius: BorderRadius.circular(20), + borderRadius: BorderRadius.circular(6), child: Container( decoration: BoxDecoration( color: colorScheme.surfaceVariant.withOpacity(0.5), - borderRadius: BorderRadius.circular(20), + borderRadius: BorderRadius.circular(6), ), - padding: const EdgeInsets.symmetric(vertical: 5, horizontal: 10), + padding: const EdgeInsets.symmetric(vertical: 4, horizontal: 10), child: Text( tag.tagName!, style: TextStyle( From b332cef4a3d0ca070ec63a979494f649dc87bd60 Mon Sep 17 00:00:00 2001 From: guozhigq Date: Fri, 15 Nov 2024 21:56:04 +0800 Subject: [PATCH 11/27] mod: favoritesSection style --- lib/pages/mine/view.dart | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/pages/mine/view.dart b/lib/pages/mine/view.dart index c2925f6e..55e8e3a9 100644 --- a/lib/pages/mine/view.dart +++ b/lib/pages/mine/view.dart @@ -355,7 +355,8 @@ class _MinePageState extends State itemBuilder: (context, index) { if (flag && index == favFolderList.length) { return Padding( - padding: const EdgeInsets.only(right: 14), + padding: + const EdgeInsets.only(right: 14, bottom: 70), child: Center( child: IconButton( style: ButtonStyle( @@ -488,7 +489,7 @@ class FavFolderItem extends StatelessWidget { child: NetworkImgLayer( src: item!.cover, width: 180, - height: 110, + height: MediaQuery.textScalerOf(context).scale(110), ), ), ), From c9e499bea7af7a35fd1e5d83d465de434f1d2501 Mon Sep 17 00:00:00 2001 From: guozhigq Date: Fri, 15 Nov 2024 22:00:25 +0800 Subject: [PATCH 12/27] fix: dynamicForward msg --- lib/pages/dynamics/forward/index.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pages/dynamics/forward/index.dart b/lib/pages/dynamics/forward/index.dart index e285a8c5..bcbe3648 100644 --- a/lib/pages/dynamics/forward/index.dart +++ b/lib/pages/dynamics/forward/index.dart @@ -47,7 +47,7 @@ class _DynamicForwardPageState extends State { widget.cb?.call(); _onClose(); } else { - SmartDialog.showToast(res['message']); + SmartDialog.showToast(res['msg']); } } From 908dd8c20d0d9df4c09cb5cd548fee97320433bd Mon Sep 17 00:00:00 2001 From: guozhigq Date: Sat, 16 Nov 2024 11:31:53 +0800 Subject: [PATCH 13/27] opt: AppBarTheme --- lib/common/pages_bottom_sheet.dart | 26 ++++++++---- lib/main.dart | 40 ++++++++++++++----- lib/pages/about/index.dart | 4 +- lib/pages/blacklist/index.dart | 5 --- lib/pages/dynamics/detail/view.dart | 12 +----- lib/pages/dynamics/view.dart | 2 - lib/pages/fan/view.dart | 5 --- lib/pages/fav/view.dart | 3 -- lib/pages/fav_edit/view.dart | 3 -- lib/pages/fav_search/view.dart | 1 - lib/pages/follow/view.dart | 5 --- lib/pages/follow_search/view.dart | 1 - lib/pages/history/view.dart | 10 +---- lib/pages/history_search/view.dart | 1 - lib/pages/home/view.dart | 1 - lib/pages/home/widgets/app_bar.dart | 3 -- lib/pages/html/view.dart | 16 +------- lib/pages/later/view.dart | 8 +--- lib/pages/live_follow/view.dart | 5 --- lib/pages/live_room/view.dart | 2 - .../live_room/widgets/bottom_control.dart | 3 -- lib/pages/member_archive/view.dart | 3 -- lib/pages/member_article/view.dart | 3 -- lib/pages/member_coin/widgets/item.dart | 1 - lib/pages/member_dynamics/view.dart | 3 -- lib/pages/member_search/view.dart | 1 - lib/pages/member_seasons/view.dart | 7 +--- lib/pages/message/at/view.dart | 4 +- lib/pages/message/like/view.dart | 4 +- lib/pages/message/reply/view.dart | 4 +- lib/pages/message/system/view.dart | 4 +- lib/pages/mine/view.dart | 2 - lib/pages/mine_edit/view.dart | 4 +- lib/pages/rank/view.dart | 1 - lib/pages/search/view.dart | 1 - lib/pages/search_result/view.dart | 2 - lib/pages/setting/extra_setting.dart | 9 +---- lib/pages/setting/pages/color_select.dart | 5 +-- lib/pages/setting/pages/logs.dart | 4 +- lib/pages/setting/pages/play_gesture_set.dart | 9 +---- lib/pages/setting/pages/play_speed_set.dart | 11 +---- lib/pages/setting/play_setting.dart | 9 +---- lib/pages/setting/privacy_setting.dart | 9 +---- lib/pages/setting/recommend_setting.dart | 9 +---- lib/pages/setting/style_setting.dart | 9 +---- lib/pages/setting/view.dart | 9 +---- lib/pages/subscription/view.dart | 8 +--- .../introduction/widgets/fav_panel.dart | 2 - .../introduction/widgets/group_panel.dart | 2 - lib/pages/video/detail/reply_reply/view.dart | 1 - lib/pages/video/detail/view.dart | 6 --- lib/pages/video/detail/widgets/app_bar.dart | 2 - .../video/detail/widgets/header_control.dart | 3 -- .../detail/widgets/watch_later_list.dart | 1 - lib/pages/webview/view.dart | 7 +--- lib/pages/whisper/view.dart | 5 +-- 56 files changed, 76 insertions(+), 244 deletions(-) diff --git a/lib/common/pages_bottom_sheet.dart b/lib/common/pages_bottom_sheet.dart index 41e713b4..e4f23608 100644 --- a/lib/common/pages_bottom_sheet.dart +++ b/lib/common/pages_bottom_sheet.dart @@ -408,17 +408,29 @@ class TitleBar extends StatelessWidget { toolbarHeight: 45, automaticallyImplyLeading: false, centerTitle: false, - title: Text( - title, - style: Theme.of(context).textTheme.titleMedium, + elevation: 1, + scrolledUnderElevation: 1, + title: Padding( + padding: const EdgeInsets.only(left: 12), + child: Text( + title, + style: Theme.of(context).textTheme.titleMedium, + ), ), actions: !isFullScreen ? [ - IconButton( - icon: const Icon(Icons.close, size: 20), - onPressed: () => Navigator.pop(context), + SizedBox( + width: 35, + height: 35, + child: IconButton( + icon: const Icon(Icons.close, size: 20), + style: ButtonStyle( + padding: MaterialStateProperty.all(EdgeInsets.zero), + ), + onPressed: () => Navigator.pop(context), + ), ), - const SizedBox(width: 14), + const SizedBox(width: 8), ] : null, ); diff --git a/lib/main.dart b/lib/main.dart index 80dcf9f9..930b8f4b 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -222,13 +222,27 @@ class BuildMainApp extends StatelessWidget { elevation: 20, ); - return GetMaterialApp( - title: 'PiliPala', - theme: ThemeData( - colorScheme: currentThemeValue == ThemeType.dark - ? darkColorScheme - : lightColorScheme, + AppBarTheme appBarTheme(ColorScheme colorScheme) { + return AppBarTheme( + backgroundColor: currentThemeValue == ThemeType.dark + ? darkColorScheme.surface + : lightColorScheme.surface, + foregroundColor: currentThemeValue == ThemeType.dark + ? darkColorScheme.onSurface + : lightColorScheme.onSurface, + elevation: 0, + titleSpacing: 0, + scrolledUnderElevation: 0, + // titleTextStyle: TextStyle( + // fontSize: Theme.of(context).textTheme.titleLarge!.fontSize), + ); + } + + ThemeData buildThemeData(ColorScheme colorScheme) { + return ThemeData( + colorScheme: colorScheme, snackBarTheme: snackBarTheme, + appBarTheme: appBarTheme(colorScheme), pageTransitionsTheme: const PageTransitionsTheme( builders: { TargetPlatform.android: ZoomPageTransitionsBuilder( @@ -236,12 +250,20 @@ class BuildMainApp extends StatelessWidget { ), }, ), + ); + } + + return GetMaterialApp( + title: 'PiliPala', + theme: buildThemeData( + currentThemeValue == ThemeType.dark + ? darkColorScheme + : lightColorScheme, ), - darkTheme: ThemeData( - colorScheme: currentThemeValue == ThemeType.light + darkTheme: buildThemeData( + currentThemeValue == ThemeType.light ? lightColorScheme : darkColorScheme, - snackBarTheme: snackBarTheme, ), localizationsDelegates: const [ GlobalCupertinoLocalizations.delegate, diff --git a/lib/pages/about/index.dart b/lib/pages/about/index.dart index 3a8e5a0a..c7cc2c59 100644 --- a/lib/pages/about/index.dart +++ b/lib/pages/about/index.dart @@ -39,9 +39,7 @@ class _AboutPageState extends State { TextStyle subTitleStyle = TextStyle(fontSize: 13, color: Theme.of(context).colorScheme.outline); return Scaffold( - appBar: AppBar( - title: Text('关于', style: Theme.of(context).textTheme.titleMedium), - ), + appBar: AppBar(title: const Text('关于')), body: SingleChildScrollView( child: Column( children: [ diff --git a/lib/pages/blacklist/index.dart b/lib/pages/blacklist/index.dart index 96eff255..13bf2f9a 100644 --- a/lib/pages/blacklist/index.dart +++ b/lib/pages/blacklist/index.dart @@ -55,14 +55,9 @@ class _BlackListPageState extends State { Widget build(BuildContext context) { return Scaffold( appBar: AppBar( - elevation: 0, - scrolledUnderElevation: 0, - titleSpacing: 0, - centerTitle: false, title: Obx( () => Text( '黑名单管理 ${_blackListController.total.value == 0 ? '' : '- ${_blackListController.total.value}'}', - style: Theme.of(context).textTheme.titleMedium, ), ), ), diff --git a/lib/pages/dynamics/detail/view.dart b/lib/pages/dynamics/detail/view.dart index 9958a13b..b1f9bea8 100644 --- a/lib/pages/dynamics/detail/view.dart +++ b/lib/pages/dynamics/detail/view.dart @@ -111,14 +111,7 @@ class _DynamicDetailPageState extends State int rpid = replyItem.rpid!; Get.to( () => Scaffold( - appBar: AppBar( - titleSpacing: 0, - centerTitle: false, - title: Text( - '评论详情', - style: Theme.of(context).textTheme.titleMedium, - ), - ), + appBar: AppBar(title: const Text('评论详情')), body: VideoReplyReplyPanel( oid: oid, rpid: rpid, @@ -192,10 +185,7 @@ class _DynamicDetailPageState extends State Widget build(BuildContext context) { return Scaffold( appBar: AppBar( - elevation: 0, scrolledUnderElevation: 1, - centerTitle: false, - titleSpacing: 0, title: StreamBuilder( stream: titleStreamC.stream, initialData: false, diff --git a/lib/pages/dynamics/view.dart b/lib/pages/dynamics/view.dart index 257ecd49..51368e2f 100644 --- a/lib/pages/dynamics/view.dart +++ b/lib/pages/dynamics/view.dart @@ -78,8 +78,6 @@ class _DynamicsPageState extends State super.build(context); return Scaffold( appBar: AppBar( - elevation: 0, - scrolledUnderElevation: 0, title: SizedBox( height: 34, child: Stack( diff --git a/lib/pages/fan/view.dart b/lib/pages/fan/view.dart index 67a1eddd..c8354815 100644 --- a/lib/pages/fan/view.dart +++ b/lib/pages/fan/view.dart @@ -49,13 +49,8 @@ class _FansPageState extends State { Widget build(BuildContext context) { return Scaffold( appBar: AppBar( - elevation: 0, - scrolledUnderElevation: 0, - centerTitle: false, - titleSpacing: 0, title: Text( _fansController.isOwner.value ? '我的粉丝' : '${_fansController.name}的粉丝', - style: Theme.of(context).textTheme.titleMedium, ), ), body: RefreshIndicator( diff --git a/lib/pages/fav/view.dart b/lib/pages/fav/view.dart index 9d7534f5..f85b2075 100644 --- a/lib/pages/fav/view.dart +++ b/lib/pages/fav/view.dart @@ -40,11 +40,8 @@ class _FavPageState extends State { Widget build(BuildContext context) { return Scaffold( appBar: AppBar( - centerTitle: false, - titleSpacing: 0, title: Obx(() => Text( '${_favController.isOwner.value ? '我' : 'Ta'}的收藏', - style: Theme.of(context).textTheme.titleMedium, )), actions: [ Obx(() => !_favController.isOwner.value diff --git a/lib/pages/fav_edit/view.dart b/lib/pages/fav_edit/view.dart index 3ef7cda3..2fecf070 100644 --- a/lib/pages/fav_edit/view.dart +++ b/lib/pages/fav_edit/view.dart @@ -19,8 +19,6 @@ class _FavEditPageState extends State { Widget build(BuildContext context) { return Scaffold( appBar: AppBar( - elevation: 0, - scrolledUnderElevation: 0, title: Obx( () => _favEditController.type.value == 'add' ? Text( @@ -32,7 +30,6 @@ class _FavEditPageState extends State { style: Theme.of(context).textTheme.titleMedium, ), ), - centerTitle: false, actions: [ Obx( () => _favEditController.privacy.value == 0 diff --git a/lib/pages/fav_search/view.dart b/lib/pages/fav_search/view.dart index 2654ccb1..8c1d1faf 100644 --- a/lib/pages/fav_search/view.dart +++ b/lib/pages/fav_search/view.dart @@ -47,7 +47,6 @@ class _FavSearchPageState extends State { Widget build(BuildContext context) { return Scaffold( appBar: AppBar( - titleSpacing: 0, actions: [ IconButton( onPressed: () => _favSearchCtr.submit(), diff --git a/lib/pages/follow/view.dart b/lib/pages/follow/view.dart index 9633e7f0..e512a3b0 100644 --- a/lib/pages/follow/view.dart +++ b/lib/pages/follow/view.dart @@ -27,15 +27,10 @@ class _FollowPageState extends State { Widget build(BuildContext context) { return Scaffold( appBar: AppBar( - elevation: 0, - scrolledUnderElevation: 0, - titleSpacing: 0, - centerTitle: false, title: Text( _followController.isOwner.value ? '我的关注' : '${_followController.name}的关注', - style: Theme.of(context).textTheme.titleMedium, ), actions: [ IconButton( diff --git a/lib/pages/follow_search/view.dart b/lib/pages/follow_search/view.dart index 78cdb11d..11cf7abe 100644 --- a/lib/pages/follow_search/view.dart +++ b/lib/pages/follow_search/view.dart @@ -47,7 +47,6 @@ class _FollowSearchPageState extends State { Widget build(BuildContext context) { return Scaffold( appBar: AppBar( - titleSpacing: 0, actions: [ IconButton( onPressed: reRequest, diff --git a/lib/pages/history/view.dart b/lib/pages/history/view.dart index f9695aed..0728401b 100644 --- a/lib/pages/history/view.dart +++ b/lib/pages/history/view.dart @@ -69,12 +69,7 @@ class _HistoryPageState extends State { appBar: AppBarWidget( visible: _historyController.enableMultiple.value, child1: AppBar( - titleSpacing: 0, - centerTitle: false, - title: Text( - '观看记录', - style: Theme.of(context).textTheme.titleMedium, - ), + title: const Text('观看记录'), actions: [ IconButton( onPressed: () => Get.toNamed('/historySearch'), @@ -127,8 +122,6 @@ class _HistoryPageState extends State { ], ), child2: AppBar( - titleSpacing: 0, - centerTitle: false, leading: IconButton( onPressed: () { _historyController.enableMultiple.value = false; @@ -143,7 +136,6 @@ class _HistoryPageState extends State { title: Obx( () => Text( '已选择${_historyController.checkedCount.value}项', - style: Theme.of(context).textTheme.titleMedium, ), ), actions: [ diff --git a/lib/pages/history_search/view.dart b/lib/pages/history_search/view.dart index f5bcae64..3914b43d 100644 --- a/lib/pages/history_search/view.dart +++ b/lib/pages/history_search/view.dart @@ -45,7 +45,6 @@ class _HistorySearchPageState extends State { Widget build(BuildContext context) { return Scaffold( appBar: AppBar( - titleSpacing: 0, actions: [ IconButton( onPressed: () => _hisCtr.submit(), diff --git a/lib/pages/home/view.dart b/lib/pages/home/view.dart index 97378eaf..ca837aba 100644 --- a/lib/pages/home/view.dart +++ b/lib/pages/home/view.dart @@ -54,7 +54,6 @@ class _HomePageState extends State backgroundColor: Colors.transparent, appBar: AppBar( toolbarHeight: 0, - elevation: 0, backgroundColor: Colors.transparent, systemOverlayStyle: Platform.isAndroid ? SystemUiOverlayStyle( diff --git a/lib/pages/home/widgets/app_bar.dart b/lib/pages/home/widgets/app_bar.dart index 4bf5200a..8715a513 100644 --- a/lib/pages/home/widgets/app_bar.dart +++ b/lib/pages/home/widgets/app_bar.dart @@ -28,7 +28,6 @@ class HomeAppBar extends StatelessWidget { background: Column( children: [ AppBar( - centerTitle: false, title: const Text( 'PiLiPaLa', style: TextStyle( @@ -73,8 +72,6 @@ class HomeAppBar extends StatelessWidget { const SizedBox(width: 10) ], - elevation: 0, - scrolledUnderElevation: 0, ), ], ), diff --git a/lib/pages/html/view.dart b/lib/pages/html/view.dart index 2c3075c8..31afcdaa 100644 --- a/lib/pages/html/view.dart +++ b/lib/pages/html/view.dart @@ -104,14 +104,7 @@ class _HtmlRenderPageState extends State int rpid = replyItem.rpid!; Get.to( () => Scaffold( - appBar: AppBar( - titleSpacing: 0, - centerTitle: false, - title: Text( - '评论详情', - style: Theme.of(context).textTheme.titleMedium, - ), - ), + appBar: AppBar(title: const Text('评论详情')), body: VideoReplyReplyPanel( oid: oid, rpid: rpid, @@ -127,12 +120,7 @@ class _HtmlRenderPageState extends State Widget build(BuildContext context) { return Scaffold( appBar: AppBar( - centerTitle: false, - titleSpacing: 0, - title: Text( - title, - style: Theme.of(context).textTheme.titleMedium, - ), + title: Text(title), actions: [ const SizedBox(width: 4), IconButton( diff --git a/lib/pages/later/view.dart b/lib/pages/later/view.dart index 7a6fc424..8645c7ad 100644 --- a/lib/pages/later/view.dart +++ b/lib/pages/later/view.dart @@ -28,18 +28,12 @@ class _LaterPageState extends State { Widget build(BuildContext context) { return Scaffold( appBar: AppBar( - titleSpacing: 0, - centerTitle: false, title: Obx( () => _laterController.laterList.isNotEmpty ? Text( '稍后再看 (${_laterController.laterList.length})', - style: Theme.of(context).textTheme.titleMedium, ) - : Text( - '稍后再看', - style: Theme.of(context).textTheme.titleMedium, - ), + : const Text('稍后再看'), ), actions: [ Obx( diff --git a/lib/pages/live_follow/view.dart b/lib/pages/live_follow/view.dart index 2b116991..e58721e0 100644 --- a/lib/pages/live_follow/view.dart +++ b/lib/pages/live_follow/view.dart @@ -42,13 +42,8 @@ class _LiveFollowPageState extends State { Widget build(BuildContext context) { return Scaffold( appBar: AppBar( - elevation: 0, - scrolledUnderElevation: 0, - titleSpacing: 0, - centerTitle: false, title: Obx(() => Text( '${_liveFollowController.liveFollowingCount}人正在直播中', - style: Theme.of(context).textTheme.titleMedium, )), ), body: Container( diff --git a/lib/pages/live_room/view.dart b/lib/pages/live_room/view.dart index 1e0814e9..11864391 100644 --- a/lib/pages/live_room/view.dart +++ b/lib/pages/live_room/view.dart @@ -259,8 +259,6 @@ class _LiveRoomPageState extends State left: 0, right: 0, child: AppBar( - centerTitle: false, - titleSpacing: 0, backgroundColor: Colors.transparent, foregroundColor: Colors.white, toolbarHeight: isPortrait ? 56 : 0, diff --git a/lib/pages/live_room/widgets/bottom_control.dart b/lib/pages/live_room/widgets/bottom_control.dart index aa3d51b8..0bd5cfac 100644 --- a/lib/pages/live_room/widgets/bottom_control.dart +++ b/lib/pages/live_room/widgets/bottom_control.dart @@ -47,10 +47,7 @@ class _BottomControlState extends State { return AppBar( backgroundColor: Colors.transparent, foregroundColor: Colors.white, - elevation: 0, - scrolledUnderElevation: 0, primary: false, - centerTitle: false, automaticallyImplyLeading: false, titleSpacing: 14, title: Row( diff --git a/lib/pages/member_archive/view.dart b/lib/pages/member_archive/view.dart index 6963dad6..d19bc74e 100644 --- a/lib/pages/member_archive/view.dart +++ b/lib/pages/member_archive/view.dart @@ -47,12 +47,9 @@ class _MemberArchivePageState extends State { Widget build(BuildContext context) { return Scaffold( appBar: AppBar( - titleSpacing: 0, - centerTitle: false, title: Obx( () => Text( '${_memberArchivesController.isOwner.value ? '我' : 'Ta'}的投稿 - ${_memberArchivesController.currentOrder['label']}', - style: Theme.of(context).textTheme.titleMedium, ), ), actions: [ diff --git a/lib/pages/member_article/view.dart b/lib/pages/member_article/view.dart index 2557beba..7cb45c43 100644 --- a/lib/pages/member_article/view.dart +++ b/lib/pages/member_article/view.dart @@ -48,12 +48,9 @@ class _MemberArticlePageState extends State { Widget build(BuildContext context) { return Scaffold( appBar: AppBar( - titleSpacing: 0, - centerTitle: false, title: Obx( () => Text( '${_memberArticleController.isOwner.value ? '我' : 'Ta'}的图文', - style: Theme.of(context).textTheme.titleMedium, ), ), ), diff --git a/lib/pages/member_coin/widgets/item.dart b/lib/pages/member_coin/widgets/item.dart index 6d732694..2a8014c4 100644 --- a/lib/pages/member_coin/widgets/item.dart +++ b/lib/pages/member_coin/widgets/item.dart @@ -20,7 +20,6 @@ class MemberCoinsItem extends StatelessWidget { Widget build(BuildContext context) { String heroTag = Utils.makeHeroTag(coinItem.aid); return Card( - elevation: 0, clipBehavior: Clip.hardEdge, margin: EdgeInsets.zero, child: InkWell( diff --git a/lib/pages/member_dynamics/view.dart b/lib/pages/member_dynamics/view.dart index e6153b7b..d7031012 100644 --- a/lib/pages/member_dynamics/view.dart +++ b/lib/pages/member_dynamics/view.dart @@ -54,12 +54,9 @@ class _MemberDynamicsPageState extends State { Widget build(BuildContext context) { return Scaffold( appBar: AppBar( - titleSpacing: 0, - centerTitle: false, title: Obx( () => Text( '${_memberDynamicController.isOwner.value ? '我' : 'Ta'}的动态', - style: Theme.of(context).textTheme.titleMedium, ), ), ), diff --git a/lib/pages/member_search/view.dart b/lib/pages/member_search/view.dart index 192c7346..438c17c8 100644 --- a/lib/pages/member_search/view.dart +++ b/lib/pages/member_search/view.dart @@ -49,7 +49,6 @@ class _MemberSearchPageState extends State Widget build(BuildContext context) { return Scaffold( appBar: AppBar( - titleSpacing: 0, actions: [ IconButton( onPressed: () => _memberSearchCtr.submit(), diff --git a/lib/pages/member_seasons/view.dart b/lib/pages/member_seasons/view.dart index 244b0a67..689ddd34 100644 --- a/lib/pages/member_seasons/view.dart +++ b/lib/pages/member_seasons/view.dart @@ -41,12 +41,7 @@ class _MemberSeasonsPageState extends State { @override Widget build(BuildContext context) { return Scaffold( - appBar: AppBar( - titleSpacing: 0, - centerTitle: false, - title: Text(Get.parameters['seasonName']!, - style: Theme.of(context).textTheme.titleMedium), - ), + appBar: AppBar(title: Text(Get.parameters['seasonName']!)), body: Padding( padding: const EdgeInsets.only( left: StyleString.safeSpace, diff --git a/lib/pages/message/at/view.dart b/lib/pages/message/at/view.dart index 542b894c..11fdb5b5 100644 --- a/lib/pages/message/at/view.dart +++ b/lib/pages/message/at/view.dart @@ -47,9 +47,7 @@ class _MessageAtPageState extends State { @override Widget build(BuildContext context) { return Scaffold( - appBar: AppBar( - title: const Text('@我的'), - ), + appBar: AppBar(title: const Text('@我的')), body: RefreshIndicator( onRefresh: () async { await _messageAtCtr.queryMessageAt(type: 'init'); diff --git a/lib/pages/message/like/view.dart b/lib/pages/message/like/view.dart index c29a7cc8..f831282f 100644 --- a/lib/pages/message/like/view.dart +++ b/lib/pages/message/like/view.dart @@ -47,9 +47,7 @@ class _MessageLikePageState extends State { @override Widget build(BuildContext context) { return Scaffold( - appBar: AppBar( - title: const Text('收到的赞'), - ), + appBar: AppBar(title: const Text('收到的赞')), body: RefreshIndicator( onRefresh: () async { await _messageLikeCtr.queryMessageLike(type: 'init'); diff --git a/lib/pages/message/reply/view.dart b/lib/pages/message/reply/view.dart index 325b494f..408942fa 100644 --- a/lib/pages/message/reply/view.dart +++ b/lib/pages/message/reply/view.dart @@ -48,9 +48,7 @@ class _MessageReplyPageState extends State { @override Widget build(BuildContext context) { return Scaffold( - appBar: AppBar( - title: const Text('回复我的'), - ), + appBar: AppBar(title: const Text('回复我的')), body: RefreshIndicator( onRefresh: () async { await _messageReplyCtr.queryMessageReply(type: 'init'); diff --git a/lib/pages/message/system/view.dart b/lib/pages/message/system/view.dart index 8e62517d..66e60735 100644 --- a/lib/pages/message/system/view.dart +++ b/lib/pages/message/system/view.dart @@ -29,9 +29,7 @@ class _MessageSystemPageState extends State { @override Widget build(BuildContext context) { return Scaffold( - appBar: AppBar( - title: const Text('系统通知'), - ), + appBar: AppBar(title: const Text('系统通知')), body: RefreshIndicator( onRefresh: () async { await _messageSystemCtr.queryAndProcessMessages(); diff --git a/lib/pages/mine/view.dart b/lib/pages/mine/view.dart index 55e8e3a9..390bbdc6 100644 --- a/lib/pages/mine/view.dart +++ b/lib/pages/mine/view.dart @@ -44,8 +44,6 @@ class _MinePageState extends State super.build(context); return Scaffold( appBar: AppBar( - scrolledUnderElevation: 0, - elevation: 0, actions: [ IconButton( icon: const Icon(Icons.search_outlined), diff --git a/lib/pages/mine_edit/view.dart b/lib/pages/mine_edit/view.dart index 700c707e..22c548a7 100644 --- a/lib/pages/mine_edit/view.dart +++ b/lib/pages/mine_edit/view.dart @@ -23,9 +23,7 @@ class _MineEditPageState extends State { @override Widget build(BuildContext context) { return Scaffold( - appBar: AppBar( - title: const Text('编辑资料'), - ), + appBar: AppBar(title: const Text('编辑资料')), body: SingleChildScrollView( padding: const EdgeInsets.all(16.0), child: FutureBuilder( diff --git a/lib/pages/rank/view.dart b/lib/pages/rank/view.dart index cf7789a2..d5236d55 100644 --- a/lib/pages/rank/view.dart +++ b/lib/pages/rank/view.dart @@ -38,7 +38,6 @@ class _RankPageState extends State backgroundColor: Colors.transparent, appBar: AppBar( toolbarHeight: 0, - elevation: 0, backgroundColor: Colors.transparent, systemOverlayStyle: Platform.isAndroid ? SystemUiOverlayStyle( diff --git a/lib/pages/search/view.dart b/lib/pages/search/view.dart index 373edf15..b59520c7 100644 --- a/lib/pages/search/view.dart +++ b/lib/pages/search/view.dart @@ -49,7 +49,6 @@ class _SearchPageState extends State with RouteAware { width: 1, ), ), - titleSpacing: 0, actions: [ IconButton( onPressed: () => _searchController.submit(), diff --git a/lib/pages/search_result/view.dart b/lib/pages/search_result/view.dart index 9056905f..5bfb16fb 100644 --- a/lib/pages/search_result/view.dart +++ b/lib/pages/search_result/view.dart @@ -51,8 +51,6 @@ class _SearchResultPageState extends State width: 1, ), ), - titleSpacing: 0, - centerTitle: false, title: GestureDetector( onTap: () => Get.back(), child: SizedBox( diff --git a/lib/pages/setting/extra_setting.dart b/lib/pages/setting/extra_setting.dart index 44add757..07cd585a 100644 --- a/lib/pages/setting/extra_setting.dart +++ b/lib/pages/setting/extra_setting.dart @@ -131,14 +131,7 @@ class _ExtraSettingState extends State { .labelMedium! .copyWith(color: Theme.of(context).colorScheme.outline); return Scaffold( - appBar: AppBar( - centerTitle: false, - titleSpacing: 0, - title: Text( - '其他设置', - style: Theme.of(context).textTheme.titleMedium, - ), - ), + appBar: AppBar(title: const Text('其他设置')), body: ListView( children: [ const SetSwitchItem( diff --git a/lib/pages/setting/pages/color_select.dart b/lib/pages/setting/pages/color_select.dart index e144eb88..83b329d0 100644 --- a/lib/pages/setting/pages/color_select.dart +++ b/lib/pages/setting/pages/color_select.dart @@ -38,10 +38,7 @@ class _ColorSelectPageState extends State { @override Widget build(BuildContext context) { return Scaffold( - appBar: AppBar( - centerTitle: false, - title: const Text('选择应用主题'), - ), + appBar: AppBar(title: const Text('选择应用主题')), body: ListView( children: [ Obx( diff --git a/lib/pages/setting/pages/logs.dart b/lib/pages/setting/pages/logs.dart index f497aee5..29690a63 100644 --- a/lib/pages/setting/pages/logs.dart +++ b/lib/pages/setting/pages/logs.dart @@ -100,9 +100,7 @@ class _LogsPageState extends State { Widget build(BuildContext context) { return Scaffold( appBar: AppBar( - centerTitle: false, - titleSpacing: 0, - title: Text('日志', style: Theme.of(context).textTheme.titleMedium), + title: const Text('日志'), actions: [ PopupMenuButton( onSelected: (String type) { diff --git a/lib/pages/setting/pages/play_gesture_set.dart b/lib/pages/setting/pages/play_gesture_set.dart index b901ade9..bad115a5 100644 --- a/lib/pages/setting/pages/play_gesture_set.dart +++ b/lib/pages/setting/pages/play_gesture_set.dart @@ -34,14 +34,7 @@ class _PlayGesturePageState extends State { .labelMedium! .copyWith(color: Theme.of(context).colorScheme.outline); return Scaffold( - appBar: AppBar( - centerTitle: false, - titleSpacing: 0, - title: Text( - '手势设置', - style: Theme.of(context).textTheme.titleMedium, - ), - ), + appBar: AppBar(title: const Text('手势设置')), body: ListView( children: [ ListTile( diff --git a/lib/pages/setting/pages/play_speed_set.dart b/lib/pages/setting/pages/play_speed_set.dart index 4636d579..49a41a15 100644 --- a/lib/pages/setting/pages/play_speed_set.dart +++ b/lib/pages/setting/pages/play_speed_set.dart @@ -204,16 +204,7 @@ class _PlaySpeedPageState extends State { @override Widget build(BuildContext context) { return Scaffold( - appBar: AppBar( - elevation: 0, - scrolledUnderElevation: 0, - titleSpacing: 0, - centerTitle: false, - title: Text( - '倍速设置', - style: Theme.of(context).textTheme.titleMedium, - ), - ), + appBar: AppBar(title: const Text('倍速设置')), body: SingleChildScrollView( child: Column( crossAxisAlignment: CrossAxisAlignment.start, diff --git a/lib/pages/setting/play_setting.dart b/lib/pages/setting/play_setting.dart index bcf071dd..e191d8fd 100644 --- a/lib/pages/setting/play_setting.dart +++ b/lib/pages/setting/play_setting.dart @@ -67,14 +67,7 @@ class _PlaySettingState extends State { .labelMedium! .copyWith(color: Theme.of(context).colorScheme.outline); return Scaffold( - appBar: AppBar( - centerTitle: false, - titleSpacing: 0, - title: Text( - '播放设置', - style: Theme.of(context).textTheme.titleMedium, - ), - ), + appBar: AppBar(title: const Text('播放设置')), body: ListView( children: [ ListTile( diff --git a/lib/pages/setting/privacy_setting.dart b/lib/pages/setting/privacy_setting.dart index 493795c2..9b7f5f6e 100644 --- a/lib/pages/setting/privacy_setting.dart +++ b/lib/pages/setting/privacy_setting.dart @@ -32,14 +32,7 @@ class _PrivacySettingState extends State { .labelMedium! .copyWith(color: Theme.of(context).colorScheme.outline); return Scaffold( - appBar: AppBar( - centerTitle: false, - titleSpacing: 0, - title: Text( - '隐私设置', - style: Theme.of(context).textTheme.titleMedium, - ), - ), + appBar: AppBar(title: const Text('隐私设置')), body: Column( children: [ ListTile( diff --git a/lib/pages/setting/recommend_setting.dart b/lib/pages/setting/recommend_setting.dart index 91631db8..16d60d25 100644 --- a/lib/pages/setting/recommend_setting.dart +++ b/lib/pages/setting/recommend_setting.dart @@ -53,14 +53,7 @@ class _RecommendSettingState extends State { .labelMedium! .copyWith(color: Theme.of(context).colorScheme.outline); return Scaffold( - appBar: AppBar( - centerTitle: false, - titleSpacing: 0, - title: Text( - '推荐设置', - style: Theme.of(context).textTheme.titleMedium, - ), - ), + appBar: AppBar(title: const Text('推荐设置')), body: ListView( children: [ ListTile( diff --git a/lib/pages/setting/style_setting.dart b/lib/pages/setting/style_setting.dart index a94cef29..5b59397e 100644 --- a/lib/pages/setting/style_setting.dart +++ b/lib/pages/setting/style_setting.dart @@ -49,14 +49,7 @@ class _StyleSettingState extends State { .labelMedium! .copyWith(color: Theme.of(context).colorScheme.outline); return Scaffold( - appBar: AppBar( - centerTitle: false, - titleSpacing: 0, - title: Text( - '外观设置', - style: Theme.of(context).textTheme.titleMedium, - ), - ), + appBar: AppBar(title: const Text('外观设置')), body: ListView( children: [ Obx( diff --git a/lib/pages/setting/view.dart b/lib/pages/setting/view.dart index 19cdedaf..68e15ce1 100644 --- a/lib/pages/setting/view.dart +++ b/lib/pages/setting/view.dart @@ -9,14 +9,7 @@ class SettingPage extends StatelessWidget { Widget build(BuildContext context) { final SettingController settingController = Get.put(SettingController()); return Scaffold( - appBar: AppBar( - centerTitle: false, - titleSpacing: 0, - title: Text( - '设置', - style: Theme.of(context).textTheme.titleMedium, - ), - ), + appBar: AppBar(title: const Text('设置')), body: Column( children: [ ListTile( diff --git a/lib/pages/subscription/view.dart b/lib/pages/subscription/view.dart index 1bd91cdc..2e265d37 100644 --- a/lib/pages/subscription/view.dart +++ b/lib/pages/subscription/view.dart @@ -40,12 +40,8 @@ class _SubPageState extends State { Widget build(BuildContext context) { return Scaffold( appBar: AppBar( - centerTitle: false, - titleSpacing: 0, - title: Obx(() => Text( - '${_subController.isOwner.value ? '我' : 'Ta'}的订阅', - style: Theme.of(context).textTheme.titleMedium, - )), + title: + Obx(() => Text('${_subController.isOwner.value ? '我' : 'Ta'}的订阅')), ), body: FutureBuilder( future: _futureBuilderFuture, diff --git a/lib/pages/video/detail/introduction/widgets/fav_panel.dart b/lib/pages/video/detail/introduction/widgets/fav_panel.dart index 4a8f57ed..b5ede124 100644 --- a/lib/pages/video/detail/introduction/widgets/fav_panel.dart +++ b/lib/pages/video/detail/introduction/widgets/fav_panel.dart @@ -30,8 +30,6 @@ class _FavPanelState extends State { return Column( children: [ AppBar( - centerTitle: false, - elevation: 0, shape: const RoundedRectangleBorder( borderRadius: BorderRadius.vertical( top: Radius.circular(20), diff --git a/lib/pages/video/detail/introduction/widgets/group_panel.dart b/lib/pages/video/detail/introduction/widgets/group_panel.dart index 1292bcdc..89b0c9a8 100644 --- a/lib/pages/video/detail/introduction/widgets/group_panel.dart +++ b/lib/pages/video/detail/introduction/widgets/group_panel.dart @@ -57,8 +57,6 @@ class _GroupPanelState extends State { return Column( children: [ AppBar( - centerTitle: false, - elevation: 0, shape: const RoundedRectangleBorder( borderRadius: BorderRadius.vertical( top: Radius.circular(20), diff --git a/lib/pages/video/detail/reply_reply/view.dart b/lib/pages/video/detail/reply_reply/view.dart index aaa84fe6..c697349d 100644 --- a/lib/pages/video/detail/reply_reply/view.dart +++ b/lib/pages/video/detail/reply_reply/view.dart @@ -89,7 +89,6 @@ class _VideoReplyReplyPanelState extends State { return AppBar( toolbarHeight: 45, automaticallyImplyLeading: false, - centerTitle: false, title: Text( '评论详情', style: Theme.of(context).textTheme.titleSmall, diff --git a/lib/pages/video/detail/view.dart b/lib/pages/video/detail/view.dart index a176841e..75f50b61 100644 --- a/lib/pages/video/detail/view.dart +++ b/lib/pages/video/detail/view.dart @@ -614,8 +614,6 @@ class _VideoDetailPageState extends State builder: ((context, snapshot) { return AppBar( backgroundColor: Colors.black, - elevation: 0, - scrolledUnderElevation: 0, ); }), ), @@ -861,12 +859,8 @@ class _VideoDetailPageState extends State return AppBar( backgroundColor: Colors.transparent, // 使背景透明 foregroundColor: Colors.white, - elevation: 0, - scrolledUnderElevation: 0, primary: false, - centerTitle: false, automaticallyImplyLeading: false, - titleSpacing: 0, title: Container( height: kToolbarHeight, padding: const EdgeInsets.symmetric(horizontal: 14), diff --git a/lib/pages/video/detail/widgets/app_bar.dart b/lib/pages/video/detail/widgets/app_bar.dart index b16623ad..bf74ac13 100644 --- a/lib/pages/video/detail/widgets/app_bar.dart +++ b/lib/pages/video/detail/widgets/app_bar.dart @@ -33,8 +33,6 @@ class ScrollAppBar extends StatelessWidget { padding: EdgeInsets.only(top: statusBarHeight), child: AppBar( primary: false, - elevation: 0, - scrolledUnderElevation: 0, centerTitle: true, title: TextButton( onPressed: () => callback(), diff --git a/lib/pages/video/detail/widgets/header_control.dart b/lib/pages/video/detail/widgets/header_control.dart index f2857398..f22bf846 100644 --- a/lib/pages/video/detail/widgets/header_control.dart +++ b/lib/pages/video/detail/widgets/header_control.dart @@ -1155,10 +1155,7 @@ class _HeaderControlState extends State { return AppBar( backgroundColor: Colors.transparent, foregroundColor: Colors.white, - elevation: 0, - scrolledUnderElevation: 0, primary: false, - centerTitle: false, automaticallyImplyLeading: false, titleSpacing: 14, title: Row( diff --git a/lib/pages/video/detail/widgets/watch_later_list.dart b/lib/pages/video/detail/widgets/watch_later_list.dart index eda6cf3e..93326ec3 100644 --- a/lib/pages/video/detail/widgets/watch_later_list.dart +++ b/lib/pages/video/detail/widgets/watch_later_list.dart @@ -85,7 +85,6 @@ class _MediaListPanelState extends State { AppBar( toolbarHeight: 45, automaticallyImplyLeading: false, - centerTitle: false, title: Text( widget.panelTitle ?? '稍后再看', style: Theme.of(context).textTheme.titleSmall, diff --git a/lib/pages/webview/view.dart b/lib/pages/webview/view.dart index cba40ad1..ec7e777d 100644 --- a/lib/pages/webview/view.dart +++ b/lib/pages/webview/view.dart @@ -19,12 +19,7 @@ class _WebviewPageState extends State { Widget build(BuildContext context) { return Scaffold( appBar: AppBar( - centerTitle: false, - titleSpacing: 0, - title: Text( - _webviewController.pageTitle, - style: Theme.of(context).textTheme.titleMedium, - ), + title: Text(_webviewController.pageTitle), actions: [ const SizedBox(width: 4), IconButton( diff --git a/lib/pages/whisper/view.dart b/lib/pages/whisper/view.dart index 721ffbe2..75e6e1c2 100644 --- a/lib/pages/whisper/view.dart +++ b/lib/pages/whisper/view.dart @@ -1,6 +1,5 @@ import 'package:easy_debounce/easy_throttle.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:get/get.dart'; import 'package:pilipala/common/constants.dart'; import 'package:pilipala/common/skeleton/skeleton.dart'; @@ -45,9 +44,7 @@ class _WhisperPageState extends State { @override Widget build(BuildContext context) { return Scaffold( - appBar: AppBar( - title: const Text('消息'), - ), + appBar: AppBar(title: const Text('消息')), body: RefreshIndicator( onRefresh: () async { _whisperController.unread(); From d8b1ee1b2a1efbeae5fe11952aa87033ccf001b5 Mon Sep 17 00:00:00 2001 From: guozhigq Date: Sat, 16 Nov 2024 13:44:41 +0800 Subject: [PATCH 14/27] opt: appScheme --- android/app/src/main/AndroidManifest.xml | 55 +----------------------- ios/Podfile.lock | 6 --- lib/utils/app_scheme.dart | 30 +++---------- pubspec.lock | 8 ---- pubspec.yaml | 1 - 5 files changed, 8 insertions(+), 92 deletions(-) diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index c948bc8f..46b34c20 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -12,7 +12,6 @@ - @@ -20,7 +19,6 @@ "android.support.customtabs.action.CustomTabsService" /> - @@ -34,7 +32,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + \ No newline at end of file diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 86cb7071..27baf9e5 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -1,8 +1,6 @@ PODS: - app_links (0.0.2): - Flutter - - appscheme (1.0.4): - - Flutter - audio_service (0.0.1): - Flutter - audio_session (0.0.1): @@ -71,7 +69,6 @@ PODS: DEPENDENCIES: - app_links (from `.symlinks/plugins/app_links/ios`) - - appscheme (from `.symlinks/plugins/appscheme/ios`) - audio_service (from `.symlinks/plugins/audio_service/ios`) - audio_session (from `.symlinks/plugins/audio_session/ios`) - auto_orientation (from `.symlinks/plugins/auto_orientation/ios`) @@ -110,8 +107,6 @@ SPEC REPOS: EXTERNAL SOURCES: app_links: :path: ".symlinks/plugins/app_links/ios" - appscheme: - :path: ".symlinks/plugins/appscheme/ios" audio_service: :path: ".symlinks/plugins/audio_service/ios" audio_session: @@ -171,7 +166,6 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: app_links: e7a6750a915a9e161c58d91bc610e8cd1d4d0ad0 - appscheme: b1c3f8862331cb20430cf9e0e4af85dbc1572ad8 audio_service: f509d65da41b9521a61f1c404dd58651f265a567 audio_session: 4f3e461722055d21515cf3261b64c973c062f345 auto_orientation: 102ed811a5938d52c86520ddd7ecd3a126b5d39d diff --git a/lib/utils/app_scheme.dart b/lib/utils/app_scheme.dart index 70e7c79d..e1fc94e3 100644 --- a/lib/utils/app_scheme.dart +++ b/lib/utils/app_scheme.dart @@ -1,5 +1,4 @@ import 'package:app_links/app_links.dart'; -import 'package:appscheme/appscheme.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; @@ -12,37 +11,20 @@ import 'utils.dart'; class PiliSchame { static late AppLinks appLinks; - static AppScheme appScheme = AppSchemeImpl.getInstance()!; static Future init() async { appLinks = AppLinks(); appLinks.uriLinkStream.listen((Uri uri) { final String scheme = uri.scheme; if (RegExp(r'^pili', caseSensitive: false).hasMatch(scheme)) { piliScheme(uri); - } - }); - - appScheme.getInitScheme().then((SchemeEntity? value) { - if (value != null) { - routePush(value); - } - }); - - appScheme.getLatestScheme().then((SchemeEntity? value) { - if (value != null) { - routePush(value); - } - }); - - appScheme.registerSchemeListener().listen((SchemeEntity? event) { - if (event != null) { - routePush(event); + } else { + routePush(uri); } }); } /// 路由跳转 - static void routePush(value) async { + static void routePush(Uri value) async { final String scheme = value.scheme; if (scheme == 'bilibili') { biliScheme(value); @@ -212,9 +194,9 @@ class PiliSchame { } } - static Future biliScheme(SchemeEntity value) async { - final String host = value.host!; - final String path = value.path!; + static Future biliScheme(Uri value) async { + final String host = value.host; + final String path = value.path; switch (host) { case 'root': Navigator.popUntil( diff --git a/pubspec.lock b/pubspec.lock index b0839e19..a3dd3af9 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -49,14 +49,6 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "1.0.4" - appscheme: - dependency: "direct main" - description: - name: appscheme - sha256: b885b65219f3839ebafc937024a1bc5ce5a75b0e458fd249ef15e80e81235b6f - url: "https://pub.flutter-io.cn" - source: hosted - version: "1.0.8" archive: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index db58395b..b2275398 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -111,7 +111,6 @@ dependencies: # 高帧率 flutter_displaymode: ^0.6.0 # scheme跳转 - appscheme: ^1.0.8 app_links: ^6.3.2 # 弹幕 ns_danmaku: From f932175a1f758ab3c0d55a6bed830ee8dfd46d06 Mon Sep 17 00:00:00 2001 From: guozhigq Date: Sat, 16 Nov 2024 14:54:57 +0800 Subject: [PATCH 15/27] opt: dynamic comment push --- lib/pages/message/at/view.dart | 2 +- lib/pages/message/like/view.dart | 2 +- lib/pages/message/reply/view.dart | 32 ++++++++++++++++++++++++++---- lib/pages/message/utils/index.dart | 13 +++++++++--- lib/utils/app_scheme.dart | 10 ++++++++-- 5 files changed, 48 insertions(+), 11 deletions(-) diff --git a/lib/pages/message/at/view.dart b/lib/pages/message/at/view.dart index 11fdb5b5..4efa1014 100644 --- a/lib/pages/message/at/view.dart +++ b/lib/pages/message/at/view.dart @@ -127,7 +127,7 @@ class AtItem extends StatelessWidget { return InkWell( onTap: () async { - MessageUtils.onClickMessage(context, uri, nativeUri, type); + MessageUtils.onClickMessage(context, uri, nativeUri, type, null); }, child: Padding( padding: const EdgeInsets.all(14), diff --git a/lib/pages/message/like/view.dart b/lib/pages/message/like/view.dart index f831282f..42c5a2ed 100644 --- a/lib/pages/message/like/view.dart +++ b/lib/pages/message/like/view.dart @@ -125,7 +125,7 @@ class LikeItem extends StatelessWidget { final String type = item.item!.type!; return InkWell( onTap: () async { - MessageUtils.onClickMessage(context, uri, nativeUri, type); + MessageUtils.onClickMessage(context, uri, nativeUri, type, null); }, child: Stack( children: [ diff --git a/lib/pages/message/reply/view.dart b/lib/pages/message/reply/view.dart index 408942fa..0cc95f6b 100644 --- a/lib/pages/message/reply/view.dart +++ b/lib/pages/message/reply/view.dart @@ -117,7 +117,7 @@ class ReplyItem extends StatelessWidget { final String type = item.item!.type!; return InkWell( onTap: () async { - MessageUtils.onClickMessage(context, uri, nativeUri, type); + MessageUtils.onClickMessage(context, uri, nativeUri, type, item.item!); }, child: Padding( padding: const EdgeInsets.all(14), @@ -155,6 +155,9 @@ class ReplyItem extends StatelessWidget { text: '回复了我的评论', style: TextStyle(color: outline), ), + if (item.item!.type! == 'dynamic') + TextSpan( + text: '对我的动态发表了评论', style: TextStyle(color: outline)), ])), const SizedBox(height: 6), Text.rich( @@ -197,11 +200,32 @@ class ReplyItem extends StatelessWidget { ), ), if (item.item!.type! == 'video') - NetworkImgLayer( + // NetworkImgLayer( + // width: 60, + // height: 60, + // src: item.item!.image, + // radius: 6, + // ), + Container( width: 60, height: 60, - src: item.item!.image, - radius: 6, + clipBehavior: Clip.hardEdge, + decoration: const BoxDecoration( + borderRadius: BorderRadius.all(Radius.circular(6)), + ), + child: Image.network(item.item!.image!, fit: BoxFit.cover), + ), + if (item.item!.type! == 'dynamic') + Container( + width: 60, + height: 80, + padding: const EdgeInsets.all(4), + child: Text( + item.item!.title!, + maxLines: 4, + style: const TextStyle(fontSize: 12, letterSpacing: 0.3), + overflow: TextOverflow.ellipsis, + ), ), ], ), diff --git a/lib/pages/message/utils/index.dart b/lib/pages/message/utils/index.dart index d45203ba..88fe8aa6 100644 --- a/lib/pages/message/utils/index.dart +++ b/lib/pages/message/utils/index.dart @@ -3,6 +3,7 @@ import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:get/get.dart'; import 'package:pilipala/http/search.dart'; import 'package:pilipala/models/common/reply_type.dart'; +import 'package:pilipala/models/msg/reply.dart'; import 'package:pilipala/pages/video/detail/reply_reply/index.dart'; import 'package:pilipala/utils/app_scheme.dart'; import 'package:pilipala/utils/utils.dart'; @@ -10,7 +11,12 @@ import 'package:pilipala/utils/utils.dart'; class MessageUtils { // 回复我的、收到的赞点击 static void onClickMessage( - BuildContext context, Uri uri, Uri nativeUri, String type) async { + BuildContext context, + Uri uri, + Uri nativeUri, + String type, + ReplyContentItem? item, + ) async { final String path = uri.path; final String bvid = path.split('/').last; String? sourceType; @@ -24,8 +30,8 @@ class MessageUtils { if (nativePath.contains('detail')) { // 动态详情 sourceType = 'opus'; - oid = nativePath.split('/')[3]; - commentRootId = nativePath.split('/')[4]; + oid = item?.subjectId!.toString() ?? nativePath.split('/')[3]; + commentRootId = item?.sourceId!.toString() ?? nativePath.split('/')[4]; } switch (type) { case 'video': @@ -47,6 +53,7 @@ class MessageUtils { } break; case 'reply': + case 'dynamic': debugPrint('commentRootId: $oid, $commentRootId'); navigateToComment( context, diff --git a/lib/utils/app_scheme.dart b/lib/utils/app_scheme.dart index e1fc94e3..48341b5e 100644 --- a/lib/utils/app_scheme.dart +++ b/lib/utils/app_scheme.dart @@ -282,8 +282,14 @@ class PiliSchame { } break; default: - SmartDialog.showToast('未匹配地址,请联系开发者'); - Clipboard.setData(ClipboardData(text: value.toString())); + final Map queryParameters = value.queryParameters; + final String? enterUri = queryParameters['enterUri']; + if (enterUri != null && enterUri.startsWith('bilibili://')) { + biliScheme(Uri.parse(enterUri)); + } else { + SmartDialog.showToast('未匹配地址,请联系开发者'); + Clipboard.setData(ClipboardData(text: value.toString())); + } break; } } From bdedd78e307501ebd5d9f08c284fa77e151e1079 Mon Sep 17 00:00:00 2001 From: guozhigq Date: Sat, 16 Nov 2024 15:18:19 +0800 Subject: [PATCH 16/27] opt: dynamic comment push --- lib/http/dynamics.dart | 2 +- lib/pages/message/utils/index.dart | 13 +++++++++++++ lib/utils/app_scheme.dart | 12 +++--------- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/lib/http/dynamics.dart b/lib/http/dynamics.dart index 5ba5675e..53ba6fc1 100644 --- a/lib/http/dynamics.dart +++ b/lib/http/dynamics.dart @@ -92,7 +92,7 @@ class DynamicsHttp { // static Future dynamicDetail({ - String? id, + required String id, }) async { var res = await Request().get(Api.dynamicDetail, data: { 'timezone_offset': -480, diff --git a/lib/pages/message/utils/index.dart b/lib/pages/message/utils/index.dart index 88fe8aa6..d2e88b5c 100644 --- a/lib/pages/message/utils/index.dart +++ b/lib/pages/message/utils/index.dart @@ -1,9 +1,12 @@ import 'package:flutter/material.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:get/get.dart'; +import 'package:pilipala/http/dynamics.dart'; import 'package:pilipala/http/search.dart'; import 'package:pilipala/models/common/reply_type.dart'; +import 'package:pilipala/models/dynamics/result.dart'; import 'package:pilipala/models/msg/reply.dart'; +import 'package:pilipala/pages/dynamics/index.dart'; import 'package:pilipala/pages/video/detail/reply_reply/index.dart'; import 'package:pilipala/utils/app_scheme.dart'; import 'package:pilipala/utils/utils.dart'; @@ -162,4 +165,14 @@ class MessageUtils { } return result; } + + // 跳转查看动态详情 + static void navigateToDynamicDetail(String opusId) async { + DynamicsController dynamicsController = Get.put(DynamicsController()); + var res = await DynamicsHttp.dynamicDetail(id: opusId); + if (res['status']) { + DynamicItemModel item = res['data']; + dynamicsController.pushDetail(item, 1); + } + } } diff --git a/lib/utils/app_scheme.dart b/lib/utils/app_scheme.dart index 48341b5e..c1dcb213 100644 --- a/lib/utils/app_scheme.dart +++ b/lib/utils/app_scheme.dart @@ -3,6 +3,7 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:get/get.dart'; +import 'package:pilipala/pages/message/utils/index.dart'; import 'package:pilipala/utils/route_push.dart'; import '../http/search.dart'; import 'id_utils.dart'; @@ -270,15 +271,8 @@ class PiliSchame { break; case 'following': if (path.startsWith('/detail')) { - var opusId = path.split('/').last; - Get.toNamed( - '/webview', - parameters: { - 'url': 'https://m.bilibili.com/opus/$opusId', - 'type': 'url', - 'pageTitle': '' - }, - ); + final String opusId = path.split('/').last; + MessageUtils.navigateToDynamicDetail(opusId); } break; default: From bfbae8199716143e8267664accd7e184e8911626 Mon Sep 17 00:00:00 2001 From: guozhigq Date: Sat, 16 Nov 2024 15:35:48 +0800 Subject: [PATCH 17/27] fix: Request get options.headers null error --- lib/http/init.dart | 3 ++- lib/pages/member_archive/view.dart | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/http/init.dart b/lib/http/init.dart index 0868570f..db56fa70 100644 --- a/lib/http/init.dart +++ b/lib/http/init.dart @@ -212,7 +212,8 @@ class Request { if (extra != null) { if (extra['ua'] != null) { options ??= Options(); - options.headers!['user-agent'] = headerUa(type: extra['ua']); + options.headers ??= {}; + options.headers?['user-agent'] = headerUa(type: extra['ua']); } } try { diff --git a/lib/pages/member_archive/view.dart b/lib/pages/member_archive/view.dart index d19bc74e..94018e62 100644 --- a/lib/pages/member_archive/view.dart +++ b/lib/pages/member_archive/view.dart @@ -117,7 +117,7 @@ class _MemberArchivePageState extends State { } } else { return HttpError( - errMsg: snapshot.data['msg'], + errMsg: snapshot.data?['msg'] ?? '请求异常', fn: () {}, ); } From e5d3e84b612c03b70643b51140199bd7043589e6 Mon Sep 17 00:00:00 2001 From: guozhigq Date: Sun, 17 Nov 2024 14:05:04 +0800 Subject: [PATCH 18/27] opt: videoDetail appbar --- lib/pages/video/detail/view.dart | 48 +++++++++++++++------ lib/pages/video/detail/widgets/app_bar.dart | 21 ++++----- 2 files changed, 42 insertions(+), 27 deletions(-) diff --git a/lib/pages/video/detail/view.dart b/lib/pages/video/detail/view.dart index 75f50b61..1585a6f3 100644 --- a/lib/pages/video/detail/view.dart +++ b/lib/pages/video/detail/view.dart @@ -123,14 +123,7 @@ class _VideoDetailPageState extends State // 流 appbarStreamListen() { appbarStream = StreamController.broadcast(); - _extendNestCtr.addListener( - () { - final double offset = _extendNestCtr.position.pixels; - vdCtr.sheetHeight.value = - Get.size.height - videoHeight - statusBarHeight + offset; - appbarStream.add(offset); - }, - ); + _extendNestCtr.addListener(_extendNestCtrListener); } // 播放器状态监听 @@ -225,6 +218,14 @@ class _VideoDetailPageState extends State statusHeight = await StatusBarControl.getHeight; } + // _extendNestCtr监听 + void _extendNestCtrListener() { + final double offset = _extendNestCtr.position.pixels; + vdCtr.sheetHeight.value = + Get.size.height - videoHeight - statusBarHeight + offset; + appbarStream.add(offset); + } + @override void dispose() { shutdownTimerService.handleWaitingFinished(); @@ -243,6 +244,7 @@ class _VideoDetailPageState extends State appbarStream.close(); WidgetsBinding.instance.removeObserver(this); _lifecycleListener.dispose(); + _extendNestCtr.removeListener(_extendNestCtrListener); super.dispose(); } @@ -594,6 +596,28 @@ class _VideoDetailPageState extends State ); } + Widget buildAppBar(BuildContext context, AsyncSnapshot snapshot) { + final double distance = + statusBarHeight + MediaQuery.of(context).padding.top; + return AppBar( + backgroundColor: Colors.black, + systemOverlayStyle: Platform.isAndroid + ? SystemUiOverlayStyle( + statusBarIconBrightness: + Theme.of(context).brightness == Brightness.dark + ? Brightness.light + : (snapshot.data! > distance + ? Brightness.dark + : Brightness.light), + ) + : Theme.of(context).brightness == Brightness.dark + ? SystemUiOverlayStyle.light + : (snapshot.data! > distance + ? SystemUiOverlayStyle.dark + : SystemUiOverlayStyle.light), + ); + } + Widget childWhenDisabled = SafeArea( top: MediaQuery.of(context).orientation == Orientation.portrait && plPlayerController?.isFullScreen.value == true, @@ -611,11 +635,7 @@ class _VideoDetailPageState extends State child: StreamBuilder( stream: appbarStream.stream.distinct(), initialData: 0, - builder: ((context, snapshot) { - return AppBar( - backgroundColor: Colors.black, - ); - }), + builder: buildAppBar, ), ), body: ExtendedNestedScrollView( @@ -773,7 +793,7 @@ class _VideoDetailPageState extends State builder: ((context, snapshot) { return ScrollAppBar( snapshot.data!.toDouble(), - () => continuePlay(), + continuePlay, playerStatus.value, null, ); diff --git a/lib/pages/video/detail/widgets/app_bar.dart b/lib/pages/video/detail/widgets/app_bar.dart index bf74ac13..6fdd72f6 100644 --- a/lib/pages/video/detail/widgets/app_bar.dart +++ b/lib/pages/video/detail/widgets/app_bar.dart @@ -34,21 +34,16 @@ class ScrollAppBar extends StatelessWidget { child: AppBar( primary: false, centerTitle: true, - title: TextButton( + title: TextButton.icon( onPressed: () => callback(), - child: Row( - mainAxisSize: MainAxisSize.min, - children: [ - const Icon(Icons.play_arrow_rounded), - Text( - playerStatus == PlayerStatus.paused - ? '继续播放' - : playerStatus == PlayerStatus.completed - ? '重新播放' - : '播放中', - ) - ], + label: Text( + playerStatus == PlayerStatus.paused + ? '继续播放' + : playerStatus == PlayerStatus.completed + ? '重新播放' + : '播放中', ), + icon: const Icon(Icons.play_arrow_rounded), ), // actions: [ // IconButton( From 88d8027b60e40d8e38c2b56f07dbb687f83dd17e Mon Sep 17 00:00:00 2001 From: guozhigq Date: Sun, 17 Nov 2024 15:59:54 +0800 Subject: [PATCH 19/27] opt: vertical video layout --- lib/pages/video/detail/controller.dart | 12 +++++++----- lib/pages/video/detail/view.dart | 18 +++++++++++++++--- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/lib/pages/video/detail/controller.dart b/lib/pages/video/detail/controller.dart index e09dd20f..0f66ad02 100644 --- a/lib/pages/video/detail/controller.dart +++ b/lib/pages/video/detail/controller.dart @@ -125,6 +125,8 @@ class VideoDetailController extends GetxController RxInt watchLaterCount = 0.obs; List skipSegments = []; int? lastPosition; + // 默认屏幕方向 + RxString videoDirection = 'horizontal'.obs; @override void onInit() { @@ -283,6 +285,10 @@ class VideoDetailController extends GetxController } else { ScreenBrightness().resetScreenBrightness(); } + videoDirection.value = (firstVideo.width != null && + firstVideo.height != null) + ? (firstVideo.width! > firstVideo.height! ? 'horizontal' : 'vertical') + : 'horizontal'; await plPlayerController.setDataSource( DataSource( videoSource: video ?? videoUrl, @@ -299,11 +305,7 @@ class VideoDetailController extends GetxController seekTo: seekToTime ?? defaultST, duration: duration ?? Duration(milliseconds: data.timeLength ?? 0), // 宽>高 水平 否则 垂直 - direction: firstVideo.width != null && firstVideo.height != null - ? ((firstVideo.width! - firstVideo.height!) > 0 - ? 'horizontal' - : 'vertical') - : null, + direction: videoDirection.value, bvid: bvid, cid: cid.value, enableHeart: enableHeart, diff --git a/lib/pages/video/detail/view.dart b/lib/pages/video/detail/view.dart index 1585a6f3..91f942d5 100644 --- a/lib/pages/video/detail/view.dart +++ b/lib/pages/video/detail/view.dart @@ -221,9 +221,15 @@ class _VideoDetailPageState extends State // _extendNestCtr监听 void _extendNestCtrListener() { final double offset = _extendNestCtr.position.pixels; - vdCtr.sheetHeight.value = - Get.size.height - videoHeight - statusBarHeight + offset; - appbarStream.add(offset); + if (vdCtr.videoDirection.value == 'horizontal') { + vdCtr.sheetHeight.value = + Get.size.height - videoHeight - statusBarHeight + offset; + appbarStream.add(offset); + } else { + if (offset > (Get.size.width * 22 / 16 - videoHeight)) { + appbarStream.add(offset - (Get.size.width * 22 / 16 - videoHeight)); + } + } } @override @@ -501,6 +507,12 @@ class _VideoDetailPageState extends State final double pinnedHeaderHeight = statusBarHeight + kToolbarHeight + videoHeight.value; // ignore: no_leading_underscores_for_local_identifiers + vdCtr.videoDirection.listen((p0) { + if (p0 == 'vertical') { + defaultVideoHeight = sizeContext.width * 22 / 16; + videoHeight.value = sizeContext.width * 22 / 16; + } + }); // 竖屏 final bool isPortrait = _context.orientation == Orientation.portrait; From c3ef35f150d1857ba2e85cb36043f229b6934949 Mon Sep 17 00:00:00 2001 From: guozhigq Date: Sun, 17 Nov 2024 19:45:06 +0800 Subject: [PATCH 20/27] mod: cancel player fullScreenCb --- lib/pages/video/detail/view.dart | 4 ---- 1 file changed, 4 deletions(-) diff --git a/lib/pages/video/detail/view.dart b/lib/pages/video/detail/view.dart index 91f942d5..599ad07c 100644 --- a/lib/pages/video/detail/view.dart +++ b/lib/pages/video/detail/view.dart @@ -555,10 +555,6 @@ class _VideoDetailPageState extends State showEposideCb: () => vdCtr.videoType == SearchType.video ? videoIntroController.showEposideHandler() : bangumiIntroController.showEposideHandler(), - fullScreenCb: (bool status) { - videoHeight.value = - status ? Get.size.height : defaultVideoHeight; - }, )); } From 570a073963dcf7f8148823fe965cd967b089818c Mon Sep 17 00:00:00 2001 From: guozhigq Date: Sun, 17 Nov 2024 19:56:14 +0800 Subject: [PATCH 21/27] mod: AppBarTheme --- lib/main.dart | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index 930b8f4b..1ec86c8e 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -224,12 +224,8 @@ class BuildMainApp extends StatelessWidget { AppBarTheme appBarTheme(ColorScheme colorScheme) { return AppBarTheme( - backgroundColor: currentThemeValue == ThemeType.dark - ? darkColorScheme.surface - : lightColorScheme.surface, - foregroundColor: currentThemeValue == ThemeType.dark - ? darkColorScheme.onSurface - : lightColorScheme.onSurface, + backgroundColor: colorScheme.surface, + foregroundColor: colorScheme.onSurface, elevation: 0, titleSpacing: 0, scrolledUnderElevation: 0, From 1252b609a9f0075fa1a046bb2c434b2b0eed1739 Mon Sep 17 00:00:00 2001 From: guozhigq Date: Sun, 17 Nov 2024 22:18:53 +0800 Subject: [PATCH 22/27] mod: userInfo data type --- lib/http/init.dart | 3 ++- lib/http/member.dart | 5 +++-- lib/pages/bangumi/controller.dart | 7 ++++--- lib/pages/bangumi/introduction/controller.dart | 5 +++-- lib/pages/bangumi/introduction/view.dart | 2 +- lib/pages/bangumi/widgets/bangumi_panel.dart | 5 +++-- lib/pages/dynamics/controller.dart | 5 +++-- lib/pages/dynamics/widgets/action_panel.dart | 2 +- lib/pages/fan/controller.dart | 9 +++++---- lib/pages/follow/controller.dart | 11 ++++++----- lib/pages/home/controller.dart | 7 ++++--- lib/pages/home/widgets/app_bar.dart | 3 ++- lib/pages/main/controller.dart | 5 +++-- lib/pages/member/controller.dart | 5 +++-- lib/pages/mine_edit/controller.dart | 3 ++- lib/pages/setting/controller.dart | 4 ++-- lib/pages/setting/privacy_setting.dart | 3 ++- lib/pages/setting/recommend_setting.dart | 3 ++- lib/pages/video/detail/controller.dart | 5 +++-- lib/pages/video/detail/introduction/controller.dart | 7 +++---- lib/pages/whisper_detail/controller.dart | 5 +++-- lib/pages/whisper_detail/view.dart | 3 --- 22 files changed, 60 insertions(+), 47 deletions(-) diff --git a/lib/http/init.dart b/lib/http/init.dart index db56fa70..8a11034c 100644 --- a/lib/http/init.dart +++ b/lib/http/init.dart @@ -9,6 +9,7 @@ import 'package:dio/dio.dart'; import 'package:dio/io.dart'; import 'package:dio_cookie_manager/dio_cookie_manager.dart'; import 'package:hive/hive.dart'; +import 'package:pilipala/models/user/info.dart'; import 'package:pilipala/utils/id_utils.dart'; import '../utils/storage.dart'; import '../utils/utils.dart'; @@ -43,7 +44,7 @@ class Request { dio.interceptors.add(cookieManager); final List cookie = await cookieManager.cookieJar .loadForRequest(Uri.parse(HttpString.baseUrl)); - final userInfo = userInfoCache.get('userInfoCache'); + final UserInfoData? userInfo = userInfoCache.get('userInfoCache'); if (userInfo != null && userInfo.mid != null) { final List cookie2 = await cookieManager.cookieJar .loadForRequest(Uri.parse(HttpString.tUrl)); diff --git a/lib/http/member.dart b/lib/http/member.dart index 53e14eae..66d0ff47 100644 --- a/lib/http/member.dart +++ b/lib/http/member.dart @@ -4,6 +4,7 @@ import 'package:hive/hive.dart'; import 'package:html/parser.dart'; import 'package:pilipala/models/member/article.dart'; import 'package:pilipala/models/member/like.dart'; +import 'package:pilipala/models/user/info.dart'; import 'package:pilipala/utils/global_data_cache.dart'; import '../common/constants.dart'; import '../models/dynamics/result.dart'; @@ -472,9 +473,9 @@ class MemberHttp { String accessKey = res.data['data']['access_token']; Box localCache = GStorage.localCache; Box userInfoCache = GStorage.userInfo; - var userInfo = userInfoCache.get('userInfoCache'); + final UserInfoData? userInfo = userInfoCache.get('userInfoCache'); localCache.put( - LocalCacheKey.accessKey, {'mid': userInfo.mid, 'value': accessKey}); + LocalCacheKey.accessKey, {'mid': userInfo!.mid, 'value': accessKey}); return {'status': true, 'data': [], 'msg': '操作成功'}; } else { return { diff --git a/lib/pages/bangumi/controller.dart b/lib/pages/bangumi/controller.dart index 746808bf..e7582cfc 100644 --- a/lib/pages/bangumi/controller.dart +++ b/lib/pages/bangumi/controller.dart @@ -3,6 +3,7 @@ import 'package:get/get.dart'; import 'package:hive/hive.dart'; import 'package:pilipala/http/bangumi.dart'; import 'package:pilipala/models/bangumi/list.dart'; +import 'package:pilipala/models/user/info.dart'; import 'package:pilipala/utils/storage.dart'; class BangumiController extends GetxController { @@ -15,14 +16,14 @@ class BangumiController extends GetxController { Box userInfoCache = GStorage.userInfo; RxBool userLogin = false.obs; late int mid; - var userInfo; + UserInfoData? userInfo; @override void onInit() { super.onInit(); userInfo = userInfoCache.get('userInfoCache'); if (userInfo != null) { - mid = userInfo.mid; + mid = userInfo!.mid!; } userLogin.value = userInfo != null; } @@ -55,7 +56,7 @@ class BangumiController extends GetxController { if (userInfo == null) { return; } - var result = await BangumiHttp.getRecentBangumi(mid: userInfo.mid); + var result = await BangumiHttp.getRecentBangumi(mid: userInfo!.mid!); if (result['status']) { bangumiFollowList.value = result['data'].list; total.value = result['data'].total; diff --git a/lib/pages/bangumi/introduction/controller.dart b/lib/pages/bangumi/introduction/controller.dart index 2e6cd392..f06e6ee8 100644 --- a/lib/pages/bangumi/introduction/controller.dart +++ b/lib/pages/bangumi/introduction/controller.dart @@ -8,6 +8,7 @@ import 'package:pilipala/http/search.dart'; import 'package:pilipala/http/video.dart'; import 'package:pilipala/models/bangumi/info.dart'; import 'package:pilipala/models/user/fav_folder.dart'; +import 'package:pilipala/models/user/info.dart'; import 'package:pilipala/pages/video/detail/index.dart'; import 'package:pilipala/pages/video/detail/reply/index.dart'; import 'package:pilipala/plugin/pl_player/models/play_repeat.dart'; @@ -57,7 +58,7 @@ class BangumiIntroController extends GetxController { RxBool isFollowed = false.obs; RxInt followStatus = 1.obs; int _tempThemeValue = -1; - var userInfo; + UserInfoData? userInfo; PersistentBottomSheetController? bottomSheetController; List> followStatusList = [ {'title': '标记为 「想看」', 'status': 1}, @@ -259,7 +260,7 @@ class BangumiIntroController extends GetxController { Future queryVideoInFolder() async { var result = await VideoHttp.videoInFolder( - mid: userInfo.mid, rid: IdUtils.bv2av(bvid)); + mid: userInfo!.mid!, rid: IdUtils.bv2av(bvid)); if (result['status']) { favFolderData.value = result['data']; } diff --git a/lib/pages/bangumi/introduction/view.dart b/lib/pages/bangumi/introduction/view.dart index 3ad0625f..75e293c4 100644 --- a/lib/pages/bangumi/introduction/view.dart +++ b/lib/pages/bangumi/introduction/view.dart @@ -148,7 +148,7 @@ class _BangumiInfoState extends State { // 收藏 showFavBottomSheet() async { - if (bangumiIntroController.userInfo.mid == null) { + if (bangumiIntroController.userInfo?.mid == null) { SmartDialog.showToast('账号未登录'); return; } diff --git a/lib/pages/bangumi/widgets/bangumi_panel.dart b/lib/pages/bangumi/widgets/bangumi_panel.dart index f6f1ff22..63da14fd 100644 --- a/lib/pages/bangumi/widgets/bangumi_panel.dart +++ b/lib/pages/bangumi/widgets/bangumi_panel.dart @@ -5,6 +5,7 @@ import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:get/get.dart'; import 'package:hive/hive.dart'; import 'package:pilipala/models/bangumi/info.dart'; +import 'package:pilipala/models/user/info.dart'; import 'package:pilipala/pages/video/detail/index.dart'; import 'package:pilipala/utils/storage.dart'; import '../../../common/pages_bottom_sheet.dart'; @@ -37,7 +38,7 @@ class _BangumiPanelState extends State { late RxInt currentIndex = (-1).obs; final ScrollController listViewScrollCtr = ScrollController(); Box userInfoCache = GStorage.userInfo; - dynamic userInfo; + UserInfoData? userInfo; // 默认未开通 int vipStatus = 0; late int cid; @@ -63,7 +64,7 @@ class _BangumiPanelState extends State { /// 获取大会员状态 userInfo = userInfoCache.get('userInfoCache'); if (userInfo != null) { - vipStatus = userInfo.vipStatus; + vipStatus = userInfo!.vipStatus!; } } diff --git a/lib/pages/dynamics/controller.dart b/lib/pages/dynamics/controller.dart index ff5c959a..cdc08bdd 100644 --- a/lib/pages/dynamics/controller.dart +++ b/lib/pages/dynamics/controller.dart @@ -10,6 +10,7 @@ import 'package:pilipala/models/common/dynamics_type.dart'; import 'package:pilipala/models/dynamics/result.dart'; import 'package:pilipala/models/dynamics/up.dart'; import 'package:pilipala/models/live/item.dart'; +import 'package:pilipala/models/user/info.dart'; import 'package:pilipala/utils/feed_back.dart'; import 'package:pilipala/utils/id_utils.dart'; import 'package:pilipala/utils/route_push.dart'; @@ -52,7 +53,7 @@ class DynamicsController extends GetxController { RxInt initialValue = 0.obs; Box userInfoCache = GStorage.userInfo; RxBool userLogin = false.obs; - var userInfo; + UserInfoData? userInfo; RxBool isLoadingDynamic = false.obs; Box setting = GStorage.setting; @@ -246,7 +247,7 @@ class DynamicsController extends GetxController { } upData.value.upList!.insertAll(0, [ UpItem(face: '', uname: '全部动态', mid: -1), - UpItem(face: userInfo.face, uname: '我', mid: userInfo.mid), + UpItem(face: userInfo!.face, uname: '我', mid: userInfo!.mid), ]); } return res; diff --git a/lib/pages/dynamics/widgets/action_panel.dart b/lib/pages/dynamics/widgets/action_panel.dart index f403ee19..26c0d7a1 100644 --- a/lib/pages/dynamics/widgets/action_panel.dart +++ b/lib/pages/dynamics/widgets/action_panel.dart @@ -90,7 +90,7 @@ class _ActionPanelState extends State SmartDialog.showToast('请先登录'); return; } - int mid = userInfo.mid; + int mid = userInfo.mid!; showModalBottomSheet( context: context, enableDrag: true, diff --git a/lib/pages/fan/controller.dart b/lib/pages/fan/controller.dart index 1a82b538..f9a9388f 100644 --- a/lib/pages/fan/controller.dart +++ b/lib/pages/fan/controller.dart @@ -3,6 +3,7 @@ import 'package:get/get.dart'; import 'package:hive/hive.dart'; import 'package:pilipala/http/fan.dart'; import 'package:pilipala/models/fans/result.dart'; +import 'package:pilipala/models/user/info.dart'; import 'package:pilipala/utils/storage.dart'; class FansController extends GetxController { @@ -13,7 +14,7 @@ class FansController extends GetxController { RxList fansList = [].obs; late int mid; late String name; - var userInfo; + UserInfoData? userInfo; RxString loadingText = '加载中...'.obs; RxBool isOwner = false.obs; @@ -23,9 +24,9 @@ class FansController extends GetxController { userInfo = userInfoCache.get('userInfoCache'); mid = Get.parameters['mid'] != null ? int.parse(Get.parameters['mid']!) - : userInfo.mid; - isOwner.value = mid == userInfo.mid; - name = Get.parameters['name'] ?? userInfo.uname; + : userInfo!.mid!; + isOwner.value = mid == userInfo?.mid; + name = Get.parameters['name'] ?? userInfo?.uname ?? ''; } Future queryFans(type) async { diff --git a/lib/pages/follow/controller.dart b/lib/pages/follow/controller.dart index e39eb3cd..04bba2f9 100644 --- a/lib/pages/follow/controller.dart +++ b/lib/pages/follow/controller.dart @@ -6,6 +6,7 @@ import 'package:pilipala/http/follow.dart'; import 'package:pilipala/http/member.dart'; import 'package:pilipala/models/follow/result.dart'; import 'package:pilipala/models/member/tags.dart'; +import 'package:pilipala/models/user/info.dart'; import 'package:pilipala/utils/storage.dart'; /// 查看自己的关注时,可以查看分类 @@ -18,7 +19,7 @@ class FollowController extends GetxController with GetTickerProviderStateMixin { RxList followList = [].obs; late int mid; late String name; - var userInfo; + UserInfoData? userInfo; RxString loadingText = '加载中...'.obs; RxBool isOwner = false.obs; late List followTags; @@ -30,9 +31,9 @@ class FollowController extends GetxController with GetTickerProviderStateMixin { userInfo = userInfoCache.get('userInfoCache'); mid = Get.parameters['mid'] != null ? int.parse(Get.parameters['mid']!) - : userInfo.mid; - isOwner.value = mid == userInfo.mid; - name = Get.parameters['name'] ?? userInfo.uname; + : userInfo!.mid!; + isOwner.value = mid == userInfo?.mid; + name = Get.parameters['name'] ?? userInfo?.uname ?? ''; } Future queryFollowings(type) async { @@ -68,7 +69,7 @@ class FollowController extends GetxController with GetTickerProviderStateMixin { // 当查看当前用户的关注时,请求关注分组 Future followUpTags() async { - if (userInfo != null && mid == userInfo.mid) { + if (userInfo != null && mid == userInfo!.mid) { var res = await MemberHttp.followUpTags(); if (res['status']) { followTags = res['data']; diff --git a/lib/pages/home/controller.dart b/lib/pages/home/controller.dart index 91f16c9f..0797f499 100644 --- a/lib/pages/home/controller.dart +++ b/lib/pages/home/controller.dart @@ -4,6 +4,7 @@ import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:hive/hive.dart'; import 'package:pilipala/models/common/tab_type.dart'; +import 'package:pilipala/models/user/info.dart'; import 'package:pilipala/utils/storage.dart'; import '../../http/index.dart'; @@ -18,7 +19,7 @@ class HomeController extends GetxController with GetTickerProviderStateMixin { Box settingStorage = GStorage.setting; RxBool userLogin = false.obs; RxString userFace = ''.obs; - var userInfo; + UserInfoData? userInfo; Box setting = GStorage.setting; late final StreamController searchBarStream = StreamController.broadcast(); @@ -33,7 +34,7 @@ class HomeController extends GetxController with GetTickerProviderStateMixin { super.onInit(); userInfo = userInfoCache.get('userInfoCache'); userLogin.value = userInfo != null; - userFace.value = userInfo != null ? userInfo.face : ''; + userFace.value = userInfo != null ? userInfo!.face! : ''; hideSearchBar = setting.get(SettingBoxKey.hideSearchBar, defaultValue: false); if (setting.get(SettingBoxKey.enableSearchWord, defaultValue: true)) { @@ -62,7 +63,7 @@ class HomeController extends GetxController with GetTickerProviderStateMixin { userInfo = await userInfoCache.get('userInfoCache'); userLogin.value = val ?? false; if (val) return; - userFace.value = userInfo != null ? userInfo.face : ''; + userFace.value = userInfo != null ? userInfo!.face! : ''; } void setTabConfig() async { diff --git a/lib/pages/home/widgets/app_bar.dart b/lib/pages/home/widgets/app_bar.dart index 8715a513..4f15cb30 100644 --- a/lib/pages/home/widgets/app_bar.dart +++ b/lib/pages/home/widgets/app_bar.dart @@ -3,6 +3,7 @@ import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:hive/hive.dart'; import 'package:pilipala/common/widgets/network_img_layer.dart'; +import 'package:pilipala/models/user/info.dart'; import 'package:pilipala/utils/storage.dart'; Box userInfoCache = GStorage.userInfo; @@ -12,7 +13,7 @@ class HomeAppBar extends StatelessWidget { @override Widget build(BuildContext context) { - var userInfo = userInfoCache.get('userInfoCache'); + final UserInfoData? userInfo = userInfoCache.get('userInfoCache'); return SliverAppBar( // forceElevated: true, scrolledUnderElevation: 0, diff --git a/lib/pages/main/controller.dart b/lib/pages/main/controller.dart index 3a3cc9eb..b89fe403 100644 --- a/lib/pages/main/controller.dart +++ b/lib/pages/main/controller.dart @@ -7,6 +7,7 @@ import 'package:flutter/material.dart'; import 'package:hive/hive.dart'; import 'package:pilipala/common/widgets/network_img_layer.dart'; import 'package:pilipala/http/common.dart'; +import 'package:pilipala/models/user/info.dart'; import 'package:pilipala/utils/storage.dart'; import 'package:pilipala/utils/utils.dart'; import '../../models/common/dynamic_badge_mode.dart'; @@ -26,7 +27,7 @@ class MainController extends GetxController { late PageController pageController; int selectedIndex = 0; Box userInfoCache = GStorage.userInfo; - dynamic userInfo; + UserInfoData? userInfo; RxBool userLogin = false.obs; late Rx dynamicBadgeType = DynamicBadgeMode.number.obs; late bool enableGradientBg; @@ -85,7 +86,7 @@ class MainController extends GetxController { } if (mineItemIndex != -1 && userInfo != null) { Widget avatar = NetworkImgLayer( - width: 28, height: 28, src: userInfo.face, type: 'avatar'); + width: 28, height: 28, src: userInfo!.face, type: 'avatar'); navigationBars[mineItemIndex]['icon'] = avatar; navigationBars[mineItemIndex]['selectIcon'] = avatar; } diff --git a/lib/pages/member/controller.dart b/lib/pages/member/controller.dart index 6e66b5ed..3c63d560 100644 --- a/lib/pages/member/controller.dart +++ b/lib/pages/member/controller.dart @@ -9,6 +9,7 @@ import 'package:pilipala/models/member/archive.dart'; import 'package:pilipala/models/member/coin.dart'; import 'package:pilipala/models/member/info.dart'; import 'package:pilipala/models/member/like.dart'; +import 'package:pilipala/models/user/info.dart'; import 'package:pilipala/utils/storage.dart'; import 'package:share_plus/share_plus.dart'; @@ -22,7 +23,7 @@ class MemberController extends GetxController { late int ownerMid; // 投稿列表 RxList? archiveList = [].obs; - dynamic userInfo; + UserInfoData? userInfo; RxInt attribute = (-1).obs; RxString attributeText = '关注'.obs; RxList recentCoinsList = [].obs; @@ -34,7 +35,7 @@ class MemberController extends GetxController { super.onInit(); mid = int.tryParse(Get.parameters['mid']!) ?? -2; userInfo = userInfoCache.get('userInfoCache'); - ownerMid = userInfo != null ? userInfo.mid : -1; + ownerMid = userInfo != null ? userInfo!.mid! : -1; isOwner.value = mid == ownerMid; face.value = Get.arguments['face'] ?? ''; heroTag = Get.arguments['heroTag'] ?? ''; diff --git a/lib/pages/mine_edit/controller.dart b/lib/pages/mine_edit/controller.dart index 148aaccc..79e1e32a 100644 --- a/lib/pages/mine_edit/controller.dart +++ b/lib/pages/mine_edit/controller.dart @@ -3,6 +3,7 @@ import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:get/get.dart'; import 'package:hive/hive.dart'; import 'package:pilipala/http/user.dart'; +import 'package:pilipala/models/user/info.dart'; import 'package:pilipala/utils/storage.dart'; class MineEditController extends GetxController { @@ -13,7 +14,7 @@ class MineEditController extends GetxController { final TextEditingController signCtr = TextEditingController(); final TextEditingController birthdayCtr = TextEditingController(); String? sex; - dynamic userInfo; + UserInfoData? userInfo; @override void onInit() { diff --git a/lib/pages/setting/controller.dart b/lib/pages/setting/controller.dart index ca027832..459a36a2 100644 --- a/lib/pages/setting/controller.dart +++ b/lib/pages/setting/controller.dart @@ -2,8 +2,8 @@ import 'package:flutter/material.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:get/get.dart'; import 'package:hive/hive.dart'; -import 'package:pilipala/http/init.dart'; import 'package:pilipala/models/common/theme_type.dart'; +import 'package:pilipala/models/user/info.dart'; import 'package:pilipala/utils/feed_back.dart'; import 'package:pilipala/utils/login.dart'; import 'package:pilipala/utils/storage.dart'; @@ -22,7 +22,7 @@ class SettingController extends GetxController { RxDouble toastOpacity = (1.0).obs; RxInt picQuality = 10.obs; Rx themeType = ThemeType.system.obs; - var userInfo; + UserInfoData? userInfo; Rx dynamicBadgeType = DynamicBadgeMode.number.obs; RxInt defaultHomePage = 0.obs; diff --git a/lib/pages/setting/privacy_setting.dart b/lib/pages/setting/privacy_setting.dart index 9b7f5f6e..3b70e86c 100644 --- a/lib/pages/setting/privacy_setting.dart +++ b/lib/pages/setting/privacy_setting.dart @@ -3,6 +3,7 @@ import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:get/get.dart'; import 'package:hive/hive.dart'; import 'package:pilipala/http/member.dart'; +import 'package:pilipala/models/user/info.dart'; import 'package:pilipala/utils/storage.dart'; class PrivacySetting extends StatefulWidget { @@ -15,7 +16,7 @@ class PrivacySetting extends StatefulWidget { class _PrivacySettingState extends State { bool userLogin = false; Box userInfoCache = GStorage.userInfo; - var userInfo; + UserInfoData? userInfo; @override void initState() { diff --git a/lib/pages/setting/recommend_setting.dart b/lib/pages/setting/recommend_setting.dart index 16d60d25..89e670c8 100644 --- a/lib/pages/setting/recommend_setting.dart +++ b/lib/pages/setting/recommend_setting.dart @@ -3,6 +3,7 @@ import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:hive/hive.dart'; import 'package:pilipala/http/member.dart'; import 'package:pilipala/models/common/rcmd_type.dart'; +import 'package:pilipala/models/user/info.dart'; import 'package:pilipala/pages/setting/widgets/select_dialog.dart'; import 'package:pilipala/utils/recommend_filter.dart'; import 'package:pilipala/utils/storage.dart'; @@ -21,7 +22,7 @@ class _RecommendSettingState extends State { static Box localCache = GStorage.localCache; late dynamic defaultRcmdType; Box userInfoCache = GStorage.userInfo; - late dynamic userInfo; + UserInfoData? userInfo; bool userLogin = false; late dynamic accessKeyInfo; // late int filterUnfollowedRatio; diff --git a/lib/pages/video/detail/controller.dart b/lib/pages/video/detail/controller.dart index 0f66ad02..da3b0cbc 100644 --- a/lib/pages/video/detail/controller.dart +++ b/lib/pages/video/detail/controller.dart @@ -14,6 +14,7 @@ import 'package:pilipala/models/common/reply_type.dart'; import 'package:pilipala/models/common/search_type.dart'; import 'package:pilipala/models/sponsor_block/segment.dart'; import 'package:pilipala/models/sponsor_block/segment_type.dart'; +import 'package:pilipala/models/user/info.dart'; import 'package:pilipala/models/video/later.dart'; import 'package:pilipala/models/video/play/quality.dart'; import 'package:pilipala/models/video/play/url.dart'; @@ -94,7 +95,7 @@ class VideoDetailController extends GetxController double? brightness; // 默认记录历史记录 bool enableHeart = true; - var userInfo; + UserInfoData? userInfo; late bool isFirstTime = true; Floating? floating; late PreferredSizeWidget headerControl; @@ -617,7 +618,7 @@ class VideoDetailController extends GetxController var count = argMap['count']; var res = await UserHttp.getMediaList( type: 2, - bizId: userInfo.mid, + bizId: userInfo!.mid!, ps: count, ); if (res['status']) { diff --git a/lib/pages/video/detail/introduction/controller.dart b/lib/pages/video/detail/introduction/controller.dart index 5ddede96..24bd7db0 100644 --- a/lib/pages/video/detail/introduction/controller.dart +++ b/lib/pages/video/detail/introduction/controller.dart @@ -9,6 +9,7 @@ import 'package:pilipala/http/constants.dart'; import 'package:pilipala/http/user.dart'; import 'package:pilipala/http/video.dart'; import 'package:pilipala/models/user/fav_folder.dart'; +import 'package:pilipala/models/user/info.dart'; import 'package:pilipala/models/video/ai.dart'; import 'package:pilipala/models/video/tags.dart'; import 'package:pilipala/models/video_detail_res.dart'; @@ -49,10 +50,8 @@ class VideoIntroController extends GetxController { List delMediaIdsNew = []; // 关注状态 默认未关注 RxMap followStatus = {}.obs; - int _tempThemeValue = -1; - RxInt lastPlayCid = 0.obs; - var userInfo; + UserInfoData? userInfo; RxList videoTags = [].obs; // 同时观看 @@ -301,7 +300,7 @@ class VideoIntroController extends GetxController { Future queryVideoInFolder() async { var result = await VideoHttp.videoInFolder( - mid: userInfo.mid, rid: IdUtils.bv2av(bvid)); + mid: userInfo!.mid!, rid: IdUtils.bv2av(bvid)); if (result['status']) { favFolderData.value = result['data']; } diff --git a/lib/pages/whisper_detail/controller.dart b/lib/pages/whisper_detail/controller.dart index 54d6a2c4..24a0f8c2 100644 --- a/lib/pages/whisper_detail/controller.dart +++ b/lib/pages/whisper_detail/controller.dart @@ -6,6 +6,7 @@ import 'package:get/get.dart'; import 'package:hive/hive.dart'; import 'package:pilipala/http/msg.dart'; import 'package:pilipala/models/msg/session.dart'; +import 'package:pilipala/models/user/info.dart'; import 'package:pilipala/pages/whisper/index.dart'; import '../../utils/feed_back.dart'; import '../../utils/storage.dart'; @@ -80,7 +81,7 @@ class WhisperDetailController extends GetxController { Future sendMsg() async { feedBack(); String message = replyContentController.text; - final userInfo = userInfoCache.get('userInfoCache'); + final UserInfoData? userInfo = userInfoCache.get('userInfoCache'); if (userInfo == null) { SmartDialog.showToast('请先登录'); return; @@ -90,7 +91,7 @@ class WhisperDetailController extends GetxController { return; } var result = await MsgHttp.sendMsg( - senderUid: userInfo.mid, + senderUid: userInfo.mid!, receiverId: int.parse(mid), content: {'content': message}, msgType: 1, diff --git a/lib/pages/whisper_detail/view.dart b/lib/pages/whisper_detail/view.dart index f79c241d..3c3d9f18 100644 --- a/lib/pages/whisper_detail/view.dart +++ b/lib/pages/whisper_detail/view.dart @@ -2,14 +2,12 @@ import 'dart:async'; import 'dart:math'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; -import 'package:hive/hive.dart'; import 'package:pilipala/common/widgets/network_img_layer.dart'; import 'package:pilipala/models/video/reply/emote.dart'; import 'package:pilipala/pages/emote/index.dart'; import 'package:pilipala/pages/video/detail/reply_new/toolbar_icon_button.dart'; import 'package:pilipala/pages/whisper_detail/controller.dart'; import 'package:pilipala/utils/feed_back.dart'; -import '../../utils/storage.dart'; import 'widget/chat_item.dart'; class WhisperDetailPage extends StatefulWidget { @@ -30,7 +28,6 @@ class _WhisperDetailPageState extends State late double emoteHeight = 230.0; double keyboardHeight = 0.0; // 键盘高度 RxString toolbarType = ''.obs; - Box userInfoCache = GStorage.userInfo; @override void initState() { From 5c8a822c2fceff24af14a65fd5fe619b47c3db5a Mon Sep 17 00:00:00 2001 From: guozhigq Date: Sun, 17 Nov 2024 22:33:53 +0800 Subject: [PATCH 23/27] opt: seasons layout --- lib/pages/member_seasons/controller.dart | 3 +- lib/pages/member_seasons/view.dart | 42 ++++++++++++++++++++---- 2 files changed, 38 insertions(+), 7 deletions(-) diff --git a/lib/pages/member_seasons/controller.dart b/lib/pages/member_seasons/controller.dart index ef85398b..07532787 100644 --- a/lib/pages/member_seasons/controller.dart +++ b/lib/pages/member_seasons/controller.dart @@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:pilipala/http/member.dart'; import 'package:pilipala/models/member/seasons.dart'; +import 'package:pilipala/utils/global_data_cache.dart'; class MemberSeasonsController extends GetxController { final ScrollController scrollController = ScrollController(); @@ -58,7 +59,7 @@ class MemberSeasonsController extends GetxController { mid: mid, seriesId: seriesId!, pn: pn, - currentMid: 17340771, + currentMid: GlobalDataCache().userInfo?.mid ?? -1, ); if (res['status']) { seasonsList.addAll(res['data'].seriesList); diff --git a/lib/pages/member_seasons/view.dart b/lib/pages/member_seasons/view.dart index 689ddd34..6bda2278 100644 --- a/lib/pages/member_seasons/view.dart +++ b/lib/pages/member_seasons/view.dart @@ -2,6 +2,8 @@ import 'package:easy_debounce/easy_throttle.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:pilipala/common/constants.dart'; +import 'package:pilipala/common/skeleton/video_card_h.dart'; +import 'package:pilipala/common/widgets/http_error.dart'; import 'controller.dart'; import 'widgets/item.dart'; @@ -54,9 +56,9 @@ class _MemberSeasonsPageState extends State { builder: (context, snapshot) { if (snapshot.connectionState == ConnectionState.done) { if (snapshot.data != null) { - Map data = snapshot.data as Map; + Map? data = snapshot.data; List list = _memberSeasonsController.seasonsList; - if (data['status']) { + if (data?['status']) { return Obx( () => list.isNotEmpty ? LayoutBuilder( @@ -82,16 +84,44 @@ class _MemberSeasonsPageState extends State { ); }, ) - : const SizedBox(), + : const HttpError( + errMsg: '没有数据', + isInSliver: false, + isShowBtn: false, + ), ); } else { - return const SizedBox(); + return HttpError( + errMsg: snapshot.data['msg'], + isInSliver: false, + fn: () { + setState(() { + _futureBuilderFuture = + _memberSeasonsController.onRefresh(); + }); + }, + ); } } else { - return const SizedBox(); + return HttpError( + errMsg: snapshot.data['msg'] ?? '请求异常', + isInSliver: false, + fn: () { + setState(() { + _futureBuilderFuture = + _memberSeasonsController.onRefresh(); + }); + }, + ); } } else { - return const SizedBox(); + return ListView.builder( + itemCount: 10, + shrinkWrap: true, + itemBuilder: (context, index) { + return const VideoCardHSkeleton(); + }, + ); } }, ), From d6247fad98b4d743038fa164d2c1454f600a8880 Mon Sep 17 00:00:00 2001 From: guozhigq Date: Sun, 17 Nov 2024 22:45:51 +0800 Subject: [PATCH 24/27] mod: verticalHeight calc --- lib/pages/video/detail/view.dart | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/pages/video/detail/view.dart b/lib/pages/video/detail/view.dart index 599ad07c..0fb97066 100644 --- a/lib/pages/video/detail/view.dart +++ b/lib/pages/video/detail/view.dart @@ -502,15 +502,16 @@ class _VideoDetailPageState extends State Widget build(BuildContext context) { final sizeContext = MediaQuery.sizeOf(context); final _context = MediaQuery.of(context); - late double defaultVideoHeight = sizeContext.width * 9 / 16; + late final double verticalHeight = sizeContext.width * 22 / 16; + late double defaultVideoHeight = vdCtr.videoDirection.value == 'vertical' + ? verticalHeight + : sizeContext.width * 9 / 16; late RxDouble videoHeight = defaultVideoHeight.obs; final double pinnedHeaderHeight = statusBarHeight + kToolbarHeight + videoHeight.value; - // ignore: no_leading_underscores_for_local_identifiers vdCtr.videoDirection.listen((p0) { if (p0 == 'vertical') { - defaultVideoHeight = sizeContext.width * 22 / 16; - videoHeight.value = sizeContext.width * 22 / 16; + videoHeight.value = defaultVideoHeight = verticalHeight; } }); From 16fa4677423b95dd829b087b6c0104c92afa6d87 Mon Sep 17 00:00:00 2001 From: guozhigq Date: Tue, 19 Nov 2024 23:50:45 +0800 Subject: [PATCH 25/27] refactor: GlobalDataCache --- lib/common/widgets/network_img_layer.dart | 2 +- lib/http/member.dart | 8 +-- lib/main.dart | 2 +- lib/pages/dynamics/widgets/up_panel.dart | 2 +- lib/pages/main/view.dart | 2 +- lib/pages/member_archive/controller.dart | 5 +- lib/pages/member_article/controller.dart | 5 +- lib/pages/member_dynamics/controller.dart | 5 +- lib/pages/member_seasons/controller.dart | 2 +- lib/pages/search/controller.dart | 8 +-- lib/pages/setting/extra_setting.dart | 4 +- lib/pages/setting/pages/action_menu_set.dart | 2 +- lib/pages/setting/pages/play_gesture_set.dart | 4 +- lib/pages/setting/play_setting.dart | 2 +- lib/pages/setting/style_setting.dart | 2 +- lib/pages/video/detail/introduction/view.dart | 6 +-- .../detail/reply/widgets/reply_item.dart | 4 +- lib/pages/video/detail/widgets/ai_detail.dart | 2 +- lib/plugin/pl_player/controller.dart | 38 +++++++------- lib/plugin/pl_player/view.dart | 4 +- lib/utils/global_data_cache.dart | 52 +++++++++---------- lib/utils/login.dart | 2 +- 22 files changed, 79 insertions(+), 84 deletions(-) diff --git a/lib/common/widgets/network_img_layer.dart b/lib/common/widgets/network_img_layer.dart index 4980e2fc..b7b5de7e 100644 --- a/lib/common/widgets/network_img_layer.dart +++ b/lib/common/widgets/network_img_layer.dart @@ -48,7 +48,7 @@ class NetworkImgLayer extends StatelessWidget { Widget build(BuildContext context) { int defaultImgQuality = 10; try { - defaultImgQuality = GlobalDataCache().imgQuality; + defaultImgQuality = GlobalDataCache.imgQuality; } catch (_) {} if (src == '' || src == null) { diff --git a/lib/http/member.dart b/lib/http/member.dart index 66d0ff47..107a9379 100644 --- a/lib/http/member.dart +++ b/lib/http/member.dart @@ -26,7 +26,7 @@ class MemberHttp { }) async { String? wWebid; if ((await getWWebid(mid: mid))['status']) { - wWebid = GlobalDataCache().wWebid; + wWebid = GlobalDataCache.wWebid; } Map params = await WbiSign().makSign({ @@ -574,7 +574,7 @@ class MemberHttp { } static Future getWWebid({required int mid}) async { - String? wWebid = GlobalDataCache().wWebid; + String? wWebid = GlobalDataCache.wWebid; if (wWebid != null) { return {'status': true, 'data': wWebid}; } @@ -588,7 +588,7 @@ class MemberHttp { final content = match.group(1); String decodedString = Uri.decodeComponent(content!); Map map = jsonDecode(decodedString); - GlobalDataCache().wWebid = map['access_id']; + GlobalDataCache.wWebid = map['access_id']; return {'status': true, 'data': map['access_id']}; } else { return {'status': false, 'data': '请检查登录状态'}; @@ -605,7 +605,7 @@ class MemberHttp { }) async { String? wWebid; if ((await getWWebid(mid: mid))['status']) { - wWebid = GlobalDataCache().wWebid; + wWebid = GlobalDataCache.wWebid; } Map params = await WbiSign().makSign({ 'host_mid': mid, diff --git a/lib/main.dart b/lib/main.dart index 1ec86c8e..5a163f49 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -65,7 +65,7 @@ void main() async { } PiliSchame.init(); - await GlobalDataCache().initialize(); + await GlobalDataCache.initialize(); } class MyApp extends StatelessWidget { diff --git a/lib/pages/dynamics/widgets/up_panel.dart b/lib/pages/dynamics/widgets/up_panel.dart index d5d7958e..607b6af7 100644 --- a/lib/pages/dynamics/widgets/up_panel.dart +++ b/lib/pages/dynamics/widgets/up_panel.dart @@ -173,7 +173,7 @@ class _UpPanelState extends State { if (data.type == 'up') { EasyThrottle.throttle('follow', const Duration(milliseconds: 300), () { - if (GlobalDataCache().enableDynamicSwitch) { + if (GlobalDataCache.enableDynamicSwitch) { onClickUp(data, i); } else { onClickUpAni(data, i); diff --git a/lib/pages/main/view.dart b/lib/pages/main/view.dart index 01fae4bf..1c4dbf62 100644 --- a/lib/pages/main/view.dart +++ b/lib/pages/main/view.dart @@ -125,7 +125,7 @@ class _MainAppState extends State with SingleTickerProviderStateMixin { double sheetHeight = MediaQuery.sizeOf(context).height - MediaQuery.of(context).padding.top - MediaQuery.sizeOf(context).width * 9 / 16; - GlobalDataCache().sheetHeight = sheetHeight; + GlobalDataCache.sheetHeight = sheetHeight; localCache.put('sheetHeight', sheetHeight); localCache.put('statusBarHeight', statusBarHeight); diff --git a/lib/pages/member_archive/controller.dart b/lib/pages/member_archive/controller.dart index 61816ed5..3fdcbedc 100644 --- a/lib/pages/member_archive/controller.dart +++ b/lib/pages/member_archive/controller.dart @@ -28,9 +28,8 @@ class MemberArchiveController extends GetxController { super.onInit(); mid = int.parse(Get.parameters['mid']!); currentOrder.value = orderList.first; - ownerMid = GlobalDataCache().userInfo != null - ? GlobalDataCache().userInfo!.mid! - : -1; + ownerMid = + GlobalDataCache.userInfo != null ? GlobalDataCache.userInfo!.mid! : -1; isOwner.value = mid == -1 || mid == ownerMid; } diff --git a/lib/pages/member_article/controller.dart b/lib/pages/member_article/controller.dart index 9c67f679..542fbc4f 100644 --- a/lib/pages/member_article/controller.dart +++ b/lib/pages/member_article/controller.dart @@ -20,9 +20,8 @@ class MemberArticleController extends GetxController { void onInit() { super.onInit(); mid = int.parse(Get.parameters['mid']!); - ownerMid = GlobalDataCache().userInfo != null - ? GlobalDataCache().userInfo!.mid! - : -1; + ownerMid = + GlobalDataCache.userInfo != null ? GlobalDataCache.userInfo!.mid! : -1; isOwner.value = mid == -1 || mid == ownerMid; } diff --git a/lib/pages/member_dynamics/controller.dart b/lib/pages/member_dynamics/controller.dart index 8fdf55b7..be5b2454 100644 --- a/lib/pages/member_dynamics/controller.dart +++ b/lib/pages/member_dynamics/controller.dart @@ -18,9 +18,8 @@ class MemberDynamicsController extends GetxController { void onInit() { super.onInit(); mid = int.parse(Get.parameters['mid']!); - ownerMid = GlobalDataCache().userInfo != null - ? GlobalDataCache().userInfo!.mid! - : -1; + ownerMid = + GlobalDataCache.userInfo != null ? GlobalDataCache.userInfo!.mid! : -1; isOwner.value = mid == -1 || mid == ownerMid; } diff --git a/lib/pages/member_seasons/controller.dart b/lib/pages/member_seasons/controller.dart index 07532787..e3f2c409 100644 --- a/lib/pages/member_seasons/controller.dart +++ b/lib/pages/member_seasons/controller.dart @@ -59,7 +59,7 @@ class MemberSeasonsController extends GetxController { mid: mid, seriesId: seriesId!, pn: pn, - currentMid: GlobalDataCache().userInfo?.mid ?? -1, + currentMid: GlobalDataCache.userInfo?.mid ?? -1, ); if (res['status']) { seasonsList.addAll(res['data'].seriesList); diff --git a/lib/pages/search/controller.dart b/lib/pages/search/controller.dart index 2da2acff..8d24f167 100644 --- a/lib/pages/search/controller.dart +++ b/lib/pages/search/controller.dart @@ -43,10 +43,10 @@ class SSearchController extends GetxController { hintText = hint; } } - historyCacheList = GlobalDataCache().historyCacheList; + historyCacheList = GlobalDataCache.historyCacheList; historyList.value = historyCacheList; enableHotKey = setting.get(SettingBoxKey.enableHotKey, defaultValue: true); - enableSearchSuggest = GlobalDataCache().enableSearchSuggest; + enableSearchSuggest = GlobalDataCache.enableSearchSuggest; } void onChange(value) { @@ -128,7 +128,7 @@ class SSearchController extends GetxController { historyCacheList = []; historyList.refresh(); localCache.put('cacheList', []); - GlobalDataCache().historyCacheList = []; + GlobalDataCache.historyCacheList = []; SmartDialog.showToast('搜索历史已清空'); } @@ -139,7 +139,7 @@ class SSearchController extends GetxController { historyList.value = historyCacheList; historyList.refresh(); localCache.put('cacheList', historyCacheList); - GlobalDataCache().historyCacheList = historyCacheList; + GlobalDataCache.historyCacheList = historyCacheList; searchFocusNode.unfocus(); } } diff --git a/lib/pages/setting/extra_setting.dart b/lib/pages/setting/extra_setting.dart index 07cd585a..fdc62f13 100644 --- a/lib/pages/setting/extra_setting.dart +++ b/lib/pages/setting/extra_setting.dart @@ -146,7 +146,7 @@ class _ExtraSettingState extends State { setKey: SettingBoxKey.enableSearchSuggest, defaultVal: true, callFn: (val) { - GlobalDataCache().enableSearchSuggest = val; + GlobalDataCache.enableSearchSuggest = val; }, ), SetSwitchItem( @@ -181,7 +181,7 @@ class _ExtraSettingState extends State { setKey: SettingBoxKey.enableAutoExpand, defaultVal: false, callFn: (val) { - GlobalDataCache().enableAutoExpand = val; + GlobalDataCache.enableAutoExpand = val; }, ), const SetSwitchItem( diff --git a/lib/pages/setting/pages/action_menu_set.dart b/lib/pages/setting/pages/action_menu_set.dart index cbbd0e84..3b211bae 100644 --- a/lib/pages/setting/pages/action_menu_set.dart +++ b/lib/pages/setting/pages/action_menu_set.dart @@ -38,7 +38,7 @@ class _ActionMenuSetPageState extends State { .map((i) => (i['value'] as ActionType).value) .toList(); setting.put(SettingBoxKey.actionTypeSort, sortedTabbar); - GlobalDataCache().actionTypeSort = sortedTabbar; + GlobalDataCache.actionTypeSort = sortedTabbar; SmartDialog.showToast('操作成功'); } diff --git a/lib/pages/setting/pages/play_gesture_set.dart b/lib/pages/setting/pages/play_gesture_set.dart index bad115a5..dc11cd6f 100644 --- a/lib/pages/setting/pages/play_gesture_set.dart +++ b/lib/pages/setting/pages/play_gesture_set.dart @@ -58,11 +58,11 @@ class _PlayGesturePageState extends State { }, ); if (result != null) { - GlobalDataCache().fullScreenGestureMode = FullScreenGestureMode + GlobalDataCache.fullScreenGestureMode = FullScreenGestureMode .values .firstWhere((element) => element.values == result); fullScreenGestureMode = - GlobalDataCache().fullScreenGestureMode.index; + GlobalDataCache.fullScreenGestureMode.index; setting.put( SettingBoxKey.fullScreenGestureMode, fullScreenGestureMode); SmartDialog.showToast('设置成功'); diff --git a/lib/pages/setting/play_setting.dart b/lib/pages/setting/play_setting.dart index e191d8fd..7090bfaf 100644 --- a/lib/pages/setting/play_setting.dart +++ b/lib/pages/setting/play_setting.dart @@ -155,7 +155,7 @@ class _PlaySettingState extends State { setKey: SettingBoxKey.enablePlayerControlAnimation, defaultVal: true, callFn: (bool val) { - GlobalDataCache().enablePlayerControlAnimation = val; + GlobalDataCache.enablePlayerControlAnimation = val; }), SetSwitchItem( title: '港澳台模式', diff --git a/lib/pages/setting/style_setting.dart b/lib/pages/setting/style_setting.dart index 5b59397e..54b97ea5 100644 --- a/lib/pages/setting/style_setting.dart +++ b/lib/pages/setting/style_setting.dart @@ -175,7 +175,7 @@ class _StyleSettingState extends State { SettingBoxKey.defaultPicQa, picQuality); Get.back(); settingController.picQuality.value = picQuality; - GlobalDataCache().imgQuality = picQuality; + GlobalDataCache.imgQuality = picQuality; SmartDialog.showToast('设置成功'); }, child: const Text('确定'), diff --git a/lib/pages/video/detail/introduction/view.dart b/lib/pages/video/detail/introduction/view.dart index 451173dd..417548d5 100644 --- a/lib/pages/video/detail/introduction/view.dart +++ b/lib/pages/video/detail/introduction/view.dart @@ -169,8 +169,8 @@ class _VideoInfoState extends State with TickerProviderStateMixin { owner = widget.videoDetail!.owner; enableAi = setting.get(SettingBoxKey.enableAi, defaultValue: true); - _expandableCtr = ExpandableController( - initialExpanded: GlobalDataCache().enableAutoExpand); + _expandableCtr = + ExpandableController(initialExpanded: GlobalDataCache.enableAutoExpand); } // 收藏 @@ -556,7 +556,7 @@ class _VideoInfoState extends State with TickerProviderStateMixin { } Widget actionGrid(BuildContext context, videoIntroController) { - final actionTypeSort = GlobalDataCache().actionTypeSort; + final actionTypeSort = GlobalDataCache.actionTypeSort; Map menuListWidgets = { 'like': Obx( diff --git a/lib/pages/video/detail/reply/widgets/reply_item.dart b/lib/pages/video/detail/reply/widgets/reply_item.dart index 5d31858f..e0a6d07f 100644 --- a/lib/pages/video/detail/reply/widgets/reply_item.dart +++ b/lib/pages/video/detail/reply/widgets/reply_item.dart @@ -52,7 +52,7 @@ class ReplyItem extends StatelessWidget { @override Widget build(BuildContext context) { final bool isOwner = int.parse(replyItem!.member!.mid!) == - (GlobalDataCache().userInfo?.mid ?? -1); + (GlobalDataCache.userInfo?.mid ?? -1); return Material( child: InkWell( // 点击整个评论区 评论详情/回复 @@ -415,7 +415,7 @@ class ReplyItemRow extends StatelessWidget { onLongPress: () { feedBack(); final bool isOwner = int.parse(replyItem!.member!.mid!) == - (GlobalDataCache().userInfo?.mid ?? -1); + (GlobalDataCache.userInfo?.mid ?? -1); showModalBottomSheet( context: context, useRootNavigator: true, diff --git a/lib/pages/video/detail/widgets/ai_detail.dart b/lib/pages/video/detail/widgets/ai_detail.dart index 64327553..c17591fb 100644 --- a/lib/pages/video/detail/widgets/ai_detail.dart +++ b/lib/pages/video/detail/widgets/ai_detail.dart @@ -18,7 +18,7 @@ class AiDetail extends StatelessWidget { Widget build(BuildContext context) { return Container( padding: const EdgeInsets.only(left: 16, right: 16), - height: GlobalDataCache().sheetHeight, + height: GlobalDataCache.sheetHeight, child: Column( children: [ _buildHeader(context), diff --git a/lib/plugin/pl_player/controller.dart b/lib/plugin/pl_player/controller.dart index de4cd9df..b69d96bb 100644 --- a/lib/plugin/pl_player/controller.dart +++ b/lib/plugin/pl_player/controller.dart @@ -278,19 +278,18 @@ class PlPlayerController { // 添加一个私有构造函数 PlPlayerController._internal(this.videoType) { - final cache = GlobalDataCache(); - isOpenDanmu.value = cache.isOpenDanmu; - blockTypes = cache.blockTypes; - showArea = cache.showArea; - opacityVal = cache.opacityVal; - fontSizeVal = cache.fontSizeVal; - danmakuDurationVal = cache.danmakuDurationVal; - strokeWidth = cache.strokeWidth; - playRepeat = cache.playRepeat; - _playbackSpeed.value = cache.playbackSpeed; - enableAutoLongPressSpeed = cache.enableAutoLongPressSpeed; - _longPressSpeed.value = cache.longPressSpeed; - speedsList = cache.speedsList; + isOpenDanmu.value = GlobalDataCache.isOpenDanmu; + blockTypes = GlobalDataCache.blockTypes; + showArea = GlobalDataCache.showArea; + opacityVal = GlobalDataCache.opacityVal; + fontSizeVal = GlobalDataCache.fontSizeVal; + danmakuDurationVal = GlobalDataCache.danmakuDurationVal; + strokeWidth = GlobalDataCache.strokeWidth; + playRepeat = GlobalDataCache.playRepeat; + _playbackSpeed.value = GlobalDataCache.playbackSpeed; + enableAutoLongPressSpeed = GlobalDataCache.enableAutoLongPressSpeed; + _longPressSpeed.value = GlobalDataCache.longPressSpeed; + speedsList = GlobalDataCache.speedsList; // _playerEventSubs = onPlayerStatusChanged.listen((PlayerStatus status) { // if (status == PlayerStatus.playing) { // WakelockPlus.enable(); @@ -1047,13 +1046,12 @@ class PlPlayerController { /// 缓存本次弹幕选项 cacheDanmakuOption() { - final cache = GlobalDataCache(); - cache.blockTypes = blockTypes; - cache.showArea = showArea; - cache.opacityVal = opacityVal; - cache.fontSizeVal = fontSizeVal; - cache.danmakuDurationVal = danmakuDurationVal; - cache.strokeWidth = strokeWidth; + GlobalDataCache.blockTypes = blockTypes; + GlobalDataCache.showArea = showArea; + GlobalDataCache.opacityVal = opacityVal; + GlobalDataCache.fontSizeVal = fontSizeVal; + GlobalDataCache.danmakuDurationVal = danmakuDurationVal; + GlobalDataCache.strokeWidth = strokeWidth; localCache.put(LocalCacheKey.danmakuBlockType, blockTypes); localCache.put(LocalCacheKey.danmakuShowArea, showArea); diff --git a/lib/plugin/pl_player/view.dart b/lib/plugin/pl_player/view.dart index 990661bc..c73bc55f 100644 --- a/lib/plugin/pl_player/view.dart +++ b/lib/plugin/pl_player/view.dart @@ -89,7 +89,7 @@ class _PLVideoPlayerState extends State late bool enableBackgroundPlay; late double screenWidth; final FullScreenGestureMode fullScreenGestureMode = - GlobalDataCache().fullScreenGestureMode; + GlobalDataCache.fullScreenGestureMode; // 用于记录上一次全屏切换手势触发时间,避免误触 DateTime? lastFullScreenToggleTime; @@ -136,7 +136,7 @@ class _PLVideoPlayerState extends State screenWidth = Get.size.width; animationController = AnimationController( vsync: this, - duration: GlobalDataCache().enablePlayerControlAnimation + duration: GlobalDataCache.enablePlayerControlAnimation ? const Duration(milliseconds: 150) : const Duration(milliseconds: 10), ); diff --git a/lib/utils/global_data_cache.dart b/lib/utils/global_data_cache.dart index 3321c660..ea673859 100644 --- a/lib/utils/global_data_cache.dart +++ b/lib/utils/global_data_cache.dart @@ -11,48 +11,48 @@ Box videoStorage = GStorage.video; Box userInfoCache = GStorage.userInfo; class GlobalDataCache { - late int imgQuality; - late FullScreenGestureMode fullScreenGestureMode; - late bool enablePlayerControlAnimation; - late List actionTypeSort; - late double sheetHeight; - String? wWebid; + static late int imgQuality; + static late FullScreenGestureMode fullScreenGestureMode; + static late bool enablePlayerControlAnimation; + static late List actionTypeSort; + static late double sheetHeight; + static String? wWebid; /// 播放器相关 // 弹幕开关 - late bool isOpenDanmu; + static late bool isOpenDanmu; // 弹幕屏蔽类型 - late List blockTypes; + static late List blockTypes; // 弹幕展示区域 - late double showArea; + static late double showArea; // 弹幕透明度 - late double opacityVal; + static late double opacityVal; // 弹幕字体大小 - late double fontSizeVal; + static late double fontSizeVal; // 弹幕显示时间 - late double danmakuDurationVal; + static late double danmakuDurationVal; // 弹幕描边宽度 - late double strokeWidth; + static late double strokeWidth; // 播放器循环模式 - late PlayRepeat playRepeat; + static late PlayRepeat playRepeat; // 播放器默认播放速度 - late double playbackSpeed; + static late double playbackSpeed; // 播放器自动长按速度 - late bool enableAutoLongPressSpeed; + static late bool enableAutoLongPressSpeed; // 播放器长按速度 - late double longPressSpeed; + static late double longPressSpeed; // 播放器速度列表 - late List speedsList; + static late List speedsList; // 用户信息 - UserInfoData? userInfo; + static UserInfoData? userInfo; // 搜索历史 - late List historyCacheList; - // - late bool enableSearchSuggest = true; + static late List historyCacheList; + // 搜索建议 + static late bool enableSearchSuggest; // 简介默认展开 - late bool enableAutoExpand = false; - // - late bool enableDynamicSwitch = true; + static late bool enableAutoExpand; + // 动态切换 + static late bool enableDynamicSwitch; // 私有构造函数 GlobalDataCache._(); @@ -64,7 +64,7 @@ class GlobalDataCache { factory GlobalDataCache() => _instance; // 异步初始化方法 - Future initialize() async { + static Future initialize() async { imgQuality = await setting.get(SettingBoxKey.defaultPicQa, defaultValue: 10); // 设置全局变量 fullScreenGestureMode = FullScreenGestureMode.values[setting.get( diff --git a/lib/utils/login.dart b/lib/utils/login.dart index 9dde1cb1..159de81d 100644 --- a/lib/utils/login.dart +++ b/lib/utils/login.dart @@ -118,7 +118,7 @@ class LoginUtils { Request.dio.options.headers['cookie'] = ''; userInfoCache.put('userInfoCache', null); localCache.put(LocalCacheKey.accessKey, {'mid': -1, 'value': ''}); - GlobalDataCache().userInfo = null; + GlobalDataCache.userInfo = null; await refreshLoginStatus(false); } } From 1ac152bb49ed159cd7366a20f23227accd882a75 Mon Sep 17 00:00:00 2001 From: guozhigq Date: Wed, 20 Nov 2024 22:45:25 +0800 Subject: [PATCH 26/27] feat: dlna switch --- lib/pages/setting/extra_setting.dart | 6 ++++ .../video/detail/widgets/header_control.dart | 33 ++++++++++--------- lib/utils/global_data_cache.dart | 3 ++ lib/utils/storage.dart | 3 +- 4 files changed, 29 insertions(+), 16 deletions(-) diff --git a/lib/pages/setting/extra_setting.dart b/lib/pages/setting/extra_setting.dart index fdc62f13..3e82f2bd 100644 --- a/lib/pages/setting/extra_setting.dart +++ b/lib/pages/setting/extra_setting.dart @@ -190,6 +190,12 @@ class _ExtraSettingState extends State { setKey: SettingBoxKey.enableRelatedVideo, defaultVal: true, ), + const SetSwitchItem( + title: '视频投屏开关', + subTitle: '打开后将在播放器右上角显示投屏入口', + setKey: SettingBoxKey.enableDlna, + defaultVal: false, + ), ListTile( dense: false, title: Text('评论展示', style: titleStyle), diff --git a/lib/pages/video/detail/widgets/header_control.dart b/lib/pages/video/detail/widgets/header_control.dart index f22bf846..bc9167d5 100644 --- a/lib/pages/video/detail/widgets/header_control.dart +++ b/lib/pages/video/detail/widgets/header_control.dart @@ -16,6 +16,7 @@ import 'package:pilipala/pages/video/detail/index.dart'; import 'package:pilipala/pages/video/detail/introduction/widgets/menu_row.dart'; import 'package:pilipala/plugin/pl_player/index.dart'; import 'package:pilipala/plugin/pl_player/models/play_repeat.dart'; +import 'package:pilipala/utils/global_data_cache.dart'; import 'package:pilipala/utils/storage.dart'; import 'package:pilipala/services/shutdown_timer_service.dart'; import '../../../../http/danmaku.dart'; @@ -1237,22 +1238,24 @@ class _HeaderControlState extends State { // ), // fuc: () => _.screenshot(), // ), - ComBtn( - icon: const Icon( - Icons.cast, - size: 19, - color: Colors.white, + if (GlobalDataCache.enableDlna) ...[ + ComBtn( + icon: const Icon( + Icons.cast, + size: 19, + color: Colors.white, + ), + fuc: () async { + showDialog( + context: context, + builder: (BuildContext context) { + return LiveDlnaPage( + datasource: widget.videoDetailCtr!.videoUrl); + }, + ); + }, ), - fuc: () async { - showDialog( - context: context, - builder: (BuildContext context) { - return LiveDlnaPage( - datasource: widget.videoDetailCtr!.videoUrl); - }, - ); - }, - ), + ], if (isFullScreen.value) ...[ SizedBox( width: 56, diff --git a/lib/utils/global_data_cache.dart b/lib/utils/global_data_cache.dart index ea673859..a421f829 100644 --- a/lib/utils/global_data_cache.dart +++ b/lib/utils/global_data_cache.dart @@ -53,6 +53,8 @@ class GlobalDataCache { static late bool enableAutoExpand; // 动态切换 static late bool enableDynamicSwitch; + // 投屏开关 + static bool enableDlna = false; // 私有构造函数 GlobalDataCache._(); @@ -120,5 +122,6 @@ class GlobalDataCache { setting.get(SettingBoxKey.enableAutoExpand, defaultValue: false); enableDynamicSwitch = setting.get(SettingBoxKey.enableDynamicSwitch, defaultValue: true); + enableDlna = setting.get(SettingBoxKey.enableDlna, defaultValue: false); } } diff --git a/lib/utils/storage.dart b/lib/utils/storage.dart index a5b36768..49a5c734 100644 --- a/lib/utils/storage.dart +++ b/lib/utils/storage.dart @@ -115,7 +115,8 @@ class SettingBoxKey { enableAi = 'enableAi', enableAutoExpand = 'enableAutoExpand', defaultHomePage = 'defaultHomePage', - enableRelatedVideo = 'enableRelatedVideo'; + enableRelatedVideo = 'enableRelatedVideo', + enableDlna = 'enableDlna'; /// 外观 static const String themeMode = 'themeMode', From b824b75bc64f5b45a784965a99424282c3b69bc9 Mon Sep 17 00:00:00 2001 From: guozhigq Date: Sat, 23 Nov 2024 00:01:16 +0800 Subject: [PATCH 27/27] opt: enableDlna switch callFn --- lib/pages/setting/extra_setting.dart | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/pages/setting/extra_setting.dart b/lib/pages/setting/extra_setting.dart index 3e82f2bd..004f3e9c 100644 --- a/lib/pages/setting/extra_setting.dart +++ b/lib/pages/setting/extra_setting.dart @@ -190,11 +190,14 @@ class _ExtraSettingState extends State { setKey: SettingBoxKey.enableRelatedVideo, defaultVal: true, ), - const SetSwitchItem( + SetSwitchItem( title: '视频投屏开关', subTitle: '打开后将在播放器右上角显示投屏入口', setKey: SettingBoxKey.enableDlna, defaultVal: false, + callFn: (bool val) { + GlobalDataCache.enableDlna = val; + }, ), ListTile( dense: false,