mirror of
https://github.com/venera-app/venera.git
synced 2025-09-28 00:07:24 +00:00
fix local comic display
This commit is contained in:
@@ -72,6 +72,8 @@ class _ComicPageState extends LoadingState<ComicPage, ComicDetails>
|
||||
}
|
||||
}
|
||||
|
||||
var isFirst = true;
|
||||
|
||||
@override
|
||||
Widget buildContent(BuildContext context, ComicDetails data) {
|
||||
return SmoothCustomScrollView(
|
||||
@@ -91,8 +93,37 @@ class _ComicPageState extends LoadingState<ComicPage, ComicDetails>
|
||||
|
||||
@override
|
||||
Future<Res<ComicDetails>> loadData() async {
|
||||
if (widget.sourceKey == 'local') {
|
||||
var localComic = LocalManager().find(widget.id, ComicType.local);
|
||||
if (localComic == null) {
|
||||
return const Res.error('Local comic not found');
|
||||
}
|
||||
var history = await HistoryManager().find(widget.id, ComicType.local);
|
||||
if(isFirst) {
|
||||
Future.microtask(() {
|
||||
App.rootContext.to(() {
|
||||
return Reader(
|
||||
type: ComicType.local,
|
||||
cid: widget.id,
|
||||
name: localComic.title,
|
||||
chapters: localComic.chapters,
|
||||
history: history ??
|
||||
History.fromModel(
|
||||
model: localComic,
|
||||
ep: 0,
|
||||
page: 0,
|
||||
),
|
||||
);
|
||||
});
|
||||
App.mainNavigatorKey!.currentContext!.pop();
|
||||
});
|
||||
isFirst = false;
|
||||
}
|
||||
await Future.delayed(const Duration(milliseconds: 200));
|
||||
return const Res.error('Local comic');
|
||||
}
|
||||
var comicSource = ComicSource.find(widget.sourceKey);
|
||||
if(comicSource == null) {
|
||||
if (comicSource == null) {
|
||||
return const Res.error('Comic source not found');
|
||||
}
|
||||
isAddToLocalFav = LocalFavoritesManager().isExist(
|
||||
@@ -101,7 +132,7 @@ class _ComicPageState extends LoadingState<ComicPage, ComicDetails>
|
||||
);
|
||||
history = await HistoryManager()
|
||||
.find(widget.id, ComicType(widget.sourceKey.hashCode));
|
||||
return comicSource!.loadComicInfo!(widget.id);
|
||||
return comicSource.loadComicInfo!(widget.id);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -500,7 +531,11 @@ abstract mixin class _ComicPageActions {
|
||||
}
|
||||
|
||||
void share() {
|
||||
Share.shareText(comic.title);
|
||||
var text = comic.title;
|
||||
if (comic.url != null) {
|
||||
text += '\n${comic.url}';
|
||||
}
|
||||
Share.shareText(text);
|
||||
}
|
||||
|
||||
/// read the comic
|
||||
@@ -694,8 +729,7 @@ abstract mixin class _ComicPageActions {
|
||||
setState(() {
|
||||
isLoading = true;
|
||||
});
|
||||
comicSource.starRatingFunc!
|
||||
(comic.id, rating.round())
|
||||
comicSource.starRatingFunc!(comic.id, rating.round())
|
||||
.then((value) {
|
||||
if (value.success) {
|
||||
App.rootContext
|
||||
|
@@ -66,7 +66,16 @@ class _ExplorePageState extends State<ExplorePage>
|
||||
return NetworkError(
|
||||
message: "No Explore Pages".tl,
|
||||
retry: () {
|
||||
setState(() {});
|
||||
setState(() {
|
||||
pages = ComicSource.all()
|
||||
.map((e) => e.explorePages)
|
||||
.expand((e) => e.map((e) => e.title))
|
||||
.toList();
|
||||
controller = TabController(
|
||||
length: pages.length,
|
||||
vsync: this,
|
||||
);
|
||||
});
|
||||
},
|
||||
withAppbar: false,
|
||||
);
|
||||
|
@@ -98,7 +98,7 @@ void addFavorite(Comic comic) {
|
||||
name: comic.title,
|
||||
coverPath: comic.cover,
|
||||
author: comic.subtitle ?? '',
|
||||
type: ComicType(comic.sourceKey.hashCode),
|
||||
type: ComicType((comic.sourceKey == 'local' ? 0 : comic.sourceKey.hashCode)),
|
||||
tags: comic.tags ?? [],
|
||||
),
|
||||
);
|
||||
|
@@ -4,6 +4,8 @@ import 'package:venera/foundation/app.dart';
|
||||
import 'package:venera/foundation/comic_source/comic_source.dart';
|
||||
import 'package:venera/foundation/comic_type.dart';
|
||||
import 'package:venera/foundation/history.dart';
|
||||
import 'package:venera/foundation/local.dart';
|
||||
import 'package:venera/utils/ext.dart';
|
||||
import 'package:venera/utils/translations.dart';
|
||||
|
||||
class HistoryPage extends StatefulWidget {
|
||||
@@ -78,9 +80,19 @@ class _HistoryPageState extends State<HistoryPage> {
|
||||
SliverGridComics(
|
||||
comics: comics.map(
|
||||
(e) {
|
||||
var cover = e.cover;
|
||||
if (!cover.isURL) {
|
||||
var localComic = LocalManager().find(
|
||||
e.id,
|
||||
e.type,
|
||||
);
|
||||
if(localComic != null) {
|
||||
cover = "file://${localComic.coverFile.path}";
|
||||
}
|
||||
}
|
||||
return Comic(
|
||||
e.title,
|
||||
e.cover,
|
||||
cover,
|
||||
e.id,
|
||||
e.subtitle,
|
||||
null,
|
||||
@@ -100,7 +112,7 @@ class _HistoryPageState extends State<HistoryPage> {
|
||||
icon: Icons.remove,
|
||||
text: 'Remove'.tl,
|
||||
onClick: () {
|
||||
if(c.sourceKey.startsWith("Invalid")) {
|
||||
if (c.sourceKey.startsWith("Invalid")) {
|
||||
HistoryManager().remove(
|
||||
c.id,
|
||||
ComicType(int.parse(c.sourceKey.split(':')[1])),
|
||||
|
@@ -15,6 +15,7 @@ import 'package:venera/pages/comic_source_page.dart';
|
||||
import 'package:venera/pages/downloading_page.dart';
|
||||
import 'package:venera/pages/history_page.dart';
|
||||
import 'package:venera/pages/search_page.dart';
|
||||
import 'package:venera/utils/ext.dart';
|
||||
import 'package:venera/utils/io.dart';
|
||||
import 'package:venera/utils/translations.dart';
|
||||
|
||||
@@ -155,12 +156,26 @@ class _HistoryState extends State<_History> {
|
||||
scrollDirection: Axis.horizontal,
|
||||
itemCount: history.length,
|
||||
itemBuilder: (context, index) {
|
||||
var cover = history[index].cover;
|
||||
ImageProvider imageProvider = CachedImageProvider(
|
||||
cover,
|
||||
sourceKey: history[index].type.comicSource?.key,
|
||||
);
|
||||
if (!cover.isURL) {
|
||||
var localComic = LocalManager().find(
|
||||
history[index].id,
|
||||
history[index].type,
|
||||
);
|
||||
if (localComic != null) {
|
||||
imageProvider = FileImage(localComic.coverFile);
|
||||
}
|
||||
}
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
context.to(
|
||||
() => ComicPage(
|
||||
id: history[index].id,
|
||||
sourceKey: history[index].type.comicSource!.key,
|
||||
sourceKey: history[index].type.sourceKey,
|
||||
),
|
||||
);
|
||||
},
|
||||
@@ -177,10 +192,7 @@ class _HistoryState extends State<_History> {
|
||||
),
|
||||
clipBehavior: Clip.antiAlias,
|
||||
child: AnimatedImage(
|
||||
image: CachedImageProvider(
|
||||
history[index].cover,
|
||||
sourceKey: history[index].type.comicSource?.key,
|
||||
),
|
||||
image: imageProvider,
|
||||
width: 96,
|
||||
height: 128,
|
||||
fit: BoxFit.cover,
|
||||
|
@@ -196,7 +196,7 @@ class _SearchPageState extends State<SearchPage> {
|
||||
runSpacing: 8,
|
||||
children: sources.map((e) {
|
||||
return OptionChip(
|
||||
text: e.name.tl,
|
||||
text: e.name,
|
||||
isSelected: searchTarget == e.key,
|
||||
onTap: () {
|
||||
setState(() {
|
||||
|
Reference in New Issue
Block a user