Skip to content

Commit

Permalink
删减代码,添加设置
Browse files Browse the repository at this point in the history
  • Loading branch information
iris1598 committed Sep 2, 2024
1 parent 747573f commit 0ff4bfc
Show file tree
Hide file tree
Showing 10 changed files with 74 additions and 327 deletions.
Binary file added assets/icon/kazumi.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion lib/controllers/watch/video_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class VideoPlayerController extends GetxController {
final String anilistID;

int bangumiID = 0;

late bool danmakuonon;
late final DanmakuController danmakuController;
// 弹幕开关
final danmakuOn = RxBool(true); // 默认值设置为 true
Expand Down Expand Up @@ -108,6 +108,8 @@ void toggleDanmaku() {
@override
void onInit() async {
Box setting = GStorage.setting;
danmakuonon= setting.get(SettingBoxKey.danmakuEnabledByDefault, defaultValue: false);
danmakuOn.value=danmakuonon;
_danmakuColor = setting.get(SettingBoxKey.danmakuColor, defaultValue: true);
_danmakuBiliBiliSource =
setting.get(SettingBoxKey.danmakuBiliBiliSource, defaultValue: true);
Expand Down
245 changes: 3 additions & 242 deletions lib/danmaku/danmaku_settings.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import 'package:miru_app/router/router.dart';
import 'package:miru_app/utils/utils.dart';
import 'package:flutter/material.dart';
import 'package:flutter_modular/flutter_modular.dart';
import 'package:miru_app/bean/settings/settings.dart';
import 'package:miru_app/utils/storage.dart';
import 'package:hive/hive.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:miru_app/popular/popular_controller.dart';
import 'package:miru_app/bean/appbar/sys_app_bar.dart';

class DanmakuSettingsPage extends StatefulWidget {
Expand All @@ -21,7 +19,6 @@ class _DanmakuSettingsPageState extends State<DanmakuSettingsPage> {
late dynamic defaultDanmakuArea;
late dynamic defaultDanmakuOpacity;
late dynamic defaultDanmakuFontSize;
final PopularController popularController = Modular.get<PopularController>();

@override
void initState() {
Expand Down Expand Up @@ -76,7 +73,7 @@ class _DanmakuSettingsPageState extends State<DanmakuSettingsPage> {
children: [
ListTile(
onTap: () {
Modular.to.pushNamed('/tab/my/danmaku/source');
router.push('/settings/danmaku/source');
},
dense: false,
title: const Text('弹幕来源'),
Expand Down Expand Up @@ -131,243 +128,7 @@ 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)),
),
ListTile(
onTap: () async {
final List<double> danAreaList = [
0.25,
0.5,
0.75,
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 danAreaList) ...<Widget>[
if (i == defaultDanmakuArea) ...<Widget>[
FilledButton(
onPressed: () async {
updateDanmakuArea(i);
SmartDialog.dismiss();
},
child: Text(i.toString()),
),
] else ...[
FilledButton.tonal(
onPressed: () async {
updateDanmakuArea(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 {
updateDanmakuArea(1.0);
SmartDialog.dismiss();
},
child: const Text('默认设置'),
),
],
);
});
},
dense: false,
title: const Text('弹幕区域'),
subtitle: Text('占据 $defaultDanmakuArea 屏幕',
style: Theme.of(context)
.textTheme
.labelMedium!
.copyWith(color: Theme.of(context).colorScheme.outline)),
),
),
],
),
),
Expand Down
43 changes: 0 additions & 43 deletions lib/popular/popular_controller.dart

This file was deleted.

34 changes: 0 additions & 34 deletions lib/popular/popular_controller.g.dart

This file was deleted.

10 changes: 10 additions & 0 deletions lib/router/router.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import 'package:fluent_ui/fluent_ui.dart';
import 'package:flutter_animate/flutter_animate.dart';
import 'package:get/get.dart';
import 'package:go_router/go_router.dart';
import 'package:miru_app/danmaku/danmaku_settings.dart';
import 'package:miru_app/danmaku/danmaku_source_settings.dart';
import 'package:miru_app/data/providers/anilist_provider.dart';
import 'package:miru_app/models/index.dart';
import 'package:miru_app/views/pages/detail_page.dart';
Expand Down Expand Up @@ -89,6 +91,14 @@ final router = GoRouter(
path: '/settings/anilist',
builder: (context, state) => _animation(const AniListTrackingPage()),
),
GoRoute(
path: '/settings/danmaku',
builder: (context, state) => _animation(const DanmakuSettingsPage()),
),
GoRoute(
path: '/settings/danmaku/source',
builder: (context, state) => _animation(const DanmakuSourceSettingsPage()),
),
GoRoute(
path: '/settings/anilist_more',
builder: (context, state) => _animation(
Expand Down
Loading

0 comments on commit 0ff4bfc

Please sign in to comment.