Upgrade to v1.5.1

This commit is contained in:
niuhuan 2022-04-30 12:59:03 +08:00
parent 46403f41fb
commit 087b09fe68
9 changed files with 246 additions and 234 deletions

View File

@ -1 +1 @@
v1.4.6
v1.5.1

View File

@ -1,3 +1,4 @@
- [x] 修复 分流2 / 分流3, API速度得到提高
- [x] 看此本子多人也在看
- [x] 本子神推荐/魔推荐
- [x] 修复一些BUG
- [x] 优化阅读器 (之前丢了一部分代码, 导致被回滚了, 全屏按钮重新写了一遍)
- [x] 优化导入导出 / 保存图片等文件系统交互操作
- [x] 优化推荐栏目

View File

@ -2,7 +2,7 @@
import 'dart:io';
import 'package:clipboard/clipboard.dart';
import 'package:filesystem_picker/filesystem_picker.dart';
import 'package:file_picker/file_picker.dart';
import 'package:flutter/material.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:pikapika/basic/Common.dart';
@ -77,13 +77,12 @@ Future<dynamic> _saveImageAndroid(String path, BuildContext context) async {
///
Future<String?> chooseFolder(BuildContext context) async {
return FilesystemPicker.open(
title: '选择一个文件夹',
pickText: '将文件保存到这里',
context: context,
fsType: FilesystemType.folder,
rootDirectory:
Directory.fromUri(Uri.file(await currentChooserRoot())).absolute,
return FilePicker.platform.getDirectoryPath(
dialogTitle: "选择一个文件夹, 将文件保存到这里",
initialDirectory: Directory
.fromUri(Uri.file(await currentChooserRoot()))
.absolute
.path,
);
}

View File

@ -73,7 +73,12 @@ class _ComicCollectionsScreenState extends State<ComicCollectionsScreen> {
color: appBarTheme.backgroundColor,
child: TabBar(
indicatorColor: theme.dividerColor,
tabs: collection.map((e) => Tab(text: e.title)).toList(),
tabs: collection
.map((e) => Tab(
text: e.title.indexOf("推薦") > 0
? e.title.substring(0, e.title.indexOf("推薦"))
: e.title))
.toList(),
),
),
body: TabBarView(

View File

@ -1,6 +1,6 @@
import 'dart:io';
import 'package:filesystem_picker/filesystem_picker.dart';
import 'package:file_picker/file_picker.dart';
import 'package:flutter/material.dart';
import 'package:pikapika/basic/Channels.dart';
import 'package:pikapika/basic/Common.dart';
@ -43,7 +43,7 @@ class _DownloadImportScreenState extends State<DownloadImportScreen> {
}
@override
Widget build(BuildContext context){
Widget build(BuildContext context) {
return rightClickPop(
child: buildScreen(context),
context: context,
@ -96,15 +96,15 @@ class _DownloadImportScreenState extends State<DownloadImportScreen> {
defaultToast(context, "$e");
return;
}
String? path = await FilesystemPicker.open(
title: '选择要导入的文件',
context: context,
rootDirectory: Directory(chooseRoot),
fsType: FilesystemType.file,
folderIconColor: Colors.teal,
allowedExtensions: ['.zip'],
fileTileSelectMode: FileTileSelectMode.wholeTile,
var ls = await FilePicker.platform.pickFiles(
dialogTitle: '选择要导入的文件',
allowMultiple: false,
initialDirectory: chooseRoot,
type: FileType.custom,
allowedExtensions: ['zip'],
allowCompression: false,
);
String? path = ls != null && ls.count > 0 ? ls.paths[0] : null;
if (path != null) {
try {
setState(() {

View File

@ -30,7 +30,7 @@ import 'Images.dart';
///////////////
Event<_ReaderControllerEventArgs> _readerControllerEvent =
Event<_ReaderControllerEventArgs>();
Event<_ReaderControllerEventArgs>();
class _ReaderControllerEventArgs extends EventArgs {
final String key;
@ -156,7 +156,7 @@ class _ImageReaderState extends State<ImageReader> {
late final FullScreenAction _fullScreenAction = currentFullScreenAction();
late final ReaderSliderPosition _readerSliderPosition =
currentReaderSliderPosition();
currentReaderSliderPosition();
@override
Widget build(BuildContext context) {
@ -186,12 +186,12 @@ class _ImageReaderContent extends StatefulWidget {
final ImageReaderStruct struct;
const _ImageReaderContent(
this.struct,
this.pagerDirection,
this.pagerType,
this.fullScreenAction,
this.readerSliderPosition,
);
this.struct,
this.pagerDirection,
this.pagerType,
this.fullScreenAction,
this.readerSliderPosition,
);
@override
State<StatefulWidget> createState() {
@ -289,55 +289,87 @@ abstract class _ImageReaderContentState extends State<_ImageReaderContent> {
@override
Widget build(BuildContext context) {
return Stack(
children: [
_buildViewer(),
_buildBar(),
],
);
switch (currentFullScreenAction()) {
//
case FullScreenAction.CONTROLLER:
return Stack(
children: [
_buildViewer(),
_buildBar(_buildFullScreenControllerStackItem()),
],
);
case FullScreenAction.TOUCH_ONCE:
return Stack(
children: [
_buildTouchOnceControllerAction(_buildViewer()),
_buildBar(Container()),
],
);
case FullScreenAction.TOUCH_DOUBLE:
return Stack(
children: [
_buildTouchDoubleControllerAction(_buildViewer()),
_buildBar(Container()),
],
);
case FullScreenAction.TOUCH_DOUBLE_ONCE_NEXT:
return Stack(
children: [
_buildTouchDoubleOnceNextControllerAction(_buildViewer()),
_buildBar(Container()),
],
);
case FullScreenAction.THREE_AREA:
return Stack(
children: [
_buildViewer(),
_buildBar(_buildThreeAreaControllerAction()),
],
);
}
}
Widget _buildBar() {
Widget _buildBar(Widget child) {
switch (widget.readerSliderPosition) {
case ReaderSliderPosition.BOTTOM:
return Column(
children: [
_buildAppBar(),
Expanded(child: _buildController()),
Expanded(child: child),
widget.struct.fullScreen
? Container()
: Container(
height: 45,
color: const Color(0x88000000),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Container(width: 15),
IconButton(
icon: const Icon(Icons.fullscreen),
color: Colors.white,
onPressed: () {
widget.struct
.onFullScreenChange(!widget.struct.fullScreen);
},
),
Container(width: 10),
Expanded(
child:
widget.pagerType != ReaderType.WEB_TOON_FREE_ZOOM
? _buildSliderBottom()
: Container(),
),
Container(width: 10),
IconButton(
icon: const Icon(Icons.skip_next_outlined),
color: Colors.white,
onPressed: _onNextAction,
),
Container(width: 15),
],
),
height: 45,
color: const Color(0x88000000),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Container(width: 15),
IconButton(
icon: const Icon(Icons.fullscreen),
color: Colors.white,
onPressed: () {
widget.struct
.onFullScreenChange(!widget.struct.fullScreen);
},
),
Container(width: 10),
Expanded(
child:
widget.pagerType != ReaderType.WEB_TOON_FREE_ZOOM
? _buildSliderBottom()
: Container(),
),
Container(width: 10),
IconButton(
icon: const Icon(Icons.skip_next_outlined),
color: Colors.white,
onPressed: _onNextAction,
),
Container(width: 15),
],
),
),
],
);
case ReaderSliderPosition.RIGHT:
@ -347,7 +379,7 @@ abstract class _ImageReaderContentState extends State<_ImageReaderContent> {
Expanded(
child: Stack(
children: [
_buildController(),
child,
_buildSliderRight(),
],
),
@ -361,7 +393,7 @@ abstract class _ImageReaderContentState extends State<_ImageReaderContent> {
Expanded(
child: Stack(
children: [
_buildController(),
child,
_buildSliderLeft(),
],
),
@ -374,19 +406,19 @@ abstract class _ImageReaderContentState extends State<_ImageReaderContent> {
Widget _buildAppBar() => widget.struct.fullScreen
? Container()
: AppBar(
title: Text(
"${widget.struct.epNameMap[widget.struct.epOrder] ?? ""} - ${widget.struct.comicTitle}"),
actions: [
IconButton(
onPressed: _onChooseEp,
icon: const Icon(Icons.menu_open),
),
IconButton(
onPressed: _onMoreSetting,
icon: const Icon(Icons.more_horiz),
),
],
);
title: Text(
"${widget.struct.epNameMap[widget.struct.epOrder] ?? ""} - ${widget.struct.comicTitle}"),
actions: [
IconButton(
onPressed: _onChooseEp,
icon: const Icon(Icons.menu_open),
),
IconButton(
onPressed: _onMoreSetting,
icon: const Icon(Icons.more_horiz),
),
],
);
Widget _buildSliderBottom() {
return Column(
@ -404,52 +436,52 @@ abstract class _ImageReaderContentState extends State<_ImageReaderContent> {
Widget _buildSliderLeft() => widget.struct.fullScreen
? Container()
: Align(
alignment: Alignment.centerLeft,
child: Material(
color: Colors.transparent,
child: Container(
width: 35,
height: 300,
decoration: const BoxDecoration(
color: Color(0x66000000),
borderRadius: BorderRadius.only(
topRight: Radius.circular(10),
bottomRight: Radius.circular(10),
),
),
padding:
const EdgeInsets.only(top: 10, bottom: 10, left: 6, right: 5),
child: Center(
child: _buildSliderWidget(Axis.vertical),
),
),
alignment: Alignment.centerLeft,
child: Material(
color: Colors.transparent,
child: Container(
width: 35,
height: 300,
decoration: const BoxDecoration(
color: Color(0x66000000),
borderRadius: BorderRadius.only(
topRight: Radius.circular(10),
bottomRight: Radius.circular(10),
),
);
),
padding:
const EdgeInsets.only(top: 10, bottom: 10, left: 6, right: 5),
child: Center(
child: _buildSliderWidget(Axis.vertical),
),
),
),
);
Widget _buildSliderRight() => widget.struct.fullScreen
? Container()
: Align(
alignment: Alignment.centerRight,
child: Material(
color: Colors.transparent,
child: Container(
width: 35,
height: 300,
decoration: const BoxDecoration(
color: Color(0x66000000),
borderRadius: BorderRadius.only(
topLeft: Radius.circular(10),
bottomLeft: Radius.circular(10),
),
),
padding:
const EdgeInsets.only(top: 10, bottom: 10, left: 5, right: 6),
child: Center(
child: _buildSliderWidget(Axis.vertical),
),
),
alignment: Alignment.centerRight,
child: Material(
color: Colors.transparent,
child: Container(
width: 35,
height: 300,
decoration: const BoxDecoration(
color: Color(0x66000000),
borderRadius: BorderRadius.only(
topLeft: Radius.circular(10),
bottomLeft: Radius.circular(10),
),
);
),
padding:
const EdgeInsets.only(top: 10, bottom: 10, left: 5, right: 6),
child: Center(
child: _buildSliderWidget(Axis.vertical),
),
),
),
);
Widget _buildSliderWidget(Axis axis) {
return FlutterSlider(
@ -501,24 +533,7 @@ abstract class _ImageReaderContentState extends State<_ImageReaderContent> {
);
}
Widget _buildController() {
switch (currentFullScreenAction()) {
case FullScreenAction.CONTROLLER:
return _buildFullScreenController();
case FullScreenAction.TOUCH_ONCE:
return _buildTouchOnceController();
case FullScreenAction.TOUCH_DOUBLE:
return _buildTouchDoubleController();
case FullScreenAction.TOUCH_DOUBLE_ONCE_NEXT:
return _buildTouchDoubleOnceNextController();
case FullScreenAction.THREE_AREA:
return _buildThreeAreaController();
default:
return Container();
}
}
Widget _buildFullScreenController() {
Widget _buildFullScreenControllerStackItem() {
if (widget.readerSliderPosition == ReaderSliderPosition.BOTTOM &&
!widget.struct.fullScreen) {
return Container();
@ -529,7 +544,7 @@ abstract class _ImageReaderContentState extends State<_ImageReaderContent> {
color: Colors.transparent,
child: Container(
padding:
const EdgeInsets.only(left: 10, right: 10, top: 4, bottom: 4),
const EdgeInsets.only(left: 10, right: 10, top: 4, bottom: 4),
margin: const EdgeInsets.only(bottom: 10),
decoration: const BoxDecoration(
borderRadius: BorderRadius.only(
@ -555,27 +570,27 @@ abstract class _ImageReaderContentState extends State<_ImageReaderContent> {
);
}
Widget _buildTouchOnceController() {
Widget _buildTouchOnceControllerAction(Widget child) {
return GestureDetector(
behavior: HitTestBehavior.translucent,
onTap: () {
widget.struct.onFullScreenChange(!widget.struct.fullScreen);
},
child: Container(),
child: child,
);
}
Widget _buildTouchDoubleController() {
Widget _buildTouchDoubleControllerAction(Widget child) {
return GestureDetector(
behavior: HitTestBehavior.translucent,
onDoubleTap: () {
widget.struct.onFullScreenChange(!widget.struct.fullScreen);
},
child: Container(),
child: child,
);
}
Widget _buildTouchDoubleOnceNextController() {
Widget _buildTouchDoubleOnceNextControllerAction(Widget child) {
return GestureDetector(
behavior: HitTestBehavior.translucent,
onTap: () {
@ -584,11 +599,11 @@ abstract class _ImageReaderContentState extends State<_ImageReaderContent> {
onDoubleTap: () {
widget.struct.onFullScreenChange(!widget.struct.fullScreen);
},
child: Container(),
child: child,
);
}
Widget _buildThreeAreaController() {
Widget _buildThreeAreaControllerAction() {
return LayoutBuilder(
builder: (BuildContext context, BoxConstraints constraints) {
var up = Expanded(
@ -703,11 +718,11 @@ abstract class _ImageReaderContentState extends State<_ImageReaderContent> {
case FullScreenAction.CONTROLLER:
return false;
case FullScreenAction.TOUCH_ONCE:
return true;
return false;
case FullScreenAction.TOUCH_DOUBLE:
return true;
return false;
case FullScreenAction.TOUCH_DOUBLE_ONCE_NEXT:
return true;
return false;
case FullScreenAction.THREE_AREA:
return true;
}
@ -735,7 +750,7 @@ class _EpChooser extends StatefulWidget {
final int epOrder;
final FutureOr Function(int) onChangeEp;
const _EpChooser(this.epNameMap, this.epOrder, this.onChangeEp);
_EpChooser(this.epNameMap, this.epOrder, this.onChangeEp);
@override
State<StatefulWidget> createState() => _EpChooserState();
@ -782,7 +797,7 @@ class _SettingPanel extends StatefulWidget {
final FutureOr Function() onReloadEp;
final FutureOr Function() onDownload;
const _SettingPanel(this.onReloadEp, this.onDownload);
_SettingPanel(this.onReloadEp, this.onDownload);
@override
State<StatefulWidget> createState() => _SettingPanelState();
@ -866,42 +881,42 @@ class _SettingPanelState extends State<_SettingPanel> {
);
}
Widget _bottomIcon({
required IconData icon,
required String title,
required void Function() onPressed,
}) {
return Expanded(
child: Center(
child: Column(
children: [
IconButton(
iconSize: 55,
icon: Column(
children: [
Container(height: 3),
Icon(
icon,
size: 25,
color: Colors.white,
),
Container(height: 3),
Text(
title,
style: const TextStyle(color: Colors.white, fontSize: 10),
maxLines: 1,
textAlign: TextAlign.center,
),
Container(height: 3),
],
),
onPressed: onPressed,
)
],
),
Widget _bottomIcon({
required IconData icon,
required String title,
required void Function() onPressed,
}) {
return Expanded(
child: Center(
child: Column(
children: [
IconButton(
iconSize: 55,
icon: Column(
children: [
Container(height: 3),
Icon(
icon,
size: 25,
color: Colors.white,
),
Container(height: 3),
Text(
title,
style: const TextStyle(color: Colors.white, fontSize: 10),
maxLines: 1,
textAlign: TextAlign.center,
),
Container(height: 3),
],
),
onPressed: onPressed,
)
],
),
);
}
),
);
}
}
///////////////////////////////////////////////////////////////////////////////
@ -953,7 +968,7 @@ class _WebToonReaderState extends _ImageReaderContentState {
}
_controllerTime = DateTime.now().millisecondsSinceEpoch + 400;
_itemScrollController.scrollTo(
index: index, // 1 position 1
index: index,
duration: const Duration(milliseconds: 400),
);
}
@ -1039,9 +1054,9 @@ class _WebToonReaderState extends _ImageReaderContentState {
return ScrollablePositionedList.builder(
initialScrollIndex: super._startIndex,
scrollDirection:
widget.pagerDirection == ReaderDirection.TOP_TO_BOTTOM
? Axis.vertical
: Axis.horizontal,
widget.pagerDirection == ReaderDirection.TOP_TO_BOTTOM
? Axis.vertical
: Axis.horizontal,
reverse: widget.pagerDirection == ReaderDirection.RIGHT_TO_LEFT,
padding: EdgeInsets.only(
// , ,
@ -1049,9 +1064,9 @@ class _WebToonReaderState extends _ImageReaderContentState {
bottom: widget.pagerDirection == ReaderDirection.TOP_TO_BOTTOM
? 130 // 130
: ( //
widget.struct.fullScreen
? super._topBarHeight() //
: super._bottomBarHeight())
widget.struct.fullScreen
? super._topBarHeight() //
: super._bottomBarHeight())
// , BAR的高度, BAR的高度,
,
),
@ -1104,7 +1119,7 @@ class _WebToonDownloadImage extends _WebToonReaderImage {
final int height;
final String format;
const _WebToonDownloadImage({
_WebToonDownloadImage({
required this.fileServer,
required this.path,
required this.localPath,
@ -1137,12 +1152,12 @@ class _WebToonRemoteImage extends _WebToonReaderImage {
final String fileServer;
final String path;
const _WebToonRemoteImage(
this.fileServer,
this.path,
Size size,
Function(Size)? onTrueSize,
) : super(size, onTrueSize);
_WebToonRemoteImage(
this.fileServer,
this.path,
Size size,
Function(Size)? onTrueSize,
) : super(size, onTrueSize);
@override
Future<RemoteImageData> imageData() async {
@ -1155,7 +1170,7 @@ abstract class _WebToonReaderImage extends StatefulWidget {
final Size size;
final Function(Size)? onTrueSize;
const _WebToonReaderImage(this.size, this.onTrueSize);
_WebToonReaderImage(this.size, this.onTrueSize);
@override
State<StatefulWidget> createState() => _WebToonReaderImageState();
@ -1182,14 +1197,14 @@ class _WebToonReaderImageState extends State<_WebToonReaderImage> {
return FutureBuilder(
future: _future,
builder: (
BuildContext context,
AsyncSnapshot<RemoteImageData> snapshot,
) {
BuildContext context,
AsyncSnapshot<RemoteImageData> snapshot,
) {
if (snapshot.hasError) {
return GestureDetector(
onLongPress: () async {
String? choose =
await chooseListDialog(context, '请选择', ['重新加载图片']);
await chooseListDialog(context, '请选择', ['重新加载图片']);
switch (choose) {
case '重新加载图片':
setState(() {
@ -1340,9 +1355,9 @@ class _ListViewReaderState extends _ImageReaderContentState
}
var list = ListView.builder(
scrollDirection:
widget.pagerDirection == ReaderDirection.TOP_TO_BOTTOM
? Axis.vertical
: Axis.horizontal,
widget.pagerDirection == ReaderDirection.TOP_TO_BOTTOM
? Axis.vertical
: Axis.horizontal,
reverse: widget.pagerDirection == ReaderDirection.RIGHT_TO_LEFT,
padding: EdgeInsets.only(
// , ,
@ -1350,9 +1365,9 @@ class _ListViewReaderState extends _ImageReaderContentState
bottom: widget.pagerDirection == ReaderDirection.TOP_TO_BOTTOM
? 130 // 130
: ( //
widget.struct.fullScreen
? super._topBarHeight() //
: super._bottomBarHeight())
widget.struct.fullScreen
? super._topBarHeight() //
: super._bottomBarHeight())
// , BAR的高度, BAR的高度,
,
),
@ -1487,7 +1502,7 @@ class _GalleryReaderState extends _ImageReaderContentState {
if (item.downloadLocalPath != null) {
return PhotoViewGalleryPageOptions(
imageProvider:
ResourceDownloadFileImageProvider(item.downloadLocalPath!),
ResourceDownloadFileImageProvider(item.downloadLocalPath!),
errorBuilder: (b, e, s) {
print("$e,$s");
return LayoutBuilder(
@ -1502,7 +1517,7 @@ class _GalleryReaderState extends _ImageReaderContentState {
}
return PhotoViewGalleryPageOptions(
imageProvider:
ResourceRemoteImageProvider(item.fileServer, item.path),
ResourceRemoteImageProvider(item.fileServer, item.path),
errorBuilder: (b, e, s) {
print("$e,$s");
return LayoutBuilder(
@ -1530,7 +1545,7 @@ class _GalleryReaderState extends _ImageReaderContentState {
}
String? choose =
await chooseListDialog(context, '请选择', ['预览图片', '保存图片']);
await chooseListDialog(context, '请选择', ['预览图片', '保存图片']);
switch (choose) {
case '预览图片':
try {
@ -1579,7 +1594,7 @@ class _GalleryReaderState extends _ImageReaderContentState {
child: Container(
margin: const EdgeInsets.only(bottom: 10),
padding:
const EdgeInsets.only(left: 10, right: 10, top: 4, bottom: 4),
const EdgeInsets.only(left: 10, right: 10, top: 4, bottom: 4),
decoration: const BoxDecoration(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(10),

View File

@ -15,7 +15,7 @@ EXTERNAL SOURCES:
SPEC CHECKSUMS:
FlutterMacOS: 57701585bf7de1b3fc2bb61f6378d73bbdea8424
url_launcher_macos: 45af3d61de06997666568a7149c1be98b41c95d4
url_launcher_macos: 597e05b8e514239626bcf4a850fcf9ef5c856ec3
PODFILE CHECKSUM: 6eac6b3292e5142cfc23bdeb71848a40ec51c14c

View File

@ -84,7 +84,7 @@ packages:
name: crypto
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.1"
version: "3.0.2"
cupertino_icons:
dependency: "direct main"
description:
@ -120,13 +120,6 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "4.5.1"
filesystem_picker:
dependency: "direct main"
description:
name: filesystem_picker
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
flutter:
dependency: "direct main"
description: flutter
@ -244,7 +237,7 @@ packages:
name: image_picker_ios
url: "https://pub.dartlang.org"
source: hosted
version: "0.8.4+11"
version: "0.8.5"
image_picker_platform_interface:
dependency: transitive
description:
@ -445,14 +438,14 @@ packages:
name: url_launcher
url: "https://pub.dartlang.org"
source: hosted
version: "6.0.20"
version: "6.1.0"
url_launcher_android:
dependency: transitive
description:
name: url_launcher_android
url: "https://pub.dartlang.org"
source: hosted
version: "6.0.15"
version: "6.0.16"
url_launcher_ios:
dependency: transitive
description:
@ -508,7 +501,7 @@ packages:
name: win32
url: "https://pub.dartlang.org"
source: hosted
version: "2.5.1"
version: "2.5.2"
xml:
dependency: transitive
description:

View File

@ -36,7 +36,6 @@ dependencies:
another_xlider: ^1.0.0
scrollable_positioned_list: ^0.2.0-nullsafety.0
permission_handler: ^8.1.4+1
filesystem_picker: ^2.0.0-nullsafety.0
url_launcher: ^6.0.9
clipboard: ^0.1.3
photo_view: ^0.13.0