move setting to unit

This commit is contained in:
niuhuan 2021-11-04 13:56:25 +08:00
parent fde1b0ae44
commit 0963ad1247
28 changed files with 172 additions and 189 deletions

View File

@ -8,14 +8,13 @@ import 'package:pikapi/basic/Method.dart';
import '../Common.dart'; import '../Common.dart';
const _propertyName = "androidDisplayMode"; const _propertyName = "androidDisplayMode";
List<String> _modes = [];
List<String> modes = [];
String _androidDisplayMode = ""; String _androidDisplayMode = "";
Future initAndroidDisplayMode() async { Future initAndroidDisplayMode() async {
if (Platform.isAndroid) { if (Platform.isAndroid) {
_androidDisplayMode = await method.loadProperty(_propertyName, ""); _androidDisplayMode = await method.loadProperty(_propertyName, "");
modes = await method.loadAndroidModes(); _modes = await method.loadAndroidModes();
await _changeMode(); await _changeMode();
} }
} }
@ -24,14 +23,10 @@ Future _changeMode() async {
await method.setAndroidMode(_androidDisplayMode); await method.setAndroidMode(_androidDisplayMode);
} }
String androidDisplayModeName() { Future<void> _chooseAndroidDisplayMode(BuildContext context) async {
return _androidDisplayMode;
}
Future<void> chooseAndroidDisplayMode(BuildContext context) async {
if (Platform.isAndroid) { if (Platform.isAndroid) {
List<String> list = [""]; List<String> list = [""];
list.addAll(modes); list.addAll(_modes);
String? result = await chooseListDialog<String>(context, "安卓屏幕刷新率", list); String? result = await chooseListDialog<String>(context, "安卓屏幕刷新率", list);
if (result != null) { if (result != null) {
await method.saveProperty(_propertyName, "$result"); await method.saveProperty(_propertyName, "$result");
@ -47,9 +42,9 @@ Widget androidDisplayModeSetting() {
builder: (BuildContext context, void Function(void Function()) setState) { builder: (BuildContext context, void Function(void Function()) setState) {
return ListTile( return ListTile(
title: Text("屏幕刷新率(安卓)"), title: Text("屏幕刷新率(安卓)"),
subtitle: Text(androidDisplayModeName()), subtitle: Text(_androidDisplayMode),
onTap: () async { onTap: () async {
await chooseAndroidDisplayMode(context); await _chooseAndroidDisplayMode(context);
setState(() {}); setState(() {});
}, },
); );

View File

@ -7,32 +7,28 @@ import 'package:flutter/material.dart';
import '../Common.dart'; import '../Common.dart';
import '../Method.dart'; import '../Method.dart';
const propertyName = "androidSecureFlag"; const _propertyName = "androidSecureFlag";
late bool androidSecureFlag; late bool _androidSecureFlag;
Future<void> initAndroidSecureFlag() async { Future<void> initAndroidSecureFlag() async {
if (Platform.isAndroid) { if (Platform.isAndroid) {
androidSecureFlag = _androidSecureFlag =
(await method.loadProperty(propertyName, "false")) == "true"; (await method.loadProperty(_propertyName, "false")) == "true";
if (androidSecureFlag) { if (_androidSecureFlag) {
await method.androidSecureFlag(true); await method.androidSecureFlag(true);
} }
} }
} }
String androidSecureFlagName() { Future<void> _chooseAndroidSecureFlag(BuildContext context) async {
return androidSecureFlag ? "" : "";
}
Future<void> chooseAndroidSecureFlag(BuildContext context) async {
String? result = String? result =
await chooseListDialog<String>(context, "禁止截图/禁止显示在任务视图", ["", ""]); await chooseListDialog<String>(context, "禁止截图/禁止显示在任务视图", ["", ""]);
if (result != null) { if (result != null) {
var target = result == ""; var target = result == "";
await method.saveProperty(propertyName, "$target"); await method.saveProperty(_propertyName, "$target");
androidSecureFlag = target; _androidSecureFlag = target;
await method.androidSecureFlag(androidSecureFlag); await method.androidSecureFlag(_androidSecureFlag);
} }
} }
@ -42,9 +38,9 @@ Widget androidSecureFlagSetting() {
(BuildContext context, void Function(void Function()) setState) { (BuildContext context, void Function(void Function()) setState) {
return ListTile( return ListTile(
title: Text("禁止截图/禁止显示在任务视图(仅安卓)"), title: Text("禁止截图/禁止显示在任务视图(仅安卓)"),
subtitle: Text(androidSecureFlagName()), subtitle: Text(_androidSecureFlag ? "" : ""),
onTap: () async { onTap: () async {
await chooseAndroidSecureFlag(context); await _chooseAndroidSecureFlag(context);
setState(() {}); setState(() {});
}); });
}); });

View File

@ -1,9 +1,16 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:pikapi/basic/Method.dart'; import 'package:pikapi/basic/Method.dart';
const _autoCleanMap = {
"一个月前": "${3600 * 24 * 30}",
"一周前": "${3600 * 24 * 7}",
"一天前": "${3600 * 24 * 1}",
"不自动清理": "${0}",
};
late String _autoCleanSec; late String _autoCleanSec;
Future<dynamic> autoClean() async { Future<dynamic> initAutoClean() async {
_autoCleanSec = _autoCleanSec =
await method.loadProperty("autoCleanSec", "${3600 * 24 * 30}"); await method.loadProperty("autoCleanSec", "${3600 * 24 * 30}");
if ("0" != _autoCleanSec) { if ("0" != _autoCleanSec) {
@ -11,14 +18,7 @@ Future<dynamic> autoClean() async {
} }
} }
var _autoCleanMap = { String _currentAutoCleanSec() {
"一个月前": "${3600 * 24 * 30}",
"一周前": "${3600 * 24 * 7}",
"一天前": "${3600 * 24 * 1}",
"不自动清理": "${0}",
};
String currentAutoCleanSec() {
for (var value in _autoCleanMap.entries) { for (var value in _autoCleanMap.entries) {
if (value.value == _autoCleanSec) { if (value.value == _autoCleanSec) {
return value.key; return value.key;
@ -27,7 +27,7 @@ String currentAutoCleanSec() {
return ""; return "";
} }
Future<void> chooseAutoCleanSec(BuildContext context) async { Future<void> _chooseAutoCleanSec(BuildContext context) async {
String? choose = await showDialog<String>( String? choose = await showDialog<String>(
context: context, context: context,
builder: (BuildContext context) { builder: (BuildContext context) {
@ -58,9 +58,9 @@ Widget autoCleanSecSetting() {
builder: (BuildContext context, void Function(void Function()) setState) { builder: (BuildContext context, void Function(void Function()) setState) {
return ListTile( return ListTile(
title: Text("自动清理缓存"), title: Text("自动清理缓存"),
subtitle: Text(currentAutoCleanSec()), subtitle: Text(_currentAutoCleanSec()),
onTap: () async { onTap: () async {
await chooseAutoCleanSec(context); await _chooseAutoCleanSec(context);
setState(() {}); setState(() {});
}, },
); );

View File

@ -5,24 +5,19 @@ import 'package:flutter/material.dart';
import '../Common.dart'; import '../Common.dart';
import '../Method.dart'; import '../Method.dart';
late bool _autoFullScreen;
bool currentAutoFullScreen() {
return _autoFullScreen;
}
const _propertyName = "autoFullScreen"; const _propertyName = "autoFullScreen";
late bool _autoFullScreen;
Future<void> initAutoFullScreen() async { Future<void> initAutoFullScreen() async {
_autoFullScreen = _autoFullScreen =
(await method.loadProperty(_propertyName, "false")) == "true"; (await method.loadProperty(_propertyName, "false")) == "true";
} }
String autoFullScreenName() { bool currentAutoFullScreen() {
return _autoFullScreen ? "" : ""; return _autoFullScreen;
} }
Future<void> chooseAutoFullScreen(BuildContext context) async { Future<void> _chooseAutoFullScreen(BuildContext context) async {
String? result = String? result =
await chooseListDialog<String>(context, "进入阅读器自动全屏", ["", ""]); await chooseListDialog<String>(context, "进入阅读器自动全屏", ["", ""]);
if (result != null) { if (result != null) {
@ -37,9 +32,9 @@ Widget autoFullScreenSetting() {
builder: (BuildContext context, void Function(void Function()) setState) { builder: (BuildContext context, void Function(void Function()) setState) {
return ListTile( return ListTile(
title: Text("进入阅读器自动全屏"), title: Text("进入阅读器自动全屏"),
subtitle: Text(autoFullScreenName()), subtitle: Text(_autoFullScreen ? "" : ""),
onTap: () async { onTap: () async {
await chooseAutoFullScreen(context); await _chooseAutoFullScreen(context);
setState(() {}); setState(() {});
}, },
); );

View File

@ -10,7 +10,7 @@ import '../Method.dart';
const _propertyName = "chooserRoot"; const _propertyName = "chooserRoot";
late String _chooserRoot; late String _chooserRoot;
Future<String?> initChooserRoot() async { Future<dynamic> initChooserRoot() async {
_chooserRoot = await method.loadProperty(_propertyName, ""); _chooserRoot = await method.loadProperty(_propertyName, "");
} }
@ -34,7 +34,7 @@ String currentChooserRoot() {
return _chooserRoot; return _chooserRoot;
} }
Future<dynamic> inputChooserRoot(BuildContext context) async { Future<dynamic> _inputChooserRoot(BuildContext context) async {
String? input = await displayTextInputDialog( String? input = await displayTextInputDialog(
context, context,
'文件夹选择器根路径', '文件夹选择器根路径',
@ -55,7 +55,7 @@ Widget chooserRootSetting() {
title: Text("文件夹选择器默认路径"), title: Text("文件夹选择器默认路径"),
subtitle: Text(currentChooserRoot()), subtitle: Text(currentChooserRoot()),
onTap: () async { onTap: () async {
await inputChooserRoot(context); await _inputChooserRoot(context);
setState(() {}); setState(() {});
}, },
); );

View File

@ -10,9 +10,8 @@ enum ContentFailedReloadAction {
TOUCH_LOADER, TOUCH_LOADER,
} }
late ContentFailedReloadAction contentFailedReloadAction;
const _propertyName = "contentFailedReloadAction"; const _propertyName = "contentFailedReloadAction";
late ContentFailedReloadAction contentFailedReloadAction;
Future<void> initContentFailedReloadAction() async { Future<void> initContentFailedReloadAction() async {
contentFailedReloadAction = contentFailedReloadAction =
@ -31,13 +30,13 @@ ContentFailedReloadAction _contentFailedReloadActionFromString(String string) {
return ContentFailedReloadAction.PULL_DOWN; return ContentFailedReloadAction.PULL_DOWN;
} }
Map<String, ContentFailedReloadAction> contentFailedReloadActionMap = { Map<String, ContentFailedReloadAction> _contentFailedReloadActionMap = {
"下拉刷新": ContentFailedReloadAction.PULL_DOWN, "下拉刷新": ContentFailedReloadAction.PULL_DOWN,
"点击屏幕刷新": ContentFailedReloadAction.TOUCH_LOADER, "点击屏幕刷新": ContentFailedReloadAction.TOUCH_LOADER,
}; };
String currentContentFailedReloadActionName() { String _currentContentFailedReloadActionName() {
for (var e in contentFailedReloadActionMap.entries) { for (var e in _contentFailedReloadActionMap.entries) {
if (e.value == contentFailedReloadAction) { if (e.value == contentFailedReloadAction) {
return e.key; return e.key;
} }
@ -45,25 +44,27 @@ String currentContentFailedReloadActionName() {
return ''; return '';
} }
Future<void> chooseContentFailedReloadAction(BuildContext context) async { Future<void> _chooseContentFailedReloadAction(BuildContext context) async {
ContentFailedReloadAction? result = ContentFailedReloadAction? result =
await chooseMapDialog<ContentFailedReloadAction>( await chooseMapDialog<ContentFailedReloadAction>(
context, contentFailedReloadActionMap, "选择页面加载失败刷新的方式"); context, _contentFailedReloadActionMap, "选择页面加载失败刷新的方式");
if (result != null) { if (result != null) {
await method.saveProperty(_propertyName, result.toString()); await method.saveProperty(_propertyName, result.toString());
contentFailedReloadAction = result; contentFailedReloadAction = result;
} }
} }
Widget contentFailedReloadActionSetting(){ Widget contentFailedReloadActionSetting() {
return StatefulBuilder(builder: (BuildContext context, void Function(void Function()) setState) { return StatefulBuilder(
return ListTile( builder: (BuildContext context, void Function(void Function()) setState) {
title: Text("加载失败时"), return ListTile(
subtitle: Text(currentContentFailedReloadActionName()), title: Text("加载失败时"),
onTap: () async { subtitle: Text(_currentContentFailedReloadActionName()),
await chooseContentFailedReloadAction(context); onTap: () async {
setState(() {}); await _chooseContentFailedReloadAction(context);
}, setState(() {});
); },
},); );
} },
);
}

View File

@ -1,3 +1,5 @@
///
import 'dart:io'; import 'dart:io';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';

View File

@ -1,3 +1,5 @@
/// 线
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:pikapi/basic/Common.dart'; import 'package:pikapi/basic/Common.dart';

View File

@ -10,17 +10,25 @@ enum FullScreenAction {
TOUCH_ONCE, TOUCH_ONCE,
} }
late FullScreenAction fullScreenAction; Map<String, FullScreenAction> _fullScreenActionMap = {
"使用控制器": FullScreenAction.CONTROLLER,
"点击屏幕一次": FullScreenAction.TOUCH_ONCE,
};
const _propertyName = "fullScreenAction"; const _propertyName = "fullScreenAction";
late FullScreenAction _fullScreenAction;
Future<void> initFullScreenAction() async { Future<void> initFullScreenAction() async {
fullScreenAction = _fullScreenActionFromString(await method.loadProperty( _fullScreenAction = _fullScreenActionFromString(await method.loadProperty(
_propertyName, _propertyName,
FullScreenAction.CONTROLLER.toString(), FullScreenAction.CONTROLLER.toString(),
)); ));
} }
FullScreenAction currentFullScreenAction() {
return _fullScreenAction;
}
FullScreenAction _fullScreenActionFromString(String string) { FullScreenAction _fullScreenActionFromString(String string) {
for (var value in FullScreenAction.values) { for (var value in FullScreenAction.values) {
if (string == value.toString()) { if (string == value.toString()) {
@ -30,26 +38,21 @@ FullScreenAction _fullScreenActionFromString(String string) {
return FullScreenAction.CONTROLLER; return FullScreenAction.CONTROLLER;
} }
Map<String, FullScreenAction> fullScreenActionMap = { String _currentFullScreenActionName() {
"使用控制器": FullScreenAction.CONTROLLER, for (var e in _fullScreenActionMap.entries) {
"点击屏幕一次": FullScreenAction.TOUCH_ONCE, if (e.value == _fullScreenAction) {
};
String currentFullScreenActionName() {
for (var e in fullScreenActionMap.entries) {
if (e.value == fullScreenAction) {
return e.key; return e.key;
} }
} }
return ''; return '';
} }
Future<void> chooseFullScreenAction(BuildContext context) async { Future<void> _chooseFullScreenAction(BuildContext context) async {
FullScreenAction? result = await chooseMapDialog<FullScreenAction>( FullScreenAction? result = await chooseMapDialog<FullScreenAction>(
context, fullScreenActionMap, "选择进入全屏的方式"); context, _fullScreenActionMap, "选择进入全屏的方式");
if (result != null) { if (result != null) {
await method.saveProperty(_propertyName, result.toString()); await method.saveProperty(_propertyName, result.toString());
fullScreenAction = result; _fullScreenAction = result;
} }
} }
@ -58,9 +61,9 @@ Widget fullScreenActionSetting() {
builder: (BuildContext context, void Function(void Function()) setState) { builder: (BuildContext context, void Function(void Function()) setState) {
return ListTile( return ListTile(
title: Text("进入全屏的方式"), title: Text("进入全屏的方式"),
subtitle: Text(currentFullScreenActionName()), subtitle: Text(_currentFullScreenActionName()),
onTap: () async { onTap: () async {
await chooseFullScreenAction(context); await _chooseFullScreenAction(context);
setState(() {}); setState(() {});
}, },
); );

View File

@ -12,9 +12,9 @@ enum FullScreenUI {
ALL, ALL,
} }
const _propertyName = "fullScreenUI";
late FullScreenUI fullScreenUI; late FullScreenUI fullScreenUI;
const _propertyName = "fullScreenUI";
Future<void> initFullScreenUI() async { Future<void> initFullScreenUI() async {
fullScreenUI = _fullScreenUIFromString(await method.loadProperty( fullScreenUI = _fullScreenUIFromString(await method.loadProperty(

View File

@ -16,11 +16,7 @@ Future<void> initKeyboardController() async {
(await method.loadProperty(_propertyName, "false")) == "true"; (await method.loadProperty(_propertyName, "false")) == "true";
} }
String keyboardControllerName() { Future<void> _chooseKeyboardController(BuildContext context) async {
return keyboardController ? "" : "";
}
Future<void> chooseKeyboardController(BuildContext context) async {
String? result = String? result =
await chooseListDialog<String>(context, "键盘控制翻页", ["", ""]); await chooseListDialog<String>(context, "键盘控制翻页", ["", ""]);
if (result != null) { if (result != null) {
@ -36,9 +32,9 @@ Widget keyboardControllerSetting() {
builder: (BuildContext context, void Function(void Function()) setState) { builder: (BuildContext context, void Function(void Function()) setState) {
return ListTile( return ListTile(
title: Text("阅读器键盘翻页(仅PC)"), title: Text("阅读器键盘翻页(仅PC)"),
subtitle: Text(keyboardControllerName()), subtitle: Text(keyboardController ? "" : ""),
onTap: () async { onTap: () async {
await chooseKeyboardController(context); await _chooseKeyboardController(context);
setState(() {}); setState(() {});
}, },
); );

View File

@ -11,8 +11,17 @@ enum ListLayout {
COVER_AND_TITLE, COVER_AND_TITLE,
} }
const Map<String, ListLayout> _listLayoutMap = {
'详情': ListLayout.INFO_CARD,
'封面': ListLayout.ONLY_IMAGE,
'封面+标题': ListLayout.COVER_AND_TITLE,
};
const _propertyName = "listLayout";
late ListLayout currentLayout; late ListLayout currentLayout;
var listLayoutEvent = Event<EventArgs>();
Future<void> initListLayout() async { Future<void> initListLayout() async {
currentLayout = _listLayoutFromString(await method.loadProperty( currentLayout = _listLayoutFromString(await method.loadProperty(
_propertyName, _propertyName,
@ -20,16 +29,6 @@ Future<void> initListLayout() async {
)); ));
} }
const _propertyName = "listLayout";
var listLayoutEvent = Event<EventArgs>();
const Map<String, ListLayout> _listLayoutMap = {
'详情': ListLayout.INFO_CARD,
'封面': ListLayout.ONLY_IMAGE,
'封面+标题': ListLayout.COVER_AND_TITLE,
};
ListLayout _listLayoutFromString(String layoutString) { ListLayout _listLayoutFromString(String layoutString) {
for (var value in ListLayout.values) { for (var value in ListLayout.values) {
if (layoutString == value.toString()) { if (layoutString == value.toString()) {
@ -39,7 +38,7 @@ ListLayout _listLayoutFromString(String layoutString) {
return ListLayout.INFO_CARD; return ListLayout.INFO_CARD;
} }
void chooseListLayout(BuildContext context) async { void _chooseListLayout(BuildContext context) async {
ListLayout? layout = await chooseMapDialog(context, _listLayoutMap, '请选择布局'); ListLayout? layout = await chooseMapDialog(context, _listLayoutMap, '请选择布局');
if (layout != null) { if (layout != null) {
await method.saveProperty(_propertyName, layout.toString()); 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: () { onPressed: () {
chooseListLayout(context); _chooseListLayout(context);
}, },
icon: Icon(Icons.view_quilt), icon: Icon(Icons.view_quilt),
); );

View File

@ -10,15 +10,23 @@ enum PagerAction {
STREAM, STREAM,
} }
late PagerAction currentPagerAction; Map<String, PagerAction> _pagerActionMap = {
"使用按钮": PagerAction.CONTROLLER,
"瀑布流": PagerAction.STREAM,
};
const _propertyName = "pagerAction"; const _propertyName = "pagerAction";
late PagerAction _pagerAction;
Future<void> initPagerAction() async { Future<void> initPagerAction() async {
currentPagerAction = _pagerActionFromString(await method.loadProperty( _pagerAction = _pagerActionFromString(await method.loadProperty(
_propertyName, PagerAction.CONTROLLER.toString())); _propertyName, PagerAction.CONTROLLER.toString()));
} }
PagerAction currentPagerAction() {
return _pagerAction;
}
PagerAction _pagerActionFromString(String string) { PagerAction _pagerActionFromString(String string) {
for (var value in PagerAction.values) { for (var value in PagerAction.values) {
if (string == value.toString()) { if (string == value.toString()) {
@ -28,26 +36,21 @@ PagerAction _pagerActionFromString(String string) {
return PagerAction.CONTROLLER; return PagerAction.CONTROLLER;
} }
Map<String, PagerAction> _pagerActionMap = { String _currentPagerActionName() {
"使用按钮": PagerAction.CONTROLLER,
"瀑布流": PagerAction.STREAM,
};
String currentPagerActionName() {
for (var e in _pagerActionMap.entries) { for (var e in _pagerActionMap.entries) {
if (e.value == currentPagerAction) { if (e.value == _pagerAction) {
return e.key; return e.key;
} }
} }
return ''; return '';
} }
Future<void> choosePagerAction(BuildContext context) async { Future<void> _choosePagerAction(BuildContext context) async {
PagerAction? result = PagerAction? result =
await chooseMapDialog<PagerAction>(context, _pagerActionMap, "选择列表页加载方式"); await chooseMapDialog<PagerAction>(context, _pagerActionMap, "选择列表页加载方式");
if (result != null) { if (result != null) {
await method.saveProperty(_propertyName, result.toString()); await method.saveProperty(_propertyName, result.toString());
currentPagerAction = result; _pagerAction = result;
} }
} }
@ -56,9 +59,9 @@ Widget pagerActionSetting() {
builder: (BuildContext context, void Function(void Function()) setState) { builder: (BuildContext context, void Function(void Function()) setState) {
return ListTile( return ListTile(
title: Text("列表页加载方式"), title: Text("列表页加载方式"),
subtitle: Text(currentPagerActionName()), subtitle: Text(_currentPagerActionName()),
onTap: () async { onTap: () async {
await choosePagerAction(context); await _choosePagerAction(context);
setState(() {}); setState(() {});
}, },
); );

View File

@ -20,7 +20,13 @@ var _qualities = {
_LabelHigh: ImageQualityHigh, _LabelHigh: ImageQualityHigh,
}; };
const _propertyName = "quality";
late String _currentQualityCode; late String _currentQualityCode;
const _defaultValue = _ImageQualityOriginal;
Future<void> initQuality() async {
_currentQualityCode = await method.loadProperty(_propertyName, _defaultValue);
}
String currentQualityCode() { String currentQualityCode() {
return _currentQualityCode; return _currentQualityCode;
@ -35,14 +41,7 @@ String _currentQualityName() {
return ''; return '';
} }
const _propertyName = "quality"; Future<void> _chooseQuality(BuildContext context) async {
const _defaultValue = _ImageQualityOriginal;
Future<void> initQuality() async {
_currentQualityCode = await method.loadProperty(_propertyName, _defaultValue);
}
Future<void> chooseQuality(BuildContext context) async {
String? code = await showDialog<String>( String? code = await showDialog<String>(
context: context, context: context,
builder: (BuildContext context) { builder: (BuildContext context) {
@ -74,7 +73,7 @@ Widget qualitySetting() {
title: Text("浏览时的图片质量"), title: Text("浏览时的图片质量"),
subtitle: Text(_currentQualityName()), subtitle: Text(_currentQualityName()),
onTap: () async { onTap: () async {
await chooseQuality(context); await _chooseQuality(context);
setState(() {}); setState(() {});
}, },
); );

View File

@ -9,21 +9,20 @@ enum ReaderDirection {
RIGHT_TO_LEFT, RIGHT_TO_LEFT,
} }
late ReaderDirection gReaderDirection; const _types = {
'从上到下': ReaderDirection.TOP_TO_BOTTOM,
'从左到右': ReaderDirection.LEFT_TO_RIGHT,
'从右到左': ReaderDirection.RIGHT_TO_LEFT,
};
const _propertyName = "readerDirection"; const _propertyName = "readerDirection";
late ReaderDirection gReaderDirection;
Future<void> initReaderDirection() async { Future<void> initReaderDirection() async {
gReaderDirection = _pagerDirectionFromString(await method.loadProperty( gReaderDirection = _pagerDirectionFromString(await method.loadProperty(
_propertyName, ReaderDirection.TOP_TO_BOTTOM.toString())); _propertyName, ReaderDirection.TOP_TO_BOTTOM.toString()));
} }
var _types = {
'从上到下': ReaderDirection.TOP_TO_BOTTOM,
'从左到右': ReaderDirection.LEFT_TO_RIGHT,
'从右到左': ReaderDirection.RIGHT_TO_LEFT,
};
ReaderDirection _pagerDirectionFromString(String pagerDirectionString) { ReaderDirection _pagerDirectionFromString(String pagerDirectionString) {
for (var value in ReaderDirection.values) { for (var value in ReaderDirection.values) {
if (pagerDirectionString == value.toString()) { if (pagerDirectionString == value.toString()) {
@ -33,7 +32,7 @@ ReaderDirection _pagerDirectionFromString(String pagerDirectionString) {
return ReaderDirection.TOP_TO_BOTTOM; return ReaderDirection.TOP_TO_BOTTOM;
} }
String currentReaderDirectionName() { String _currentReaderDirectionName() {
for (var e in _types.entries) { for (var e in _types.entries) {
if (e.value == gReaderDirection) { if (e.value == gReaderDirection) {
return e.key; return e.key;
@ -42,6 +41,7 @@ String currentReaderDirectionName() {
return ''; return '';
} }
/// ?? to ActionButton And Event ??
Future<void> choosePagerDirection(BuildContext buildContext) async { Future<void> choosePagerDirection(BuildContext buildContext) async {
ReaderDirection? choose = await showDialog<ReaderDirection>( ReaderDirection? choose = await showDialog<ReaderDirection>(
context: buildContext, context: buildContext,
@ -70,7 +70,7 @@ Widget readerDirectionSetting() {
builder: (BuildContext context, void Function(void Function()) setState) { builder: (BuildContext context, void Function(void Function()) setState) {
return ListTile( return ListTile(
title: Text("阅读器方向"), title: Text("阅读器方向"),
subtitle: Text(currentReaderDirectionName()), subtitle: Text(_currentReaderDirectionName()),
onTap: () async { onTap: () async {
await choosePagerDirection(context); await choosePagerDirection(context);
setState(() {}); setState(() {});

View File

@ -1,30 +1,32 @@
/// ///
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import '../Method.dart'; import '../Method.dart';
late ReaderType gReaderType;
const _propertyName = "readerType";
Future<dynamic> initReaderType() async {
gReaderType = _readerTypeFromString(
await method.loadProperty(_propertyName, ReaderType.WEB_TOON.toString()));
}
enum ReaderType { enum ReaderType {
WEB_TOON, WEB_TOON,
WEB_TOON_ZOOM, WEB_TOON_ZOOM,
GALLERY, GALLERY,
} }
var _types = { const _types = {
'WebToon (默认)': ReaderType.WEB_TOON, 'WebToon (默认)': ReaderType.WEB_TOON,
'WebToon + 双击放大': ReaderType.WEB_TOON_ZOOM, 'WebToon + 双击放大': ReaderType.WEB_TOON_ZOOM,
'相册': ReaderType.GALLERY, '相册': ReaderType.GALLERY,
}; };
const _propertyName = "readerType";
late ReaderType _readerType;
Future<dynamic> initReaderType() async {
_readerType = _readerTypeFromString(
await method.loadProperty(_propertyName, ReaderType.WEB_TOON.toString()));
}
ReaderType currentReaderType() {
return _readerType;
}
ReaderType _readerTypeFromString(String pagerTypeString) { ReaderType _readerTypeFromString(String pagerTypeString) {
for (var value in ReaderType.values) { for (var value in ReaderType.values) {
if (pagerTypeString == value.toString()) { if (pagerTypeString == value.toString()) {
@ -36,7 +38,7 @@ ReaderType _readerTypeFromString(String pagerTypeString) {
String currentReaderTypeName() { String currentReaderTypeName() {
for (var e in _types.entries) { for (var e in _types.entries) {
if (e.value == gReaderType) { if (e.value == _readerType) {
return e.key; return e.key;
} }
} }
@ -62,7 +64,7 @@ Future<void> choosePagerType(BuildContext buildContext) async {
); );
if (t != null) { if (t != null) {
await method.saveProperty(_propertyName, t.toString()); await method.saveProperty(_propertyName, t.toString());
gReaderType = t; _readerType = t;
} }
} }

View File

@ -10,12 +10,10 @@ import 'package:multi_select_flutter/multi_select_flutter.dart';
import '../Method.dart'; import '../Method.dart';
import '../store/Categories.dart'; import '../store/Categories.dart';
late List<String> shadowCategories;
var shadowCategoriesEvent = Event<EventArgs>();
// mapper
const _propertyName = "shadowCategories"; const _propertyName = "shadowCategories";
late List<String> shadowCategories;
var shadowCategoriesEvent = Event<EventArgs>();
/// ///
Future<List<String>> _loadShadowCategories() async { Future<List<String>> _loadShadowCategories() async {

View File

@ -5,19 +5,18 @@ import 'package:flutter/material.dart';
import '../Common.dart'; import '../Common.dart';
import '../Method.dart'; import '../Method.dart';
int _timeOffsetHour = 8;
int currentTimeOffsetHour() {
return _timeOffsetHour;
}
const _propertyName = "timeOffsetHour"; const _propertyName = "timeOffsetHour";
int _timeOffsetHour = 8;
Future<void> initTimeZone() async { Future<void> initTimeZone() async {
_timeOffsetHour = int.parse(await method.loadProperty(_propertyName, "8")); _timeOffsetHour = int.parse(await method.loadProperty(_propertyName, "8"));
} }
Future<void> chooseTimeZone(BuildContext context) async { int currentTimeOffsetHour() {
return _timeOffsetHour;
}
Future<void> _chooseTimeZone(BuildContext context) async {
List<String> timeZones = []; List<String> timeZones = [];
for (var i = -12; i <= 12; i++) { for (var i = -12; i <= 12; i++) {
var str = i.toString(); var str = i.toString();
@ -47,7 +46,7 @@ Widget timeZoneSetting() {
title: Text("时区"), title: Text("时区"),
subtitle: Text(c), subtitle: Text(c),
onTap: () async { onTap: () async {
await chooseTimeZone(context); await _chooseTimeZone(context);
setState(() {}); setState(() {});
}, },
); );

View File

@ -7,25 +7,20 @@ import 'package:flutter/material.dart';
import '../Common.dart'; import '../Common.dart';
import '../Method.dart'; import '../Method.dart';
const propertyName = "volumeController"; const _propertyName = "volumeController";
late bool volumeController; late bool volumeController;
Future<void> initVolumeController() async { Future<void> initVolumeController() async {
volumeController = volumeController =
(await method.loadProperty(propertyName, "false")) == "true"; (await method.loadProperty(_propertyName, "false")) == "true";
} }
String volumeControllerName() { Future<void> _chooseVolumeController(BuildContext context) async {
return volumeController ? "" : "";
}
Future<void> chooseVolumeController(BuildContext context) async {
String? result = String? result =
await chooseListDialog<String>(context, "音量键控制翻页", ["", ""]); await chooseListDialog<String>(context, "音量键控制翻页", ["", ""]);
if (result != null) { if (result != null) {
var target = result == ""; var target = result == "";
await method.saveProperty(propertyName, "$target"); await method.saveProperty(_propertyName, "$target");
volumeController = target; volumeController = target;
} }
} }
@ -36,9 +31,9 @@ Widget volumeControllerSetting() {
(BuildContext context, void Function(void Function()) setState) { (BuildContext context, void Function(void Function()) setState) {
return ListTile( return ListTile(
title: Text("阅读器音量键翻页(仅安卓)"), title: Text("阅读器音量键翻页(仅安卓)"),
subtitle: Text(volumeControllerName()), subtitle: Text(volumeController ? "" : ""),
onTap: () async { onTap: () async {
await chooseVolumeController(context); await _chooseVolumeController(context);
setState(() {}); setState(() {});
}); });
}); });

View File

@ -18,7 +18,7 @@ class ComicReaderScreen extends StatefulWidget {
final List<Ep> epList; final List<Ep> epList;
final currentEpOrder; final currentEpOrder;
final int? initPictureRank; final int? initPictureRank;
final ReaderType pagerType = gReaderType; final ReaderType pagerType = currentReaderType();
final ReaderDirection pagerDirection = gReaderDirection; final ReaderDirection pagerDirection = gReaderDirection;
late final bool autoFullScreen; late final bool autoFullScreen;
@ -149,7 +149,7 @@ class _ComicReaderScreenState extends State<ComicReaderScreen> {
IconButton( IconButton(
onPressed: () async { onPressed: () async {
await choosePagerType(context); await choosePagerType(context);
if (widget.pagerType != gReaderType) { if (widget.pagerType != currentReaderType()) {
_reloadReader(); _reloadReader();
} }
}, },

View File

@ -51,7 +51,7 @@ class _ComicsScreenState extends State<ComicsScreen> {
title: new Text(categoryTitle(widget.category)), title: new Text(categoryTitle(widget.category)),
actions: [ actions: [
shadowCategoriesActionButton(context), shadowCategoriesActionButton(context),
chooseLayoutAction(context), chooseLayoutActionButton(context),
_chooseCategoryAction(), _chooseCategoryAction(),
_categorySearchBar.getSearchAction(context), _categorySearchBar.getSearchAction(context),
], ],
@ -125,7 +125,7 @@ class _ComicsScreenState extends State<ComicsScreen> {
title: Text(title), title: Text(title),
actions: [ actions: [
shadowCategoriesActionButton(context), shadowCategoriesActionButton(context),
chooseLayoutAction(context), chooseLayoutActionButton(context),
_chooseCategoryAction(), _chooseCategoryAction(),
], ],
); );

View File

@ -17,7 +17,7 @@ class DownloadReaderScreen extends StatefulWidget {
final List<DownloadEp> epList; final List<DownloadEp> epList;
final int currentEpOrder; final int currentEpOrder;
final int? initPictureRank; final int? initPictureRank;
final ReaderType pagerType = gReaderType; final ReaderType pagerType = currentReaderType();
final ReaderDirection pagerDirection = gReaderDirection; final ReaderDirection pagerDirection = gReaderDirection;
late final bool autoFullScreen; late final bool autoFullScreen;
@ -118,7 +118,6 @@ class _DownloadReaderScreenState extends State<DownloadReaderScreen> {
super.dispose(); super.dispose();
} }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return readerKeyboardHolder(_build(context)); return readerKeyboardHolder(_build(context));
@ -143,7 +142,7 @@ class _DownloadReaderScreenState extends State<DownloadReaderScreen> {
IconButton( IconButton(
onPressed: () async { onPressed: () async {
await choosePagerType(context); await choosePagerType(context);
if (widget.pagerType != gReaderType) { if (widget.pagerType != currentReaderType()) {
_reloadReader(); _reloadReader();
} }
}, },

View File

@ -43,7 +43,7 @@ class _InitScreenState extends State<InitScreen> {
Future<dynamic> _init() async { Future<dynamic> _init() async {
// //
await initPlatform(); // , await initPlatform(); // ,
await autoClean(); await initAutoClean();
await initAddress(); await initAddress();
await initProxy(); await initProxy();
await initQuality(); await initQuality();

View File

@ -28,7 +28,7 @@ class _RandomComicsScreenState extends State<RandomComicsScreen> {
title: Text('随机本子'), title: Text('随机本子'),
actions: [ actions: [
shadowCategoriesActionButton(context), shadowCategoriesActionButton(context),
chooseLayoutAction(context), chooseLayoutActionButton(context),
], ],
), ),
body: ComicListBuilder(_future, _reload), body: ComicListBuilder(_future, _reload),

View File

@ -17,7 +17,7 @@ class RankingsScreen extends StatelessWidget {
title: Text('排行榜'), title: Text('排行榜'),
actions: [ actions: [
shadowCategoriesActionButton(context), shadowCategoriesActionButton(context),
chooseLayoutAction(context), chooseLayoutActionButton(context),
], ],
), ),
body: DefaultTabController( body: DefaultTabController(

View File

@ -49,7 +49,7 @@ class _SearchScreenState extends State<SearchScreen> {
title: Text("${categoryTitle(widget.category)} ${widget.keyword}"), title: Text("${categoryTitle(widget.category)} ${widget.keyword}"),
actions: [ actions: [
shadowCategoriesActionButton(context), shadowCategoriesActionButton(context),
chooseLayoutAction(context), chooseLayoutActionButton(context),
_chooseCategoryAction(), _chooseCategoryAction(),
_searchBar.getSearchAction(context), _searchBar.getSearchAction(context),
], ],

View File

@ -41,7 +41,7 @@ class _ComicPagerState extends State<ComicPager> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
switch (currentPagerAction) { switch (currentPagerAction()) {
case PagerAction.CONTROLLER: case PagerAction.CONTROLLER:
return ControllerComicPager(fetchPage: widget.fetchPage); return ControllerComicPager(fetchPage: widget.fetchPage);
case PagerAction.STREAM: case PagerAction.STREAM:

View File

@ -148,7 +148,7 @@ class ImageReader extends StatelessWidget {
reader = Container(); reader = Container();
break; break;
} }
switch (fullScreenAction) { switch (currentFullScreenAction()) {
case FullScreenAction.CONTROLLER: case FullScreenAction.CONTROLLER:
reader = Stack( reader = Stack(
children: [ children: [