基于自定义规则的番剧采集APP,支持流媒体在线观看,支持弹幕,支持实时超分辨率。
refactor(player): remove tab danmaku input and simplify control boundaries
Predidit782e70766a8e
diff --git a/lib/pages/player/controller/player_danmaku_controller.dart b/lib/pages/player/controller/player_danmaku_controller.dartindex 2f550f0c..268a6911 100644--- a/lib/pages/player/controller/player_danmaku_controller.dart+++ b/lib/pages/player/controller/player_danmaku_controller.dart@@ -2,7 +2,6 @@import 'package:canvas_danmaku/canvas_danmaku.dart' as canvas;import 'package:kazumi/modules/danmaku/danmaku_module.dart';-import 'package:kazumi/pages/player/controller/player_models.dart';import 'package:kazumi/pages/download/download_controller.dart';import 'package:kazumi/request/apis/danmaku_api.dart';import 'package:kazumi/services/logging/logger.dart';@@ -100,7 +99,6 @@ abstract class _PlayerDanmakuController with Store {bool danmakuOn = false;@observablebool danmakuLoading = false;- DanmakuDestination danmakuDestination = DanmakuDestination.remoteDanmaku;int bangumiID = 0;int _scheduledDanmakuGeneration = 0;@@ -137,8 +135,7 @@ abstract class _PlayerDanmakuController with Store {canvasController.clear();}- // Fetching must not mutate current danmaku state; VideoPageController applies- // the result only after confirming the playback session is still current.+ // Apply fetched data only after VideoPageController validates the session.Future<DanmakuLoadResult> fetchDanmaku(int bangumiId,String pluginName,diff --git a/lib/pages/player/controller/player_models.dart b/lib/pages/player/controller/player_models.dartindex d8ced769..0f4f506b 100644--- a/lib/pages/player/controller/player_models.dart+++ b/lib/pages/player/controller/player_models.dart@@ -11,7 +11,7 @@ class PlaybackInitParams {final int danmakuEpisodeNumber;final String pageUrl;- /// 集数排序号,语义同 EpisodeRef.sortNumber(在线解析自标题、离线为 episodeNumber)。+ /// Parsed title number online, downloaded episode number offline.final int? sortNumber;final Map<String, String> httpHeaders;final bool adBlockerEnabled;@@ -42,11 +42,6 @@ class PlaybackInitParams {});}-enum DanmakuDestination {- chatRoom,- remoteDanmaku,-}-class SyncPlayChatMessage {final String username;final String message;diff --git a/lib/pages/video/danmaku_destination_sheet.dart b/lib/pages/player/danmaku_destination_sheet.dartsimilarity index 95%rename from lib/pages/video/danmaku_destination_sheet.dartrename to lib/pages/player/danmaku_destination_sheet.dartindex 96212e17..c0210825 100644--- a/lib/pages/video/danmaku_destination_sheet.dart+++ b/lib/pages/player/danmaku_destination_sheet.dart@@ -3,7 +3,11 @@ import 'package:flutter/material.dart';import 'package:kazumi/bean/dialog/adaptive_bottom_sheet.dart';import 'package:kazumi/bean/dialog/material_bottom_sheet.dart';import 'package:kazumi/bean/widget/split_list_row.dart';-import 'package:kazumi/pages/player/controller/player_models.dart';++enum DanmakuDestination {+ chatRoom,+ remoteDanmaku,+}Future<DanmakuDestination?> showDanmakuDestinationSheet(BuildContext context) {return showAdaptiveBottomSheet<DanmakuDestination>(diff --git a/lib/pages/player/player_item.dart b/lib/pages/player/player_item.dartindex 014b6ca5..3dc2f911 100644--- a/lib/pages/player/player_item.dart+++ b/lib/pages/player/player_item.dart@@ -51,8 +51,6 @@ class PlayerItem extends StatefulWidget {required this.changeEpisode,required this.onBackPressed,required this.keyboardFocus,- required this.sendDanmaku,- required this.showDanmakuDestinationPickerAndSend,required this.pauseForTimedShutdown,this.disableAnimations = false,});@@ -65,10 +63,8 @@ class PlayerItem extends StatefulWidget {final Future<void> Function(int episode, {int currentRoad, int offset})changeEpisode;final void Function(BuildContext) onBackPressed;- final bool Function(String) sendDanmaku;final FocusNode keyboardFocus;final bool disableAnimations;- final Future<bool> Function(String) showDanmakuDestinationPickerAndSend;final VoidCallback pauseForTimedShutdown;@override@@ -110,12 +106,11 @@ class _PlayerItemState extends State<PlayerItem>late bool _danmakuUseSystemFont;late double _danmakuBorderSize;- late bool haEnable;late bool autoPlayNext;late bool backgroundPlayback;late bool brightnessVolumeGesture;- /// Idle timeout before the player panel auto-hides, in milliseconds.+ // Auto-hide delay in milliseconds.late int playerControllerLayerDisappearTime;Timer? hideTimer;@@ -149,16 +144,11 @@ class _PlayerItemState extends State<PlayerItem>_scheduleAndroidPIPSourceRectSync();}- /// Pauses playback and suspends demuxer prefetch when the app is- /// backgrounded on Android/iOS, unless background playback is enabled.@overridevoid didChangeAppLifecycleState(AppLifecycleState state) async {super.didChangeAppLifecycleState(state);if (state == AppLifecycleState.paused && !backgroundPlayback) {- // Requested before any await so the suspend intent is recorded in- // lifecycle dispatch order; a later resumed callback then wins even- // if this callback is still awaiting pause(). The demuxer keeps- // prefetching while paused, so suspend regardless of playing state.+ // Suspend before awaiting pause so a later resume wins; pause alone keeps prefetching.final suspend = playerController.playback.setPrefetchSuspended(true);if (playerController.playback.mediaPlayer != null &&playerController.playback.playerPlaying) {@@ -238,9 +228,7 @@ class _PlayerItemState extends State<PlayerItem>);}- /// The letterboxed video image in physical pixels, relative to the Flutter- /// view. Android animates the picture in picture window out of this rect- /// instead of shrinking the whole window.+ // Android PiP expects the letterboxed video bounds in physical pixels.Rect? _androidPIPSourceRect() {if (!mounted) {return null;@@ -276,9 +264,7 @@ class _PlayerItemState extends State<PlayerItem>);}- /// The panel is dropped before the request, not from the mode callback:- /// tearing it down while the window animates steals the frames the resized- /// surface needs.+ // Remove controls before PiP entry to avoid rebuilding during the resize animation.Future<void> enterAndroidPictureInPicture() async {if (!Platform.isAndroid || !mounted) {return;@@ -325,7 +311,6 @@ class _PlayerItemState extends State<PlayerItem>}}- /// Gesture triggered entry uses the rect last handed to the platform.void _scheduleAndroidPIPSourceRectSync() {if (!Platform.isAndroid || _pipSourceRectSyncScheduled) {return;@@ -421,8 +406,6 @@ class _PlayerItemState extends State<PlayerItem>episode: targetEpisode,road: currentRoad,);- // Resolution failures surface through the controller's failed state;- // the toast here is progress feedback only.final targetRef = videoPageController.resolveEpisode(targetSelection);if (targetRef != null) {KazumiDialog.showToast(message: '正在加载${targetRef.displayTitle}');@@ -494,7 +477,7 @@ class _PlayerItemState extends State<PlayerItem>if (playerController.panel.showVideoController) {hideVideoController();} else {- displayVideoController();+ showVideoController();}}@@ -907,10 +890,6 @@ class _PlayerItemState extends State<PlayerItem>}}- void displayVideoController() {- showVideoController();- }-void hideVideoController() {if (!_canHidePlayerPanel) {return;@@ -920,7 +899,6 @@ class _PlayerItemState extends State<PlayerItem>playerController.panel.showVideoController = false;}- // All temporary panel blockers flow through this single lease registry.PlayerPanelHold acquirePlayerPanelHold() {late final PlayerPanelHold hold;hold = PlayerPanelHold(@@ -948,8 +926,7 @@ class _PlayerItemState extends State<PlayerItem>}}- // Fullscreen and system overlay changes can tear down panel interactions, so- // the parent owns an emergency release path for every outstanding hold.+ // Fullscreen and system overlays can dispose controls before their holds are released.void _releasePlayerPanelHolds() {for (final hold in _playerPanelHolds.toList()) {hold.releaseSilently();@@ -1145,8 +1122,7 @@ class _PlayerItemState extends State<PlayerItem>videoPageController.roadList[playingSelection.road];if (playerController.playback.completed && !videoPageController.loading) {if (playerController.playback.resumedNearEnd) {- // Completion of a stale near-end resume is not a real watch;- // replay from the beginning instead of advancing.+ // Replay stale near-end resumes instead of advancing to the next episode.unawaited(playerController.playback.restartFromBeginning());} else if (playingSelection.episode < playingRoadData.data.length &&autoPlayNext) {@@ -1154,8 +1130,7 @@ class _PlayerItemState extends State<PlayerItem>episode: playingSelection.episode + 1,road: playingSelection.road,);- // Resolution failures surface through the controller's failed state- // instead of silently retrying here every second.+ // Let the controller report resolution failures without retrying every tick.final nextRef = videoPageController.resolveEpisode(nextSelection);if (nextRef != null) {KazumiDialog.showToast(message: '正在加载${nextRef.displayTitle}');@@ -1335,32 +1310,17 @@ class _PlayerItemState extends State<PlayerItem>);}- /// Used to decide which panel is used.- /// It's too complicated to write these in conditional sentence.- /// * true: use [PlayerItemPanel]- /// * false: use [SmallestPlayerItemPanel]- bool needFullPanel(BuildContext context) {- // windows too small, workaround for ohos floating window- if (MediaQuery.sizeOf(context).width < LayoutBreakpoint.compact['width']!) {+ bool _needsFullPanel(BuildContext context) {+ final size = MediaQuery.sizeOf(context);+ if (size.width < LayoutBreakpoint.compact['width']!) {return false;}- // in desktop pip modeif (videoPageController.isPip) {return false;}- // does not meet Google's phone landscape height and tablet landscape width requirements.if (!isDesktop() &&- (MediaQuery.sizeOf(context).height >- LayoutBreakpoint.compact['height']! &&- MediaQuery.sizeOf(context).width <- LayoutBreakpoint.medium['width']!)) {- return false;- }- if (isDesktop() &&- (MediaQuery.sizeOf(context).height >- LayoutBreakpoint.compact['height']! &&- MediaQuery.sizeOf(context).width <- LayoutBreakpoint.compact['width']!)) {+ size.height > LayoutBreakpoint.compact['height']! &&+ size.width < LayoutBreakpoint.medium['width']!) {return false;}return true;@@ -1458,7 +1418,6 @@ class _PlayerItemState extends State<PlayerItem>_danmakuFontWeight = GStorage.getSetting(SettingsKeys.danmakuFontWeight);_danmakuUseSystemFont = GStorage.getSetting(SettingsKeys.useSystemFont);_danmakuBorderSize = GStorage.getSetting(SettingsKeys.danmakuBorderSize);- haEnable = GStorage.getSetting(SettingsKeys.hAenable);autoPlayNext = GStorage.getSetting(SettingsKeys.autoPlayNext);backgroundPlayback = GStorage.getSetting(SettingsKeys.backgroundPlayback);brightnessVolumeGesture =@@ -1470,13 +1429,12 @@ class _PlayerItemState extends State<PlayerItem>unawaited(_bindAudioService());playerTimer = getPlayerTimer();windowManager.addListener(this);- displayVideoController();+ showVideoController();}@overridevoid dispose() {- // Playback lifetime is owned by the route-scoped PlayerController.- // This widget only detaches UI listeners and timers.+ // The route-scoped PlayerController owns playback disposal._fullscreenListener();_playerSizeListener();WidgetsBinding.instance.removeObserver(this);@@ -1510,13 +1468,12 @@ class _PlayerItemState extends State<PlayerItem>? SystemMouseCursors.none: SystemMouseCursors.basic,onHover: (PointerEvent pointerEvent) {- // workaround for android.- // I don't know why, but android tap event will trigger onHover event.+ // Android taps can emit hover events.if (isDesktop()) {if (pointerEvent.position.dy > 50 &&pointerEvent.position.dy <MediaQuery.of(context).size.height - 70) {- displayVideoController();+ showVideoController();} else {if (!playerController.panel.showVideoController) {_panelVisibilityController.forward();@@ -1636,8 +1593,7 @@ class _PlayerItemState extends State<PlayerItem>area: _danmakuArea,opacity: _opacity,fontSize: _fontSize,- // Playback speed is applied by updateDanmakuSpeed,- // right after the controller is handed over.+ // Speed scaling is applied after canvas creation.duration: _danmakuDuration,lineHeight: _danmakuLineHeight,strokeWidth: _border ? _danmakuBorderSize : 0.0,@@ -1657,14 +1613,13 @@ class _PlayerItemState extends State<PlayerItem>(Platform.isAndroid &&(videoPageController.isPip || _pipEnterRequested))? const SizedBox.shrink()- : (needFullPanel(context))+ : (_needsFullPanel(context))? PlayerItemPanel(playerController: playerController,videoPageController: videoPageController,onBackPressed: widget.onBackPressed,setPlaybackSpeed: setPlaybackSpeed,showDanmakuSwitch: showDanmakuSwitch,- changeEpisode: widget.changeEpisode,toggleMenu: widget.toggleMenu,handleFullscreen: handleFullscreen,enterAndroidPictureInPicture:@@ -1678,15 +1633,12 @@ class _PlayerItemState extends State<PlayerItem>panelVisibilityController:_panelVisibilityController,keyboardFocus: widget.keyboardFocus,- sendDanmaku: widget.sendDanmaku,acquirePlayerPanelHold: acquirePlayerPanelHold,onMenuVisibilityChanged:_handlePlayerMenuVisibilityChanged,handleDanmaku: handleDanmaku,showVideoInfo: showVideoInfo,showSyncPlayPanel: showSyncPlayPanel,- showDanmakuDestinationPickerAndSend:- widget.showDanmakuDestinationPickerAndSend,pauseForTimedShutdown:widget.pauseForTimedShutdown,disableAnimations: widget.disableAnimations,@@ -1774,7 +1726,6 @@ class _PlayerItemState extends State<PlayerItem>final double delta = details.delta.dy;if (tapPosition < sectionWidth) {- // Left half adjusts brightness.playerController.panel.brightnessSeeking =true;_showBrightnessAdjustmentHud();@@ -1787,7 +1738,6 @@ class _PlayerItemState extends State<PlayerItem>setBrightness(result);playerController.panel.brightness = result;} else {- // Right half adjusts volume._showVolumeAdjustmentHud();if (!playerController.panel.volumeSeeking) {playerController.panel.volumeSeeking = true;diff --git a/lib/pages/player/player_item_panel.dart b/lib/pages/player/player_item_panel.dartindex 6003f1c1..ec39878d 100644--- a/lib/pages/player/player_item_panel.dart+++ b/lib/pages/player/player_item_panel.dart@@ -1,11 +1,13 @@import 'dart:async';import 'dart:io';+import 'package:canvas_danmaku/models/danmaku_content_item.dart';import 'package:flutter/material.dart';import 'package:flutter_mobx/flutter_mobx.dart';import 'package:flutter_modular/flutter_modular.dart';import 'package:flutter_svg/flutter_svg.dart';import 'package:kazumi/bean/widget/play_pause_icon.dart';import 'package:kazumi/pages/player/player_adjustment_hud.dart';+import 'package:kazumi/pages/player/danmaku_destination_sheet.dart';import 'package:kazumi/pages/player/controller/player_aspect_ratio.dart';import 'package:kazumi/pages/player/controller/player_super_resolution.dart';import 'package:kazumi/bean/widget/embedded_native_control_area.dart';@@ -33,7 +35,6 @@ class PlayerItemPanel extends StatefulWidget {required this.onBackPressed,required this.setPlaybackSpeed,required this.showDanmakuSwitch,- required this.changeEpisode,required this.handleFullscreen,required this.enterAndroidPictureInPicture,required this.handleScreenShot,@@ -44,14 +45,12 @@ class PlayerItemPanel extends StatefulWidget {required this.panelVisibilityController,required this.toggleMenu,required this.keyboardFocus,- required this.sendDanmaku,required this.acquirePlayerPanelHold,required this.onMenuVisibilityChanged,required this.handleDanmaku,required this.skipOP,required this.showVideoInfo,required this.showSyncPlayPanel,- required this.showDanmakuDestinationPickerAndSend,required this.pauseForTimedShutdown,this.disableAnimations = false,});@@ -61,7 +60,6 @@ class PlayerItemPanel extends StatefulWidget {final void Function(BuildContext) onBackPressed;final Future<void> Function(double) setPlaybackSpeed;final void Function() showDanmakuSwitch;- final Future<void> Function(int, {int currentRoad, int offset}) changeEpisode;final void Function() toggleMenu;final void Function() handleFullscreen;final Future<void> Function() enterAndroidPictureInPicture;@@ -77,10 +75,8 @@ class PlayerItemPanel extends StatefulWidget {final void Function() handleDanmaku;final void Function(String direction) handlePreNextEpisode;final void Function() skipOP;- final bool Function(String) sendDanmaku;final void Function() showVideoInfo;final void Function() showSyncPlayPanel;- final Future<bool> Function(String) showDanmakuDestinationPickerAndSend;final VoidCallback pauseForTimedShutdown;final bool disableAnimations;@@ -132,13 +128,50 @@ class _PlayerItemPanelState extends State<PlayerItemPanel> {textFieldFocus.unfocus();_releaseDanmakuTextFieldPanel();- final sent = await widget.showDanmakuDestinationPickerAndSend(message);- if (!mounted) {+ if (message.trim().isEmpty) {+ KazumiDialog.showToast(message: '弹幕内容为空');return;}- if (sent) {- textController.clear();++ final destination = await showDanmakuDestinationSheet(context);+ if (!mounted || destination == null) {+ return;+ }++ widget.keyboardFocus.requestFocus();+ if (playerController.danmaku.danDanmakus.isEmpty) {+ KazumiDialog.showToast(message: '当前剧集不支持弹幕发送的说');+ return;+ }+ if (message.length > 100) {+ KazumiDialog.showToast(message: '弹幕内容过长');+ return;+ }++ if (destination == DanmakuDestination.chatRoom) {+ if (playerController.syncplay.syncplayRoom.isEmpty) {+ KazumiDialog.showToast(message: '你还没有加入一起看,无法发送聊天室弹幕');+ return;+ }++ final sender =+ playerController.syncplay.syncplayController?.username ?? '我';+ playerController.danmaku.canvasController.addDanmaku(+ DanmakuContentItem(+ '$sender:$message',+ color: Colors.orange,+ isColorful: true,+ type: DanmakuItemType.bottom,+ extra: DateTime.now().millisecondsSinceEpoch,+ ),+ );+ unawaited(playerController.sendSyncPlayChatMessage(message));+ } else {+ // This provider has no send API; display a local echo.+ playerController.danmaku.canvasController+ .addDanmaku(DanmakuContentItem(message, selfSend: true));}+ textController.clear();}Widget get danmakuTextField {@@ -212,58 +245,6 @@ class _PlayerItemPanelState extends State<PlayerItemPanel> {});}- void showSetSpeedSheet() {- final double currentSpeed = playerController.playback.playerSpeed;- KazumiDialog.show(builder: (context) {- return AlertDialog(- title: const Text('播放速度'),- content: StatefulBuilder(- builder: (BuildContext context, StateSetter setState) {- return Wrap(- spacing: 8,- runSpacing: isDesktop() ? 8 : 0,- children: [- for (final double i in defaultPlaySpeedList) ...<Widget>[- if (i == currentSpeed)- FilledButton(- onPressed: () async {- await widget.setPlaybackSpeed(i);- KazumiDialog.dismiss();- },- child: Text(i.toString()),- )- else- FilledButton.tonal(- onPressed: () async {- await widget.setPlaybackSpeed(i);- KazumiDialog.dismiss();- },- child: Text(i.toString()),- ),- ]- ],- );- }),- actions: <Widget>[- TextButton(- onPressed: () => KazumiDialog.dismiss(),- child: Text(- '取消',- style: TextStyle(color: Theme.of(context).colorScheme.outline),- ),- ),- TextButton(- onPressed: () async {- await widget.setPlaybackSpeed(1.0);- KazumiDialog.dismiss();- },- child: const Text('默认速度'),- ),- ],- );- });- }-void showForwardChange() {KazumiDialog.show(builder: (context) {String input = "";@@ -514,8 +495,7 @@ class _PlayerItemPanelState extends State<PlayerItemPanel> {Positioned(top: 25,child: Observer(builder: (context) {- // PlayerSeekHud latches values only while visible, so skipping the- // position reads when hidden keeps the 1s tick from rebuilding this.+ // Hidden HUDs must not observe playback ticks.final visible = playerController.panel.showSeekTime;return PlayerSeekHud(visible: visible,@@ -632,9 +612,7 @@ class _PlayerItemPanelState extends State<PlayerItemPanel> {child: Column(crossAxisAlignment: CrossAxisAlignment.start,children: [- // Position reads stay inside these narrow Observers so the 1s- // progress tick rebuilds only the bar and time text, not the- // whole bottom bar.+ // Keep playback ticks inside the progress and time observers.if (!isDesktop() && !isTablet())Container(padding: const EdgeInsets.only(left: 10.0, bottom: 10),diff --git a/lib/pages/video/danmaku_send_sheet.dart b/lib/pages/video/danmaku_send_sheet.dartdeleted file mode 100644index b46cd9c0..00000000--- a/lib/pages/video/danmaku_send_sheet.dart+++ /dev/null@@ -1,75 +0,0 @@-import 'package:flutter/material.dart';--Future<String?> showMobileDanmakuInputSheet(BuildContext context) {- return showModalBottomSheet<String>(- context: context,- shape: const BeveledRectangleBorder(),- isScrollControlled: true,- builder: (context) => const _MobileDanmakuInputSheet(),- );-}--class _MobileDanmakuInputSheet extends StatefulWidget {- const _MobileDanmakuInputSheet();-- @override- State<_MobileDanmakuInputSheet> createState() =>- _MobileDanmakuInputSheetState();-}--class _MobileDanmakuInputSheetState extends State<_MobileDanmakuInputSheet> {- String _danmakuText = '';-- void _submit([String? value]) {- Navigator.of(context).pop(value ?? _danmakuText);- }-- @override- Widget build(BuildContext context) {- return Padding(- padding: EdgeInsets.only(- bottom: MediaQuery.viewInsetsOf(context).bottom,- left: 8,- ),- child: Row(- mainAxisAlignment: MainAxisAlignment.center,- children: [- Expanded(- child: Container(- constraints: const BoxConstraints(maxHeight: 34),- child: TextField(- style: const TextStyle(fontSize: 15),- autofocus: true,- textInputAction: TextInputAction.send,- textAlignVertical: TextAlignVertical.center,- onChanged: (value) => _danmakuText = value,- onSubmitted: _submit,- decoration: const InputDecoration(- filled: true,- floatingLabelBehavior: FloatingLabelBehavior.never,- hintText: '发个友善的弹幕见证当下',- hintStyle: TextStyle(fontSize: 14),- alignLabelWithHint: true,- contentPadding:- EdgeInsets.symmetric(vertical: 8, horizontal: 12),- border: OutlineInputBorder(- borderSide: BorderSide.none,- borderRadius: BorderRadius.all(Radius.circular(20)),- ),- ),- ),- ),- ),- IconButton(- tooltip: '发送',- onPressed: _submit,- icon: Icon(- Icons.send_rounded,- color: Theme.of(context).colorScheme.primary,- ),- ),- ],- ),- );- }-}diff --git a/lib/pages/video/player_content_tabs.dart b/lib/pages/video/player_content_tabs.dartindex 6039875d..37b4b7d6 100644--- a/lib/pages/video/player_content_tabs.dart+++ b/lib/pages/video/player_content_tabs.dart@@ -5,12 +5,10 @@ class PlayerContentTabs extends StatelessWidget {super.key,required this.controller,required this.onEpisodesSelected,- this.trailing,});final TabController controller;final VoidCallback onEpisodesSelected;- final Widget? trailing;@overrideWidget build(BuildContext context) {@@ -21,37 +19,26 @@ class PlayerContentTabs extends StatelessWidget {return Material(color: colors.surface,- child: Row(- children: [- Expanded(- child: TabBar(- controller: controller,- padding: EdgeInsets.zero,- dividerHeight: 0,- splashBorderRadius: BorderRadius.zero,- indicatorSize: TabBarIndicatorSize.label,- indicatorWeight: 4,- labelColor: colors.primary,- unselectedLabelColor: colors.onSurfaceVariant,- labelStyle: theme.textTheme.titleSmall?.copyWith(- fontWeight: FontWeight.w700,- ),- unselectedLabelStyle: theme.textTheme.titleSmall,- labelPadding: const EdgeInsets.symmetric(horizontal: 4),- onTap: (index) {- if (index == 0) onEpisodesSelected();- },- tabs: [- Tab(text: '选集', height: height),- Tab(text: '评论', height: height),- ],- ),- ),- if (trailing != null)- Padding(- padding: const EdgeInsets.symmetric(horizontal: 8),- child: trailing,- ),+ child: TabBar(+ controller: controller,+ padding: EdgeInsets.zero,+ dividerHeight: 0,+ splashBorderRadius: BorderRadius.zero,+ indicatorSize: TabBarIndicatorSize.label,+ indicatorWeight: 4,+ labelColor: colors.primary,+ unselectedLabelColor: colors.onSurfaceVariant,+ labelStyle: theme.textTheme.titleSmall?.copyWith(+ fontWeight: FontWeight.w700,+ ),+ unselectedLabelStyle: theme.textTheme.titleSmall,+ labelPadding: const EdgeInsets.symmetric(horizontal: 4),+ onTap: (index) {+ if (index == 0) onEpisodesSelected();+ },+ tabs: [+ Tab(text: '选集', height: height),+ Tab(text: '评论', height: height),],),);diff --git a/lib/pages/video/video_page.dart b/lib/pages/video/video_page.dartindex b2396430..b1e134db 100644--- a/lib/pages/video/video_page.dart+++ b/lib/pages/video/video_page.dart@@ -21,8 +21,6 @@ import 'package:kazumi/pages/history/history_controller.dart';import 'package:kazumi/pages/player/episode_comments_sheet.dart';import 'package:kazumi/pages/player/player_controller.dart';import 'package:kazumi/pages/player/player_item.dart';-import 'package:kazumi/pages/video/danmaku_destination_sheet.dart';-import 'package:kazumi/pages/video/danmaku_send_sheet.dart';import 'package:kazumi/pages/video/episode_selection_panel.dart';import 'package:kazumi/pages/video/player_content_tabs.dart';import 'package:kazumi/pages/video/video_controller.dart';@@ -447,80 +445,6 @@ class _VideoPageState extends State<VideoPage>}}- bool sendDanmaku(String msg) {- keyboardFocus.requestFocus();- if (playerController.danmaku.danDanmakus.isEmpty) {- KazumiDialog.showToast(- message: '当前剧集不支持弹幕发送的说',- );- return false;- }- if (msg.isEmpty) {- KazumiDialog.showToast(message: '弹幕内容为空');- return false;- } else if (msg.length > 100) {- KazumiDialog.showToast(message: '弹幕内容过长');- return false;- }-- final destination = playerController.danmaku.danmakuDestination;-- if (destination == DanmakuDestination.chatRoom) {- if (playerController.syncplay.syncplayRoom.isEmpty) {- KazumiDialog.showToast(message: '你还没有加入一起看,无法发送聊天室弹幕');- return false;- }-- final sender =- playerController.syncplay.syncplayController?.username ?? '我';- final String displayText = '$sender:$msg';-- playerController.danmaku.canvasController.addDanmaku(- DanmakuContentItem(- displayText,- color: Colors.orange,- isColorful: true,- type: DanmakuItemType.bottom,- extra: DateTime.now().millisecondsSinceEpoch,- ),- );-- unawaited(playerController.sendSyncPlayChatMessage(msg));- } else {- // This provider has no send API; display a local echo.- playerController.danmaku.canvasController- .addDanmaku(DanmakuContentItem(msg, selfSend: true));- }-- return true;- }-- Future<void> showMobileDanmakuInput() async {- final message = await showMobileDanmakuInputSheet(context);-- if (!mounted || message == null) {- return;- }- await showDanmakuDestinationPickerAndSend(message);- }-- Future<bool> showDanmakuDestinationPickerAndSend(String msg) async {- if (msg.trim().isEmpty) {- KazumiDialog.showToast(message: '弹幕内容为空');- return false;- }-- final result = await showDanmakuDestinationSheet(context);-- if (result == null || !mounted) {- return false;- }-- setState(() {});- playerController.danmaku.danmakuDestination = result;- return sendDanmaku(msg);- }-@overrideWidget build(BuildContext context) {final bool isLandscape = _windowIsLandscape;@@ -774,10 +698,7 @@ class _VideoPageState extends State<VideoPage>changeEpisode: changeEpisode,onBackPressed: onBackPressed,keyboardFocus: keyboardFocus,- sendDanmaku: sendDanmaku,disableAnimations: disableAnimations,- showDanmakuDestinationPickerAndSend:- showDanmakuDestinationPickerAndSend,pauseForTimedShutdown: pauseForTimedShutdown,),),@@ -840,7 +761,6 @@ class _VideoPageState extends State<VideoPage>Widget get tabBody {final colors = Theme.of(context).colorScheme;- final bool danmakuOn = playerController.danmaku.danmakuOn;final int episodeNum = videoPageController.commentsEpisode;return ColoredBox(@@ -851,23 +771,6 @@ class _VideoPageState extends State<VideoPage>PlayerContentTabs(controller: tabController,onEpisodesSelected: _revealCurrentEpisode,- trailing: !_windowIsLandscape- ? IconButton.filledTonal(- tooltip: danmakuOn ? '发送弹幕' : '弹幕已关闭',- onPressed: () {- if (danmakuOn && !videoPageController.loading) {- showMobileDanmakuInput();- } else if (videoPageController.loading) {- KazumiDialog.showToast(message: '请等待视频加载完成');- } else {- KazumiDialog.showToast(message: '请先打开弹幕');- }- },- icon: Icon(danmakuOn- ? Icons.edit_note_rounded- : Icons.comments_disabled_outlined),- )- : null,),Expanded(child: TabBarView(