mirror of
https://github.com/venera-app/venera.git
synced 2025-09-27 15:57:25 +00:00
Compare commits
18 Commits
v1.0.0-bet
...
v1.0.0
Author | SHA1 | Date | |
---|---|---|---|
![]() |
a508d85ce6 | ||
![]() |
a09fb0e81c | ||
![]() |
1883c3ee5b | ||
![]() |
3518949f99 | ||
![]() |
0589e63be7 | ||
![]() |
c2d3f3e56d | ||
![]() |
3e1bb5ef5c | ||
![]() |
7ce84d095e | ||
![]() |
373411e49d | ||
![]() |
0fba86d6a0 | ||
![]() |
97a6e456a5 | ||
![]() |
363f3641fb | ||
![]() |
02bda275b1 | ||
![]() |
093a772dff | ||
![]() |
5280f26981 | ||
![]() |
cc29ff0c33 | ||
![]() |
0db633a9d9 | ||
![]() |
c4dc12e050 |
27
README.md
27
README.md
@@ -1,16 +1,25 @@
|
|||||||
# venera
|
# venera
|
||||||
|
|
||||||
A comic app.
|
[](https://flutter.dev/)
|
||||||
|
[](https://github.com/venera-app/venera/blob/master/LICENSE)
|
||||||
|
[](https://github.com/venera-app/venera/releases)
|
||||||
|
[](https://github.com/venera-app/venera/stargazers)
|
||||||
|
|
||||||
## Getting Started
|
A comic reader that support reading local and network comics.
|
||||||
|
|
||||||
This project is a starting point for a Flutter application.
|
## Current Status
|
||||||
|
|
||||||
A few resources to get you started if this is your first Flutter project:
|
The project is still under development, and the current version is not stable.
|
||||||
|
|
||||||
- [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab)
|
Use the project at your own risk.
|
||||||
- [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook)
|
|
||||||
|
|
||||||
For help getting started with Flutter development, view the
|
## Create a new comic source
|
||||||
[online documentation](https://docs.flutter.dev/), which offers tutorials,
|
|
||||||
samples, guidance on mobile development, and a full API reference.
|
See [venera-configs](https://github.com/venera-app/venera-configs)
|
||||||
|
|
||||||
|
## Thanks
|
||||||
|
|
||||||
|
### Tags Translation
|
||||||
|
[](https://github.com/EhTagTranslation/Database)
|
||||||
|
|
||||||
|
The Chinese translation of the manga tags is from this project.
|
||||||
|
@@ -144,7 +144,9 @@
|
|||||||
"The directory name will be used as the comic title. And the name of chapter directories will be used as the chapter titles." : "目录名称将被用作漫画标题。章节目录的名称将被用作章节标题。",
|
"The directory name will be used as the comic title. And the name of chapter directories will be used as the chapter titles." : "目录名称将被用作漫画标题。章节目录的名称将被用作章节标题。",
|
||||||
"Export as cbz": "导出为cbz",
|
"Export as cbz": "导出为cbz",
|
||||||
"Select a cbz file." : "选择一个cbz文件",
|
"Select a cbz file." : "选择一个cbz文件",
|
||||||
"A cbz file" : "一个cbz文件"
|
"A cbz file" : "一个cbz文件",
|
||||||
|
"Fullscreen": "全屏",
|
||||||
|
"Exit": "退出"
|
||||||
},
|
},
|
||||||
"zh_TW": {
|
"zh_TW": {
|
||||||
"Home": "首頁",
|
"Home": "首頁",
|
||||||
@@ -291,6 +293,8 @@
|
|||||||
"The directory name will be used as the comic title. And the name of chapter directories will be used as the chapter titles." : "目錄名稱將被用作漫畫標題。章節目錄的名稱將被用作章節標題。",
|
"The directory name will be used as the comic title. And the name of chapter directories will be used as the chapter titles." : "目錄名稱將被用作漫畫標題。章節目錄的名稱將被用作章節標題。",
|
||||||
"Export as cbz": "匯出為cbz",
|
"Export as cbz": "匯出為cbz",
|
||||||
"Select a cbz file." : "選擇一個cbz文件",
|
"Select a cbz file." : "選擇一個cbz文件",
|
||||||
"A cbz file" : "一個cbz文件"
|
"A cbz file" : "一個cbz文件",
|
||||||
|
"Fullscreen": "全螢幕",
|
||||||
|
"Exit": "退出"
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -382,7 +382,7 @@ class _ComicDescription extends StatelessWidget {
|
|||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Text(
|
Text(
|
||||||
title,
|
title.trim(),
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
fontWeight: FontWeight.w500,
|
fontWeight: FontWeight.w500,
|
||||||
fontSize: 14.0,
|
fontSize: 14.0,
|
||||||
@@ -405,47 +405,56 @@ class _ComicDescription extends StatelessWidget {
|
|||||||
height: 4,
|
height: 4,
|
||||||
),
|
),
|
||||||
if (tags != null)
|
if (tags != null)
|
||||||
LayoutBuilder(builder: (context, constraints) {
|
Expanded(
|
||||||
return Container(
|
child: LayoutBuilder(builder: (context, constraints) {
|
||||||
constraints: const BoxConstraints(maxHeight: 47),
|
if (constraints.maxHeight < 22) {
|
||||||
child: Wrap(
|
return Container();
|
||||||
runAlignment: WrapAlignment.start,
|
}
|
||||||
|
int cnt = (constraints.maxHeight - 22).toInt() ~/ 25;
|
||||||
|
return Container(
|
||||||
clipBehavior: Clip.antiAlias,
|
clipBehavior: Clip.antiAlias,
|
||||||
crossAxisAlignment: WrapCrossAlignment.end,
|
height: 22 + cnt * 25,
|
||||||
spacing: 4,
|
width: double.infinity,
|
||||||
runSpacing: 3,
|
decoration: const BoxDecoration(),
|
||||||
children: [
|
child: Wrap(
|
||||||
for (var s in tags!)
|
runAlignment: WrapAlignment.start,
|
||||||
Container(
|
clipBehavior: Clip.antiAlias,
|
||||||
height: 22,
|
crossAxisAlignment: WrapCrossAlignment.end,
|
||||||
padding: const EdgeInsets.fromLTRB(3,2,3,2),
|
spacing: 4,
|
||||||
constraints: BoxConstraints(
|
runSpacing: 3,
|
||||||
maxWidth: constraints.maxWidth * 0.45,
|
children: [
|
||||||
),
|
for (var s in tags!)
|
||||||
decoration: BoxDecoration(
|
Container(
|
||||||
color: s == "Unavailable"
|
height: 22,
|
||||||
? Theme.of(context).colorScheme.errorContainer
|
padding: const EdgeInsets.fromLTRB(3, 2, 3, 2),
|
||||||
: Theme.of(context)
|
constraints: BoxConstraints(
|
||||||
.colorScheme
|
maxWidth: constraints.maxWidth * 0.45,
|
||||||
.secondaryContainer,
|
),
|
||||||
borderRadius:
|
decoration: BoxDecoration(
|
||||||
const BorderRadius.all(Radius.circular(8)),
|
color: s == "Unavailable"
|
||||||
),
|
? Theme.of(context).colorScheme.errorContainer
|
||||||
child: Text(
|
: Theme.of(context)
|
||||||
enableTranslate
|
.colorScheme
|
||||||
? TagsTranslation.translateTag(s)
|
.secondaryContainer,
|
||||||
: s,
|
borderRadius:
|
||||||
style: const TextStyle(fontSize: 12),
|
const BorderRadius.all(Radius.circular(8)),
|
||||||
softWrap: true,
|
),
|
||||||
overflow: TextOverflow.ellipsis,
|
child: Center(
|
||||||
maxLines: 1,
|
widthFactor: 1,
|
||||||
)),
|
child: Text(
|
||||||
],
|
enableTranslate
|
||||||
),
|
? TagsTranslation.translateTag(s)
|
||||||
);
|
: s.split(':').last,
|
||||||
}),
|
style: const TextStyle(fontSize: 12),
|
||||||
const Spacer(),
|
softWrap: true,
|
||||||
if (rating != null) StarRating(value: rating!, size: 18),
|
overflow: TextOverflow.ellipsis,
|
||||||
|
maxLines: 1,
|
||||||
|
))),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
).toAlign(Alignment.topCenter);
|
||||||
|
}),
|
||||||
|
),
|
||||||
Row(
|
Row(
|
||||||
crossAxisAlignment: CrossAxisAlignment.end,
|
crossAxisAlignment: CrossAxisAlignment.end,
|
||||||
children: [
|
children: [
|
||||||
@@ -453,6 +462,7 @@ class _ComicDescription extends StatelessWidget {
|
|||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
|
if (rating != null) StarRating(value: rating!, size: 18),
|
||||||
Text(
|
Text(
|
||||||
description,
|
description,
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
@@ -469,10 +479,12 @@ class _ComicDescription extends StatelessWidget {
|
|||||||
color: Theme.of(context).colorScheme.tertiaryContainer,
|
color: Theme.of(context).colorScheme.tertiaryContainer,
|
||||||
borderRadius: const BorderRadius.all(Radius.circular(8)),
|
borderRadius: const BorderRadius.all(Radius.circular(8)),
|
||||||
),
|
),
|
||||||
child: Text(
|
child: Center(
|
||||||
badge!,
|
child:Text(
|
||||||
style: const TextStyle(fontSize: 12),
|
"${badge![0].toUpperCase()}${badge!.substring(1).toLowerCase()}",
|
||||||
),
|
style: const TextStyle(fontSize: 12),
|
||||||
|
),
|
||||||
|
)
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
@@ -21,7 +21,6 @@ import 'package:venera/foundation/history.dart';
|
|||||||
import 'package:venera/foundation/image_provider/cached_image.dart';
|
import 'package:venera/foundation/image_provider/cached_image.dart';
|
||||||
import 'package:venera/foundation/local.dart';
|
import 'package:venera/foundation/local.dart';
|
||||||
import 'package:venera/foundation/res.dart';
|
import 'package:venera/foundation/res.dart';
|
||||||
import 'package:venera/foundation/state_controller.dart';
|
|
||||||
import 'package:venera/network/cloudflare.dart';
|
import 'package:venera/network/cloudflare.dart';
|
||||||
import 'package:venera/pages/comic_page.dart';
|
import 'package:venera/pages/comic_page.dart';
|
||||||
import 'package:venera/pages/favorites/favorites_page.dart';
|
import 'package:venera/pages/favorites/favorites_page.dart';
|
||||||
@@ -45,4 +44,5 @@ part 'scroll.dart';
|
|||||||
part 'select.dart';
|
part 'select.dart';
|
||||||
part 'side_bar.dart';
|
part 'side_bar.dart';
|
||||||
part 'comic.dart';
|
part 'comic.dart';
|
||||||
part 'effects.dart';
|
part 'effects.dart';
|
||||||
|
part 'gesture.dart';
|
22
lib/components/gesture.dart
Normal file
22
lib/components/gesture.dart
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
part of 'components.dart';
|
||||||
|
|
||||||
|
class MouseBackDetector extends StatelessWidget {
|
||||||
|
const MouseBackDetector({super.key, required this.onTapDown, required this.child});
|
||||||
|
|
||||||
|
final Widget child;
|
||||||
|
|
||||||
|
final void Function() onTapDown;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Listener(
|
||||||
|
onPointerDown: (event) {
|
||||||
|
if (event.buttons == kBackMouseButton) {
|
||||||
|
onTapDown();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
behavior: HitTestBehavior.translucent,
|
||||||
|
child: child,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@@ -16,7 +16,14 @@ class SmoothCustomScrollView extends StatelessWidget {
|
|||||||
return CustomScrollView(
|
return CustomScrollView(
|
||||||
controller: controller,
|
controller: controller,
|
||||||
physics: physics,
|
physics: physics,
|
||||||
slivers: slivers,
|
slivers: [
|
||||||
|
...slivers,
|
||||||
|
SliverPadding(
|
||||||
|
padding: EdgeInsets.only(
|
||||||
|
bottom: context.padding.bottom,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@@ -87,7 +94,7 @@ class _SmoothScrollProviderState extends State<SmoothScrollProvider> {
|
|||||||
_controller.position.minScrollExtent,
|
_controller.position.minScrollExtent,
|
||||||
_controller.position.maxScrollExtent,
|
_controller.position.maxScrollExtent,
|
||||||
);
|
);
|
||||||
if(_futurePosition == old) return;
|
if (_futurePosition == old) return;
|
||||||
_controller.animateTo(_futurePosition!,
|
_controller.animateTo(_futurePosition!,
|
||||||
duration: _fastAnimationDuration, curve: Curves.linear);
|
duration: _fastAnimationDuration, curve: Curves.linear);
|
||||||
}
|
}
|
||||||
|
@@ -10,7 +10,7 @@ export "widget_utils.dart";
|
|||||||
export "context.dart";
|
export "context.dart";
|
||||||
|
|
||||||
class _App {
|
class _App {
|
||||||
final version = "1.0.0-beta";
|
final version = "1.0.0";
|
||||||
|
|
||||||
bool get isAndroid => Platform.isAndroid;
|
bool get isAndroid => Platform.isAndroid;
|
||||||
|
|
||||||
|
@@ -20,7 +20,7 @@ void main(List<String> args) {
|
|||||||
runZonedGuarded(() async {
|
runZonedGuarded(() async {
|
||||||
WidgetsFlutterBinding.ensureInitialized();
|
WidgetsFlutterBinding.ensureInitialized();
|
||||||
await init();
|
await init();
|
||||||
if(App.isAndroid) {
|
if (App.isAndroid) {
|
||||||
handleLinks();
|
handleLinks();
|
||||||
}
|
}
|
||||||
FlutterError.onError = (details) {
|
FlutterError.onError = (details) {
|
||||||
@@ -73,6 +73,7 @@ class _MyAppState extends State<MyApp> {
|
|||||||
el.markNeedsBuild();
|
el.markNeedsBuild();
|
||||||
el.visitChildren(rebuild);
|
el.visitChildren(rebuild);
|
||||||
}
|
}
|
||||||
|
|
||||||
(context as Element).visitChildren(rebuild);
|
(context as Element).visitChildren(rebuild);
|
||||||
setState(() {});
|
setState(() {});
|
||||||
}
|
}
|
||||||
@@ -114,10 +115,10 @@ class _MyAppState extends State<MyApp> {
|
|||||||
],
|
],
|
||||||
locale: () {
|
locale: () {
|
||||||
var lang = appdata.settings['language'];
|
var lang = appdata.settings['language'];
|
||||||
if(lang == 'system') {
|
if (lang == 'system') {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return switch(lang) {
|
return switch (lang) {
|
||||||
'zh-CN' => const Locale('zh', 'CN'),
|
'zh-CN' => const Locale('zh', 'CN'),
|
||||||
'zh-TW' => const Locale('zh', 'TW'),
|
'zh-TW' => const Locale('zh', 'TW'),
|
||||||
'en-US' => const Locale('en'),
|
'en-US' => const Locale('en'),
|
||||||
@@ -148,7 +149,10 @@ class _MyAppState extends State<MyApp> {
|
|||||||
App.pop,
|
App.pop,
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
child: WindowFrame(widget),
|
child: MouseBackDetector(
|
||||||
|
onTapDown: App.pop,
|
||||||
|
child: WindowFrame(widget),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return _SystemUiProvider(Material(
|
return _SystemUiProvider(Material(
|
||||||
@@ -174,11 +178,13 @@ class _SystemUiProvider extends StatelessWidget {
|
|||||||
systemUiStyle = SystemUiOverlayStyle.dark.copyWith(
|
systemUiStyle = SystemUiOverlayStyle.dark.copyWith(
|
||||||
statusBarColor: Colors.transparent,
|
statusBarColor: Colors.transparent,
|
||||||
systemNavigationBarColor: Colors.transparent,
|
systemNavigationBarColor: Colors.transparent,
|
||||||
|
systemNavigationBarIconBrightness: Brightness.dark,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
systemUiStyle = SystemUiOverlayStyle.light.copyWith(
|
systemUiStyle = SystemUiOverlayStyle.light.copyWith(
|
||||||
statusBarColor: Colors.transparent,
|
statusBarColor: Colors.transparent,
|
||||||
systemNavigationBarColor: Colors.transparent,
|
systemNavigationBarColor: Colors.transparent,
|
||||||
|
systemNavigationBarIconBrightness: Brightness.light,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return AnnotatedRegion<SystemUiOverlayStyle>(
|
return AnnotatedRegion<SystemUiOverlayStyle>(
|
||||||
|
@@ -2,6 +2,7 @@ import 'dart:io';
|
|||||||
|
|
||||||
import 'package:dio/dio.dart';
|
import 'package:dio/dio.dart';
|
||||||
import 'package:sqlite3/sqlite3.dart';
|
import 'package:sqlite3/sqlite3.dart';
|
||||||
|
import 'package:venera/foundation/log.dart';
|
||||||
import 'package:venera/utils/ext.dart';
|
import 'package:venera/utils/ext.dart';
|
||||||
|
|
||||||
class CookieJarSql {
|
class CookieJarSql {
|
||||||
@@ -130,9 +131,17 @@ class CookieJarSql {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void saveFromResponseCookieHeader(Uri uri, List<String> cookieHeader) {
|
void saveFromResponseCookieHeader(Uri uri, List<String> cookieHeader) {
|
||||||
var cookies = cookieHeader
|
var cookies = <Cookie>[];
|
||||||
.map((header) => Cookie.fromSetCookieValue(header))
|
for (var header in cookieHeader) {
|
||||||
.toList();
|
try{
|
||||||
|
var cookie = Cookie.fromSetCookieValue(header);
|
||||||
|
cookies.add(cookie);
|
||||||
|
}
|
||||||
|
catch(_) {
|
||||||
|
Log.warning("Network", "Invalid cookie header: $header");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
saveFromResponse(uri, cookies);
|
saveFromResponse(uri, cookies);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -458,7 +458,7 @@ class _ComicPageState extends LoadingState<ComicPage, ComicDetails>
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget buildRecommend() {
|
Widget buildRecommend() {
|
||||||
if (comic.recommend == null) {
|
if (comic.recommend == null||comic.recommend!.isEmpty) {
|
||||||
return const SliverPadding(padding: EdgeInsets.zero);
|
return const SliverPadding(padding: EdgeInsets.zero);
|
||||||
}
|
}
|
||||||
return SliverMainAxisGroup(slivers: [
|
return SliverMainAxisGroup(slivers: [
|
||||||
|
@@ -699,7 +699,7 @@ class _ImportComicsWidgetState extends State<_ImportComicsWidget> {
|
|||||||
subtitle: '',
|
subtitle: '',
|
||||||
tags: [],
|
tags: [],
|
||||||
directory: directory.name,
|
directory: directory.name,
|
||||||
chapters: Map.fromIterables(chapters, chapters),
|
chapters: hasChapters ? Map.fromIterables(chapters, chapters) : null,
|
||||||
cover: coverPath,
|
cover: coverPath,
|
||||||
comicType: ComicType.local,
|
comicType: ComicType.local,
|
||||||
downloadedChapters: chapters,
|
downloadedChapters: chapters,
|
||||||
|
@@ -12,14 +12,16 @@ class _ReaderGestureDetector extends StatefulWidget {
|
|||||||
class _ReaderGestureDetectorState extends State<_ReaderGestureDetector> {
|
class _ReaderGestureDetectorState extends State<_ReaderGestureDetector> {
|
||||||
late TapGestureRecognizer _tapGestureRecognizer;
|
late TapGestureRecognizer _tapGestureRecognizer;
|
||||||
|
|
||||||
static const _kDoubleTapMinTime = Duration(milliseconds: 200);
|
static const _kDoubleTapMaxTime = Duration(milliseconds: 200);
|
||||||
|
|
||||||
static const _kLongPressMinTime = Duration(milliseconds: 200);
|
static const _kLongPressMinTime = Duration(milliseconds: 250);
|
||||||
|
|
||||||
static const _kDoubleTapMaxDistanceSquared = 20.0 * 20.0;
|
static const _kDoubleTapMaxDistanceSquared = 20.0 * 20.0;
|
||||||
|
|
||||||
static const _kTapToTurnPagePercent = 0.3;
|
static const _kTapToTurnPagePercent = 0.3;
|
||||||
|
|
||||||
|
_DragListener? dragListener;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
_tapGestureRecognizer = TapGestureRecognizer()
|
_tapGestureRecognizer = TapGestureRecognizer()
|
||||||
@@ -28,6 +30,7 @@ class _ReaderGestureDetectorState extends State<_ReaderGestureDetector> {
|
|||||||
onSecondaryTapUp(details.globalPosition);
|
onSecondaryTapUp(details.globalPosition);
|
||||||
};
|
};
|
||||||
super.initState();
|
super.initState();
|
||||||
|
context.readerScaffold._gestureDetectorState = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -38,11 +41,20 @@ class _ReaderGestureDetectorState extends State<_ReaderGestureDetector> {
|
|||||||
_lastTapPointer = event.pointer;
|
_lastTapPointer = event.pointer;
|
||||||
_lastTapMoveDistance = Offset.zero;
|
_lastTapMoveDistance = Offset.zero;
|
||||||
_tapGestureRecognizer.addPointer(event);
|
_tapGestureRecognizer.addPointer(event);
|
||||||
|
if(_dragInProgress) {
|
||||||
|
dragListener?.onEnd?.call();
|
||||||
|
_dragInProgress = false;
|
||||||
|
}
|
||||||
Future.delayed(_kLongPressMinTime, () {
|
Future.delayed(_kLongPressMinTime, () {
|
||||||
if (_lastTapPointer == event.pointer &&
|
if (_lastTapPointer == event.pointer) {
|
||||||
_lastTapMoveDistance!.distanceSquared < 20.0 * 20.0) {
|
if(_lastTapMoveDistance!.distanceSquared < 20.0 * 20.0) {
|
||||||
onLongPressedDown(event.position);
|
onLongPressedDown(event.position);
|
||||||
_longPressInProgress = true;
|
_longPressInProgress = true;
|
||||||
|
} else {
|
||||||
|
_dragInProgress = true;
|
||||||
|
dragListener?.onStart?.call(event.position);
|
||||||
|
dragListener?.onMove?.call(_lastTapMoveDistance!);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@@ -50,11 +62,18 @@ class _ReaderGestureDetectorState extends State<_ReaderGestureDetector> {
|
|||||||
if (event.pointer == _lastTapPointer) {
|
if (event.pointer == _lastTapPointer) {
|
||||||
_lastTapMoveDistance = event.delta + _lastTapMoveDistance!;
|
_lastTapMoveDistance = event.delta + _lastTapMoveDistance!;
|
||||||
}
|
}
|
||||||
|
if(_dragInProgress) {
|
||||||
|
dragListener?.onMove?.call(event.delta);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
onPointerUp: (event) {
|
onPointerUp: (event) {
|
||||||
if (_longPressInProgress) {
|
if (_longPressInProgress) {
|
||||||
onLongPressedUp(event.position);
|
onLongPressedUp(event.position);
|
||||||
}
|
}
|
||||||
|
if(_dragInProgress) {
|
||||||
|
dragListener?.onEnd?.call();
|
||||||
|
_dragInProgress = false;
|
||||||
|
}
|
||||||
_lastTapPointer = null;
|
_lastTapPointer = null;
|
||||||
_lastTapMoveDistance = null;
|
_lastTapMoveDistance = null;
|
||||||
},
|
},
|
||||||
@@ -89,6 +108,8 @@ class _ReaderGestureDetectorState extends State<_ReaderGestureDetector> {
|
|||||||
|
|
||||||
bool _longPressInProgress = false;
|
bool _longPressInProgress = false;
|
||||||
|
|
||||||
|
bool _dragInProgress = false;
|
||||||
|
|
||||||
void onTapUp(TapUpDetails event) {
|
void onTapUp(TapUpDetails event) {
|
||||||
if (_longPressInProgress) {
|
if (_longPressInProgress) {
|
||||||
_longPressInProgress = false;
|
_longPressInProgress = false;
|
||||||
@@ -107,7 +128,7 @@ class _ReaderGestureDetectorState extends State<_ReaderGestureDetector> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
_previousEvent = event;
|
_previousEvent = event;
|
||||||
Future.delayed(_kDoubleTapMinTime, () {
|
Future.delayed(_kDoubleTapMaxTime, () {
|
||||||
if (_previousEvent == event) {
|
if (_previousEvent == event) {
|
||||||
onTap(location);
|
onTap(location);
|
||||||
_previousEvent = null;
|
_previousEvent = null;
|
||||||
@@ -183,25 +204,33 @@ class _ReaderGestureDetectorState extends State<_ReaderGestureDetector> {
|
|||||||
location,
|
location,
|
||||||
[
|
[
|
||||||
MenuEntry(
|
MenuEntry(
|
||||||
text: "Settings".tl,
|
icon: Icons.settings,
|
||||||
onClick: () {
|
text: "Settings".tl,
|
||||||
context.readerScaffold.openSetting();
|
onClick: () {
|
||||||
}),
|
context.readerScaffold.openSetting();
|
||||||
|
},
|
||||||
|
),
|
||||||
MenuEntry(
|
MenuEntry(
|
||||||
text: "Chapters".tl,
|
icon: Icons.menu,
|
||||||
onClick: () {
|
text: "Chapters".tl,
|
||||||
context.readerScaffold.openChapterDrawer();
|
onClick: () {
|
||||||
}),
|
context.readerScaffold.openChapterDrawer();
|
||||||
|
},
|
||||||
|
),
|
||||||
MenuEntry(
|
MenuEntry(
|
||||||
text: "Fullscreen".tl,
|
icon: Icons.fullscreen,
|
||||||
onClick: () {
|
text: "Fullscreen".tl,
|
||||||
context.reader.fullscreen();
|
onClick: () {
|
||||||
}),
|
context.reader.fullscreen();
|
||||||
|
},
|
||||||
|
),
|
||||||
MenuEntry(
|
MenuEntry(
|
||||||
text: "Exit".tl,
|
icon: Icons.exit_to_app,
|
||||||
onClick: () {
|
text: "Exit".tl,
|
||||||
context.pop();
|
onClick: () {
|
||||||
}),
|
context.pop();
|
||||||
|
},
|
||||||
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -214,3 +243,11 @@ class _ReaderGestureDetectorState extends State<_ReaderGestureDetector> {
|
|||||||
context.reader._imageViewController?.handleLongPressDown(location);
|
context.reader._imageViewController?.handleLongPressDown(location);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class _DragListener {
|
||||||
|
void Function(Offset point)? onStart;
|
||||||
|
void Function(Offset offset)? onMove;
|
||||||
|
void Function()? onEnd;
|
||||||
|
|
||||||
|
_DragListener({this.onStart, this.onMove, this.onEnd});
|
||||||
|
}
|
@@ -116,6 +116,9 @@ class _GalleryModeState extends State<_GalleryMode>
|
|||||||
controller = PageController(initialPage: reader.page);
|
controller = PageController(initialPage: reader.page);
|
||||||
reader._imageViewController = this;
|
reader._imageViewController = this;
|
||||||
cached = List.filled(reader.maxPage + 2, false);
|
cached = List.filled(reader.maxPage + 2, false);
|
||||||
|
Future.microtask(() {
|
||||||
|
context.readerScaffold.setFloatingButton(0);
|
||||||
|
});
|
||||||
super.initState();
|
super.initState();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -180,11 +183,11 @@ class _GalleryModeState extends State<_GalleryMode>
|
|||||||
),
|
),
|
||||||
onPageChanged: (i) {
|
onPageChanged: (i) {
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
if (!reader.toNextChapter()) {
|
if (!reader.toPrevChapter()) {
|
||||||
reader.toPage(1);
|
reader.toPage(1);
|
||||||
}
|
}
|
||||||
} else if (i == reader.maxPage + 1) {
|
} else if (i == reader.maxPage + 1) {
|
||||||
if (!reader.toPrevChapter()) {
|
if (!reader.toNextChapter()) {
|
||||||
reader.toPage(reader.maxPage);
|
reader.toPage(reader.maxPage);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@@ -2,6 +2,7 @@ library venera_reader;
|
|||||||
|
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/gestures.dart';
|
import 'package:flutter/gestures.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/rendering.dart';
|
import 'package:flutter/rendering.dart';
|
||||||
@@ -105,6 +106,7 @@ class _ReaderState extends State<Reader> with _ReaderLocation, _ReaderWindow {
|
|||||||
Future.microtask(() {
|
Future.microtask(() {
|
||||||
updateHistory();
|
updateHistory();
|
||||||
});
|
});
|
||||||
|
SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersive);
|
||||||
super.initState();
|
super.initState();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -112,6 +114,7 @@ class _ReaderState extends State<Reader> with _ReaderLocation, _ReaderWindow {
|
|||||||
void dispose() {
|
void dispose() {
|
||||||
autoPageTurningTimer?.cancel();
|
autoPageTurningTimer?.cancel();
|
||||||
focusNode.dispose();
|
focusNode.dispose();
|
||||||
|
SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge);
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -20,21 +20,68 @@ class _ReaderScaffoldState extends State<_ReaderScaffold> {
|
|||||||
|
|
||||||
int showFloatingButtonValue = 0;
|
int showFloatingButtonValue = 0;
|
||||||
|
|
||||||
double fABValue = 0;
|
var lastValue = 0;
|
||||||
|
|
||||||
|
var fABValue = ValueNotifier<double>(0);
|
||||||
|
|
||||||
|
_ReaderGestureDetectorState? _gestureDetectorState;
|
||||||
|
|
||||||
void setFloatingButton(int value) {
|
void setFloatingButton(int value) {
|
||||||
|
lastValue = showFloatingButtonValue;
|
||||||
if (value == 0) {
|
if (value == 0) {
|
||||||
if (showFloatingButtonValue != 0) {
|
if (showFloatingButtonValue != 0) {
|
||||||
showFloatingButtonValue = 0;
|
showFloatingButtonValue = 0;
|
||||||
fABValue = 0;
|
fABValue.value = 0;
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
_gestureDetectorState!.dragListener = null;
|
||||||
}
|
}
|
||||||
|
var readerMode = context.reader.mode;
|
||||||
if (value == 1 && showFloatingButtonValue == 0) {
|
if (value == 1 && showFloatingButtonValue == 0) {
|
||||||
showFloatingButtonValue = 1;
|
showFloatingButtonValue = 1;
|
||||||
|
_gestureDetectorState!.dragListener = _DragListener(
|
||||||
|
onMove: (offset) {
|
||||||
|
if (readerMode == ReaderMode.continuousTopToBottom) {
|
||||||
|
fABValue.value -= offset.dy;
|
||||||
|
} else if (readerMode == ReaderMode.continuousLeftToRight) {
|
||||||
|
fABValue.value -= offset.dx;
|
||||||
|
} else if (readerMode == ReaderMode.continuousRightToLeft) {
|
||||||
|
fABValue.value += offset.dx;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onEnd: () {
|
||||||
|
if (fABValue.value.abs() > 58 * 3) {
|
||||||
|
setState(() {
|
||||||
|
showFloatingButtonValue = 0;
|
||||||
|
});
|
||||||
|
context.reader.toNextChapter();
|
||||||
|
}
|
||||||
|
fABValue.value = 0;
|
||||||
|
},
|
||||||
|
);
|
||||||
update();
|
update();
|
||||||
} else if (value == -1 && showFloatingButtonValue == 0) {
|
} else if (value == -1 && showFloatingButtonValue == 0) {
|
||||||
showFloatingButtonValue = -1;
|
showFloatingButtonValue = -1;
|
||||||
|
_gestureDetectorState!.dragListener = _DragListener(
|
||||||
|
onMove: (offset) {
|
||||||
|
if (readerMode == ReaderMode.continuousTopToBottom) {
|
||||||
|
fABValue.value += offset.dy;
|
||||||
|
} else if (readerMode == ReaderMode.continuousLeftToRight) {
|
||||||
|
fABValue.value += offset.dx;
|
||||||
|
} else if (readerMode == ReaderMode.continuousRightToLeft) {
|
||||||
|
fABValue.value -= offset.dx;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onEnd: () {
|
||||||
|
if (fABValue.value.abs() > 58 * 3) {
|
||||||
|
setState(() {
|
||||||
|
showFloatingButtonValue = 0;
|
||||||
|
});
|
||||||
|
context.reader.toPrevChapter();
|
||||||
|
}
|
||||||
|
fABValue.value = 0;
|
||||||
|
},
|
||||||
|
);
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -47,6 +94,9 @@ class _ReaderScaffoldState extends State<_ReaderScaffold> {
|
|||||||
sliderFocus.nextFocus();
|
sliderFocus.nextFocus();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
if (rotation != null) {
|
||||||
|
SystemChrome.setPreferredOrientations(DeviceOrientation.values);
|
||||||
|
}
|
||||||
super.initState();
|
super.initState();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,6 +107,11 @@ class _ReaderScaffoldState extends State<_ReaderScaffold> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void openOrClose() {
|
void openOrClose() {
|
||||||
|
if(!_isOpen) {
|
||||||
|
SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge);
|
||||||
|
} else {
|
||||||
|
SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersive);
|
||||||
|
}
|
||||||
setState(() {
|
setState(() {
|
||||||
_isOpen = !_isOpen;
|
_isOpen = !_isOpen;
|
||||||
});
|
});
|
||||||
@@ -76,6 +131,12 @@ class _ReaderScaffoldState extends State<_ReaderScaffold> {
|
|||||||
child: widget.child,
|
child: widget.child,
|
||||||
),
|
),
|
||||||
buildPageInfoText(),
|
buildPageInfoText(),
|
||||||
|
AnimatedPositioned(
|
||||||
|
duration: const Duration(milliseconds: 180),
|
||||||
|
right: 16,
|
||||||
|
bottom: showFloatingButtonValue == 0 ? -58 : 16,
|
||||||
|
child: buildEpChangeButton(),
|
||||||
|
),
|
||||||
AnimatedPositioned(
|
AnimatedPositioned(
|
||||||
duration: const Duration(milliseconds: 180),
|
duration: const Duration(milliseconds: 180),
|
||||||
top: _isOpen ? 0 : -(kTopBarHeight + context.padding.top),
|
top: _isOpen ? 0 : -(kTopBarHeight + context.padding.top),
|
||||||
@@ -86,18 +147,11 @@ class _ReaderScaffoldState extends State<_ReaderScaffold> {
|
|||||||
),
|
),
|
||||||
AnimatedPositioned(
|
AnimatedPositioned(
|
||||||
duration: const Duration(milliseconds: 180),
|
duration: const Duration(milliseconds: 180),
|
||||||
bottom: _isOpen ? 0 : -(kBottomBarHeight + context.padding.bottom),
|
bottom: _isOpen ? 0 : -kBottomBarHeight,
|
||||||
left: 0,
|
left: 0,
|
||||||
right: 0,
|
right: 0,
|
||||||
height: kBottomBarHeight + context.padding.bottom,
|
|
||||||
child: buildBottom(),
|
child: buildBottom(),
|
||||||
),
|
),
|
||||||
AnimatedPositioned(
|
|
||||||
duration: const Duration(milliseconds: 180),
|
|
||||||
right: 16,
|
|
||||||
bottom: showFloatingButtonValue == 0 ? -58 : 16,
|
|
||||||
child: buildEpChangeButton(),
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -150,7 +204,7 @@ class _ReaderScaffoldState extends State<_ReaderScaffold> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget child = SizedBox(
|
Widget child = SizedBox(
|
||||||
height: kBottomBarHeight + MediaQuery.of(context).padding.bottom,
|
height: kBottomBarHeight,
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
@@ -160,14 +214,34 @@ class _ReaderScaffoldState extends State<_ReaderScaffold> {
|
|||||||
children: [
|
children: [
|
||||||
const SizedBox(width: 8),
|
const SizedBox(width: 8),
|
||||||
IconButton.filledTonal(
|
IconButton.filledTonal(
|
||||||
onPressed: context.reader.toPrevChapter,
|
onPressed: () {
|
||||||
|
if (!context.reader.toPrevChapter()) {
|
||||||
|
context.reader.toPage(1);
|
||||||
|
} else {
|
||||||
|
if(showFloatingButtonValue != 0) {
|
||||||
|
setState(() {
|
||||||
|
showFloatingButtonValue = 0;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
icon: const Icon(Icons.first_page),
|
icon: const Icon(Icons.first_page),
|
||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: buildSlider(),
|
child: buildSlider(),
|
||||||
),
|
),
|
||||||
IconButton.filledTonal(
|
IconButton.filledTonal(
|
||||||
onPressed: context.reader.toNextChapter,
|
onPressed: () {
|
||||||
|
if (!context.reader.toNextChapter()) {
|
||||||
|
context.reader.toPage(context.reader.maxPage);
|
||||||
|
} else {
|
||||||
|
if(showFloatingButtonValue != 0) {
|
||||||
|
setState(() {
|
||||||
|
showFloatingButtonValue = 0;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
icon: const Icon(Icons.last_page)),
|
icon: const Icon(Icons.last_page)),
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
width: 8,
|
width: 8,
|
||||||
@@ -359,8 +433,8 @@ class _ReaderScaffoldState extends State<_ReaderScaffold> {
|
|||||||
if (imageKey.startsWith("file://")) {
|
if (imageKey.startsWith("file://")) {
|
||||||
return await File(imageKey.substring(7)).readAsBytes();
|
return await File(imageKey.substring(7)).readAsBytes();
|
||||||
} else {
|
} else {
|
||||||
return (await CacheManager()
|
return (await CacheManager().findCache(
|
||||||
.findCache("$imageKey@${context.reader.type.sourceKey}@${context.reader.cid}@${context.reader.eid}"))!
|
"$imageKey@${context.reader.type.sourceKey}@${context.reader.cid}@${context.reader.eid}"))!
|
||||||
.readAsBytes();
|
.readAsBytes();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -402,11 +476,6 @@ class _ReaderScaffoldState extends State<_ReaderScaffold> {
|
|||||||
Widget buildEpChangeButton() {
|
Widget buildEpChangeButton() {
|
||||||
if (context.reader.widget.chapters == null) return const SizedBox();
|
if (context.reader.widget.chapters == null) return const SizedBox();
|
||||||
switch (showFloatingButtonValue) {
|
switch (showFloatingButtonValue) {
|
||||||
case -1:
|
|
||||||
return FloatingActionButton(
|
|
||||||
onPressed: () => context.reader.toPrevChapter(),
|
|
||||||
child: const Icon(Icons.arrow_back_ios_outlined),
|
|
||||||
);
|
|
||||||
case 0:
|
case 0:
|
||||||
return Container(
|
return Container(
|
||||||
width: 58,
|
width: 58,
|
||||||
@@ -417,11 +486,14 @@ class _ReaderScaffoldState extends State<_ReaderScaffold> {
|
|||||||
borderRadius: BorderRadius.circular(16),
|
borderRadius: BorderRadius.circular(16),
|
||||||
),
|
),
|
||||||
child: Icon(
|
child: Icon(
|
||||||
Icons.arrow_forward_ios,
|
lastValue == 1
|
||||||
|
? Icons.arrow_forward_ios
|
||||||
|
: Icons.arrow_back_ios_outlined,
|
||||||
size: 24,
|
size: 24,
|
||||||
color: Theme.of(context).colorScheme.onPrimaryContainer,
|
color: Theme.of(context).colorScheme.onPrimaryContainer,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
case -1:
|
||||||
case 1:
|
case 1:
|
||||||
return Container(
|
return Container(
|
||||||
width: 58,
|
width: 58,
|
||||||
@@ -431,37 +503,54 @@ class _ReaderScaffoldState extends State<_ReaderScaffold> {
|
|||||||
color: Theme.of(context).colorScheme.primaryContainer,
|
color: Theme.of(context).colorScheme.primaryContainer,
|
||||||
borderRadius: BorderRadius.circular(16),
|
borderRadius: BorderRadius.circular(16),
|
||||||
),
|
),
|
||||||
child: Stack(
|
child: ValueListenableBuilder(
|
||||||
children: [
|
valueListenable: fABValue,
|
||||||
Positioned.fill(
|
builder: (context, value, child) {
|
||||||
child: Material(
|
return Stack(
|
||||||
color: Colors.transparent,
|
children: [
|
||||||
child: InkWell(
|
Positioned.fill(
|
||||||
onTap: () => context.reader.toNextChapter(),
|
child: Material(
|
||||||
borderRadius: BorderRadius.circular(16),
|
color: Colors.transparent,
|
||||||
child: Center(
|
child: InkWell(
|
||||||
child: Icon(
|
onTap: () {
|
||||||
Icons.arrow_forward_ios,
|
setFloatingButton(0);
|
||||||
size: 24,
|
if (showFloatingButtonValue == 1) {
|
||||||
color: Theme.of(context).colorScheme.onPrimaryContainer,
|
context.reader.toNextChapter();
|
||||||
)),
|
} else {
|
||||||
|
context.reader.toPrevChapter();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
borderRadius: BorderRadius.circular(16),
|
||||||
|
child: Center(
|
||||||
|
child: Icon(
|
||||||
|
showFloatingButtonValue == 1
|
||||||
|
? Icons.arrow_forward_ios
|
||||||
|
: Icons.arrow_back_ios_outlined,
|
||||||
|
size: 24,
|
||||||
|
color: Theme.of(context)
|
||||||
|
.colorScheme
|
||||||
|
.onPrimaryContainer,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
Positioned(
|
||||||
),
|
bottom: 0,
|
||||||
Positioned(
|
left: 0,
|
||||||
bottom: 0,
|
right: 0,
|
||||||
left: 0,
|
height: value.clamp(0, 58*3) / 3,
|
||||||
right: 0,
|
child: ColoredBox(
|
||||||
height: fABValue,
|
color: Theme.of(context)
|
||||||
child: ColoredBox(
|
.colorScheme
|
||||||
color: Theme.of(context)
|
.surfaceTint
|
||||||
.colorScheme
|
.withOpacity(0.2),
|
||||||
.surfaceTint
|
child: const SizedBox.expand(),
|
||||||
.withOpacity(0.2),
|
),
|
||||||
child: const SizedBox.expand(),
|
),
|
||||||
),
|
],
|
||||||
)
|
);
|
||||||
],
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@@ -2,7 +2,7 @@ name: venera
|
|||||||
description: "A comic app."
|
description: "A comic app."
|
||||||
publish_to: 'none'
|
publish_to: 'none'
|
||||||
|
|
||||||
version: 1.0.0-beta+1
|
version: 1.0.0+1
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: '>=3.5.0 <4.0.0'
|
sdk: '>=3.5.0 <4.0.0'
|
||||||
|
Reference in New Issue
Block a user