基于自定义规则的番剧采集APP,支持流媒体在线观看,支持弹幕,支持实时超分辨率。
refactor: use shared platform checks for desktop detection
Predidit4effe14ee78b
diff --git a/lib/pages/player/player_item.dart b/lib/pages/player/player_item.dartindex 4be9fa8d..4ffa5579 100644--- a/lib/pages/player/player_item.dart+++ b/lib/pages/player/player_item.dart@@ -1186,10 +1186,7 @@ class _PlayerItemState extends State<PlayerItem>.applyExternalVolume(playerController.playback.playerVolume);}}- if (!Platform.isWindows &&- !Platform.isMacOS &&- !Platform.isLinux &&- !playerController.panel.brightnessSeeking) {+ if (!isDesktop() && !playerController.panel.brightnessSeeking) {ScreenBrightnessPlatform.instance.application.then((value) {if (!mounted) return;playerController.panel.brightness = value;diff --git a/lib/pages/player/player_item_panel.dart b/lib/pages/player/player_item_panel.dartindex d63d4a09..6a5b336c 100644--- a/lib/pages/player/player_item_panel.dart+++ b/lib/pages/player/player_item_panel.dart@@ -1,6 +1,6 @@import 'dart:async';+import 'dart:io';-import 'package:flutter/foundation.dart';import 'package:canvas_danmaku/models/danmaku_content_item.dart';import 'package:flutter/material.dart';import 'package:flutter_mobx/flutter_mobx.dart';@@ -23,6 +23,7 @@ import 'package:kazumi/services/player/remote.dart';import 'package:kazumi/bean/appbar/drag_to_move_bar.dart' as dtb;import 'package:kazumi/pages/settings/danmaku/danmaku_settings_sheet.dart';import 'package:kazumi/utils/constants.dart';+import 'package:kazumi/utils/device.dart';import 'package:audio_video_progress_bar/audio_video_progress_bar.dart';import 'package:kazumi/services/player/timed_shutdown_service.dart';import 'package:kazumi/utils/format.dart';@@ -113,14 +114,6 @@ class _PlayerItemPanelState extends State<PlayerItemPanel> {late final Widget _cachedDanmakuOffIcon;late final Widget _cachedDanmakuSettingsIcon;- bool get _desktop => switch (defaultTargetPlatform) {- TargetPlatform.windows ||- TargetPlatform.linux ||- TargetPlatform.macOS =>- true,- _ => false,- };-static const double _danmakuIconSize = 24.0;static const double _loadingIndicatorStrokeWidth = 2.0;@@ -234,14 +227,14 @@ class _PlayerItemPanelState extends State<PlayerItemPanel> {return PlayerPanelHoldFocusRegion(acquirePlayerPanelHold: widget.acquirePlayerPanelHold,child: Container(- constraints: _desktop+ constraints: isDesktop()? const BoxConstraints(maxWidth: 500, maxHeight: 33): const BoxConstraints(maxHeight: 33),padding: const EdgeInsets.symmetric(horizontal: 8),child: TextField(focusNode: textFieldFocus,- style:- TextStyle(fontSize: _desktop ? 15 : 13, color: Colors.white),+ style: TextStyle(+ fontSize: isDesktop() ? 15 : 13, color: Colors.white),controller: textController,textAlignVertical: TextAlignVertical.center,decoration: InputDecoration(@@ -253,14 +246,14 @@ class _PlayerItemPanelState extends State<PlayerItemPanel> {? '发个友善的弹幕见证当下': '已关闭弹幕',hintStyle: TextStyle(- fontSize: _desktop ? 15 : 13, color: Colors.white60),+ fontSize: isDesktop() ? 15 : 13, color: Colors.white60),alignLabelWithHint: true,contentPadding: EdgeInsets.symmetric(- vertical: 8, horizontal: _desktop ? 8 : 12),+ vertical: 8, horizontal: isDesktop() ? 8 : 12),border: OutlineInputBorder(borderSide: BorderSide.none,borderRadius:- BorderRadius.all(Radius.circular(_desktop ? 8 : 20)),+ BorderRadius.all(Radius.circular(isDesktop() ? 8 : 20)),),suffixIconConstraints: const BoxConstraints(minWidth: 0),suffixIcon: Row(@@ -279,7 +272,7 @@ class _PlayerItemPanelState extends State<PlayerItemPanel> {: Theme.of(context).disabledColor,shape: RoundedRectangleBorder(borderRadius:- BorderRadius.circular(_desktop ? 8 : 20),+ BorderRadius.circular(isDesktop() ? 8 : 20),),),child: const Text('发送'),@@ -511,7 +504,7 @@ class _PlayerItemPanelState extends State<PlayerItemPanel> {);}),),- if (!_desktop)+ if (!isDesktop())Positioned(right: 0,top: 0,@@ -691,8 +684,8 @@ class _PlayerItemPanelState extends State<PlayerItemPanel> {);Widget get _wideControls => Row(children: [- if (_desktop) Expanded(child: _desktopDanmakuControls),- if (!_desktop) ...[+ if (isDesktop()) Expanded(child: _desktopDanmakuControls),+ if (!isDesktop()) ...[IconButton(color: Colors.white,icon: playerController.danmaku.danmakuOn@@ -748,7 +741,7 @@ class _PlayerItemPanelState extends State<PlayerItemPanel> {compact: compact,timePlacement: PlayerTimeLabelPlacement.forViewport(MediaQuery.sizeOf(context),- desktop: _desktop,+ desktop: isDesktop(),),playPause: IconButton(tooltip: playerController.playback.playing ? '暂停' : '播放',@@ -788,7 +781,7 @@ class _PlayerItemPanelState extends State<PlayerItemPanel> {'${compact ? ' ' : ''}${durationToString(playerController.playback.currentPosition)} / ${durationToString(playerController.playback.duration)}',style: TextStyle(color: Colors.white,- fontSize: !compact && _desktop ? 16 : 12,+ fontSize: !compact && isDesktop() ? 16 : 12,fontFeatures: [FontFeature.tabularFigures()],),)),@@ -802,7 +795,9 @@ class _PlayerItemPanelState extends State<PlayerItemPanel> {if (videoPageController.isPip) {return compact ? const Text(' ') : const SizedBox.shrink();}- if (!_desktop && widget.fillsWindow && !videoPageController.isFullscreen) {+ if (!isDesktop() &&+ widget.fillsWindow &&+ !videoPageController.isFullscreen) {return const SizedBox.shrink();}return IconButton(@@ -855,18 +850,18 @@ class _PlayerItemPanelState extends State<PlayerItemPanel> {),),_forwardButton(),- if (_desktop)+ if (isDesktop())PlayerScreenshotControls(controller: playerController.screenshots,onCapture: widget.handleScreenShot,onReview: widget.showScreenshotCandidates,),- if ((_desktop &&+ if ((isDesktop() &&(compact || !videoPageController.isFullscreen)) ||- (defaultTargetPlatform == TargetPlatform.android))+ Platform.isAndroid)IconButton(onPressed: () async {- if (_desktop) {+ if (isDesktop()) {if (videoPageController.isPip) {await PipUtils.exitDesktopPIPWindow();} else {diff --git a/lib/services/platform/display_mode_service.dart b/lib/services/platform/display_mode_service.dartindex d4967268..5c1305fa 100644--- a/lib/services/platform/display_mode_service.dart+++ b/lib/services/platform/display_mode_service.dart@@ -1,6 +1,8 @@-import 'package:flutter/foundation.dart';+import 'dart:io';+import 'package:flutter/services.dart';import 'package:kazumi/services/logging/logger.dart';+import 'package:kazumi/utils/device.dart';import 'package:window_manager/window_manager.dart';class DisplayModeService {@@ -14,9 +16,7 @@ class DisplayModeService {static Future<void> applyVideoFullscreen(bool fullscreen) {return _pendingFullscreen = _pendingFullscreen.then((_) async {- if (defaultTargetPlatform == TargetPlatform.linux ||- defaultTargetPlatform == TargetPlatform.macOS ||- defaultTargetPlatform == TargetPlatform.windows) {+ if (isDesktop()) {await _attempt(() => windowManager.setFullScreen(fullscreen));return;}@@ -59,10 +59,10 @@ class DisplayModeService {late final Future<void> request;request = (_pendingSystemBars ?? Future<void>.value()).then((_) => _attempt(() async {- if (defaultTargetPlatform == TargetPlatform.android) {+ if (Platform.isAndroid) {await _intentChannel.invokeMethod('setSystemBarsHidden', hidden);- } else if (defaultTargetPlatform == TargetPlatform.iOS) {+ } else if (Platform.isIOS) {await SystemChrome.setEnabledSystemUIMode(hidden? SystemUiMode.immersiveStickydiff --git a/lib/services/storage/settings_keys.dart b/lib/services/storage/settings_keys.dartindex aacf6a3e..68f7374a 100644--- a/lib/services/storage/settings_keys.dart+++ b/lib/services/storage/settings_keys.dart@@ -1,11 +1,5 @@-import 'package:flutter/foundation.dart';import 'package:kazumi/services/player/syncplay_endpoint.dart';--/// Desktop platforms (Windows/macOS/Linux), used for setting defaults.-bool get _isDesktopPlatform =>- defaultTargetPlatform == TargetPlatform.windows ||- defaultTargetPlatform == TargetPlatform.macOS ||- defaultTargetPlatform == TargetPlatform.linux;+import 'package:kazumi/utils/device.dart';enum SettingGroup {player,@@ -114,7 +108,7 @@ class SettingsKeys {'pauseOnDanmakuEdit',true,group: SettingGroup.danmaku,- defaultResolver: (_) => !_isDesktopPlatform,+ defaultResolver: (_) => !isDesktop(),);static const danmakuBorder = SettingKey<bool>(_SettingBoxKey.danmakuBorder,