Merge pull request #594 from lings03/favorite

Optimize favorite page and home page.
This commit is contained in:
ynyx631
2025-11-01 12:29:42 +08:00
committed by GitHub
6 changed files with 173 additions and 84 deletions

View File

@@ -689,7 +689,7 @@ class _LocalFavoritesPageState extends State<_LocalFavoritesPage> {
),
];
},
onTap: (c) {
onTap: (c, heroID) {
if (multiSelectMode) {
setState(() {
if (selectedComics.containsKey(c as FavoriteItem)) {
@@ -701,20 +701,24 @@ class _LocalFavoritesPageState extends State<_LocalFavoritesPage> {
lastSelectedIndex = comics.indexOf(c);
});
} else if (appdata.settings["onClickFavorite"] == "viewDetail") {
App.mainNavigatorKey?.currentContext
?.to(() => ComicPage(id: c.id, sourceKey: c.sourceKey));
} else {
App.mainNavigatorKey?.currentContext?.to(
() => ReaderWithLoading(
() => ComicPage(
id: c.id,
sourceKey: c.sourceKey,
cover: c.cover,
title: c.title,
heroID: heroID,
),
enableIOSGesture: false,
iosFullScreenGesture: false,
);
} else {
App.mainNavigatorKey?.currentContext?.to(
() => ReaderWithLoading(id: c.id, sourceKey: c.sourceKey),
);
}
},
onLongPressed: (c) {
onLongPressed: (c, heroID) {
setState(() {
if (!multiSelectMode) {
multiSelectMode = true;

View File

@@ -211,7 +211,7 @@ class _HistoryPageState extends State<HistoryPage> {
selections: selectedComics,
onLongPressed: null,
onTap: multiSelectMode
? (c) {
? (c, heroID) {
setState(() {
if (selectedComics.containsKey(c as History)) {
selectedComics.remove(c);

View File

@@ -302,13 +302,18 @@ class _HistoryState extends State<_History> {
scrollDirection: Axis.horizontal,
itemCount: history.length,
itemBuilder: (context, index) {
final heroID = history[index].id.hashCode;
return SimpleComicTile(
comic: history[index],
heroID: heroID,
onTap: () {
context.to(
() => ComicPage(
id: history[index].id,
sourceKey: history[index].type.sourceKey,
cover: history[index].cover,
title: history[index].title,
heroID: heroID,
),
);
},
@@ -386,7 +391,9 @@ class _LocalState extends State<_Local> {
Container(
margin: const EdgeInsets.symmetric(horizontal: 8),
padding: const EdgeInsets.symmetric(
horizontal: 8, vertical: 2),
horizontal: 8,
vertical: 2,
),
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.secondaryContainer,
borderRadius: BorderRadius.circular(8),
@@ -405,9 +412,22 @@ class _LocalState extends State<_Local> {
scrollDirection: Axis.horizontal,
itemCount: local.length,
itemBuilder: (context, index) {
return SimpleComicTile(comic: local[index])
.paddingHorizontal(8)
.paddingVertical(2);
final heroID = local[index].id.hashCode;
return SimpleComicTile(
comic: local[index],
heroID: heroID,
onTap: () {
context.to(
() => ComicPage(
id: local[index].id,
sourceKey: local[index].sourceKey,
cover: local[index].cover,
title: local[index].title,
heroID: heroID,
),
);
},
).paddingHorizontal(8).paddingVertical(2);
},
),
).paddingHorizontal(8),

View File

@@ -285,13 +285,13 @@ class _LocalComicsPageState extends State<LocalComicsPage> {
SliverGridComics(
comics: comics,
selections: selectedComics,
onLongPressed: (c) {
onLongPressed: (c, heroID) {
setState(() {
multiSelectMode = true;
selectedComics[c as LocalComic] = true;
});
},
onTap: (c) {
onTap: (c, heroID) {
if (multiSelectMode) {
setState(() {
if (selectedComics.containsKey(c as LocalComic)) {