Skip to content

Commit

Permalink
弹幕设置
Browse files Browse the repository at this point in the history
  • Loading branch information
iris1598 committed Sep 3, 2024
1 parent 827fe9e commit ecc7384
Show file tree
Hide file tree
Showing 3 changed files with 176 additions and 133 deletions.
172 changes: 171 additions & 1 deletion lib/danmaku/danmaku_settings.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'dart:io';

import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:get/get.dart';
import 'package:get/get_core/src/get_main.dart';
import 'package:miru_app/danmaku/danmaku_source_settings.dart';
Expand Down Expand Up @@ -37,6 +38,7 @@ class _DanmakuSettingsPageState extends State<DanmakuSettingsPage> {
}

void onBackPressed(BuildContext context) {
//navigationBarState.showNavigate();
// Navigator.of(context).pop();
}

Expand Down Expand Up @@ -64,6 +66,7 @@ class _DanmakuSettingsPageState extends State<DanmakuSettingsPage> {
@override
Widget build(BuildContext context) {
WidgetsBinding.instance.addPostFrameCallback((_) {
//navigationBarState.hideNavigate();
});
return PopScope(
canPop: true,
Expand Down Expand Up @@ -135,7 +138,174 @@ class _DanmakuSettingsPageState extends State<DanmakuSettingsPage> {
setKey: SettingBoxKey.danmakuMassive,
defaultVal: false,
),
),
),
ListTile(
onTap: () async {
final List<double> danFontList = [
10.0,
11.0,
12.0,
13.0,
14.0,
15.0,
16.0,
17.0,
18.0,
19.0,
20.0,
21.0,
22.0,
23.0,
24.0,
25.0,
26.0,
27.0,
28.0,
29.0,
30.0,
31.0,
32.0,
];
SmartDialog.show(
useAnimation: false,
builder: (context) {
return AlertDialog(
title: const Text('字体大小'),
content: StatefulBuilder(builder:
(BuildContext context, StateSetter setState) {
return Wrap(
spacing: 8,
runSpacing: 2,
children: [
for (final double i in danFontList) ...<Widget>[
if (i == defaultDanmakuFontSize) ...<Widget>[
FilledButton(
onPressed: () async {
updateDanmakuFontSize(i);
SmartDialog.dismiss();
},
child: Text(i.toString()),
),
] else ...[
FilledButton.tonal(
onPressed: () async {
updateDanmakuFontSize(i);
SmartDialog.dismiss();
},
child: Text(i.toString()),
),
]
]
],
);
}),
actions: <Widget>[
TextButton(
onPressed: () => SmartDialog.dismiss(),
child: Text(
'取消',
style: TextStyle(
color: Theme.of(context).colorScheme.outline),
),
),
TextButton(
onPressed: () async {
updateDanmakuFontSize(
(Utils.isCompact())
? 16.0
: 25.0);
SmartDialog.dismiss();
},
child: const Text('默认设置'),
),
],
);
});
},
dense: false,
title: const Text('字体大小'),
subtitle: Text('$defaultDanmakuFontSize',
style: Theme.of(context)
.textTheme
.labelMedium!
.copyWith(color: Theme.of(context).colorScheme.outline)),
),
ListTile(
onTap: () async {
final List<double> danOpacityList = [
0.1,
0.2,
0.3,
0.4,
0.5,
0.6,
0.7,
0.8,
0.9,
1.0,
];
SmartDialog.show(
useAnimation: false,
builder: (context) {
return AlertDialog(
title: const Text('弹幕不透明度'),
content: StatefulBuilder(builder:
(BuildContext context, StateSetter setState) {
return Wrap(
spacing: 8,
runSpacing: 2,
children: [
for (final double i
in danOpacityList) ...<Widget>[
if (i == defaultDanmakuOpacity) ...<Widget>[
FilledButton(
onPressed: () async {
updateDanmakuOpacity(i);
SmartDialog.dismiss();
},
child: Text(i.toString()),
),
] else ...[
FilledButton.tonal(
onPressed: () async {
updateDanmakuOpacity(i);
SmartDialog.dismiss();
},
child: Text(i.toString()),
),
]
]
],
);
}),
actions: <Widget>[
TextButton(
onPressed: () => SmartDialog.dismiss(),
child: Text(
'取消',
style: TextStyle(
color: Theme.of(context).colorScheme.outline),
),
),
TextButton(
onPressed: () async {
updateDanmakuOpacity(1.0);
SmartDialog.dismiss();
},
child: const Text('默认设置'),
),
],
);
});
},
dense: false,
title: const Text('弹幕不透明度'),
subtitle: Text('$defaultDanmakuOpacity',
style: Theme.of(context)
.textTheme
.labelMedium!
.copyWith(color: Theme.of(context).colorScheme.outline)),
),
],
),
),
Expand Down
132 changes: 0 additions & 132 deletions lib/danmaku/danmaku_settings_window.dart

This file was deleted.

5 changes: 5 additions & 0 deletions lib/views/pages/watch/video/video_player_content.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import 'package:miru_app/controllers/watch/video_controller.dart';
import 'package:miru_app/utils/i18n.dart';
import 'package:miru_app/utils/router.dart';
import 'package:miru_app/utils/storage.dart';
import 'package:miru_app/utils/utils.dart';
import 'package:miru_app/views/widgets/platform_widget.dart';
import 'package:window_manager/window_manager.dart';

Expand All @@ -30,6 +31,7 @@ class _VideoPlayerContenState extends State<VideoPlayerConten> {
late double danmakuArea;
late bool _hideTop;
late bool _hideBottom;
late double _fontSize;
late bool _hideScroll;
late bool _massiveMode;

Expand Down Expand Up @@ -569,6 +571,8 @@ Widget _buildWithDanmaku(BuildContext context, Widget Function(BuildContext) bui
_hideScroll = !setting.get(SettingBoxKey.danmakuScroll, defaultValue: true);
_massiveMode =
setting.get(SettingBoxKey.danmakuMassive, defaultValue: false);
_fontSize = setting.get(SettingBoxKey.danmakuFontSize,
defaultValue: (Utils.isCompact()) ? 16.0 : 25.0);
return Stack(
children: [
builder(context), // This is the video player widget
Expand All @@ -583,6 +587,7 @@ Widget _buildWithDanmaku(BuildContext context, Widget Function(BuildContext) bui
hideScroll: _hideScroll,
hideBottom: _hideBottom,
opacity: _opacity,
fontSize: _fontSize,
duration: _duration.toInt(),
showStroke: _border,
massiveMode: _massiveMode,
Expand Down

0 comments on commit ecc7384

Please sign in to comment.