diff --git a/lib/basic/config/AndroidDisplayMode.dart b/lib/basic/config/AndroidDisplayMode.dart index f9fca1e..d6d4134 100644 --- a/lib/basic/config/AndroidDisplayMode.dart +++ b/lib/basic/config/AndroidDisplayMode.dart @@ -8,14 +8,13 @@ import 'package:pikapi/basic/Method.dart'; import '../Common.dart'; const _propertyName = "androidDisplayMode"; - -List modes = []; +List _modes = []; String _androidDisplayMode = ""; Future initAndroidDisplayMode() async { if (Platform.isAndroid) { _androidDisplayMode = await method.loadProperty(_propertyName, ""); - modes = await method.loadAndroidModes(); + _modes = await method.loadAndroidModes(); await _changeMode(); } } @@ -24,14 +23,10 @@ Future _changeMode() async { await method.setAndroidMode(_androidDisplayMode); } -String androidDisplayModeName() { - return _androidDisplayMode; -} - -Future chooseAndroidDisplayMode(BuildContext context) async { +Future _chooseAndroidDisplayMode(BuildContext context) async { if (Platform.isAndroid) { List list = [""]; - list.addAll(modes); + list.addAll(_modes); String? result = await chooseListDialog(context, "安卓屏幕刷新率", list); if (result != null) { await method.saveProperty(_propertyName, "$result"); @@ -47,9 +42,9 @@ Widget androidDisplayModeSetting() { builder: (BuildContext context, void Function(void Function()) setState) { return ListTile( title: Text("屏幕刷新率(安卓)"), - subtitle: Text(androidDisplayModeName()), + subtitle: Text(_androidDisplayMode), onTap: () async { - await chooseAndroidDisplayMode(context); + await _chooseAndroidDisplayMode(context); setState(() {}); }, ); diff --git a/lib/basic/config/AndroidSecureFlag.dart b/lib/basic/config/AndroidSecureFlag.dart index 1a675bc..f9dfba1 100644 --- a/lib/basic/config/AndroidSecureFlag.dart +++ b/lib/basic/config/AndroidSecureFlag.dart @@ -7,32 +7,28 @@ import 'package:flutter/material.dart'; import '../Common.dart'; import '../Method.dart'; -const propertyName = "androidSecureFlag"; +const _propertyName = "androidSecureFlag"; -late bool androidSecureFlag; +late bool _androidSecureFlag; Future initAndroidSecureFlag() async { if (Platform.isAndroid) { - androidSecureFlag = - (await method.loadProperty(propertyName, "false")) == "true"; - if (androidSecureFlag) { + _androidSecureFlag = + (await method.loadProperty(_propertyName, "false")) == "true"; + if (_androidSecureFlag) { await method.androidSecureFlag(true); } } } -String androidSecureFlagName() { - return androidSecureFlag ? "是" : "否"; -} - -Future chooseAndroidSecureFlag(BuildContext context) async { +Future _chooseAndroidSecureFlag(BuildContext context) async { String? result = await chooseListDialog(context, "禁止截图/禁止显示在任务视图", ["是", "否"]); if (result != null) { var target = result == "是"; - await method.saveProperty(propertyName, "$target"); - androidSecureFlag = target; - await method.androidSecureFlag(androidSecureFlag); + await method.saveProperty(_propertyName, "$target"); + _androidSecureFlag = target; + await method.androidSecureFlag(_androidSecureFlag); } } @@ -42,9 +38,9 @@ Widget androidSecureFlagSetting() { (BuildContext context, void Function(void Function()) setState) { return ListTile( title: Text("禁止截图/禁止显示在任务视图(仅安卓)"), - subtitle: Text(androidSecureFlagName()), + subtitle: Text(_androidSecureFlag ? "是" : "否"), onTap: () async { - await chooseAndroidSecureFlag(context); + await _chooseAndroidSecureFlag(context); setState(() {}); }); }); diff --git a/lib/basic/config/AutoClean.dart b/lib/basic/config/AutoClean.dart index 5d15813..a990e52 100644 --- a/lib/basic/config/AutoClean.dart +++ b/lib/basic/config/AutoClean.dart @@ -1,9 +1,16 @@ import 'package:flutter/material.dart'; import 'package:pikapi/basic/Method.dart'; + +const _autoCleanMap = { + "一个月前": "${3600 * 24 * 30}", + "一周前": "${3600 * 24 * 7}", + "一天前": "${3600 * 24 * 1}", + "不自动清理": "${0}", +}; late String _autoCleanSec; -Future autoClean() async { +Future initAutoClean() async { _autoCleanSec = await method.loadProperty("autoCleanSec", "${3600 * 24 * 30}"); if ("0" != _autoCleanSec) { @@ -11,14 +18,7 @@ Future autoClean() async { } } -var _autoCleanMap = { - "一个月前": "${3600 * 24 * 30}", - "一周前": "${3600 * 24 * 7}", - "一天前": "${3600 * 24 * 1}", - "不自动清理": "${0}", -}; - -String currentAutoCleanSec() { +String _currentAutoCleanSec() { for (var value in _autoCleanMap.entries) { if (value.value == _autoCleanSec) { return value.key; @@ -27,7 +27,7 @@ String currentAutoCleanSec() { return ""; } -Future chooseAutoCleanSec(BuildContext context) async { +Future _chooseAutoCleanSec(BuildContext context) async { String? choose = await showDialog( context: context, builder: (BuildContext context) { @@ -58,9 +58,9 @@ Widget autoCleanSecSetting() { builder: (BuildContext context, void Function(void Function()) setState) { return ListTile( title: Text("自动清理缓存"), - subtitle: Text(currentAutoCleanSec()), + subtitle: Text(_currentAutoCleanSec()), onTap: () async { - await chooseAutoCleanSec(context); + await _chooseAutoCleanSec(context); setState(() {}); }, ); diff --git a/lib/basic/config/AutoFullScreen.dart b/lib/basic/config/AutoFullScreen.dart index cf73cee..22fde67 100644 --- a/lib/basic/config/AutoFullScreen.dart +++ b/lib/basic/config/AutoFullScreen.dart @@ -5,24 +5,19 @@ import 'package:flutter/material.dart'; import '../Common.dart'; import '../Method.dart'; -late bool _autoFullScreen; - -bool currentAutoFullScreen() { - return _autoFullScreen; -} - const _propertyName = "autoFullScreen"; +late bool _autoFullScreen; Future initAutoFullScreen() async { _autoFullScreen = (await method.loadProperty(_propertyName, "false")) == "true"; } -String autoFullScreenName() { - return _autoFullScreen ? "是" : "否"; +bool currentAutoFullScreen() { + return _autoFullScreen; } -Future chooseAutoFullScreen(BuildContext context) async { +Future _chooseAutoFullScreen(BuildContext context) async { String? result = await chooseListDialog(context, "进入阅读器自动全屏", ["是", "否"]); if (result != null) { @@ -37,9 +32,9 @@ Widget autoFullScreenSetting() { builder: (BuildContext context, void Function(void Function()) setState) { return ListTile( title: Text("进入阅读器自动全屏"), - subtitle: Text(autoFullScreenName()), + subtitle: Text(_autoFullScreen ? "是" : "否"), onTap: () async { - await chooseAutoFullScreen(context); + await _chooseAutoFullScreen(context); setState(() {}); }, ); diff --git a/lib/basic/config/ChooserRoot.dart b/lib/basic/config/ChooserRoot.dart index 2f132ba..6168a7a 100644 --- a/lib/basic/config/ChooserRoot.dart +++ b/lib/basic/config/ChooserRoot.dart @@ -10,7 +10,7 @@ import '../Method.dart'; const _propertyName = "chooserRoot"; late String _chooserRoot; -Future initChooserRoot() async { +Future initChooserRoot() async { _chooserRoot = await method.loadProperty(_propertyName, ""); } @@ -34,7 +34,7 @@ String currentChooserRoot() { return _chooserRoot; } -Future inputChooserRoot(BuildContext context) async { +Future _inputChooserRoot(BuildContext context) async { String? input = await displayTextInputDialog( context, '文件夹选择器根路径', @@ -55,7 +55,7 @@ Widget chooserRootSetting() { title: Text("文件夹选择器默认路径"), subtitle: Text(currentChooserRoot()), onTap: () async { - await inputChooserRoot(context); + await _inputChooserRoot(context); setState(() {}); }, ); diff --git a/lib/basic/config/ContentFailedReloadAction.dart b/lib/basic/config/ContentFailedReloadAction.dart index 85fbbd5..4d08517 100644 --- a/lib/basic/config/ContentFailedReloadAction.dart +++ b/lib/basic/config/ContentFailedReloadAction.dart @@ -10,9 +10,8 @@ enum ContentFailedReloadAction { TOUCH_LOADER, } -late ContentFailedReloadAction contentFailedReloadAction; - const _propertyName = "contentFailedReloadAction"; +late ContentFailedReloadAction contentFailedReloadAction; Future initContentFailedReloadAction() async { contentFailedReloadAction = @@ -31,13 +30,13 @@ ContentFailedReloadAction _contentFailedReloadActionFromString(String string) { return ContentFailedReloadAction.PULL_DOWN; } -Map contentFailedReloadActionMap = { +Map _contentFailedReloadActionMap = { "下拉刷新": ContentFailedReloadAction.PULL_DOWN, "点击屏幕刷新": ContentFailedReloadAction.TOUCH_LOADER, }; -String currentContentFailedReloadActionName() { - for (var e in contentFailedReloadActionMap.entries) { +String _currentContentFailedReloadActionName() { + for (var e in _contentFailedReloadActionMap.entries) { if (e.value == contentFailedReloadAction) { return e.key; } @@ -45,25 +44,27 @@ String currentContentFailedReloadActionName() { return ''; } -Future chooseContentFailedReloadAction(BuildContext context) async { +Future _chooseContentFailedReloadAction(BuildContext context) async { ContentFailedReloadAction? result = await chooseMapDialog( - context, contentFailedReloadActionMap, "选择页面加载失败刷新的方式"); + context, _contentFailedReloadActionMap, "选择页面加载失败刷新的方式"); if (result != null) { await method.saveProperty(_propertyName, result.toString()); contentFailedReloadAction = result; } } -Widget contentFailedReloadActionSetting(){ - return StatefulBuilder(builder: (BuildContext context, void Function(void Function()) setState) { - return ListTile( - title: Text("加载失败时"), - subtitle: Text(currentContentFailedReloadActionName()), - onTap: () async { - await chooseContentFailedReloadAction(context); - setState(() {}); - }, - ); - },); -} \ No newline at end of file +Widget contentFailedReloadActionSetting() { + return StatefulBuilder( + builder: (BuildContext context, void Function(void Function()) setState) { + return ListTile( + title: Text("加载失败时"), + subtitle: Text(_currentContentFailedReloadActionName()), + onTap: () async { + await _chooseContentFailedReloadAction(context); + setState(() {}); + }, + ); + }, + ); +} diff --git a/lib/basic/config/DownloadAndExportPath.dart b/lib/basic/config/DownloadAndExportPath.dart index 4aab2c4..140e498 100644 --- a/lib/basic/config/DownloadAndExportPath.dart +++ b/lib/basic/config/DownloadAndExportPath.dart @@ -1,3 +1,5 @@ +/// 下载的同时导出到文件系统 + import 'dart:io'; import 'package:flutter/cupertino.dart'; diff --git a/lib/basic/config/DownloadThreadCount.dart b/lib/basic/config/DownloadThreadCount.dart index bdfc60f..41689f3 100644 --- a/lib/basic/config/DownloadThreadCount.dart +++ b/lib/basic/config/DownloadThreadCount.dart @@ -1,3 +1,5 @@ +/// 多线程下载并发数 + import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:pikapi/basic/Common.dart'; diff --git a/lib/basic/config/FullScreenAction.dart b/lib/basic/config/FullScreenAction.dart index 9f45429..6bdce7c 100644 --- a/lib/basic/config/FullScreenAction.dart +++ b/lib/basic/config/FullScreenAction.dart @@ -10,17 +10,25 @@ enum FullScreenAction { TOUCH_ONCE, } -late FullScreenAction fullScreenAction; +Map _fullScreenActionMap = { + "使用控制器": FullScreenAction.CONTROLLER, + "点击屏幕一次": FullScreenAction.TOUCH_ONCE, +}; const _propertyName = "fullScreenAction"; +late FullScreenAction _fullScreenAction; Future initFullScreenAction() async { - fullScreenAction = _fullScreenActionFromString(await method.loadProperty( + _fullScreenAction = _fullScreenActionFromString(await method.loadProperty( _propertyName, FullScreenAction.CONTROLLER.toString(), )); } +FullScreenAction currentFullScreenAction() { + return _fullScreenAction; +} + FullScreenAction _fullScreenActionFromString(String string) { for (var value in FullScreenAction.values) { if (string == value.toString()) { @@ -30,26 +38,21 @@ FullScreenAction _fullScreenActionFromString(String string) { return FullScreenAction.CONTROLLER; } -Map fullScreenActionMap = { - "使用控制器": FullScreenAction.CONTROLLER, - "点击屏幕一次": FullScreenAction.TOUCH_ONCE, -}; - -String currentFullScreenActionName() { - for (var e in fullScreenActionMap.entries) { - if (e.value == fullScreenAction) { +String _currentFullScreenActionName() { + for (var e in _fullScreenActionMap.entries) { + if (e.value == _fullScreenAction) { return e.key; } } return ''; } -Future chooseFullScreenAction(BuildContext context) async { +Future _chooseFullScreenAction(BuildContext context) async { FullScreenAction? result = await chooseMapDialog( - context, fullScreenActionMap, "选择进入全屏的方式"); + context, _fullScreenActionMap, "选择进入全屏的方式"); if (result != null) { await method.saveProperty(_propertyName, result.toString()); - fullScreenAction = result; + _fullScreenAction = result; } } @@ -58,9 +61,9 @@ Widget fullScreenActionSetting() { builder: (BuildContext context, void Function(void Function()) setState) { return ListTile( title: Text("进入全屏的方式"), - subtitle: Text(currentFullScreenActionName()), + subtitle: Text(_currentFullScreenActionName()), onTap: () async { - await chooseFullScreenAction(context); + await _chooseFullScreenAction(context); setState(() {}); }, ); diff --git a/lib/basic/config/FullScreenUI.dart b/lib/basic/config/FullScreenUI.dart index 588b9e4..4d2f9b2 100644 --- a/lib/basic/config/FullScreenUI.dart +++ b/lib/basic/config/FullScreenUI.dart @@ -12,9 +12,9 @@ enum FullScreenUI { ALL, } +const _propertyName = "fullScreenUI"; late FullScreenUI fullScreenUI; -const _propertyName = "fullScreenUI"; Future initFullScreenUI() async { fullScreenUI = _fullScreenUIFromString(await method.loadProperty( diff --git a/lib/basic/config/KeyboardController.dart b/lib/basic/config/KeyboardController.dart index fba7225..409e163 100644 --- a/lib/basic/config/KeyboardController.dart +++ b/lib/basic/config/KeyboardController.dart @@ -16,11 +16,7 @@ Future initKeyboardController() async { (await method.loadProperty(_propertyName, "false")) == "true"; } -String keyboardControllerName() { - return keyboardController ? "是" : "否"; -} - -Future chooseKeyboardController(BuildContext context) async { +Future _chooseKeyboardController(BuildContext context) async { String? result = await chooseListDialog(context, "键盘控制翻页", ["是", "否"]); if (result != null) { @@ -36,9 +32,9 @@ Widget keyboardControllerSetting() { builder: (BuildContext context, void Function(void Function()) setState) { return ListTile( title: Text("阅读器键盘翻页(仅PC)"), - subtitle: Text(keyboardControllerName()), + subtitle: Text(keyboardController ? "是" : "否"), onTap: () async { - await chooseKeyboardController(context); + await _chooseKeyboardController(context); setState(() {}); }, ); diff --git a/lib/basic/config/ListLayout.dart b/lib/basic/config/ListLayout.dart index 9453cd3..6e75a58 100644 --- a/lib/basic/config/ListLayout.dart +++ b/lib/basic/config/ListLayout.dart @@ -11,8 +11,17 @@ enum ListLayout { COVER_AND_TITLE, } +const Map _listLayoutMap = { + '详情': ListLayout.INFO_CARD, + '封面': ListLayout.ONLY_IMAGE, + '封面+标题': ListLayout.COVER_AND_TITLE, +}; + +const _propertyName = "listLayout"; late ListLayout currentLayout; +var listLayoutEvent = Event(); + Future initListLayout() async { currentLayout = _listLayoutFromString(await method.loadProperty( _propertyName, @@ -20,16 +29,6 @@ Future initListLayout() async { )); } -const _propertyName = "listLayout"; - -var listLayoutEvent = Event(); - -const Map _listLayoutMap = { - '详情': ListLayout.INFO_CARD, - '封面': ListLayout.ONLY_IMAGE, - '封面+标题': ListLayout.COVER_AND_TITLE, -}; - ListLayout _listLayoutFromString(String layoutString) { for (var value in ListLayout.values) { if (layoutString == value.toString()) { @@ -39,7 +38,7 @@ ListLayout _listLayoutFromString(String layoutString) { return ListLayout.INFO_CARD; } -void chooseListLayout(BuildContext context) async { +void _chooseListLayout(BuildContext context) async { ListLayout? layout = await chooseMapDialog(context, _listLayoutMap, '请选择布局'); if (layout != null) { await method.saveProperty(_propertyName, layout.toString()); @@ -48,10 +47,9 @@ void chooseListLayout(BuildContext context) async { } } -IconButton chooseLayoutAction(BuildContext context) => IconButton( +IconButton chooseLayoutActionButton(BuildContext context) => IconButton( onPressed: () { - chooseListLayout(context); + _chooseListLayout(context); }, icon: Icon(Icons.view_quilt), ); - diff --git a/lib/basic/config/PagerAction.dart b/lib/basic/config/PagerAction.dart index b377859..5ff136f 100644 --- a/lib/basic/config/PagerAction.dart +++ b/lib/basic/config/PagerAction.dart @@ -10,15 +10,23 @@ enum PagerAction { STREAM, } -late PagerAction currentPagerAction; +Map _pagerActionMap = { + "使用按钮": PagerAction.CONTROLLER, + "瀑布流": PagerAction.STREAM, +}; const _propertyName = "pagerAction"; +late PagerAction _pagerAction; Future initPagerAction() async { - currentPagerAction = _pagerActionFromString(await method.loadProperty( + _pagerAction = _pagerActionFromString(await method.loadProperty( _propertyName, PagerAction.CONTROLLER.toString())); } +PagerAction currentPagerAction() { + return _pagerAction; +} + PagerAction _pagerActionFromString(String string) { for (var value in PagerAction.values) { if (string == value.toString()) { @@ -28,26 +36,21 @@ PagerAction _pagerActionFromString(String string) { return PagerAction.CONTROLLER; } -Map _pagerActionMap = { - "使用按钮": PagerAction.CONTROLLER, - "瀑布流": PagerAction.STREAM, -}; - -String currentPagerActionName() { +String _currentPagerActionName() { for (var e in _pagerActionMap.entries) { - if (e.value == currentPagerAction) { + if (e.value == _pagerAction) { return e.key; } } return ''; } -Future choosePagerAction(BuildContext context) async { +Future _choosePagerAction(BuildContext context) async { PagerAction? result = await chooseMapDialog(context, _pagerActionMap, "选择列表页加载方式"); if (result != null) { await method.saveProperty(_propertyName, result.toString()); - currentPagerAction = result; + _pagerAction = result; } } @@ -56,9 +59,9 @@ Widget pagerActionSetting() { builder: (BuildContext context, void Function(void Function()) setState) { return ListTile( title: Text("列表页加载方式"), - subtitle: Text(currentPagerActionName()), + subtitle: Text(_currentPagerActionName()), onTap: () async { - await choosePagerAction(context); + await _choosePagerAction(context); setState(() {}); }, ); diff --git a/lib/basic/config/Quality.dart b/lib/basic/config/Quality.dart index 6c49546..5e06079 100644 --- a/lib/basic/config/Quality.dart +++ b/lib/basic/config/Quality.dart @@ -20,7 +20,13 @@ var _qualities = { _LabelHigh: ImageQualityHigh, }; +const _propertyName = "quality"; late String _currentQualityCode; +const _defaultValue = _ImageQualityOriginal; + +Future initQuality() async { + _currentQualityCode = await method.loadProperty(_propertyName, _defaultValue); +} String currentQualityCode() { return _currentQualityCode; @@ -35,14 +41,7 @@ String _currentQualityName() { return ''; } -const _propertyName = "quality"; -const _defaultValue = _ImageQualityOriginal; - -Future initQuality() async { - _currentQualityCode = await method.loadProperty(_propertyName, _defaultValue); -} - -Future chooseQuality(BuildContext context) async { +Future _chooseQuality(BuildContext context) async { String? code = await showDialog( context: context, builder: (BuildContext context) { @@ -74,7 +73,7 @@ Widget qualitySetting() { title: Text("浏览时的图片质量"), subtitle: Text(_currentQualityName()), onTap: () async { - await chooseQuality(context); + await _chooseQuality(context); setState(() {}); }, ); diff --git a/lib/basic/config/ReaderDirection.dart b/lib/basic/config/ReaderDirection.dart index 00a6eb0..e71a594 100644 --- a/lib/basic/config/ReaderDirection.dart +++ b/lib/basic/config/ReaderDirection.dart @@ -9,21 +9,20 @@ enum ReaderDirection { RIGHT_TO_LEFT, } -late ReaderDirection gReaderDirection; +const _types = { + '从上到下': ReaderDirection.TOP_TO_BOTTOM, + '从左到右': ReaderDirection.LEFT_TO_RIGHT, + '从右到左': ReaderDirection.RIGHT_TO_LEFT, +}; const _propertyName = "readerDirection"; +late ReaderDirection gReaderDirection; Future initReaderDirection() async { gReaderDirection = _pagerDirectionFromString(await method.loadProperty( _propertyName, ReaderDirection.TOP_TO_BOTTOM.toString())); } -var _types = { - '从上到下': ReaderDirection.TOP_TO_BOTTOM, - '从左到右': ReaderDirection.LEFT_TO_RIGHT, - '从右到左': ReaderDirection.RIGHT_TO_LEFT, -}; - ReaderDirection _pagerDirectionFromString(String pagerDirectionString) { for (var value in ReaderDirection.values) { if (pagerDirectionString == value.toString()) { @@ -33,7 +32,7 @@ ReaderDirection _pagerDirectionFromString(String pagerDirectionString) { return ReaderDirection.TOP_TO_BOTTOM; } -String currentReaderDirectionName() { +String _currentReaderDirectionName() { for (var e in _types.entries) { if (e.value == gReaderDirection) { return e.key; @@ -42,6 +41,7 @@ String currentReaderDirectionName() { return ''; } +/// ?? to ActionButton And Event ?? Future choosePagerDirection(BuildContext buildContext) async { ReaderDirection? choose = await showDialog( context: buildContext, @@ -70,7 +70,7 @@ Widget readerDirectionSetting() { builder: (BuildContext context, void Function(void Function()) setState) { return ListTile( title: Text("阅读器方向"), - subtitle: Text(currentReaderDirectionName()), + subtitle: Text(_currentReaderDirectionName()), onTap: () async { await choosePagerDirection(context); setState(() {}); diff --git a/lib/basic/config/ReaderType.dart b/lib/basic/config/ReaderType.dart index 5797713..2feabeb 100644 --- a/lib/basic/config/ReaderType.dart +++ b/lib/basic/config/ReaderType.dart @@ -1,30 +1,32 @@ /// 阅读器的类型 import 'package:flutter/material.dart'; - import '../Method.dart'; -late ReaderType gReaderType; - -const _propertyName = "readerType"; - -Future initReaderType() async { - gReaderType = _readerTypeFromString( - await method.loadProperty(_propertyName, ReaderType.WEB_TOON.toString())); -} - enum ReaderType { WEB_TOON, WEB_TOON_ZOOM, GALLERY, } -var _types = { +const _types = { 'WebToon (默认)': ReaderType.WEB_TOON, 'WebToon + 双击放大': ReaderType.WEB_TOON_ZOOM, '相册': ReaderType.GALLERY, }; +const _propertyName = "readerType"; +late ReaderType _readerType; + +Future initReaderType() async { + _readerType = _readerTypeFromString( + await method.loadProperty(_propertyName, ReaderType.WEB_TOON.toString())); +} + +ReaderType currentReaderType() { + return _readerType; +} + ReaderType _readerTypeFromString(String pagerTypeString) { for (var value in ReaderType.values) { if (pagerTypeString == value.toString()) { @@ -36,7 +38,7 @@ ReaderType _readerTypeFromString(String pagerTypeString) { String currentReaderTypeName() { for (var e in _types.entries) { - if (e.value == gReaderType) { + if (e.value == _readerType) { return e.key; } } @@ -62,7 +64,7 @@ Future choosePagerType(BuildContext buildContext) async { ); if (t != null) { await method.saveProperty(_propertyName, t.toString()); - gReaderType = t; + _readerType = t; } } diff --git a/lib/basic/config/ShadowCategories.dart b/lib/basic/config/ShadowCategories.dart index 4470cbe..f5235ec 100644 --- a/lib/basic/config/ShadowCategories.dart +++ b/lib/basic/config/ShadowCategories.dart @@ -10,12 +10,10 @@ import 'package:multi_select_flutter/multi_select_flutter.dart'; import '../Method.dart'; import '../store/Categories.dart'; -late List shadowCategories; -var shadowCategoriesEvent = Event(); - -// mapper - const _propertyName = "shadowCategories"; +late List shadowCategories; + +var shadowCategoriesEvent = Event(); /// 获取封印的类型 Future> _loadShadowCategories() async { diff --git a/lib/basic/config/TimeOffsetHour.dart b/lib/basic/config/TimeOffsetHour.dart index 77a6431..6ff1579 100644 --- a/lib/basic/config/TimeOffsetHour.dart +++ b/lib/basic/config/TimeOffsetHour.dart @@ -5,19 +5,18 @@ import 'package:flutter/material.dart'; import '../Common.dart'; import '../Method.dart'; -int _timeOffsetHour = 8; - -int currentTimeOffsetHour() { - return _timeOffsetHour; -} - const _propertyName = "timeOffsetHour"; +int _timeOffsetHour = 8; Future initTimeZone() async { _timeOffsetHour = int.parse(await method.loadProperty(_propertyName, "8")); } -Future chooseTimeZone(BuildContext context) async { +int currentTimeOffsetHour() { + return _timeOffsetHour; +} + +Future _chooseTimeZone(BuildContext context) async { List timeZones = []; for (var i = -12; i <= 12; i++) { var str = i.toString(); @@ -47,7 +46,7 @@ Widget timeZoneSetting() { title: Text("时区"), subtitle: Text(c), onTap: () async { - await chooseTimeZone(context); + await _chooseTimeZone(context); setState(() {}); }, ); diff --git a/lib/basic/config/VolumeController.dart b/lib/basic/config/VolumeController.dart index 9ab81c4..bb016fb 100644 --- a/lib/basic/config/VolumeController.dart +++ b/lib/basic/config/VolumeController.dart @@ -7,25 +7,20 @@ import 'package:flutter/material.dart'; import '../Common.dart'; import '../Method.dart'; -const propertyName = "volumeController"; - +const _propertyName = "volumeController"; late bool volumeController; Future initVolumeController() async { volumeController = - (await method.loadProperty(propertyName, "false")) == "true"; + (await method.loadProperty(_propertyName, "false")) == "true"; } -String volumeControllerName() { - return volumeController ? "是" : "否"; -} - -Future chooseVolumeController(BuildContext context) async { +Future _chooseVolumeController(BuildContext context) async { String? result = await chooseListDialog(context, "音量键控制翻页", ["是", "否"]); if (result != null) { var target = result == "是"; - await method.saveProperty(propertyName, "$target"); + await method.saveProperty(_propertyName, "$target"); volumeController = target; } } @@ -36,9 +31,9 @@ Widget volumeControllerSetting() { (BuildContext context, void Function(void Function()) setState) { return ListTile( title: Text("阅读器音量键翻页(仅安卓)"), - subtitle: Text(volumeControllerName()), + subtitle: Text(volumeController ? "是" : "否"), onTap: () async { - await chooseVolumeController(context); + await _chooseVolumeController(context); setState(() {}); }); }); diff --git a/lib/screens/ComicReaderScreen.dart b/lib/screens/ComicReaderScreen.dart index ded8116..0589735 100644 --- a/lib/screens/ComicReaderScreen.dart +++ b/lib/screens/ComicReaderScreen.dart @@ -18,7 +18,7 @@ class ComicReaderScreen extends StatefulWidget { final List epList; final currentEpOrder; final int? initPictureRank; - final ReaderType pagerType = gReaderType; + final ReaderType pagerType = currentReaderType(); final ReaderDirection pagerDirection = gReaderDirection; late final bool autoFullScreen; @@ -149,7 +149,7 @@ class _ComicReaderScreenState extends State { IconButton( onPressed: () async { await choosePagerType(context); - if (widget.pagerType != gReaderType) { + if (widget.pagerType != currentReaderType()) { _reloadReader(); } }, diff --git a/lib/screens/ComicsScreen.dart b/lib/screens/ComicsScreen.dart index 3a856b4..59b67a7 100644 --- a/lib/screens/ComicsScreen.dart +++ b/lib/screens/ComicsScreen.dart @@ -51,7 +51,7 @@ class _ComicsScreenState extends State { title: new Text(categoryTitle(widget.category)), actions: [ shadowCategoriesActionButton(context), - chooseLayoutAction(context), + chooseLayoutActionButton(context), _chooseCategoryAction(), _categorySearchBar.getSearchAction(context), ], @@ -125,7 +125,7 @@ class _ComicsScreenState extends State { title: Text(title), actions: [ shadowCategoriesActionButton(context), - chooseLayoutAction(context), + chooseLayoutActionButton(context), _chooseCategoryAction(), ], ); diff --git a/lib/screens/DownloadReaderScreen.dart b/lib/screens/DownloadReaderScreen.dart index 844ff38..76c895a 100644 --- a/lib/screens/DownloadReaderScreen.dart +++ b/lib/screens/DownloadReaderScreen.dart @@ -17,7 +17,7 @@ class DownloadReaderScreen extends StatefulWidget { final List epList; final int currentEpOrder; final int? initPictureRank; - final ReaderType pagerType = gReaderType; + final ReaderType pagerType = currentReaderType(); final ReaderDirection pagerDirection = gReaderDirection; late final bool autoFullScreen; @@ -118,7 +118,6 @@ class _DownloadReaderScreenState extends State { super.dispose(); } - @override Widget build(BuildContext context) { return readerKeyboardHolder(_build(context)); @@ -143,7 +142,7 @@ class _DownloadReaderScreenState extends State { IconButton( onPressed: () async { await choosePagerType(context); - if (widget.pagerType != gReaderType) { + if (widget.pagerType != currentReaderType()) { _reloadReader(); } }, diff --git a/lib/screens/InitScreen.dart b/lib/screens/InitScreen.dart index ee42a25..95ddfdc 100644 --- a/lib/screens/InitScreen.dart +++ b/lib/screens/InitScreen.dart @@ -43,7 +43,7 @@ class _InitScreenState extends State { Future _init() async { // 初始化配置文件 await initPlatform(); // 必须第一个初始化, 加载设备信息 - await autoClean(); + await initAutoClean(); await initAddress(); await initProxy(); await initQuality(); diff --git a/lib/screens/RandomComicsScreen.dart b/lib/screens/RandomComicsScreen.dart index acf5fad..a41e3fe 100644 --- a/lib/screens/RandomComicsScreen.dart +++ b/lib/screens/RandomComicsScreen.dart @@ -28,7 +28,7 @@ class _RandomComicsScreenState extends State { title: Text('随机本子'), actions: [ shadowCategoriesActionButton(context), - chooseLayoutAction(context), + chooseLayoutActionButton(context), ], ), body: ComicListBuilder(_future, _reload), diff --git a/lib/screens/RankingsScreen.dart b/lib/screens/RankingsScreen.dart index 43861c5..eaff4fe 100644 --- a/lib/screens/RankingsScreen.dart +++ b/lib/screens/RankingsScreen.dart @@ -17,7 +17,7 @@ class RankingsScreen extends StatelessWidget { title: Text('排行榜'), actions: [ shadowCategoriesActionButton(context), - chooseLayoutAction(context), + chooseLayoutActionButton(context), ], ), body: DefaultTabController( diff --git a/lib/screens/SearchScreen.dart b/lib/screens/SearchScreen.dart index 7e8c5ff..8102eb3 100644 --- a/lib/screens/SearchScreen.dart +++ b/lib/screens/SearchScreen.dart @@ -49,7 +49,7 @@ class _SearchScreenState extends State { title: Text("${categoryTitle(widget.category)} ${widget.keyword}"), actions: [ shadowCategoriesActionButton(context), - chooseLayoutAction(context), + chooseLayoutActionButton(context), _chooseCategoryAction(), _searchBar.getSearchAction(context), ], diff --git a/lib/screens/components/ComicPager.dart b/lib/screens/components/ComicPager.dart index e1bd1d8..5a422e5 100644 --- a/lib/screens/components/ComicPager.dart +++ b/lib/screens/components/ComicPager.dart @@ -41,7 +41,7 @@ class _ComicPagerState extends State { @override Widget build(BuildContext context) { - switch (currentPagerAction) { + switch (currentPagerAction()) { case PagerAction.CONTROLLER: return ControllerComicPager(fetchPage: widget.fetchPage); case PagerAction.STREAM: diff --git a/lib/screens/components/ImageReader.dart b/lib/screens/components/ImageReader.dart index 9905306..6df0711 100644 --- a/lib/screens/components/ImageReader.dart +++ b/lib/screens/components/ImageReader.dart @@ -148,7 +148,7 @@ class ImageReader extends StatelessWidget { reader = Container(); break; } - switch (fullScreenAction) { + switch (currentFullScreenAction()) { case FullScreenAction.CONTROLLER: reader = Stack( children: [