mirror of
https://github.com/venera-app/venera.git
synced 2025-09-27 15:57:25 +00:00
Display number on local favorites.
This commit is contained in:
@@ -396,7 +396,7 @@ class ImageFavoriteManager with ChangeNotifier {
|
|||||||
var token = ServicesBinding.rootIsolateToken!;
|
var token = ServicesBinding.rootIsolateToken!;
|
||||||
var count = ImageFavoriteManager().length;
|
var count = ImageFavoriteManager().length;
|
||||||
if (count == 0) {
|
if (count == 0) {
|
||||||
return Future.value(ImageFavoritesComputed([], [], []));
|
return Future.value(ImageFavoritesComputed([], [], [], 0));
|
||||||
} else if (count > 100) {
|
} else if (count > 100) {
|
||||||
return Isolate.run(() async {
|
return Isolate.run(() async {
|
||||||
BackgroundIsolateBinaryMessenger.ensureInitialized(token);
|
BackgroundIsolateBinaryMessenger.ensureInitialized(token);
|
||||||
@@ -436,8 +436,10 @@ class ImageFavoriteManager with ChangeNotifier {
|
|||||||
Map<String, int> authorCount = {};
|
Map<String, int> authorCount = {};
|
||||||
Map<ImageFavoritesComic, int> comicImageCount = {};
|
Map<ImageFavoritesComic, int> comicImageCount = {};
|
||||||
Map<ImageFavoritesComic, int> comicMaxPages = {};
|
Map<ImageFavoritesComic, int> comicMaxPages = {};
|
||||||
|
int count = 0;
|
||||||
|
|
||||||
for (var comic in comics) {
|
for (var comic in comics) {
|
||||||
|
count += comic.images.length;
|
||||||
for (var tag in comic.tags) {
|
for (var tag in comic.tags) {
|
||||||
String finalTag = tag;
|
String finalTag = tag;
|
||||||
tagCount[finalTag] = (tagCount[finalTag] ?? 0) + 1;
|
tagCount[finalTag] = (tagCount[finalTag] ?? 0) + 1;
|
||||||
@@ -492,6 +494,7 @@ class ImageFavoriteManager with ChangeNotifier {
|
|||||||
.map((comic) => TextWithCount(comic.key.title, comic.value))
|
.map((comic) => TextWithCount(comic.key.title, comic.value))
|
||||||
.take(maxLength)
|
.take(maxLength)
|
||||||
.toList(),
|
.toList(),
|
||||||
|
count,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -524,11 +527,14 @@ class ImageFavoritesComputed {
|
|||||||
/// 基于喜欢的图片数排序
|
/// 基于喜欢的图片数排序
|
||||||
final List<TextWithCount> comics;
|
final List<TextWithCount> comics;
|
||||||
|
|
||||||
|
final int count;
|
||||||
|
|
||||||
/// 计算后的图片收藏数据
|
/// 计算后的图片收藏数据
|
||||||
const ImageFavoritesComputed(
|
const ImageFavoritesComputed(
|
||||||
this.tags,
|
this.tags,
|
||||||
this.authors,
|
this.authors,
|
||||||
this.comics,
|
this.comics,
|
||||||
|
this.count,
|
||||||
);
|
);
|
||||||
|
|
||||||
bool get isEmpty => tags.isEmpty && authors.isEmpty && comics.isEmpty;
|
bool get isEmpty => tags.isEmpty && authors.isEmpty && comics.isEmpty;
|
||||||
|
@@ -823,6 +823,20 @@ class _ImageFavoritesState extends State<ImageFavorites> {
|
|||||||
Center(
|
Center(
|
||||||
child: Text('Image Favorites'.tl, style: ts.s18),
|
child: Text('Image Favorites'.tl, style: ts.s18),
|
||||||
),
|
),
|
||||||
|
if (hasData)
|
||||||
|
Container(
|
||||||
|
margin: const EdgeInsets.symmetric(horizontal: 8),
|
||||||
|
padding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 8, vertical: 2),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Theme.of(context).colorScheme.secondaryContainer,
|
||||||
|
borderRadius: BorderRadius.circular(8),
|
||||||
|
),
|
||||||
|
child: Text(
|
||||||
|
imageFavoritesCompute!.count.toString(),
|
||||||
|
style: ts.s12,
|
||||||
|
),
|
||||||
|
),
|
||||||
const Spacer(),
|
const Spacer(),
|
||||||
const Icon(Icons.arrow_right),
|
const Icon(Icons.arrow_right),
|
||||||
],
|
],
|
||||||
|
Reference in New Issue
Block a user