diff --git a/lib/pages/common/publish/common_rich_text_pub_page.dart b/lib/pages/common/publish/common_rich_text_pub_page.dart index a71e9d420..9463eb4f4 100644 --- a/lib/pages/common/publish/common_rich_text_pub_page.dart +++ b/lib/pages/common/publish/common_rich_text_pub_page.dart @@ -156,7 +156,7 @@ abstract class CommonRichTextPubPageState toolbarTitle: '裁剪', toolbarColor: colorScheme.secondaryContainer, toolbarWidgetColor: colorScheme.onSecondaryContainer, - statusBarLight: colorScheme.brightness.isLight, + statusBarLight: colorScheme.isLight, ), IOSUiSettings(title: '裁剪'), ], diff --git a/lib/pages/fav_create/view.dart b/lib/pages/fav_create/view.dart index b9cef9ca3..2c047fc92 100644 --- a/lib/pages/fav_create/view.dart +++ b/lib/pages/fav_create/view.dart @@ -125,7 +125,7 @@ class _CreateFavPageState extends State { toolbarTitle: '裁剪', toolbarColor: theme.colorScheme.secondaryContainer, toolbarWidgetColor: theme.colorScheme.onSecondaryContainer, - statusBarLight: theme.colorScheme.brightness.isLight, + statusBarLight: theme.colorScheme.isLight, aspectRatioPresets: [CropAspectRatioPreset.ratio16x9], lockAspectRatio: true, hideBottomControls: true, diff --git a/lib/pages/live_room/superchat/superchat_card.dart b/lib/pages/live_room/superchat/superchat_card.dart index bd5356538..a95c73c10 100644 --- a/lib/pages/live_room/superchat/superchat_card.dart +++ b/lib/pages/live_room/superchat/superchat_card.dart @@ -43,7 +43,9 @@ class _SuperChatCardState extends State { } void _remove() { - Future.delayed(const Duration(seconds: 1), _onRemove); + WidgetsBinding.instance.addPostFrameCallback((_) { + Future.delayed(const Duration(seconds: 1), _onRemove); + }); } void _onRemove() { diff --git a/lib/pages/live_room/view.dart b/lib/pages/live_room/view.dart index 1f1e09ba3..2b4b6d636 100644 --- a/lib/pages/live_room/view.dart +++ b/lib/pages/live_room/view.dart @@ -830,14 +830,14 @@ class _LiveRoomPageState extends State ), Builder( builder: (context) { - final theme = Theme.of(context).colorScheme; + final colorScheme = Theme.of(context).colorScheme; return Material( type: MaterialType.transparency, child: Stack( clipBehavior: Clip.none, children: [ InkWell( - overlayColor: overlayColor(theme), + overlayColor: overlayColor(colorScheme), customBorder: const CircleBorder(), onTapDown: _liveRoomController.onLikeTapDown, onTapUp: _liveRoomController.onLikeTapUp, @@ -873,9 +873,9 @@ class _LiveRoomPageState extends State 'x$likeClickTime', style: TextStyle( fontSize: 16, - color: theme.brightness.isDark - ? theme.primary - : theme.inversePrimary, + color: colorScheme.isDark + ? colorScheme.primary + : colorScheme.inversePrimary, ), ), ); diff --git a/lib/pages/member/widget/user_info_card.dart b/lib/pages/member/widget/user_info_card.dart index 3c6d55cdc..6372df873 100644 --- a/lib/pages/member/widget/user_info_card.dart +++ b/lib/pages/member/widget/user_info_card.dart @@ -43,7 +43,7 @@ class UserInfoCard extends StatelessWidget { @override Widget build(BuildContext context) { final colorScheme = Theme.of(context).colorScheme; - final isLight = colorScheme.brightness.isLight; + final isLight = colorScheme.isLight; final isPortrait = context.width < 600; return ViewSafeArea( top: !isPortrait, diff --git a/lib/pages/member_profile/view.dart b/lib/pages/member_profile/view.dart index ca26941a9..281b70076 100644 --- a/lib/pages/member_profile/view.dart +++ b/lib/pages/member_profile/view.dart @@ -497,7 +497,7 @@ class _EditProfilePageState extends State { toolbarTitle: '裁剪', toolbarColor: theme.colorScheme.secondaryContainer, toolbarWidgetColor: theme.colorScheme.onSecondaryContainer, - statusBarLight: theme.colorScheme.brightness.isLight, + statusBarLight: theme.colorScheme.isLight, aspectRatioPresets: [CropAspectRatioPresetCustom()], lockAspectRatio: true, hideBottomControls: true, diff --git a/lib/pages/popular_series/view.dart b/lib/pages/popular_series/view.dart index 632a2a0f2..4545cc488 100644 --- a/lib/pages/popular_series/view.dart +++ b/lib/pages/popular_series/view.dart @@ -142,7 +142,9 @@ class _PopularSeriesPageState extends State with GridMixin { return ListTile( dense: true, minTileHeight: 44, - selected: isCurr, + tileColor: isCurr + ? Theme.of(context).highlightColor + : null, onTap: () { Get.back(); if (!isCurr) { diff --git a/lib/pages/setting/widgets/select_dialog.dart b/lib/pages/setting/widgets/select_dialog.dart index 5260a9d01..bfd9ff3fd 100644 --- a/lib/pages/setting/widgets/select_dialog.dart +++ b/lib/pages/setting/widgets/select_dialog.dart @@ -31,6 +31,9 @@ class SelectDialog extends StatelessWidget { return AlertDialog( clipBehavior: Clip.hardEdge, title: Text(title), + constraints: subtitleBuilder != null + ? const BoxConstraints(maxWidth: 320, minWidth: 320) + : null, contentPadding: const EdgeInsets.symmetric(vertical: 12), content: SingleChildScrollView( child: RadioGroup( diff --git a/lib/pages/video/introduction/ugc/widgets/action_item.dart b/lib/pages/video/introduction/ugc/widgets/action_item.dart index d84059799..7f62c9634 100644 --- a/lib/pages/video/introduction/ugc/widgets/action_item.dart +++ b/lib/pages/video/introduction/ugc/widgets/action_item.dart @@ -1,5 +1,6 @@ import 'dart:math' show pi; +import 'package:PiliPlus/utils/extension.dart'; import 'package:flutter/material.dart'; class ActionItem extends StatelessWidget { @@ -35,16 +36,17 @@ class ActionItem extends StatelessWidget { @override Widget build(BuildContext context) { final theme = Theme.of(context); + final colorScheme = theme.colorScheme; + late final primary = !expand && colorScheme.isLight + ? colorScheme.inversePrimary + : colorScheme.primary; Widget child = Icon( selectStatus ? selectIcon!.icon! : icon.icon, size: 18, - color: selectStatus - ? theme.colorScheme.primary - : icon.color ?? theme.colorScheme.outline, + color: selectStatus ? primary : icon.color ?? colorScheme.outline, ); if (animation != null) { - final primary = theme.colorScheme.primary; child = Stack( clipBehavior: Clip.none, alignment: Alignment.center, diff --git a/lib/pages/video/widgets/player_focus.dart b/lib/pages/video/widgets/player_focus.dart index 7e942f934..f110386f2 100644 --- a/lib/pages/video/widgets/player_focus.dart +++ b/lib/pages/video/widgets/player_focus.dart @@ -68,7 +68,7 @@ class PlayerFocus extends StatelessWidget { plPlayerController ..cancelLongPressTimer() ..longPressTimer ??= Timer.periodic( - const Duration(milliseconds: 200), + const Duration(milliseconds: 150), (_) => _setVolume(isIncrease: isIncrease), ); } @@ -137,8 +137,8 @@ class PlayerFocus extends StatelessWidget { final speed = isDigit1 ? 1.0 : 2.0; if (speed != plPlayerController.playbackSpeed) { plPlayerController.setPlaybackSpeed(speed); - SmartDialog.showToast('${speed}x播放'); } + SmartDialog.showToast('${speed}x播放'); } return true; } diff --git a/lib/plugin/pl_player/controller.dart b/lib/plugin/pl_player/controller.dart index 689267b2d..76331f170 100644 --- a/lib/plugin/pl_player/controller.dart +++ b/lib/plugin/pl_player/controller.dart @@ -1499,7 +1499,7 @@ class PlPlayerController { await landscape(inAppFullScreen: inAppFullScreen); } } else if (isFullScreen.value && !status) { - showStatusBar(inAppFullScreen: inAppFullScreen); + showStatusBar(); toggleFullScreen(false); if (mode == FullScreenMode.none) { fsProcessing = false; diff --git a/lib/plugin/pl_player/utils/fullscreen.dart b/lib/plugin/pl_player/utils/fullscreen.dart index bc9e1f897..bb5dcd553 100644 --- a/lib/plugin/pl_player/utils/fullscreen.dart +++ b/lib/plugin/pl_player/utils/fullscreen.dart @@ -9,18 +9,13 @@ import 'package:flutter/services.dart'; //横屏 Future landscape({bool inAppFullScreen = false}) async { - dynamic document; try { - if (kIsWeb) { - await document.documentElement?.requestFullscreen(); - } else if (Utils.isMobile) { + if (Utils.isMobile) { await AutoOrientation.landscapeAutoMode(forceSensor: true); } else if (Utils.isDesktop && !inAppFullScreen) { await const MethodChannel( 'com.alexmercerind/media_kit_video', - ).invokeMethod( - 'Utils.EnterNativeFullscreen', - ); + ).invokeMethod('Utils.EnterNativeFullscreen'); } } catch (exception, stacktrace) { if (kDebugMode) { @@ -76,30 +71,27 @@ Future hideStatusBar() async { bool _showStatusBar = true; //退出全屏显示 -Future showStatusBar({bool inAppFullScreen = false}) async { +Future showStatusBar() async { if (_showStatusBar) { return; } _showStatusBar = true; - dynamic document; - late SystemUiMode mode = SystemUiMode.edgeToEdge; try { - if (kIsWeb) { - document.exitFullscreen(); - } else if (Utils.isMobile) { + if (Utils.isMobile) { + SystemUiMode mode; if (Platform.isAndroid && (await Utils.sdkInt < 29)) { mode = SystemUiMode.manual; + } else { + mode = SystemUiMode.edgeToEdge; } await SystemChrome.setEnabledSystemUIMode( mode, overlays: SystemUiOverlay.values, ); - } else if (Utils.isDesktop && !inAppFullScreen) { + } else if (Utils.isDesktop) { await const MethodChannel( 'com.alexmercerind/media_kit_video', - ).invokeMethod( - 'Utils.ExitNativeFullscreen', - ); + ).invokeMethod('Utils.ExitNativeFullscreen'); } } catch (_) { if (kDebugMode) rethrow; diff --git a/lib/utils/cache_manage.dart b/lib/utils/cache_manage.dart index 61bed5b96..7052e4a55 100644 --- a/lib/utils/cache_manage.dart +++ b/lib/utils/cache_manage.dart @@ -4,6 +4,7 @@ import 'dart:io'; import 'package:PiliPlus/utils/extension.dart'; import 'package:PiliPlus/utils/storage_pref.dart'; import 'package:PiliPlus/utils/utils.dart'; +import 'package:flutter/foundation.dart' show kDebugMode; import 'package:path_provider/path_provider.dart'; abstract class CacheManage { @@ -11,28 +12,23 @@ abstract class CacheManage { static Future loadApplicationCache([ final num maxSize = double.infinity, ]) async { - /// clear all of image in memory - // clearMemoryImageCache(); - /// get ImageCache - // var res = getMemoryImageCache(); - - // 缓存大小 - // cached_network_image directory - Directory tempDirectory = await getTemporaryDirectory(); - if (Utils.isDesktop) { - final dir = Directory('${tempDirectory.path}/libCachedImageData'); - if (dir.existsSync()) { - return await getTotalSizeOfFilesInDir(dir, maxSize); - } else { - return 0; + try { + Directory tempDirectory = await getTemporaryDirectory(); + if (Utils.isDesktop) { + final dir = Directory('${tempDirectory.path}/libCachedImageData'); + if (dir.existsSync()) { + return await getTotalSizeOfFilesInDir(dir, maxSize); + } else { + return 0; + } } - } - // 获取缓存大小 - if (tempDirectory.existsSync()) { - return await getTotalSizeOfFilesInDir(tempDirectory, maxSize); + if (tempDirectory.existsSync()) { + return await getTotalSizeOfFilesInDir(tempDirectory, maxSize); + } + } catch (_) { + if (kDebugMode) rethrow; } - return 0; } @@ -66,20 +62,23 @@ abstract class CacheManage { // 清除 Library/Caches 目录及文件缓存 static Future clearLibraryCache() async { - var tempDirectory = await getTemporaryDirectory(); - if (Utils.isDesktop) { - final dir = Directory('${tempDirectory.path}/libCachedImageData'); - if (dir.existsSync()) { - await dir.delete(recursive: true); + try { + var tempDirectory = await getTemporaryDirectory(); + if (Utils.isDesktop) { + final dir = Directory('${tempDirectory.path}/libCachedImageData'); + if (dir.existsSync()) { + await dir.delete(recursive: true); + } + return; } - return; - } - if (tempDirectory.existsSync()) { - // await appDocDir.delete(recursive: true); - final children = tempDirectory.list(recursive: false); - await for (final file in children) { - await file.delete(recursive: true); + if (tempDirectory.existsSync()) { + final children = tempDirectory.list(recursive: false); + await for (final file in children) { + await file.delete(recursive: true); + } } + } catch (_) { + if (kDebugMode) rethrow; } } diff --git a/lib/utils/extension.dart b/lib/utils/extension.dart index 0b56cfb7b..8ac276e69 100644 --- a/lib/utils/extension.dart +++ b/lib/utils/extension.dart @@ -109,6 +109,10 @@ extension ColorSchemeExt on ColorScheme { Color get freeColor => brightness.isLight ? const Color(0xFFFF7F24) : const Color(0xFFD66011); + + bool get isLight => brightness.isLight; + + bool get isDark => brightness.isDark; } extension Unique on List {