fix 3 area control type can't exit reader bug, rewrite reader

This commit is contained in:
niuhuan 2021-12-02 10:32:35 +08:00
parent a6fda8669c
commit 340ef3b693
7 changed files with 186 additions and 261 deletions

View File

@ -37,7 +37,7 @@ Widget androidSecureFlagSetting() {
return StatefulBuilder(builder: return StatefulBuilder(builder:
(BuildContext context, void Function(void Function()) setState) { (BuildContext context, void Function(void Function()) setState) {
return ListTile( return ListTile(
title: Text("禁止截图/禁止显示在任务视图(仅安卓)"), title: Text("禁止截图/禁止显示在任务视图"),
subtitle: Text(_androidSecureFlag ? "" : ""), subtitle: Text(_androidSecureFlag ? "" : ""),
onTap: () async { onTap: () async {
await _chooseAndroidSecureFlag(context); await _chooseAndroidSecureFlag(context);

View File

@ -12,9 +12,9 @@ enum FullScreenAction {
} }
Map<String, FullScreenAction> _fullScreenActionMap = { Map<String, FullScreenAction> _fullScreenActionMap = {
"使用控制器": FullScreenAction.CONTROLLER, "使用控制器全屏": FullScreenAction.CONTROLLER,
"点击屏幕一次": FullScreenAction.TOUCH_ONCE, "点击屏幕一次全屏": FullScreenAction.TOUCH_ONCE,
"将屏幕划分成三个区域": FullScreenAction.THREE_AREA, "将屏幕划分成三个区域 (上一页, 下一页, 全屏)": FullScreenAction.THREE_AREA,
}; };
const _propertyName = "fullScreenAction"; const _propertyName = "fullScreenAction";
@ -51,7 +51,7 @@ String _currentFullScreenActionName() {
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;
@ -62,7 +62,7 @@ Widget fullScreenActionSetting() {
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: Text("进入全屏的方式"), title: Text("操控方式"),
subtitle: Text(_currentFullScreenActionName()), subtitle: Text(_currentFullScreenActionName()),
onTap: () async { onTap: () async {
await _chooseFullScreenAction(context); await _chooseFullScreenAction(context);

View File

@ -19,7 +19,7 @@ bool noAnimation() {
Future<void> _chooseNoAnimation(BuildContext context) async { Future<void> _chooseNoAnimation(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");
@ -31,7 +31,7 @@ Widget noAnimationSetting() {
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: Text("取消翻页动画"), title: Text("取消键盘或音量翻页动画"),
subtitle: Text(_noAnimation ? "" : ""), subtitle: Text(_noAnimation ? "" : ""),
onTap: () async { onTap: () async {
await _chooseNoAnimation(context); await _chooseNoAnimation(context);

View File

@ -30,7 +30,7 @@ Widget volumeControllerSetting() {
return StatefulBuilder(builder: return StatefulBuilder(builder:
(BuildContext context, void Function(void Function()) setState) { (BuildContext context, void Function(void Function()) setState) {
return ListTile( return ListTile(
title: Text("阅读器音量键翻页(仅安卓)"), title: Text("阅读器音量键翻页"),
subtitle: Text(volumeController ? "" : ""), subtitle: Text(volumeController ? "" : ""),
onTap: () async { onTap: () async {
await _chooseVolumeController(context); await _chooseVolumeController(context);

View File

@ -21,8 +21,6 @@ class ComicReaderScreen extends StatefulWidget {
final List<Ep> epList; final List<Ep> epList;
final currentEpOrder; final currentEpOrder;
final int? initPicturePosition; final int? initPicturePosition;
final ReaderType pagerType = currentReaderType();
final ReaderDirection pagerDirection = gReaderDirection;
late final bool autoFullScreen; late final bool autoFullScreen;
ComicReaderScreen({ ComicReaderScreen({
@ -78,54 +76,42 @@ class _ComicReaderScreenState extends State<ComicReaderScreen> {
widget.comicInfo.id, _ep.order, _ep.title, position); widget.comicInfo.id, _ep.order, _ep.title, position);
} }
FutureOr<dynamic> Function() _previousAction = () => null; FutureOr<dynamic> _onChangeEp(int epOrder) {
String _nextText = "";
FutureOr<dynamic> Function() _nextAction = () => null;
@override
void initState() {
// NEXT
var orderMap = Map<int, Ep>(); var orderMap = Map<int, Ep>();
widget.epList.forEach((element) { widget.epList.forEach((element) {
orderMap[element.order] = element; orderMap[element.order] = element;
}); });
if (orderMap.containsKey(widget.currentEpOrder - 1)) { if (orderMap.containsKey(epOrder)) {
_previousAction = () { _replacement = true;
_replacement = true; Navigator.of(context).pushReplacement(
Navigator.of(context).pushReplacement( MaterialPageRoute(
MaterialPageRoute( builder: (context) => ComicReaderScreen(
builder: (context) => ComicReaderScreen( comicInfo: widget.comicInfo,
comicInfo: widget.comicInfo, epList: widget.epList,
epList: widget.epList, currentEpOrder: epOrder,
currentEpOrder: widget.currentEpOrder - 1, autoFullScreen: _fullScreen,
autoFullScreen: _fullScreen,
),
), ),
); ),
}; );
} else {
_previousAction = () => defaultToast(context, "已经到头了");
}
if (orderMap.containsKey(widget.currentEpOrder + 1)) {
_nextText = "下一章";
_nextAction = () {
_replacement = true;
Navigator.of(context).pushReplacement(
MaterialPageRoute(
builder: (context) => ComicReaderScreen(
comicInfo: widget.comicInfo,
epList: widget.epList,
currentEpOrder: widget.currentEpOrder + 1,
autoFullScreen: _fullScreen,
),
),
);
};
} else {
_nextText = "阅读结束";
_nextAction = () => Navigator.of(context).pop();
} }
}
FutureOr<dynamic> _onReloadEp() {
_replacement = true;
Navigator.of(context).pushReplacement(MaterialPageRoute(
builder: (context) => ComicReaderScreen(
comicInfo: widget.comicInfo,
epList: widget.epList,
currentEpOrder: widget.currentEpOrder,
initPicturePosition: _lastChangeRank ?? widget.initPicturePosition,
// maybe null
autoFullScreen: _fullScreen,
),
));
}
@override
void initState() {
// EP // EP
widget.epList.forEach((element) { widget.epList.forEach((element) {
if (element.order == widget.currentEpOrder) { if (element.order == widget.currentEpOrder) {
@ -150,20 +136,6 @@ class _ComicReaderScreenState extends State<ComicReaderScreen> {
return readerKeyboardHolder(_build(context)); return readerKeyboardHolder(_build(context));
} }
Future _onSelectDirection() async {
await choosePagerDirection(context);
if (widget.pagerDirection != gReaderDirection) {
_reloadReader();
}
}
Future _onSelectReaderType() async {
await choosePagerType(context);
if (widget.pagerType != currentReaderType()) {
_reloadReader();
}
}
Widget _build(BuildContext context) { Widget _build(BuildContext context) {
return FutureBuilder( return FutureBuilder(
future: _future, future: _future,
@ -176,16 +148,6 @@ class _ComicReaderScreenState extends State<ComicReaderScreen> {
: AppBar( : AppBar(
backgroundColor: readerAppbarColor, backgroundColor: readerAppbarColor,
title: Text("${_ep.title} - ${widget.comicInfo.title}"), title: Text("${_ep.title} - ${widget.comicInfo.title}"),
actions: [
IconButton(
onPressed: _onSelectDirection,
icon: Icon(Icons.grid_goldenratio),
),
IconButton(
onPressed: _onSelectReaderType,
icon: Icon(Icons.view_day_outlined),
),
],
), ),
body: ContentError( body: ContentError(
error: snapshot.error, error: snapshot.error,
@ -205,16 +167,6 @@ class _ComicReaderScreenState extends State<ComicReaderScreen> {
: AppBar( : AppBar(
backgroundColor: readerAppbarColor, backgroundColor: readerAppbarColor,
title: Text("${_ep.title} - ${widget.comicInfo.title}"), title: Text("${_ep.title} - ${widget.comicInfo.title}"),
actions: [
IconButton(
onPressed: _onSelectDirection,
icon: Icon(Icons.grid_goldenratio),
),
IconButton(
onPressed: _onSelectReaderType,
icon: Icon(Icons.view_day_outlined),
),
],
), ),
body: ContentLoading(label: '加载中'), body: ContentLoading(label: '加载中'),
); );
@ -224,33 +176,28 @@ class _ComicReaderScreenState extends State<ComicReaderScreen> {
epNameMap[element.order] = element.title; epNameMap[element.order] = element.title;
}); });
return Scaffold( return Scaffold(
body: ImageReader( body: ImageReader(
ImageReaderStruct( ImageReaderStruct(
images: snapshot.data! images: snapshot.data!
.map((e) => ReaderImageInfo( .map((e) => ReaderImageInfo(
e.fileServer, e.fileServer,
e.path, e.path,
null, null,
null, null,
null, null,
null, null,
null, null,
)) ))
.toList(), .toList(),
fullScreen: _fullScreen, fullScreen: _fullScreen,
onFullScreenChange: _onFullScreenChange, onFullScreenChange: _onFullScreenChange,
onNextText: _nextText,
onPreviousAction: _previousAction,
onNextAction: _nextAction,
onPositionChange: _onPositionChange, onPositionChange: _onPositionChange,
initPosition: widget.initPicturePosition, initPosition: widget.initPicturePosition,
pagerType: widget.pagerType,
pagerDirection: widget.pagerDirection,
epNameMap: epNameMap, epNameMap: epNameMap,
epOrder: _ep.order, epOrder: _ep.order,
comicTitle: widget.comicInfo.title, comicTitle: widget.comicInfo.title,
onSelectDirection: _onSelectDirection, onChangeEp: _onChangeEp,
onSelectReaderType: _onSelectReaderType, onReloadEp: _onReloadEp,
), ),
), ),
); );
@ -265,19 +212,4 @@ class _ComicReaderScreenState extends State<ComicReaderScreen> {
_fullScreen = fullScreen; _fullScreen = fullScreen;
}); });
} }
//
void _reloadReader() {
_replacement = true;
Navigator.of(context).pushReplacement(MaterialPageRoute(
builder: (context) => ComicReaderScreen(
comicInfo: widget.comicInfo,
epList: widget.epList,
currentEpOrder: widget.currentEpOrder,
initPicturePosition: _lastChangeRank ?? widget.initPicturePosition,
// maybe null
autoFullScreen: _fullScreen,
),
));
}
} }

View File

@ -71,54 +71,44 @@ class _DownloadReaderScreenState extends State<DownloadReaderScreen> {
widget.comicInfo.id, _ep.epOrder, _ep.title, position); widget.comicInfo.id, _ep.epOrder, _ep.title, position);
} }
FutureOr<dynamic> Function() _previousAction = () => null; FutureOr<dynamic> _onChangeEp(int epOrder) {
String _nextText = "";
FutureOr<dynamic> Function() _nextAction = () => null;
@override
void initState() {
// NEXT
var orderMap = Map<int, DownloadEp>(); var orderMap = Map<int, DownloadEp>();
widget.epList.forEach((element) { widget.epList.forEach((element) {
orderMap[element.epOrder] = element; orderMap[element.epOrder] = element;
}); });
if (orderMap.containsKey(widget.currentEpOrder - 1)) { if (orderMap.containsKey(epOrder)) {
_previousAction = () { _replacement = true;
_replacement = true; Navigator.of(context).pushReplacement(
Navigator.of(context).pushReplacement( MaterialPageRoute(
MaterialPageRoute( builder: (context) => DownloadReaderScreen(
builder: (context) => DownloadReaderScreen( comicInfo: widget.comicInfo,
comicInfo: widget.comicInfo, epList: widget.epList,
epList: widget.epList, currentEpOrder: epOrder,
currentEpOrder: widget.currentEpOrder - 1, autoFullScreen: _fullScreen,
autoFullScreen: _fullScreen,
),
), ),
); ),
}; );
} else {
_previousAction = () => defaultToast(context, "已经到头了");
}
if (orderMap.containsKey(widget.currentEpOrder + 1)) {
_nextText = "下一章";
_nextAction = () {
_replacement = true;
Navigator.of(context).pushReplacement(
MaterialPageRoute(
builder: (context) => DownloadReaderScreen(
comicInfo: widget.comicInfo,
epList: widget.epList,
currentEpOrder: widget.currentEpOrder + 1,
autoFullScreen: _fullScreen,
),
),
);
};
} else {
_nextText = "阅读结束";
_nextAction = () => Navigator.of(context).pop();
} }
}
FutureOr<dynamic> _onReloadEp() {
_replacement = true;
Navigator.of(context).pushReplacement(
MaterialPageRoute(
builder: (context) => DownloadReaderScreen(
comicInfo: widget.comicInfo,
epList: widget.epList,
currentEpOrder: widget.currentEpOrder,
initPicturePosition: _lastChangeRank ?? widget.initPicturePosition,
// maybe null
autoFullScreen: _fullScreen,
),
),
);
}
@override
void initState() {
// EP // EP
widget.epList.forEach((element) { widget.epList.forEach((element) {
if (element.epOrder == widget.currentEpOrder) { if (element.epOrder == widget.currentEpOrder) {
@ -143,20 +133,6 @@ class _DownloadReaderScreenState extends State<DownloadReaderScreen> {
return readerKeyboardHolder(_build(context)); return readerKeyboardHolder(_build(context));
} }
Future _onSelectDirection() async {
await choosePagerDirection(context);
if (widget.pagerDirection != gReaderDirection) {
_reloadReader();
}
}
Future _onSelectReaderType() async {
await choosePagerType(context);
if (widget.pagerType != currentReaderType()) {
_reloadReader();
}
}
Widget _build(BuildContext context) { Widget _build(BuildContext context) {
return FutureBuilder( return FutureBuilder(
future: _future, future: _future,
@ -167,16 +143,6 @@ class _DownloadReaderScreenState extends State<DownloadReaderScreen> {
? null ? null
: AppBar( : AppBar(
title: Text("${_ep.title} - ${widget.comicInfo.title}"), title: Text("${_ep.title} - ${widget.comicInfo.title}"),
actions: [
IconButton(
onPressed: _onSelectDirection,
icon: Icon(Icons.grid_goldenratio),
),
IconButton(
onPressed: _onSelectReaderType,
icon: Icon(Icons.view_day_outlined),
),
],
), ),
body: ContentError( body: ContentError(
error: snapshot.error, error: snapshot.error,
@ -195,16 +161,6 @@ class _DownloadReaderScreenState extends State<DownloadReaderScreen> {
? null ? null
: AppBar( : AppBar(
title: Text("${_ep.title} - ${widget.comicInfo.title}"), title: Text("${_ep.title} - ${widget.comicInfo.title}"),
actions: [
IconButton(
onPressed: _onSelectDirection,
icon: Icon(Icons.grid_goldenratio),
),
IconButton(
onPressed: _onSelectReaderType,
icon: Icon(Icons.view_day_outlined),
),
],
), ),
body: ContentLoading(label: '加载中'), body: ContentLoading(label: '加载中'),
); );
@ -222,18 +178,13 @@ class _DownloadReaderScreenState extends State<DownloadReaderScreen> {
.toList(), .toList(),
fullScreen: _fullScreen, fullScreen: _fullScreen,
onFullScreenChange: _onFullScreenChange, onFullScreenChange: _onFullScreenChange,
onNextText: _nextText,
onPreviousAction: _previousAction,
onNextAction: _nextAction,
onPositionChange: _onPositionChange, onPositionChange: _onPositionChange,
initPosition: widget.initPicturePosition, initPosition: widget.initPicturePosition,
pagerType: widget.pagerType,
pagerDirection: widget.pagerDirection,
epOrder: _ep.epOrder, epOrder: _ep.epOrder,
epNameMap: epNameMap, epNameMap: epNameMap,
comicTitle: widget.comicInfo.title, comicTitle: widget.comicInfo.title,
onSelectDirection: _onSelectDirection, onReloadEp: _onReloadEp,
onSelectReaderType: _onSelectReaderType, onChangeEp: _onChangeEp,
), ),
), ),
); );
@ -248,21 +199,4 @@ class _DownloadReaderScreenState extends State<DownloadReaderScreen> {
_fullScreen = fullScreen; _fullScreen = fullScreen;
}); });
} }
//
void _reloadReader() {
_replacement = true;
Navigator.of(context).pushReplacement(
MaterialPageRoute(
builder: (context) => DownloadReaderScreen(
comicInfo: widget.comicInfo,
epList: widget.epList,
currentEpOrder: widget.currentEpOrder,
initPicturePosition: _lastChangeRank ?? widget.initPicturePosition,
// maybe null
autoFullScreen: _fullScreen,
),
),
);
}
} }

View File

@ -107,35 +107,25 @@ class ImageReaderStruct {
final List<ReaderImageInfo> images; final List<ReaderImageInfo> images;
final bool fullScreen; final bool fullScreen;
final FutureOr<dynamic> Function(bool fullScreen) onFullScreenChange; final FutureOr<dynamic> Function(bool fullScreen) onFullScreenChange;
final String onNextText;
final FutureOr<dynamic> Function() onPreviousAction;
final FutureOr<dynamic> Function() onNextAction;
final FutureOr<dynamic> Function(int) onPositionChange; final FutureOr<dynamic> Function(int) onPositionChange;
final int? initPosition; final int? initPosition;
final ReaderType pagerType;
final ReaderDirection pagerDirection;
final Map<int, String> epNameMap; final Map<int, String> epNameMap;
final int epOrder; final int epOrder;
final String comicTitle; final String comicTitle;
final FutureOr<dynamic> Function() onSelectDirection; final FutureOr<dynamic> Function(int) onChangeEp;
final FutureOr<dynamic> Function() onSelectReaderType; final FutureOr<dynamic> Function() onReloadEp;
const ImageReaderStruct({ const ImageReaderStruct({
required this.images, required this.images,
required this.fullScreen, required this.fullScreen,
required this.onFullScreenChange, required this.onFullScreenChange,
required this.onNextText,
required this.onPreviousAction,
required this.onNextAction,
required this.onPositionChange, required this.onPositionChange,
this.initPosition, this.initPosition,
required this.pagerType,
required this.pagerDirection,
required this.epNameMap, required this.epNameMap,
required this.epOrder, required this.epOrder,
required this.comicTitle, required this.comicTitle,
required this.onSelectDirection, required this.onChangeEp,
required this.onSelectReaderType, required this.onReloadEp,
}); });
} }
@ -146,9 +136,39 @@ class ImageReader extends StatefulWidget {
const ImageReader(this.struct); const ImageReader(this.struct);
@override
State<StatefulWidget> createState() => _ImageReaderState();
}
class _ImageReaderState extends State<ImageReader> {
//
final ReaderDirection pagerDirection = gReaderDirection;
//
final ReaderType pagerType = currentReaderType();
@override
Widget build(BuildContext context) {
return _ImageReaderContent(widget.struct, pagerDirection, pagerType);
}
}
//
class _ImageReaderContent extends StatefulWidget {
//
final ReaderDirection pagerDirection;
//
final ReaderType pagerType;
final ImageReaderStruct struct;
const _ImageReaderContent(this.struct, this.pagerDirection, this.pagerType);
@override @override
State<StatefulWidget> createState() { State<StatefulWidget> createState() {
switch (struct.pagerType) { switch (pagerType) {
case ReaderType.WEB_TOON: case ReaderType.WEB_TOON:
return _WebToonReaderState(); return _WebToonReaderState();
case ReaderType.WEB_TOON_ZOOM: case ReaderType.WEB_TOON_ZOOM:
@ -161,13 +181,14 @@ class ImageReader extends StatefulWidget {
} }
} }
abstract class _ImageReaderState extends State<ImageReader> { abstract class _ImageReaderContentState extends State<_ImageReaderContent> {
// //
Widget _buildViewer(); Widget _buildViewer();
// , // ,
void _needJumpTo(int index, bool animation); void _needJumpTo(int index, bool animation);
//
late bool _listVolume; late bool _listVolume;
@override @override
@ -275,11 +296,11 @@ abstract class _ImageReaderState extends State<ImageReader> {
backgroundColor: readerAppbarColor2, backgroundColor: readerAppbarColor2,
actions: [ actions: [
IconButton( IconButton(
onPressed: widget.struct.onSelectDirection, onPressed: _onSelectDirection,
icon: Icon(Icons.grid_goldenratio), icon: Icon(Icons.grid_goldenratio),
), ),
IconButton( IconButton(
onPressed: widget.struct.onSelectReaderType, onPressed: _onSelectReaderType,
icon: Icon(Icons.view_day_outlined), icon: Icon(Icons.view_day_outlined),
), ),
], ],
@ -364,9 +385,7 @@ abstract class _ImageReaderState extends State<ImageReader> {
IconButton( IconButton(
icon: Icon(Icons.skip_next_outlined), icon: Icon(Icons.skip_next_outlined),
color: Colors.white, color: Colors.white,
onPressed: () { onPressed: _onNextAction,
widget.struct.onNextAction();
},
), ),
Container(width: 15), Container(width: 15),
], ],
@ -453,7 +472,7 @@ abstract class _ImageReaderState extends State<ImageReader> {
), ),
); );
late Widget child; late Widget child;
switch (widget.struct.pagerDirection) { switch (widget.pagerDirection) {
case ReaderDirection.TOP_TO_BOTTOM: case ReaderDirection.TOP_TO_BOTTOM:
child = Column(children: [ child = Column(children: [
up, up,
@ -479,16 +498,53 @@ abstract class _ImageReaderState extends State<ImageReader> {
return Container( return Container(
width: constraints.maxWidth, width: constraints.maxWidth,
height: constraints.maxHeight, height: constraints.maxHeight,
child: child, child: Column(
children: [
Container(
height: widget.struct.fullScreen
? 0
: Scaffold.of(context).appBarMaxHeight ?? 0,
),
Expanded(child: child),
Container(
height: widget.struct.fullScreen ? 0 : 45,
),
],
),
); );
}, },
); );
} }
Future _onSelectDirection() async {
await choosePagerDirection(context);
if (widget.pagerDirection != gReaderDirection) {
widget.struct.onReloadEp();
}
}
Future _onSelectReaderType() async {
await choosePagerType(context);
if (widget.pagerType != currentReaderType()) {
widget.struct.onReloadEp();
}
}
Future _onNextAction() async {
if (widget.struct.epNameMap.containsKey(widget.struct.epOrder + 1)) {
widget.struct.onChangeEp(widget.struct.epOrder + 1);
} else {
defaultToast(context, "已经到头了");
}
}
bool _hasNextEp() =>
widget.struct.epNameMap.containsKey(widget.struct.epOrder + 1);
} }
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
class _WebToonReaderState extends _ImageReaderState { class _WebToonReaderState extends _ImageReaderContentState {
var _controllerTime = DateTime.now().millisecondsSinceEpoch + 400; var _controllerTime = DateTime.now().millisecondsSinceEpoch + 400;
late final List<Size?> _trueSizes = []; late final List<Size?> _trueSizes = [];
late final ItemScrollController _itemScrollController; late final ItemScrollController _itemScrollController;
@ -560,7 +616,7 @@ class _WebToonReaderState extends _ImageReaderState {
for (var index = 0; index < widget.struct.images.length; index++) { for (var index = 0; index < widget.struct.images.length; index++) {
late Size renderSize; late Size renderSize;
if (_trueSizes[index] != null) { if (_trueSizes[index] != null) {
if (widget.struct.pagerDirection == ReaderDirection.TOP_TO_BOTTOM) { if (widget.pagerDirection == ReaderDirection.TOP_TO_BOTTOM) {
renderSize = Size( renderSize = Size(
constraints.maxWidth, constraints.maxWidth,
constraints.maxWidth * constraints.maxWidth *
@ -576,7 +632,7 @@ class _WebToonReaderState extends _ImageReaderState {
); );
} }
} else { } else {
if (widget.struct.pagerDirection == ReaderDirection.TOP_TO_BOTTOM) { if (widget.pagerDirection == ReaderDirection.TOP_TO_BOTTOM) {
renderSize = Size(constraints.maxWidth, constraints.maxWidth / 2); renderSize = Size(constraints.maxWidth, constraints.maxWidth / 2);
} else { } else {
// ReaderDirection.LEFT_TO_RIGHT // ReaderDirection.LEFT_TO_RIGHT
@ -616,19 +672,17 @@ class _WebToonReaderState extends _ImageReaderState {
return ScrollablePositionedList.builder( return ScrollablePositionedList.builder(
initialScrollIndex: super._startIndex, initialScrollIndex: super._startIndex,
scrollDirection: scrollDirection:
widget.struct.pagerDirection == ReaderDirection.TOP_TO_BOTTOM widget.pagerDirection == ReaderDirection.TOP_TO_BOTTOM
? Axis.vertical ? Axis.vertical
: Axis.horizontal, : Axis.horizontal,
reverse: reverse: widget.pagerDirection == ReaderDirection.RIGHT_TO_LEFT,
widget.struct.pagerDirection == ReaderDirection.RIGHT_TO_LEFT,
padding: EdgeInsets.only( padding: EdgeInsets.only(
top: (scaffold.appBarMaxHeight ?? 0), top: (scaffold.appBarMaxHeight ?? 0),
bottom: bottom: widget.pagerDirection == ReaderDirection.TOP_TO_BOTTOM
widget.struct.pagerDirection == ReaderDirection.TOP_TO_BOTTOM ? 130
? 130 : (widget.struct.fullScreen
: (widget.struct.fullScreen ? (scaffold.appBarMaxHeight ?? 0)
? (scaffold.appBarMaxHeight ?? 0) : 45),
: 45),
), ),
itemScrollController: _itemScrollController, itemScrollController: _itemScrollController,
itemPositionsListener: _itemPositionsListener, itemPositionsListener: _itemPositionsListener,
@ -648,11 +702,17 @@ class _WebToonReaderState extends _ImageReaderState {
return Container( return Container(
padding: EdgeInsets.all(20), padding: EdgeInsets.all(20),
child: MaterialButton( child: MaterialButton(
onPressed: widget.struct.onNextAction, onPressed: () {
if (super._hasNextEp()) {
super._onNextAction();
} else {
Navigator.of(context).pop();
}
},
textColor: Colors.white, textColor: Colors.white,
child: Container( child: Container(
padding: EdgeInsets.only(top: 40, bottom: 40), padding: EdgeInsets.only(top: 40, bottom: 40),
child: Text(widget.struct.onNextText), child: Text(super._hasNextEp() ? '下一章' : '结束阅读'),
), ),
), ),
); );
@ -794,7 +854,7 @@ class _WebToonZoomReaderState extends _WebToonReaderState {
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
class _GalleryReaderState extends _ImageReaderState { class _GalleryReaderState extends _ImageReaderContentState {
late PageController _pageController; late PageController _pageController;
@override @override
@ -834,11 +894,10 @@ class _GalleryReaderState extends _ImageReaderState {
Widget _buildViewer() { Widget _buildViewer() {
Widget gallery = PhotoViewGallery.builder( Widget gallery = PhotoViewGallery.builder(
scrollDirection: scrollDirection: widget.pagerDirection == ReaderDirection.TOP_TO_BOTTOM
widget.struct.pagerDirection == ReaderDirection.TOP_TO_BOTTOM ? Axis.vertical
? Axis.vertical : Axis.horizontal,
: Axis.horizontal, reverse: widget.pagerDirection == ReaderDirection.RIGHT_TO_LEFT,
reverse: widget.struct.pagerDirection == ReaderDirection.RIGHT_TO_LEFT,
backgroundDecoration: BoxDecoration(color: Colors.black), backgroundDecoration: BoxDecoration(color: Colors.black),
loadingBuilder: (context, event) => LayoutBuilder( loadingBuilder: (context, event) => LayoutBuilder(
builder: (BuildContext context, BoxConstraints constraints) { builder: (BuildContext context, BoxConstraints constraints) {