mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-06-29 22:00:16 +08:00
tweaks (#2426)
* opt: danmaku weight
* opt: cache clean
* opt: level img
* opt: play icon
* opt: svg big-vip
* opt: webview ua
* opt: simple dialog
* feat: export vtt
* tweak
* opt: mapIndexed
* feat: more subtitle
* refa: settings page
* feat: codec list options
* drawPath
Signed-off-by: dom <githubaccount56556@proton.me>
* custom dialog option
Signed-off-by: dom <githubaccount56556@proton.me>
* update
Signed-off-by: dom <githubaccount56556@proton.me>
* Revert "drawPath"
This reverts commit e8a4b19f0f.
* opt: _initStreamIndex
* fix: avoid gap
* fix: scale [skip ci]
* fix: hide repost menu not login
* tweaks
Signed-off-by: dom <githubaccount56556@proton.me>
---------
Co-authored-by: dom <githubaccount56556@proton.me>
This commit is contained in:
committed by
GitHub
parent
3dee6a85e5
commit
9d94c72e95
65
lib/pages/setting/common_setting.dart
Normal file
65
lib/pages/setting/common_setting.dart
Normal file
@@ -0,0 +1,65 @@
|
||||
import 'package:PiliPlus/models/common/setting_type.dart';
|
||||
import 'package:PiliPlus/pages/setting/models/model.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class CommonSetting extends StatefulWidget {
|
||||
const CommonSetting({
|
||||
super.key,
|
||||
required this.settingType,
|
||||
this.showAppBar = true,
|
||||
});
|
||||
|
||||
final bool showAppBar;
|
||||
final SettingType settingType;
|
||||
|
||||
@override
|
||||
State<CommonSetting> createState() => _CommonSettingState();
|
||||
}
|
||||
|
||||
class _CommonSettingState extends State<CommonSetting> {
|
||||
late EdgeInsets padding;
|
||||
late List<SettingsModel> settings;
|
||||
|
||||
void _initSetting() {
|
||||
settings = widget.settingType.settings;
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_initSetting();
|
||||
}
|
||||
|
||||
@override
|
||||
void didUpdateWidget(CommonSetting oldWidget) {
|
||||
super.didUpdateWidget(oldWidget);
|
||||
if (widget.settingType != oldWidget.settingType) {
|
||||
_initSetting();
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
super.didChangeDependencies();
|
||||
padding = MediaQuery.viewPaddingOf(context);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final showAppBar = widget.showAppBar;
|
||||
return Scaffold(
|
||||
resizeToAvoidBottomInset: false,
|
||||
appBar: showAppBar ? AppBar(title: Text(widget.settingType.title)) : null,
|
||||
body: ListView.builder(
|
||||
key: ValueKey(widget.settingType),
|
||||
padding: EdgeInsets.only(
|
||||
left: showAppBar ? padding.left : 0,
|
||||
right: showAppBar ? padding.right : 0,
|
||||
bottom: padding.bottom + 100,
|
||||
),
|
||||
itemCount: settings.length,
|
||||
itemBuilder: (context, index) => settings[index].widget,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
import 'package:PiliPlus/pages/setting/models/extra_settings.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class ExtraSetting extends StatefulWidget {
|
||||
const ExtraSetting({super.key, this.showAppBar = true});
|
||||
|
||||
final bool showAppBar;
|
||||
|
||||
@override
|
||||
State<ExtraSetting> createState() => _ExtraSettingState();
|
||||
}
|
||||
|
||||
class _ExtraSettingState extends State<ExtraSetting> {
|
||||
final settings = extraSettings;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final showAppBar = widget.showAppBar;
|
||||
final padding = MediaQuery.viewPaddingOf(context);
|
||||
return Scaffold(
|
||||
resizeToAvoidBottomInset: false,
|
||||
appBar: showAppBar ? AppBar(title: const Text('其它设置')) : null,
|
||||
body: ListView.builder(
|
||||
padding: EdgeInsets.only(
|
||||
left: showAppBar ? padding.left : 0,
|
||||
right: showAppBar ? padding.right : 0,
|
||||
bottom: padding.bottom + 100,
|
||||
),
|
||||
itemCount: settings.length,
|
||||
itemBuilder: (context, index) => settings[index].widget,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ import 'dart:io';
|
||||
import 'dart:math' show max;
|
||||
|
||||
import 'package:PiliPlus/common/widgets/custom_icon.dart';
|
||||
import 'package:PiliPlus/common/widgets/dialog/simple_dialog_option.dart';
|
||||
import 'package:PiliPlus/common/widgets/flutter/refresh_indicator.dart';
|
||||
import 'package:PiliPlus/common/widgets/gesture/horizontal_drag_gesture_recognizer.dart'
|
||||
show deviceTouchSlop, touchSlopH;
|
||||
@@ -595,19 +596,10 @@ List<SettingsModel> get extraSettings => [
|
||||
onTap: _showProxyDialog,
|
||||
),
|
||||
),
|
||||
const SwitchModel(
|
||||
title: '自动清除缓存',
|
||||
subtitle: '每次启动时清除缓存',
|
||||
leading: Icon(Icons.auto_delete_outlined),
|
||||
setKey: SettingBoxKey.autoClearCache,
|
||||
defaultVal: false,
|
||||
),
|
||||
NormalModel(
|
||||
title: '最大缓存大小',
|
||||
getSubtitle: () {
|
||||
final num = Pref.maxCacheSize;
|
||||
return '当前最大缓存大小: 「${num == 0 ? '无限' : CacheManager.formatSize(Pref.maxCacheSize)}」';
|
||||
},
|
||||
getSubtitle: () =>
|
||||
'当前最大缓存大小: 「${CacheManager.formatSize(Pref.maxCacheSize)}」',
|
||||
leading: const Icon(Icons.delete_outlined),
|
||||
onTap: _showCacheDialog,
|
||||
),
|
||||
@@ -721,48 +713,42 @@ Future<void> audioNormalization(
|
||||
void _showDownPathDialog(BuildContext context, VoidCallback setState) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
builder: (context) => SimpleDialog(
|
||||
clipBehavior: Clip.hardEdge,
|
||||
contentPadding: const EdgeInsets.symmetric(vertical: 12),
|
||||
content: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
ListTile(
|
||||
onTap: () {
|
||||
Get.back();
|
||||
Utils.copyText(downloadPath);
|
||||
},
|
||||
dense: true,
|
||||
title: const Text('复制', style: TextStyle(fontSize: 14)),
|
||||
),
|
||||
ListTile(
|
||||
onTap: () {
|
||||
Get.back();
|
||||
final defPath = defDownloadPath;
|
||||
if (downloadPath == defPath) return;
|
||||
downloadPath = defPath;
|
||||
setState();
|
||||
Get.find<DownloadService>().initDownloadList();
|
||||
GStorage.setting.delete(SettingBoxKey.downloadPath);
|
||||
},
|
||||
dense: true,
|
||||
title: const Text('重置', style: TextStyle(fontSize: 14)),
|
||||
),
|
||||
ListTile(
|
||||
onTap: () async {
|
||||
Get.back();
|
||||
final path = await FilePicker.getDirectoryPath();
|
||||
if (path == null || path == downloadPath) return;
|
||||
downloadPath = path;
|
||||
setState();
|
||||
Get.find<DownloadService>().initDownloadList();
|
||||
GStorage.setting.put(SettingBoxKey.downloadPath, path);
|
||||
},
|
||||
dense: true,
|
||||
title: const Text('设置新路径', style: TextStyle(fontSize: 14)),
|
||||
),
|
||||
],
|
||||
),
|
||||
children: [
|
||||
DialogOption(
|
||||
onPressed: () {
|
||||
Get.back();
|
||||
Utils.copyText(downloadPath);
|
||||
},
|
||||
child: const Text('复制', style: TextStyle(fontSize: 14)),
|
||||
),
|
||||
DialogOption(
|
||||
onPressed: () {
|
||||
Get.back();
|
||||
final defPath = defDownloadPath;
|
||||
if (downloadPath == defPath) return;
|
||||
downloadPath = defPath;
|
||||
setState();
|
||||
Get.find<DownloadService>().initDownloadList();
|
||||
GStorage.setting.delete(SettingBoxKey.downloadPath);
|
||||
},
|
||||
child: const Text('重置', style: TextStyle(fontSize: 14)),
|
||||
),
|
||||
DialogOption(
|
||||
onPressed: () async {
|
||||
Get.back();
|
||||
final path = await FilePicker.getDirectoryPath();
|
||||
if (path == null || path == downloadPath) return;
|
||||
downloadPath = path;
|
||||
setState();
|
||||
Get.find<DownloadService>().initDownloadList();
|
||||
GStorage.setting.put(SettingBoxKey.downloadPath, path);
|
||||
},
|
||||
child: const Text('设置新路径', style: TextStyle(fontSize: 14)),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -25,9 +25,7 @@ List<SettingsModel> get privacySettings => [
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
title: const Text('账号模式详情'),
|
||||
content: SingleChildScrollView(
|
||||
child: _getAccountDetail(context),
|
||||
),
|
||||
content: SingleChildScrollView(child: _getAccountDetail(context)),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: Get.back,
|
||||
|
||||
@@ -93,8 +93,8 @@ List<SettingsModel> get recommendSettings => [
|
||||
onChanged: (value) => RecommendFilter.exemptFilterForFollowed = value,
|
||||
),
|
||||
SwitchModel(
|
||||
title: '过滤器也应用于相关视频',
|
||||
subtitle: '视频详情页的相关视频也进行过滤¹',
|
||||
title: '过滤器也应用于详情页相关视频',
|
||||
subtitle: '其它(如热门视频、搜索等)均不受过滤器影响,无法豁免相关视频中的已关注UP',
|
||||
leading: const Icon(Icons.explore_outlined),
|
||||
setKey: SettingBoxKey.applyFilterToRelatedVideos,
|
||||
defaultVal: true,
|
||||
|
||||
@@ -127,16 +127,11 @@ List<SettingsModel> get videoSettings => [
|
||||
NormalModel(
|
||||
title: '首选解码格式',
|
||||
leading: const Icon(Icons.movie_creation_outlined),
|
||||
getSubtitle: () =>
|
||||
'首选解码格式:${VideoDecodeFormatType.fromCode(Pref.defaultDecode).description},请根据设备支持情况与需求调整',
|
||||
onTap: _showDecodeDialog,
|
||||
),
|
||||
NormalModel(
|
||||
title: '次选解码格式',
|
||||
getSubtitle: () =>
|
||||
'非杜比视频次选:${VideoDecodeFormatType.fromCode(Pref.secondDecode).description},仍无则选择首个提供的解码格式',
|
||||
leading: const Icon(Icons.swap_horizontal_circle_outlined),
|
||||
onTap: _showSecondDecodeDialog,
|
||||
getSubtitle: () {
|
||||
final list = Pref.preferCodecs;
|
||||
return '首选解码格式:${(list.isEmpty ? '第一个可用' : list.map((i) => i.name).join(","))},请根据设备支持情况与需求调整';
|
||||
},
|
||||
onTap: _showCodecsDialog,
|
||||
),
|
||||
if (kDebugMode || Platform.isAndroid)
|
||||
NormalModel(
|
||||
@@ -349,42 +344,25 @@ Future<void> _showLiveCellularQaDialog(
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _showDecodeDialog(
|
||||
Future<void> _showCodecsDialog(
|
||||
BuildContext context,
|
||||
VoidCallback setState,
|
||||
) async {
|
||||
final res = await showDialog<String>(
|
||||
final res = await showDialog<List<VideoDecodeFormatType>>(
|
||||
context: context,
|
||||
builder: (context) => SelectDialog<String>(
|
||||
title: '默认解码格式',
|
||||
value: Pref.defaultDecode,
|
||||
values: VideoDecodeFormatType.values
|
||||
.map((e) => (e.codes.first, e.description))
|
||||
.toList(),
|
||||
builder: (context) => OrderedMultiSelectDialog<VideoDecodeFormatType>(
|
||||
title: '首选解码格式',
|
||||
initValues: Pref.preferCodecs,
|
||||
values: {for (final e in VideoDecodeFormatType.values) e: e.name},
|
||||
),
|
||||
);
|
||||
if (res != null) {
|
||||
await GStorage.setting.put(SettingBoxKey.defaultDecode, res);
|
||||
setState();
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _showSecondDecodeDialog(
|
||||
BuildContext context,
|
||||
VoidCallback setState,
|
||||
) async {
|
||||
final res = await showDialog<String>(
|
||||
context: context,
|
||||
builder: (context) => SelectDialog<String>(
|
||||
title: '次选解码格式',
|
||||
value: Pref.secondDecode,
|
||||
values: VideoDecodeFormatType.values
|
||||
.map((e) => (e.codes.first, e.description))
|
||||
.toList(),
|
||||
),
|
||||
);
|
||||
if (res != null) {
|
||||
await GStorage.setting.put(SettingBoxKey.secondDecode, res);
|
||||
await (res.isEmpty
|
||||
? GStorage.setting.delete(SettingBoxKey.preferCodecs)
|
||||
: GStorage.setting.put(
|
||||
SettingBoxKey.preferCodecs,
|
||||
res.map((i) => i.name).toList(),
|
||||
));
|
||||
setState();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ class _BarSetPageState extends State<BarSetPage> with ReorderMixin {
|
||||
late final String key;
|
||||
late final String title;
|
||||
late final List<Pair<EnumWithLabel, bool>> list;
|
||||
late EdgeInsets padding;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -29,7 +30,7 @@ class _BarSetPageState extends State<BarSetPage> with ReorderMixin {
|
||||
.map((e) => Pair(first: e, second: cache?.contains(e.index) ?? true))
|
||||
.toList();
|
||||
if (cache != null && cache.isNotEmpty) {
|
||||
final cacheIndex = {for (final (k, v) in cache.indexed) v: k};
|
||||
final cacheIndex = {for (int i = 0; i < cache.length; i++) cache[i]: i};
|
||||
list.sort((a, b) {
|
||||
final indexA = cacheIndex[a.first.index] ?? cacheIndex.length;
|
||||
final indexB = cacheIndex[b.first.index] ?? cacheIndex.length;
|
||||
@@ -38,6 +39,13 @@ class _BarSetPageState extends State<BarSetPage> with ReorderMixin {
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
super.didChangeDependencies();
|
||||
final viewPad = MediaQuery.viewPaddingOf(context);
|
||||
padding = .only(top: 10, right: viewPad.right + 34, bottom: viewPad.bottom);
|
||||
}
|
||||
|
||||
void saveEdit() {
|
||||
GStorage.setting.put(
|
||||
key,
|
||||
@@ -73,9 +81,7 @@ class _BarSetPageState extends State<BarSetPage> with ReorderMixin {
|
||||
onReorderItem: onReorderItem,
|
||||
proxyDecorator: proxyDecorator,
|
||||
footer: Padding(
|
||||
padding:
|
||||
MediaQuery.viewPaddingOf(context).copyWith(top: 0, left: 0) +
|
||||
const EdgeInsets.only(right: 34, top: 10),
|
||||
padding: padding,
|
||||
child: const Align(
|
||||
alignment: Alignment.centerRight,
|
||||
child: Text('*长按拖动排序'),
|
||||
|
||||
@@ -15,6 +15,7 @@ import 'package:PiliPlus/utils/storage.dart';
|
||||
import 'package:PiliPlus/utils/storage_key.dart';
|
||||
import 'package:PiliPlus/utils/storage_pref.dart';
|
||||
import 'package:PiliPlus/utils/theme_utils.dart';
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:flex_seed_scheme/flex_seed_scheme.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
@@ -148,10 +149,8 @@ class _ColorSelectPageState extends State<ColorSelectPage> {
|
||||
alignment: WrapAlignment.center,
|
||||
spacing: 22,
|
||||
runSpacing: 18,
|
||||
children: colorThemeTypes.indexed.map(
|
||||
(e) {
|
||||
final index = e.$1;
|
||||
final item = e.$2;
|
||||
children: colorThemeTypes.mapIndexed(
|
||||
(index, item) {
|
||||
return GestureDetector(
|
||||
behavior: HitTestBehavior.opaque,
|
||||
onTap: () {
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
import 'package:PiliPlus/pages/setting/models/play_settings.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class PlaySetting extends StatefulWidget {
|
||||
const PlaySetting({super.key, this.showAppBar = true});
|
||||
|
||||
final bool showAppBar;
|
||||
|
||||
@override
|
||||
State<PlaySetting> createState() => _PlaySettingState();
|
||||
}
|
||||
|
||||
class _PlaySettingState extends State<PlaySetting> {
|
||||
final settings = playSettings;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final showAppBar = widget.showAppBar;
|
||||
final padding = MediaQuery.viewPaddingOf(context);
|
||||
return Scaffold(
|
||||
resizeToAvoidBottomInset: false,
|
||||
appBar: showAppBar ? AppBar(title: const Text('播放器设置')) : null,
|
||||
body: ListView.builder(
|
||||
padding: EdgeInsets.only(
|
||||
left: showAppBar ? padding.left : 0,
|
||||
right: showAppBar ? padding.right : 0,
|
||||
bottom: padding.bottom + 100,
|
||||
),
|
||||
itemCount: settings.length,
|
||||
itemBuilder: (context, index) => settings[index].widget,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
import 'package:PiliPlus/pages/setting/models/privacy_settings.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class PrivacySetting extends StatefulWidget {
|
||||
const PrivacySetting({super.key, this.showAppBar = true});
|
||||
|
||||
final bool showAppBar;
|
||||
|
||||
@override
|
||||
State<PrivacySetting> createState() => _PrivacySettingState();
|
||||
}
|
||||
|
||||
class _PrivacySettingState extends State<PrivacySetting> {
|
||||
final settings = privacySettings;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final showAppBar = widget.showAppBar;
|
||||
final padding = MediaQuery.viewPaddingOf(context);
|
||||
return Scaffold(
|
||||
resizeToAvoidBottomInset: false,
|
||||
appBar: showAppBar ? AppBar(title: const Text('隐私设置')) : null,
|
||||
body: ListView(
|
||||
padding: EdgeInsets.only(
|
||||
left: showAppBar ? padding.left : 0,
|
||||
right: showAppBar ? padding.right : 0,
|
||||
bottom: padding.bottom + 100,
|
||||
),
|
||||
children: settings.map((item) => item.widget).toList(),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
import 'package:PiliPlus/common/widgets/flutter/list_tile.dart';
|
||||
import 'package:PiliPlus/pages/setting/models/recommend_settings.dart';
|
||||
import 'package:flutter/material.dart' hide ListTile;
|
||||
|
||||
class RecommendSetting extends StatefulWidget {
|
||||
const RecommendSetting({super.key, this.showAppBar = true});
|
||||
|
||||
final bool showAppBar;
|
||||
|
||||
@override
|
||||
State<RecommendSetting> createState() => _RecommendSettingState();
|
||||
}
|
||||
|
||||
class _RecommendSettingState extends State<RecommendSetting> {
|
||||
final list = recommendSettings;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final showAppBar = widget.showAppBar;
|
||||
final padding = MediaQuery.viewPaddingOf(context);
|
||||
final theme = Theme.of(context);
|
||||
return Scaffold(
|
||||
resizeToAvoidBottomInset: false,
|
||||
appBar: widget.showAppBar ? AppBar(title: const Text('推荐流设置')) : null,
|
||||
body: ListView(
|
||||
padding: EdgeInsets.only(
|
||||
left: showAppBar ? padding.left : 0,
|
||||
right: showAppBar ? padding.right : 0,
|
||||
bottom: padding.bottom + 100,
|
||||
),
|
||||
children: [
|
||||
...list.take(4).map((item) => item.widget),
|
||||
const Divider(height: 1),
|
||||
...list.skip(4).map((item) => item.widget),
|
||||
ListTile(
|
||||
dense: true,
|
||||
subtitle: Text(
|
||||
'¹ 由于接口未提供关注信息,无法豁免相关视频中的已关注Up。\n\n'
|
||||
'* 其它(如热门视频、手动搜索、链接跳转等)均不受过滤器影响。\n'
|
||||
'* 设定较严苛的条件可导致推荐项数锐减或多次请求,请酌情选择。\n'
|
||||
'* 后续可能会增加更多过滤条件,敬请期待。',
|
||||
style: theme.textTheme.labelSmall!.copyWith(
|
||||
color: theme.colorScheme.outline.withValues(alpha: 0.7),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
import 'package:PiliPlus/pages/setting/models/style_settings.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class StyleSetting extends StatefulWidget {
|
||||
const StyleSetting({super.key, this.showAppBar = true});
|
||||
|
||||
final bool showAppBar;
|
||||
|
||||
@override
|
||||
State<StyleSetting> createState() => _StyleSettingState();
|
||||
}
|
||||
|
||||
class _StyleSettingState extends State<StyleSetting> {
|
||||
final settings = styleSettings;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final showAppBar = widget.showAppBar;
|
||||
final padding = MediaQuery.viewPaddingOf(context);
|
||||
return Scaffold(
|
||||
resizeToAvoidBottomInset: false,
|
||||
appBar: showAppBar ? AppBar(title: const Text('外观设置')) : null,
|
||||
body: ListView.builder(
|
||||
padding: EdgeInsets.only(
|
||||
left: showAppBar ? padding.left : 0,
|
||||
right: showAppBar ? padding.right : 0,
|
||||
bottom: padding.bottom + 100,
|
||||
),
|
||||
itemCount: settings.length,
|
||||
itemBuilder: (context, index) => settings[index].widget,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
import 'package:PiliPlus/pages/setting/models/video_settings.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class VideoSetting extends StatefulWidget {
|
||||
const VideoSetting({super.key, this.showAppBar = true});
|
||||
|
||||
final bool showAppBar;
|
||||
|
||||
@override
|
||||
State<VideoSetting> createState() => _VideoSettingState();
|
||||
}
|
||||
|
||||
class _VideoSettingState extends State<VideoSetting> {
|
||||
final settings = videoSettings;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final showAppBar = widget.showAppBar;
|
||||
final padding = MediaQuery.viewPaddingOf(context);
|
||||
return Scaffold(
|
||||
resizeToAvoidBottomInset: false,
|
||||
appBar: showAppBar ? AppBar(title: const Text('音视频设置')) : null,
|
||||
body: ListView.builder(
|
||||
padding: EdgeInsets.only(
|
||||
left: showAppBar ? padding.left : 0,
|
||||
right: showAppBar ? padding.right : 0,
|
||||
bottom: padding.bottom + 100,
|
||||
),
|
||||
itemCount: settings.length,
|
||||
itemBuilder: (context, index) => settings[index].widget,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -4,12 +4,7 @@ import 'package:PiliPlus/http/login.dart';
|
||||
import 'package:PiliPlus/models/common/setting_type.dart';
|
||||
import 'package:PiliPlus/pages/about/view.dart';
|
||||
import 'package:PiliPlus/pages/login/controller.dart';
|
||||
import 'package:PiliPlus/pages/setting/extra_setting.dart';
|
||||
import 'package:PiliPlus/pages/setting/play_setting.dart';
|
||||
import 'package:PiliPlus/pages/setting/privacy_setting.dart';
|
||||
import 'package:PiliPlus/pages/setting/recommend_setting.dart';
|
||||
import 'package:PiliPlus/pages/setting/style_setting.dart';
|
||||
import 'package:PiliPlus/pages/setting/video_setting.dart';
|
||||
import 'package:PiliPlus/pages/setting/common_setting.dart';
|
||||
import 'package:PiliPlus/pages/setting/widgets/multi_select_dialog.dart';
|
||||
import 'package:PiliPlus/pages/webdav/view.dart';
|
||||
import 'package:PiliPlus/utils/accounts.dart';
|
||||
@@ -43,6 +38,7 @@ class _SettingPageState extends State<SettingPage> {
|
||||
late SettingType _type = SettingType.privacySetting;
|
||||
final RxBool _noAccount = Accounts.account.isEmpty.obs;
|
||||
late bool _isPortrait;
|
||||
late ThemeData theme;
|
||||
|
||||
static const List<_SettingsModel> _items = [
|
||||
_SettingsModel(
|
||||
@@ -86,9 +82,15 @@ class _SettingPageState extends State<SettingPage> {
|
||||
];
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
void didChangeDependencies() {
|
||||
super.didChangeDependencies();
|
||||
|
||||
theme = Theme.of(context);
|
||||
_isPortrait = MediaQuery.sizeOf(context).isPortrait;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
resizeToAvoidBottomInset: false,
|
||||
appBar: AppBar(
|
||||
@@ -111,28 +113,19 @@ class _SettingPageState extends State<SettingPage> {
|
||||
Expanded(
|
||||
flex: 6,
|
||||
child: switch (_type) {
|
||||
SettingType.privacySetting => const PrivacySetting(
|
||||
.privacySetting ||
|
||||
.recommendSetting ||
|
||||
.videoSetting ||
|
||||
.playSetting ||
|
||||
.styleSetting ||
|
||||
.extraSetting => CommonSetting(
|
||||
settingType: _type,
|
||||
showAppBar: false,
|
||||
),
|
||||
SettingType.recommendSetting => const RecommendSetting(
|
||||
.webdavSetting => const WebDavSettingPage(
|
||||
showAppBar: false,
|
||||
),
|
||||
SettingType.videoSetting => const VideoSetting(
|
||||
showAppBar: false,
|
||||
),
|
||||
SettingType.playSetting => const PlaySetting(
|
||||
showAppBar: false,
|
||||
),
|
||||
SettingType.styleSetting => const StyleSetting(
|
||||
showAppBar: false,
|
||||
),
|
||||
SettingType.extraSetting => const ExtraSetting(
|
||||
showAppBar: false,
|
||||
),
|
||||
SettingType.webdavSetting => const WebDavSettingPage(
|
||||
showAppBar: false,
|
||||
),
|
||||
SettingType.about => const AboutPage(showAppBar: false),
|
||||
.about => const AboutPage(showAppBar: false),
|
||||
},
|
||||
),
|
||||
],
|
||||
@@ -149,7 +142,18 @@ class _SettingPageState extends State<SettingPage> {
|
||||
|
||||
void _toPage(SettingType type) {
|
||||
if (_isPortrait) {
|
||||
Get.toNamed('/${type.name}');
|
||||
Get.to(
|
||||
() => switch (type) {
|
||||
.privacySetting ||
|
||||
.recommendSetting ||
|
||||
.videoSetting ||
|
||||
.playSetting ||
|
||||
.styleSetting ||
|
||||
.extraSetting => CommonSetting(settingType: type),
|
||||
.webdavSetting => const WebDavSettingPage(),
|
||||
.about => const AboutPage(),
|
||||
},
|
||||
);
|
||||
} else {
|
||||
_type = type;
|
||||
setState(() {});
|
||||
|
||||
Reference in New Issue
Block a user