Image reader background color

This commit is contained in:
niuhuan 2023-04-13 17:46:43 +08:00
parent 1136394723
commit 260aea01cd
6 changed files with 111 additions and 13 deletions

View File

@ -1,3 +1,4 @@
v1.7.3 v1.7.3
- [x] ✨ 可以隐藏发电图标 - [x] ✨ 可以隐藏发电图标(设置项)
- [x] ✨ 可以给阅读器加灰度滤镜(设置项)(墨水屏下或许有用) - [x] ✨ 可以给阅读器加灰度滤镜(设置项)(彩色墨水屏下或许有用)
- [x] ✨ 可以选择阅读器背景色(设置项)(白色可防止墨水屏下拖影)

View File

@ -84,7 +84,7 @@ Future<void> chooseImageFilter(BuildContext context) async {
ImageFilter? result = await chooseMapDialog<ImageFilter>( ImageFilter? result = await chooseMapDialog<ImageFilter>(
context, context,
map, map,
"选择全屏UI", "选择阅读器图片滤镜",
); );
if (result != null) { if (result != null) {
await method.saveProperty(_propertyName, result.name); await method.saveProperty(_propertyName, result.name);
@ -96,7 +96,7 @@ Widget imageFilterSetting() {
return StatefulBuilder( return StatefulBuilder(
builder: (BuildContext context, void Function(void Function()) setState) { builder: (BuildContext context, void Function(void Function()) setState) {
return ListTile( return ListTile(
title: const Text("阅读器滤镜"), title: const Text("阅读器图片滤镜"),
subtitle: Text(imageFilter.name), subtitle: Text(imageFilter.name),
onTap: () async { onTap: () async {
await chooseImageFilter(context); await chooseImageFilter(context);

View File

@ -0,0 +1,81 @@
import 'dart:ui';
import 'package:flutter/material.dart';
import '../Common.dart';
import '../Method.dart';
const _propertyName = "readerBackgroundColor";
late ReaderBackgroundColor readerBackgroundColor;
Color get readerBackgroundColorObj => readerBackgroundColor.color;
Future<void> initReaderBackgroundColor() async {
readerBackgroundColor =
_readerBackgroundColorFromString(await method.loadProperty(
_propertyName,
_colors[0].name,
));
}
ReaderBackgroundColor _readerBackgroundColorFromString(String string) {
for (var value in _colors) {
if (string == value.name) {
return value;
}
}
return _colors[0];
}
class ReaderBackgroundColor {
final String name;
final Color color;
ReaderBackgroundColor(this.name, this.color);
}
final List<ReaderBackgroundColor> _colors = [
ReaderBackgroundColor(
"黑色",
Colors.black,
),
ReaderBackgroundColor(
"灰度",
Colors.grey,
),
ReaderBackgroundColor(
"白色",
Colors.white,
),
];
Future<void> chooseReaderBackgroundColor(BuildContext context) async {
Map<String, ReaderBackgroundColor> map = {};
for (var element in _colors) {
map[element.name] = element;
}
ReaderBackgroundColor? result = await chooseMapDialog<ReaderBackgroundColor>(
context,
map,
"选择阅读器背景色",
);
if (result != null) {
await method.saveProperty(_propertyName, result.name);
readerBackgroundColor = result;
}
}
Widget readerBackgroundColorSetting() {
return StatefulBuilder(
builder: (BuildContext context, void Function(void Function()) setState) {
return ListTile(
title: const Text("阅读器背景色"),
subtitle: Text(readerBackgroundColor.name),
onTap: () async {
await chooseReaderBackgroundColor(context);
setState(() {});
},
);
},
);
}

View File

@ -49,6 +49,7 @@ import '../basic/config/ExportRename.dart';
import '../basic/config/HiddenFdIcon.dart'; import '../basic/config/HiddenFdIcon.dart';
import '../basic/config/IconLoading.dart'; import '../basic/config/IconLoading.dart';
import '../basic/config/IsPro.dart'; import '../basic/config/IsPro.dart';
import '../basic/config/ReaderBackgroundColor.dart';
import '../basic/config/WebDav.dart'; import '../basic/config/WebDav.dart';
import 'AccountScreen.dart'; import 'AccountScreen.dart';
import 'AppScreen.dart'; import 'AppScreen.dart';
@ -117,6 +118,7 @@ class _InitScreenState extends State<InitScreen> {
await initUseApiLoadImage(); await initUseApiLoadImage();
await initWebDav(); await initWebDav();
await initImageFilter(); await initImageFilter();
await initReaderBackgroundColor();
String? initUrl; String? initUrl;
if (Platform.isAndroid || Platform.isIOS) { if (Platform.isAndroid || Platform.isIOS) {

View File

@ -19,6 +19,7 @@ import 'package:pikapika/basic/config/KeyboardController.dart';
import 'package:pikapika/basic/config/NoAnimation.dart'; import 'package:pikapika/basic/config/NoAnimation.dart';
import 'package:pikapika/basic/config/PagerAction.dart'; import 'package:pikapika/basic/config/PagerAction.dart';
import 'package:pikapika/basic/config/Quality.dart'; import 'package:pikapika/basic/config/Quality.dart';
import 'package:pikapika/basic/config/ReaderBackgroundColor.dart';
import 'package:pikapika/basic/config/ReaderDirection.dart'; import 'package:pikapika/basic/config/ReaderDirection.dart';
import 'package:pikapika/basic/config/ReaderSliderPosition.dart'; import 'package:pikapika/basic/config/ReaderSliderPosition.dart';
import 'package:pikapika/basic/config/ReaderType.dart'; import 'package:pikapika/basic/config/ReaderType.dart';
@ -161,6 +162,7 @@ class _SettingsScreenState extends State<SettingsScreen> {
keyboardControllerSetting(), keyboardControllerSetting(),
const Divider(), const Divider(),
imageFilterSetting(), imageFilterSetting(),
readerBackgroundColorSetting(),
const Divider(), const Divider(),
const Padding(padding: EdgeInsets.only(top: 15)), const Padding(padding: EdgeInsets.only(top: 15)),
]), ]),

View File

@ -25,6 +25,7 @@ import 'package:pikapika/basic/config/VolumeController.dart';
import 'package:pikapika/screens/components/PkzImages.dart'; import 'package:pikapika/screens/components/PkzImages.dart';
import 'package:scrollable_positioned_list/scrollable_positioned_list.dart'; import 'package:scrollable_positioned_list/scrollable_positioned_list.dart';
import '../../basic/config/IconLoading.dart'; import '../../basic/config/IconLoading.dart';
import '../../basic/config/ReaderBackgroundColor.dart';
import '../../basic/config/UseApiLoadImage.dart'; import '../../basic/config/UseApiLoadImage.dart';
import '../FilePhotoViewScreen.dart'; import '../FilePhotoViewScreen.dart';
import 'gesture_zoom_box.dart'; import 'gesture_zoom_box.dart';
@ -1052,8 +1053,8 @@ class _WebToonReaderState extends _ImageReaderContentState {
@override @override
Widget _buildViewer() { Widget _buildViewer() {
return Container( return Container(
decoration: const BoxDecoration( decoration: BoxDecoration(
color: Colors.black, color: readerBackgroundColorObj,
), ),
child: _buildList(), child: _buildList(),
); );
@ -1180,7 +1181,7 @@ class _WebToonReaderState extends _ImageReaderContentState {
Navigator.of(context).pop(); Navigator.of(context).pop();
} }
}, },
textColor: Colors.white, textColor: invertColor(readerBackgroundColorObj),
child: Container( child: Container(
padding: const EdgeInsets.only(top: 40, bottom: 40), padding: const EdgeInsets.only(top: 40, bottom: 40),
child: Text(super._hasNextEp() ? '下一章' : '结束阅读'), child: Text(super._hasNextEp() ? '下一章' : '结束阅读'),
@ -1396,8 +1397,8 @@ class _ListViewReaderState extends _ImageReaderContentState
@override @override
Widget _buildViewer() { Widget _buildViewer() {
return Container( return Container(
decoration: const BoxDecoration( decoration: BoxDecoration(
color: Colors.black, color: readerBackgroundColorObj,
), ),
child: _buildList(), child: _buildList(),
); );
@ -1531,7 +1532,7 @@ class _ListViewReaderState extends _ImageReaderContentState
Navigator.of(context).pop(); Navigator.of(context).pop();
} }
}, },
textColor: Colors.white, textColor: invertColor(readerBackgroundColorObj),
child: Container( child: Container(
padding: const EdgeInsets.only(top: 40, bottom: 40), padding: const EdgeInsets.only(top: 40, bottom: 40),
child: Text(super._hasNextEp() ? '下一章' : '结束阅读'), child: Text(super._hasNextEp() ? '下一章' : '结束阅读'),
@ -1611,7 +1612,7 @@ class _GalleryReaderState extends _ImageReaderContentState {
? Axis.vertical ? Axis.vertical
: Axis.horizontal, : Axis.horizontal,
reverse: widget.pagerDirection == ReaderDirection.RIGHT_TO_LEFT, reverse: widget.pagerDirection == ReaderDirection.RIGHT_TO_LEFT,
backgroundDecoration: const BoxDecoration(color: Colors.black), backgroundDecoration: BoxDecoration(color: readerBackgroundColorObj),
loadingBuilder: (context, event) => LayoutBuilder( loadingBuilder: (context, event) => LayoutBuilder(
builder: (BuildContext context, BoxConstraints constraints) { builder: (BuildContext context, BoxConstraints constraints) {
return buildLoading(constraints.maxWidth, constraints.maxHeight); return buildLoading(constraints.maxWidth, constraints.maxHeight);
@ -1754,8 +1755,10 @@ class _GalleryReaderState extends _ImageReaderContentState {
Navigator.of(context).pop(); Navigator.of(context).pop();
} }
}, },
child: Text(_hasNextEp() ? '下一章' : '结束阅读', child: Text(
style: const TextStyle(color: Colors.white)), _hasNextEp() ? '下一章' : '结束阅读',
style: const TextStyle(color: Colors.white),
),
), ),
), ),
), ),
@ -1763,4 +1766,13 @@ class _GalleryReaderState extends _ImageReaderContentState {
} }
} }
Color invertColor(Color color) {
return Color.fromRGBO(
255 - color.red,
255 - color.green,
255 - color.blue,
1.0,
);
}
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////