pikapika/lib/screens/SettingsScreen.dart

280 lines
8.8 KiB
Dart
Raw Permalink Normal View History

2021-10-16 17:17:06 +00:00
import 'dart:io';
2021-09-29 23:57:09 +00:00
import 'package:flutter/material.dart';
2021-11-11 03:00:38 +00:00
import 'package:pikapika/basic/Common.dart';
import 'package:pikapika/basic/config/AndroidDisplayMode.dart';
import 'package:pikapika/basic/config/AndroidSecureFlag.dart';
import 'package:pikapika/basic/config/AutoClean.dart';
import 'package:pikapika/basic/config/AutoFullScreen.dart';
import 'package:pikapika/basic/config/ChooserRoot.dart';
import 'package:pikapika/basic/config/ContentFailedReloadAction.dart';
import 'package:pikapika/basic/config/DownloadAndExportPath.dart';
import 'package:pikapika/basic/config/DownloadThreadCount.dart';
2022-02-25 10:46:11 +00:00
import 'package:pikapika/basic/config/ExportRename.dart';
2021-11-11 03:00:38 +00:00
import 'package:pikapika/basic/config/FullScreenAction.dart';
import 'package:pikapika/basic/config/FullScreenUI.dart';
2022-09-05 03:05:46 +00:00
import 'package:pikapika/basic/config/IconLoading.dart';
2022-07-09 07:11:26 +00:00
import 'package:pikapika/basic/config/IsPro.dart';
2021-11-11 03:00:38 +00:00
import 'package:pikapika/basic/config/KeyboardController.dart';
2021-11-21 13:18:23 +00:00
import 'package:pikapika/basic/config/NoAnimation.dart';
2021-11-11 03:00:38 +00:00
import 'package:pikapika/basic/config/PagerAction.dart';
2022-02-25 06:31:25 +00:00
import 'package:pikapika/basic/config/Quality.dart';
import 'package:pikapika/basic/config/ReaderBackgroundColor.dart';
2021-11-11 03:00:38 +00:00
import 'package:pikapika/basic/config/ReaderDirection.dart';
2021-12-09 00:08:01 +00:00
import 'package:pikapika/basic/config/ReaderSliderPosition.dart';
2021-11-11 03:00:38 +00:00
import 'package:pikapika/basic/config/ReaderType.dart';
import 'package:pikapika/basic/config/ShadowCategories.dart';
2022-08-20 15:16:13 +00:00
import 'package:pikapika/basic/config/ShowCommentAtDownload.dart';
2021-11-11 03:00:38 +00:00
import 'package:pikapika/basic/config/Themes.dart';
import 'package:pikapika/basic/config/TimeOffsetHour.dart';
import 'package:pikapika/basic/config/VolumeController.dart';
2022-06-29 19:02:01 +00:00
import 'package:pikapika/basic/config/ShadowCategoriesMode.dart';
2021-11-11 03:00:38 +00:00
import 'package:pikapika/screens/components/NetworkSetting.dart';
2022-03-19 04:12:27 +00:00
import 'package:pikapika/screens/components/RightClickPop.dart';
2021-09-29 23:57:09 +00:00
2022-05-14 13:45:00 +00:00
import '../basic/config/Authentication.dart';
2022-09-05 03:36:25 +00:00
import '../basic/config/CategoriesColumnCount.dart';
2022-10-27 07:21:46 +00:00
import '../basic/config/DownloadCachePath.dart';
2023-04-12 09:48:48 +00:00
import '../basic/config/HiddenFdIcon.dart';
2023-04-13 09:26:07 +00:00
import '../basic/config/ImageFilter.dart';
2022-03-25 14:57:30 +00:00
import '../basic/config/UsingRightClickPop.dart';
import '../basic/config/WebDav.dart';
2022-08-11 03:21:55 +00:00
import '../basic/config/WillPopNotice.dart';
2021-09-29 23:57:09 +00:00
import 'CleanScreen.dart';
2021-10-18 09:31:05 +00:00
import 'MigrateScreen.dart';
2022-02-25 06:31:25 +00:00
import 'ModifyPasswordScreen.dart';
2023-02-11 01:26:33 +00:00
import 'ThemeScreen.dart';
2023-03-28 08:03:19 +00:00
import 'WebServerScreen.dart';
2021-09-29 23:57:09 +00:00
2023-02-11 01:26:33 +00:00
class SettingsScreen extends StatefulWidget {
2022-05-14 13:45:00 +00:00
final bool hiddenAccountInfo;
const SettingsScreen({Key? key, this.hiddenAccountInfo = false})
: super(key: key);
2022-03-17 03:31:25 +00:00
2023-02-11 01:26:33 +00:00
@override
State<StatefulWidget> createState() => _SettingsScreenState();
}
class _SettingsScreenState extends State<SettingsScreen> {
2021-09-29 23:57:09 +00:00
@override
2022-03-19 04:12:27 +00:00
Widget build(BuildContext context) {
2022-03-25 14:57:30 +00:00
return rightClickPop(
child: buildScreen(context),
context: context,
canPop: true,
);
2022-03-19 04:12:27 +00:00
}
2023-02-11 01:26:33 +00:00
late var _index = 0;
Widget buildScreen(BuildContext context) {
final List<_IconAndWidgets> iaws = [
_IconAndWidgets(Icons.lan, [
const Padding(padding: EdgeInsets.only(top: 15)),
const Divider(),
const ListTile(
subtitle: Text("网络&账户"),
2021-09-29 23:57:09 +00:00
),
2023-02-11 01:26:33 +00:00
const Divider(),
widget.hiddenAccountInfo
? Container()
: ListTile(
onTap: () async {
Navigator.push(
context,
mixRoute(
builder: (context) => const ModifyPasswordScreen(),
),
);
},
title: const Text('修改密码'),
),
const Divider(),
const NetworkSetting(),
const Padding(padding: EdgeInsets.only(top: 15)),
const Divider(),
const ListTile(
subtitle: Text("同步"),
),
...webDavSettings(context),
2023-02-11 01:26:33 +00:00
const Divider(),
const Padding(padding: EdgeInsets.only(top: 15)),
]),
_IconAndWidgets(Icons.ad_units, [
const Padding(padding: EdgeInsets.only(top: 15)),
const Divider(),
const ListTile(
subtitle: Text("系统&界面"),
),
const Divider(),
ListTile(
onTap: () async {
if (androidNightModeDisplay) {
Navigator.push(
context,
mixRoute(builder: (context) => const ThemeScreen()),
);
} else {
chooseLightTheme(context);
}
},
title: const Text('主题'),
),
fullScreenUISetting(),
noAnimationSetting(),
iconLoadingSetting(),
categoriesColumnCountSetting(),
willPopNoticeSetting(),
2023-04-12 09:48:48 +00:00
hiddenFdIconSetting(),
2023-02-11 01:26:33 +00:00
pagerActionSetting(),
contentFailedReloadActionSetting(),
timeZoneSetting(),
fontSetting(),
usingRightClickPopSetting(),
const Divider(),
androidDisplayModeSetting(),
androidSecureFlagSetting(),
authenticationSetting(),
const Divider(),
migrate(context),
const Divider(),
const Padding(padding: EdgeInsets.only(top: 15)),
]),
_IconAndWidgets(Icons.confirmation_num_rounded, [
const Divider(),
const Padding(padding: EdgeInsets.only(top: 15)),
const Divider(),
const ListTile(
subtitle: Text("内容&阅读器"),
),
const Divider(),
shadowCategoriesModeSetting(),
shadowCategoriesSetting(),
const Divider(),
qualitySetting(),
readerTypeSetting(),
readerDirectionSetting(),
readerSliderPositionSetting(),
autoFullScreenSetting(),
fullScreenActionSetting(),
volumeControllerSetting(),
keyboardControllerSetting(),
const Divider(),
2023-04-13 09:26:07 +00:00
imageFilterSetting(),
readerBackgroundColorSetting(),
2023-04-13 09:26:07 +00:00
const Divider(),
2023-02-11 01:26:33 +00:00
const Padding(padding: EdgeInsets.only(top: 15)),
]),
_IconAndWidgets(Icons.download, [
const Padding(padding: EdgeInsets.only(top: 15)),
const Divider(),
const ListTile(
subtitle: Text("下载&缓存"),
),
const Divider(),
2023-03-28 08:03:19 +00:00
ListTile(
title: const Text("启动Web服务器"),
subtitle: const Text("让局域网内的设备通过浏览器看下载的漫画"),
onTap: (){
Navigator.of(context).push(
mixRoute(
builder: (BuildContext context) =>
const WebServerScreen(),
),
);
},
),
const Divider(),
2023-02-11 01:26:33 +00:00
autoCleanSecSetting(),
ListTile(
onTap: () {
Navigator.push(
context,
mixRoute(builder: (context) => const CleanScreen()),
);
},
title: const Text('清除缓存'),
),
const Divider(),
chooserRootSetting(),
downloadThreadCountSetting(),
downloadAndExportPathSetting(),
showCommentAtDownloadSetting(),
exportRenameSetting(),
const Divider(),
downloadCachePathSetting(),
importViewLogFromOff(),
const Divider(),
2023-02-11 01:26:33 +00:00
const Padding(padding: EdgeInsets.only(top: 15)),
]),
];
var i = 0;
return Scaffold(
appBar: AppBar(
title: const Text('设置'),
actions: [
...iaws.map(
(e) {
final idx = i;
return Opacity(
child: IconButton(
onPressed: () {
setState(() {
_index = idx;
});
},
icon: Icon(e.icon),
),
opacity: i++ == _index ? 1 : .75,
);
},
)
],
),
body: ListView(
children: iaws[_index].widgets,
),
);
}
2021-10-16 17:17:06 +00:00
2021-11-04 03:45:22 +00:00
Widget migrate(BuildContext context) {
2021-10-16 17:17:06 +00:00
if (Platform.isAndroid) {
return ListTile(
2022-07-09 07:11:26 +00:00
title: Text(
"文件迁移" + (!isPro ? "(发电)" : ""),
style: TextStyle(
color: !isPro ? Colors.grey : null,
),
),
subtitle: const Text("更换您的数据文件夹到内存卡"),
2021-10-16 17:17:06 +00:00
onTap: () async {
2022-07-09 07:11:26 +00:00
if (!isPro) {
defaultToast(context, "请先发电再使用");
return;
}
2021-11-04 03:45:22 +00:00
var f =
await confirmDialog(context, "文件迁移", "此功能菜单保存后, 需要重启程序, 您确认吗");
2021-10-18 09:31:05 +00:00
if (f) {
Navigator.of(context).pushAndRemoveUntil(
2023-01-31 10:50:51 +00:00
mixRoute(builder: (BuildContext context) {
2022-03-19 04:12:27 +00:00
return const MigrateScreen();
2021-10-18 09:31:05 +00:00
}),
(route) => false,
);
}
2021-10-16 17:17:06 +00:00
},
);
}
return Container();
}
2021-09-29 23:57:09 +00:00
}
2023-02-11 01:26:33 +00:00
class _IconAndWidgets {
final IconData icon;
final List<Widget> widgets;
_IconAndWidgets(this.icon, this.widgets);
}