Signed-off-by: dom <githubaccount56556@proton.me>
This commit is contained in:
dom
2026-05-14 12:13:17 +08:00
parent 025775d231
commit 09be4f45f0
78 changed files with 428 additions and 849 deletions

View File

@@ -18,7 +18,7 @@ class _ExtraSettingState extends State<ExtraSetting> {
Widget build(BuildContext context) {
final showAppBar = widget.showAppBar;
final padding = MediaQuery.viewPaddingOf(context);
return scaffold(
return scaffold_(
appBar: showAppBar ? AppBar(title: const Text('其它设置')) : null,
body: ListView.builder(
padding: EdgeInsets.only(

View File

@@ -1,102 +0,0 @@
import 'package:PiliPlus/common/widgets/pair.dart';
import 'package:PiliPlus/common/widgets/reorder_mixin.dart';
import 'package:PiliPlus/common/widgets/scaffold.dart';
import 'package:PiliPlus/models/common/enum_with_label.dart';
import 'package:PiliPlus/utils/storage.dart';
import 'package:flutter/material.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:get/get.dart';
class BarSetPage extends StatefulWidget {
const BarSetPage({super.key});
@override
State<BarSetPage> createState() => _BarSetPageState();
}
class _BarSetPageState extends State<BarSetPage> with ReorderMixin {
late final String key;
late final String title;
late final List<Pair<EnumWithLabel, bool>> list;
@override
void initState() {
super.initState();
final Map<String, dynamic> args = Get.arguments;
key = args['key'];
title = args['title'];
final List? cache = GStorage.setting.get(key);
list = (args['defaultBars'] as List<EnumWithLabel>)
.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};
list.sort((a, b) {
final indexA = cacheIndex[a.first.index] ?? cacheIndex.length;
final indexB = cacheIndex[b.first.index] ?? cacheIndex.length;
return indexA.compareTo(indexB);
});
}
}
void saveEdit() {
GStorage.setting.put(
key,
list.where((e) => e.second).map((e) => e.first.index).toList(),
);
SmartDialog.showToast('保存成功,下次启动时生效');
}
void onReset() {
Get.back();
GStorage.setting.delete(key);
SmartDialog.showToast('重置成功,下次启动时生效');
}
void onReorder(int oldIndex, int newIndex) {
if (newIndex > oldIndex) newIndex -= 1;
list.insert(newIndex, list.removeAt(oldIndex));
setState(() {});
}
@override
Widget build(BuildContext context) {
return scaffold(
appBar: AppBar(
title: Text('$title编辑'),
actions: [
TextButton(onPressed: onReset, child: const Text('重置')),
TextButton(onPressed: saveEdit, child: const Text('保存')),
const SizedBox(width: 12),
],
),
body: ReorderableListView(
onReorder: onReorder,
proxyDecorator: proxyDecorator,
footer: Padding(
padding:
MediaQuery.viewPaddingOf(context).copyWith(top: 0, left: 0) +
const .only(right: 34, top: 10),
child: const Align(
alignment: Alignment.centerRight,
child: Text('*长按拖动排序'),
),
),
children: list
.map(
(e) => CheckboxListTile(
key: ValueKey(e.hashCode),
value: e.second,
onChanged: (bool? value) {
e.second = value!;
setState(() {});
},
title: Text(e.first.label),
secondary: const Icon(Icons.drag_indicator_rounded),
),
)
.toList(),
),
);
}
}

View File

@@ -18,7 +18,7 @@ class _PlaySettingState extends State<PlaySetting> {
Widget build(BuildContext context) {
final showAppBar = widget.showAppBar;
final padding = MediaQuery.viewPaddingOf(context);
return scaffold(
return scaffold_(
appBar: showAppBar ? AppBar(title: const Text('播放器设置')) : null,
body: ListView.builder(
padding: EdgeInsets.only(

View File

@@ -18,7 +18,7 @@ class _PrivacySettingState extends State<PrivacySetting> {
Widget build(BuildContext context) {
final showAppBar = widget.showAppBar;
final padding = MediaQuery.viewPaddingOf(context);
return scaffold(
return scaffold_(
appBar: showAppBar ? AppBar(title: const Text('隐私设置')) : null,
body: ListView(
padding: .only(

View File

@@ -48,7 +48,7 @@ class _SlideColorPickerState extends State<SlideColorPicker> {
children: [
const SizedBox(width: 16),
SizedBox(
width: MediaQuery.textScalerOf(context).scale(16),
width: 16,
child: Text(title),
),
const SizedBox(width: 12),
@@ -70,7 +70,7 @@ class _SlideColorPickerState extends State<SlideColorPicker> {
),
const SizedBox(width: 12),
SizedBox(
width: MediaQuery.textScalerOf(context).scale(25) + 16,
width: 41,
child: Text(
value.toString(),
textAlign: TextAlign.start,

View File

@@ -18,7 +18,7 @@ class _StyleSettingState extends State<StyleSetting> {
Widget build(BuildContext context) {
final showAppBar = widget.showAppBar;
final padding = MediaQuery.viewPaddingOf(context);
return scaffold(
return scaffold_(
appBar: showAppBar ? AppBar(title: const Text('外观设置')) : null,
body: ListView.builder(
padding: EdgeInsets.only(

View File

@@ -18,7 +18,7 @@ class _VideoSettingState extends State<VideoSetting> {
Widget build(BuildContext context) {
final showAppBar = widget.showAppBar;
final padding = MediaQuery.viewPaddingOf(context);
return scaffold(
return scaffold_(
appBar: showAppBar ? AppBar(title: const Text('音视频设置')) : null,
body: ListView.builder(
padding: EdgeInsets.only(