mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-04-26 13:25:49 +08:00
opt: ao (#1811)
* opt: ao * multi select --------- Co-authored-by: dom <githubaccount56556@proton.me>
This commit is contained in:
committed by
GitHub
parent
038f03a4e7
commit
bfb2becb2d
@@ -134,54 +134,12 @@ List<SettingsModel> get extraSettings => [
|
||||
],
|
||||
),
|
||||
),
|
||||
NormalModel(
|
||||
leading: const Icon(MdiIcons.debugStepOver),
|
||||
getPopupMenuModel(
|
||||
title: '番剧片头/片尾跳过类型',
|
||||
getTrailing: () => Builder(
|
||||
builder: (context) {
|
||||
final pgcSkipType = Pref.pgcSkipType;
|
||||
final colorScheme = ColorScheme.of(context);
|
||||
final color = pgcSkipType == SkipType.disable
|
||||
? colorScheme.outline
|
||||
: colorScheme.secondary;
|
||||
return PopupMenuButton<SkipType>(
|
||||
initialValue: pgcSkipType,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 8),
|
||||
child: Text.rich(
|
||||
style: TextStyle(fontSize: 14, height: 1, color: color),
|
||||
strutStyle: const StrutStyle(
|
||||
leading: 0,
|
||||
height: 1,
|
||||
fontSize: 14,
|
||||
),
|
||||
TextSpan(
|
||||
children: [
|
||||
TextSpan(text: pgcSkipType.title),
|
||||
WidgetSpan(
|
||||
alignment: .middle,
|
||||
child: Icon(
|
||||
MdiIcons.unfoldMoreHorizontal,
|
||||
size: 14,
|
||||
color: color,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
onSelected: (value) async {
|
||||
await GStorage.setting.put(SettingBoxKey.pgcSkipType, value.index);
|
||||
if (context.mounted) {
|
||||
(context as Element).markNeedsBuild();
|
||||
}
|
||||
},
|
||||
itemBuilder: (context) => SkipType.values
|
||||
.map((e) => PopupMenuItem(value: e, child: Text(e.title)))
|
||||
.toList(),
|
||||
);
|
||||
},
|
||||
),
|
||||
leading: const Icon(MdiIcons.debugStepOver),
|
||||
key: SettingBoxKey.pgcSkipType,
|
||||
values: SkipType.values,
|
||||
defaultIndex: SkipType.skipOnce.index,
|
||||
),
|
||||
SwitchModel(
|
||||
title: '检查未读动态',
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'package:PiliPlus/common/constants.dart';
|
||||
import 'package:PiliPlus/models/common/enum_with_label.dart';
|
||||
import 'package:PiliPlus/pages/setting/widgets/normal_item.dart';
|
||||
import 'package:PiliPlus/pages/setting/widgets/select_dialog.dart';
|
||||
import 'package:PiliPlus/pages/setting/widgets/switch_item.dart';
|
||||
@@ -7,6 +8,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart' show FilteringTextInputFormatter;
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:material_design_icons_flutter/material_design_icons_flutter.dart';
|
||||
|
||||
@immutable
|
||||
sealed class SettingsModel {
|
||||
@@ -258,3 +260,61 @@ SettingsModel getVideoFilterSelectModel({
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
SettingsModel getPopupMenuModel({
|
||||
required String title,
|
||||
Widget? leading,
|
||||
String? subtitle,
|
||||
required String key,
|
||||
required List<EnumWithLabel> values,
|
||||
int defaultIndex = 0,
|
||||
}) {
|
||||
// final globalKey = GlobalKey<PopupMenuButtonState<EnumWithLabel>>();
|
||||
return NormalModel(
|
||||
title: title,
|
||||
subtitle: subtitle,
|
||||
leading: leading,
|
||||
// onTap: (context, setState) => globalKey.currentState?.showButtonMenu(),
|
||||
getTrailing: () => Builder(
|
||||
builder: (context) {
|
||||
final color = ColorScheme.of(context).secondary;
|
||||
final v = values[GStorage.setting.get(key, defaultValue: defaultIndex)];
|
||||
return PopupMenuButton(
|
||||
// key: globalKey,
|
||||
padding: .zero,
|
||||
initialValue: v,
|
||||
onSelected: (value) async {
|
||||
await GStorage.setting.put(key, value.index);
|
||||
if (context.mounted) {
|
||||
(context as Element).markNeedsBuild();
|
||||
}
|
||||
},
|
||||
itemBuilder: (context) => values
|
||||
.map((i) => PopupMenuItem(value: i, child: Text(i.label)))
|
||||
.toList(),
|
||||
child: Padding(
|
||||
padding: const .symmetric(vertical: 8),
|
||||
child: Text.rich(
|
||||
style: TextStyle(fontSize: 14, height: 1, color: color),
|
||||
strutStyle: const StrutStyle(leading: 0, height: 1, fontSize: 14),
|
||||
TextSpan(
|
||||
children: [
|
||||
TextSpan(text: v.label),
|
||||
WidgetSpan(
|
||||
alignment: .middle,
|
||||
child: Icon(
|
||||
size: 14,
|
||||
MdiIcons.unfoldMoreHorizontal,
|
||||
color: color,
|
||||
),
|
||||
),
|
||||
],
|
||||
style: TextStyle(color: color),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -8,11 +8,13 @@ import 'package:PiliPlus/models/common/video/video_quality.dart';
|
||||
import 'package:PiliPlus/pages/setting/models/model.dart';
|
||||
import 'package:PiliPlus/pages/setting/widgets/ordered_multi_select_dialog.dart';
|
||||
import 'package:PiliPlus/pages/setting/widgets/select_dialog.dart';
|
||||
import 'package:PiliPlus/plugin/pl_player/models/audio_output_type.dart';
|
||||
import 'package:PiliPlus/plugin/pl_player/models/hwdec_type.dart';
|
||||
import 'package:PiliPlus/utils/storage.dart';
|
||||
import 'package:PiliPlus/utils/storage_key.dart';
|
||||
import 'package:PiliPlus/utils/storage_pref.dart';
|
||||
import 'package:PiliPlus/utils/video_utils.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:material_design_icons_flutter/material_design_icons_flutter.dart';
|
||||
@@ -317,13 +319,32 @@ List<SettingsModel> get videoSettings => [
|
||||
}
|
||||
},
|
||||
),
|
||||
if (Platform.isAndroid)
|
||||
const SwitchModel(
|
||||
title: '优先使用 OpenSL ES 输出音频',
|
||||
leading: Icon(Icons.speaker_outlined),
|
||||
subtitle: '关闭则优先使用AAudio输出音频(此项即mpv的--ao),若遇系统音效丢失、无声、音画不同步等问题请尝试打开。',
|
||||
setKey: SettingBoxKey.useOpenSLES,
|
||||
defaultVal: false,
|
||||
if (kDebugMode || Platform.isAndroid)
|
||||
NormalModel(
|
||||
title: '音频输出设备',
|
||||
leading: const Icon(Icons.speaker_outlined),
|
||||
getSubtitle: () => '当前:${Pref.audioOutput}',
|
||||
onTap: (context, setState) async {
|
||||
final result = await showDialog<List<String>>(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return OrderedMultiSelectDialog<String>(
|
||||
title: '音频输出设备',
|
||||
initValues: Pref.audioOutput.split(','),
|
||||
values: {
|
||||
for (final e in AudioOutput.values) e.name: e.label,
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
if (result != null && result.isNotEmpty) {
|
||||
await GStorage.setting.put(
|
||||
SettingBoxKey.audioOutput,
|
||||
result.join(','),
|
||||
);
|
||||
setState();
|
||||
}
|
||||
},
|
||||
),
|
||||
const SwitchModel(
|
||||
title: '扩大缓冲区',
|
||||
|
||||
Reference in New Issue
Block a user