Skip to content

Commit

Permalink
Merge pull request #572 from ErBWs/mod-player
Browse files Browse the repository at this point in the history
mod: move episode comments to menu
  • Loading branch information
Predidit authored Jan 8, 2025
2 parents 415e48c + 7214a08 commit 224e66c
Show file tree
Hide file tree
Showing 3 changed files with 190 additions and 183 deletions.
89 changes: 47 additions & 42 deletions lib/pages/player/episode_comments_sheet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ class EpisodeCommentsSheet extends StatefulWidget {
State<EpisodeCommentsSheet> createState() => _EpisodeCommentsSheetState();
}

class _EpisodeCommentsSheetState extends State<EpisodeCommentsSheet> {
class _EpisodeCommentsSheetState extends State<EpisodeCommentsSheet>
with AutomaticKeepAliveClientMixin {
final infoController = Modular.get<InfoController>();
bool isLoading = false;
bool commentsQueryTimeout = false;
Expand Down Expand Up @@ -137,57 +138,61 @@ class _EpisodeCommentsSheetState extends State<EpisodeCommentsSheet> {
void showEpisodeSelection() {
final TextEditingController textController = TextEditingController();
KazumiDialog.show(
builder: (context) {
return AlertDialog(
title: const Text('输入集数'),
content: StatefulBuilder(
builder: (BuildContext context, StateSetter setState) {
return TextField(
inputFormatters: <TextInputFormatter>[
FilteringTextInputFormatter.digitsOnly
],
controller: textController,
);
}),
actions: [
TextButton(
onPressed: () => KazumiDialog.dismiss(),
child: Text(
'取消',
style:
TextStyle(color: Theme.of(context).colorScheme.outline),
),
),
TextButton(
onPressed: () {
if (textController.text.isEmpty) {
KazumiDialog.showToast(message: '请输入集数');
return;
}
final ep = int.tryParse(textController.text) ?? 0;
if (ep == 0) {
return;
}
setState(() {
isLoading = true;
});
loadComments(ep);
KazumiDialog.dismiss();
},
child: const Text('刷新'),
builder: (context) {
return AlertDialog(
title: const Text('输入集数'),
content: StatefulBuilder(
builder: (BuildContext context, StateSetter setState) {
return TextField(
inputFormatters: <TextInputFormatter>[
FilteringTextInputFormatter.digitsOnly
],
controller: textController,
);
}),
actions: [
TextButton(
onPressed: () => KazumiDialog.dismiss(),
child: Text(
'取消',
style: TextStyle(color: Theme.of(context).colorScheme.outline),
),
],
);
});
),
TextButton(
onPressed: () {
if (textController.text.isEmpty) {
KazumiDialog.showToast(message: '请输入集数');
return;
}
final ep = int.tryParse(textController.text) ?? 0;
if (ep == 0) {
return;
}
setState(() {
isLoading = true;
});
loadComments(ep);
KazumiDialog.dismiss();
},
child: const Text('刷新'),
),
],
);
},
);
}

@override
Widget build(BuildContext context) {
super.build(context);
return Scaffold(
body: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [commentsInfo, Expanded(child: episodeCommentsBody)],
),
);
}

@override
bool get wantKeepAlive => true;
}
68 changes: 7 additions & 61 deletions lib/pages/player/player_item.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import 'package:kazumi/modules/danmaku/danmaku_episode_response.dart';
import 'package:kazumi/bean/appbar/drag_to_move_bar.dart' as dtb;
import 'package:kazumi/pages/settings/danmaku/danmaku_settings_window.dart';
import 'package:kazumi/utils/constants.dart';
import 'package:kazumi/pages/player/episode_comments_sheet.dart';
import 'package:saver_gallery/saver_gallery.dart';
import 'package:mobx/mobx.dart' as mobx;
import 'package:kazumi/bean/widget/collect_button.dart';
Expand Down Expand Up @@ -182,6 +181,8 @@ class _PlayerItemState extends State<PlayerItem>
if (!showVideoController) {
displayVideoController();
}
hideTimer?.cancel();
startHideTimer();
}

void _handleMouseScroller() {
Expand Down Expand Up @@ -371,7 +372,10 @@ class _PlayerItemState extends State<PlayerItem>
_handleFullscreenChange(context);
if (videoPageController.isFullscreen) {
Utils.exitFullScreen();
widget.locateEpisode();
if (!Utils.isDesktop()) {
widget.locateEpisode();
videoPageController.showTabBody = true;
}
} else {
Utils.enterFullScreen();
videoPageController.showTabBody = false;
Expand Down Expand Up @@ -1393,64 +1397,7 @@ class _PlayerItemState extends State<PlayerItem>
fontWeight: FontWeight.bold),
),
),
IconButton(
color: Colors.white,
icon: const Icon(Icons.comment),
onPressed: () {
bool needRestart = playerController.playing;
playerController.pause();
episodeNum = Utils.extractEpisodeNumber(
videoPageController
.roadList[videoPageController
.currentRoad]
.identifier[
videoPageController.currentEpisode -
1]);
if (episodeNum == 0 ||
episodeNum >
videoPageController
.roadList[videoPageController
.currentRoad]
.identifier
.length) {
episodeNum =
videoPageController.currentEpisode;
}
showModalBottomSheet(
isScrollControlled: true,
constraints: BoxConstraints(
maxHeight: MediaQuery.of(context)
.size
.height *
3 /
4,
maxWidth: (MediaQuery.of(context)
.size
.width >
MediaQuery.of(context)
.size
.height)
? MediaQuery.of(context)
.size
.width *
9 /
16
: MediaQuery.of(context)
.size
.width),
clipBehavior: Clip.antiAlias,
context: context,
builder: (context) {
return EpisodeCommentsSheet(
episode: episodeNum);
}).whenComplete(() {
if (needRestart) {
playerController.play();
}
_focusNode.requestFocus();
});
},
),
forwardIcon(),
// 追番
CollectButton(
bangumiItem: infoController.bangumiItem),
Expand Down Expand Up @@ -1580,7 +1527,6 @@ class _PlayerItemState extends State<PlayerItem>
},
)
: Container(),
forwardIcon(),
Expanded(
child: ProgressBar(
timeLabelLocation: TimeLabelLocation.none,
Expand Down
Loading

0 comments on commit 224e66c

Please sign in to comment.