mirror of
https://github.com/kodjodevf/mangayomi.git
synced 2026-04-21 11:51:57 +00:00
add library categories sort
This commit is contained in:
parent
3f1470ec99
commit
b4c9278ffe
14 changed files with 736 additions and 1057 deletions
|
|
@ -31,7 +31,7 @@ class Manga {
|
|||
|
||||
int? lastUpdate;
|
||||
|
||||
String? lastRead;
|
||||
int? lastRead;
|
||||
|
||||
List<int>? categories;
|
||||
|
||||
|
|
@ -53,6 +53,6 @@ class Manga {
|
|||
this.dateAdded,
|
||||
this.lastUpdate,
|
||||
this.categories,
|
||||
this.lastRead,
|
||||
this.lastRead = 0,
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ const MangaSchema = CollectionSchema(
|
|||
r'lastRead': PropertySchema(
|
||||
id: 8,
|
||||
name: r'lastRead',
|
||||
type: IsarType.string,
|
||||
type: IsarType.long,
|
||||
),
|
||||
r'lastUpdate': PropertySchema(
|
||||
id: 9,
|
||||
|
|
@ -158,12 +158,6 @@ int _mangaEstimateSize(
|
|||
bytesCount += 3 + value.length * 3;
|
||||
}
|
||||
}
|
||||
{
|
||||
final value = object.lastRead;
|
||||
if (value != null) {
|
||||
bytesCount += 3 + value.length * 3;
|
||||
}
|
||||
}
|
||||
{
|
||||
final value = object.link;
|
||||
if (value != null) {
|
||||
|
|
@ -205,7 +199,7 @@ void _mangaSerialize(
|
|||
writer.writeStringList(offsets[5], object.genre);
|
||||
writer.writeString(offsets[6], object.imageUrl);
|
||||
writer.writeString(offsets[7], object.lang);
|
||||
writer.writeString(offsets[8], object.lastRead);
|
||||
writer.writeLong(offsets[8], object.lastRead);
|
||||
writer.writeLong(offsets[9], object.lastUpdate);
|
||||
writer.writeString(offsets[10], object.link);
|
||||
writer.writeString(offsets[11], object.name);
|
||||
|
|
@ -229,7 +223,7 @@ Manga _mangaDeserialize(
|
|||
id: id,
|
||||
imageUrl: reader.readStringOrNull(offsets[6]),
|
||||
lang: reader.readStringOrNull(offsets[7]),
|
||||
lastRead: reader.readStringOrNull(offsets[8]),
|
||||
lastRead: reader.readLongOrNull(offsets[8]),
|
||||
lastUpdate: reader.readLongOrNull(offsets[9]),
|
||||
link: reader.readStringOrNull(offsets[10]),
|
||||
name: reader.readStringOrNull(offsets[11]),
|
||||
|
|
@ -263,7 +257,7 @@ P _mangaDeserializeProp<P>(
|
|||
case 7:
|
||||
return (reader.readStringOrNull(offset)) as P;
|
||||
case 8:
|
||||
return (reader.readStringOrNull(offset)) as P;
|
||||
return (reader.readLongOrNull(offset)) as P;
|
||||
case 9:
|
||||
return (reader.readLongOrNull(offset)) as P;
|
||||
case 10:
|
||||
|
|
@ -1497,54 +1491,46 @@ extension MangaQueryFilter on QueryBuilder<Manga, Manga, QFilterCondition> {
|
|||
}
|
||||
|
||||
QueryBuilder<Manga, Manga, QAfterFilterCondition> lastReadEqualTo(
|
||||
String? value, {
|
||||
bool caseSensitive = true,
|
||||
}) {
|
||||
int? value) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.equalTo(
|
||||
property: r'lastRead',
|
||||
value: value,
|
||||
caseSensitive: caseSensitive,
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Manga, Manga, QAfterFilterCondition> lastReadGreaterThan(
|
||||
String? value, {
|
||||
int? value, {
|
||||
bool include = false,
|
||||
bool caseSensitive = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.greaterThan(
|
||||
include: include,
|
||||
property: r'lastRead',
|
||||
value: value,
|
||||
caseSensitive: caseSensitive,
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Manga, Manga, QAfterFilterCondition> lastReadLessThan(
|
||||
String? value, {
|
||||
int? value, {
|
||||
bool include = false,
|
||||
bool caseSensitive = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.lessThan(
|
||||
include: include,
|
||||
property: r'lastRead',
|
||||
value: value,
|
||||
caseSensitive: caseSensitive,
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Manga, Manga, QAfterFilterCondition> lastReadBetween(
|
||||
String? lower,
|
||||
String? upper, {
|
||||
int? lower,
|
||||
int? upper, {
|
||||
bool includeLower = true,
|
||||
bool includeUpper = true,
|
||||
bool caseSensitive = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.between(
|
||||
|
|
@ -1553,75 +1539,6 @@ extension MangaQueryFilter on QueryBuilder<Manga, Manga, QFilterCondition> {
|
|||
includeLower: includeLower,
|
||||
upper: upper,
|
||||
includeUpper: includeUpper,
|
||||
caseSensitive: caseSensitive,
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Manga, Manga, QAfterFilterCondition> lastReadStartsWith(
|
||||
String value, {
|
||||
bool caseSensitive = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.startsWith(
|
||||
property: r'lastRead',
|
||||
value: value,
|
||||
caseSensitive: caseSensitive,
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Manga, Manga, QAfterFilterCondition> lastReadEndsWith(
|
||||
String value, {
|
||||
bool caseSensitive = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.endsWith(
|
||||
property: r'lastRead',
|
||||
value: value,
|
||||
caseSensitive: caseSensitive,
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Manga, Manga, QAfterFilterCondition> lastReadContains(
|
||||
String value,
|
||||
{bool caseSensitive = true}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.contains(
|
||||
property: r'lastRead',
|
||||
value: value,
|
||||
caseSensitive: caseSensitive,
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Manga, Manga, QAfterFilterCondition> lastReadMatches(
|
||||
String pattern,
|
||||
{bool caseSensitive = true}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.matches(
|
||||
property: r'lastRead',
|
||||
wildcard: pattern,
|
||||
caseSensitive: caseSensitive,
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Manga, Manga, QAfterFilterCondition> lastReadIsEmpty() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.equalTo(
|
||||
property: r'lastRead',
|
||||
value: '',
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Manga, Manga, QAfterFilterCondition> lastReadIsNotEmpty() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.greaterThan(
|
||||
property: r'lastRead',
|
||||
value: '',
|
||||
));
|
||||
});
|
||||
}
|
||||
|
|
@ -2691,10 +2608,9 @@ extension MangaQueryWhereDistinct on QueryBuilder<Manga, Manga, QDistinct> {
|
|||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Manga, Manga, QDistinct> distinctByLastRead(
|
||||
{bool caseSensitive = true}) {
|
||||
QueryBuilder<Manga, Manga, QDistinct> distinctByLastRead() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addDistinctBy(r'lastRead', caseSensitive: caseSensitive);
|
||||
return query.addDistinctBy(r'lastRead');
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -2788,7 +2704,7 @@ extension MangaQueryProperty on QueryBuilder<Manga, Manga, QQueryProperty> {
|
|||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Manga, String?, QQueryOperations> lastReadProperty() {
|
||||
QueryBuilder<Manga, int?, QQueryOperations> lastReadProperty() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addPropertyName(r'lastRead');
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:isar/isar.dart';
|
||||
import 'package:mangayomi/main.dart';
|
||||
import 'package:mangayomi/models/chapter.dart';
|
||||
import 'package:mangayomi/models/manga.dart';
|
||||
import 'package:mangayomi/providers/hive_provider.dart';
|
||||
import 'package:mangayomi/services/get_manga_detail.dart';
|
||||
|
|
@ -180,24 +183,48 @@ class _MangaGlobalImageCardState extends ConsumerState<MangaGlobalImageCard>
|
|||
data: (data) {
|
||||
return GestureDetector(
|
||||
onTap: () async {
|
||||
final modelManga = Manga(
|
||||
final manga = Manga(
|
||||
imageUrl: data.imageUrl,
|
||||
name: data.name,
|
||||
genre: data.genre,
|
||||
author: data.author,
|
||||
status: data.status,
|
||||
description: data.description,
|
||||
favorite: false,
|
||||
link: data.url,
|
||||
source: data.source,
|
||||
lang: widget.lang,
|
||||
dateAdded: DateTime.now().microsecondsSinceEpoch,
|
||||
lastUpdate: DateTime.now().microsecondsSinceEpoch,
|
||||
categories: null,
|
||||
lastRead: '');
|
||||
if (mounted) {
|
||||
context.push('/manga-reader/detail', extra: modelManga);
|
||||
lastUpdate: DateTime.now().millisecondsSinceEpoch);
|
||||
|
||||
final empty = isar.mangas
|
||||
.filter()
|
||||
.langEqualTo(widget.lang)
|
||||
.nameEqualTo(data.name)
|
||||
.sourceEqualTo(data.source)
|
||||
.isEmptySync();
|
||||
if (empty) {
|
||||
isar.writeTxnSync(() {
|
||||
isar.mangas.putSync(manga);
|
||||
for (var i = 0; i < data.chapters.length; i++) {
|
||||
final chapters = Chapter(
|
||||
name: data.chapters[i].name,
|
||||
url: data.chapters[i].url,
|
||||
dateUpload: data.chapters[i].dateUpload,
|
||||
scanlator: data.chapters[i].scanlator,
|
||||
mangaId: manga.id)
|
||||
..manga.value = manga;
|
||||
isar.chapters.putSync(chapters);
|
||||
chapters.manga.saveSync();
|
||||
}
|
||||
});
|
||||
}
|
||||
final mangaId = isar.mangas
|
||||
.filter()
|
||||
.langEqualTo(widget.lang)
|
||||
.nameEqualTo(data.name)
|
||||
.sourceEqualTo(data.source)
|
||||
.findFirstSync()!
|
||||
.id!;
|
||||
context.push('/manga-reader/detail', extra: mangaId);
|
||||
},
|
||||
child: SizedBox(
|
||||
width: 90,
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
import 'dart:developer';
|
||||
|
||||
import 'package:draggable_menu/draggable_menu.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:isar/isar.dart';
|
||||
import 'package:mangayomi/main.dart';
|
||||
import 'package:mangayomi/models/history.dart';
|
||||
import 'package:mangayomi/models/manga.dart';
|
||||
import 'package:mangayomi/providers/hive_provider.dart';
|
||||
import 'package:mangayomi/utils/media_query.dart';
|
||||
|
|
@ -12,6 +13,7 @@ import 'package:mangayomi/views/library/search_text_form_field.dart';
|
|||
import 'package:mangayomi/views/library/widgets/library_gridview_widget.dart';
|
||||
import 'package:mangayomi/views/library/widgets/library_listview_widget.dart';
|
||||
import 'package:mangayomi/views/manga/detail/widgets/chapter_filter_list_tile_widget.dart';
|
||||
import 'package:mangayomi/views/manga/detail/widgets/chapter_sort_list_tile_widget.dart';
|
||||
import 'package:mangayomi/views/more/settings/categoties/providers/isar_providers.dart';
|
||||
import 'package:mangayomi/views/widgets/error_text.dart';
|
||||
import 'package:mangayomi/views/widgets/progress_center.dart';
|
||||
|
|
@ -25,11 +27,11 @@ class LibraryScreen extends ConsumerStatefulWidget {
|
|||
|
||||
class _LibraryScreenState extends ConsumerState<LibraryScreen>
|
||||
with TickerProviderStateMixin {
|
||||
bool isSearch = false;
|
||||
bool _isSearch = false;
|
||||
final List<Manga> _entries = [];
|
||||
final _textEditingController = TextEditingController();
|
||||
late TabController tabBarController;
|
||||
int tabIndex = 0;
|
||||
int _tabIndex = 0;
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final categories = ref.watch(getMangaCategorieStreamProvider);
|
||||
|
|
@ -50,13 +52,14 @@ class _LibraryScreenState extends ConsumerState<LibraryScreen>
|
|||
? entr.length + 1
|
||||
: entr.length,
|
||||
vsync: this);
|
||||
tabBarController.animateTo(tabIndex);
|
||||
tabBarController.animateTo(_tabIndex);
|
||||
tabBarController.addListener(() {
|
||||
tabIndex = tabBarController.index;
|
||||
_tabIndex = tabBarController.index;
|
||||
});
|
||||
|
||||
return Consumer(builder: (context, ref, child) {
|
||||
final reverse = ref.watch(libraryReverseListStateProvider);
|
||||
bool reverse =
|
||||
ref.watch(sortLibraryMangaStateProvider)["reverse"];
|
||||
|
||||
final continueReaderBtn = ref
|
||||
.watch(libraryShowContinueReadingButtonStateProvider);
|
||||
|
|
@ -81,18 +84,23 @@ class _LibraryScreenState extends ConsumerState<LibraryScreen>
|
|||
final bookmarkedFilterType = ref.watch(
|
||||
mangaFilterBookmarkedStateProvider(
|
||||
mangaList: _entries));
|
||||
final numberOfItemsList = _filterMangas(
|
||||
final sortType = ref
|
||||
.watch(sortLibraryMangaStateProvider)['index'] as int;
|
||||
final numberOfItemsList = _filterAndSortMangas(
|
||||
data: man,
|
||||
downloadFilterType: downloadFilterType,
|
||||
unreadFilterType: unreadFilterType,
|
||||
startedFilterType: startedFilterType,
|
||||
bookmarkedFilterType: bookmarkedFilterType);
|
||||
final withoutCateogoryNumberOfItemsList = _filterMangas(
|
||||
data: withoutCategory,
|
||||
downloadFilterType: downloadFilterType,
|
||||
unreadFilterType: unreadFilterType,
|
||||
startedFilterType: startedFilterType,
|
||||
bookmarkedFilterType: bookmarkedFilterType);
|
||||
bookmarkedFilterType: bookmarkedFilterType,
|
||||
sortType: sortType);
|
||||
final withoutCateogoryNumberOfItemsList =
|
||||
_filterAndSortMangas(
|
||||
data: withoutCategory,
|
||||
downloadFilterType: downloadFilterType,
|
||||
unreadFilterType: unreadFilterType,
|
||||
startedFilterType: startedFilterType,
|
||||
bookmarkedFilterType: bookmarkedFilterType,
|
||||
sortType: sortType);
|
||||
return DefaultTabController(
|
||||
length: entr.length,
|
||||
child: Scaffold(
|
||||
|
|
@ -136,7 +144,7 @@ class _LibraryScreenState extends ConsumerState<LibraryScreen>
|
|||
.color),
|
||||
),
|
||||
)
|
||||
: _categoriNumberOfItems(
|
||||
: _categoriesNumberOfItems(
|
||||
downloadFilterType:
|
||||
downloadFilterType,
|
||||
unreadFilterType:
|
||||
|
|
@ -160,7 +168,7 @@ class _LibraryScreenState extends ConsumerState<LibraryScreen>
|
|||
children: [
|
||||
Tab(text: entr[i].name),
|
||||
if (showNumbersOfItems)
|
||||
_categoriNumberOfItems(
|
||||
_categoriesNumberOfItems(
|
||||
downloadFilterType:
|
||||
downloadFilterType,
|
||||
unreadFilterType:
|
||||
|
|
@ -245,7 +253,8 @@ class _LibraryScreenState extends ConsumerState<LibraryScreen>
|
|||
});
|
||||
}
|
||||
return Consumer(builder: (context, ref, child) {
|
||||
final reverse = ref.watch(libraryReverseListStateProvider);
|
||||
bool reverse =
|
||||
ref.watch(sortLibraryMangaStateProvider)["reverse"];
|
||||
final continueReaderBtn =
|
||||
ref.watch(libraryShowContinueReadingButtonStateProvider);
|
||||
final showNumbersOfItems =
|
||||
|
|
@ -267,12 +276,15 @@ class _LibraryScreenState extends ConsumerState<LibraryScreen>
|
|||
mangaFilterStartedStateProvider(mangaList: _entries));
|
||||
final bookmarkedFilterType = ref.watch(
|
||||
mangaFilterBookmarkedStateProvider(mangaList: _entries));
|
||||
final numberOfItemsList = _filterMangas(
|
||||
final sortType =
|
||||
ref.watch(sortLibraryMangaStateProvider)['index'] as int;
|
||||
final numberOfItemsList = _filterAndSortMangas(
|
||||
data: man,
|
||||
downloadFilterType: downloadFilterType,
|
||||
unreadFilterType: unreadFilterType,
|
||||
startedFilterType: startedFilterType,
|
||||
bookmarkedFilterType: bookmarkedFilterType);
|
||||
bookmarkedFilterType: bookmarkedFilterType,
|
||||
sortType: sortType);
|
||||
return Scaffold(
|
||||
appBar: _appBar(isNotFiltering, showNumbersOfItems,
|
||||
numberOfItemsList.length),
|
||||
|
|
@ -314,7 +326,7 @@ class _LibraryScreenState extends ConsumerState<LibraryScreen>
|
|||
);
|
||||
}
|
||||
|
||||
Widget _categoriNumberOfItems(
|
||||
Widget _categoriesNumberOfItems(
|
||||
{required int downloadFilterType,
|
||||
required int unreadFilterType,
|
||||
required int startedFilterType,
|
||||
|
|
@ -324,14 +336,16 @@ class _LibraryScreenState extends ConsumerState<LibraryScreen>
|
|||
required bool continueReaderBtn,
|
||||
required int categoryId}) {
|
||||
final mangas = ref.watch(getAllMangaStreamProvider(categoryId: categoryId));
|
||||
final sortType = ref.watch(sortLibraryMangaStateProvider)['index'] as int;
|
||||
return mangas.when(
|
||||
data: (data) {
|
||||
final categoriNumberOfItemsList = _filterMangas(
|
||||
final categoriNumberOfItemsList = _filterAndSortMangas(
|
||||
data: data,
|
||||
downloadFilterType: downloadFilterType,
|
||||
unreadFilterType: unreadFilterType,
|
||||
startedFilterType: startedFilterType,
|
||||
bookmarkedFilterType: bookmarkedFilterType);
|
||||
bookmarkedFilterType: bookmarkedFilterType,
|
||||
sortType: sortType);
|
||||
return CircleAvatar(
|
||||
backgroundColor: Theme.of(context).focusColor,
|
||||
radius: 8,
|
||||
|
|
@ -365,15 +379,17 @@ class _LibraryScreenState extends ConsumerState<LibraryScreen>
|
|||
required WidgetRef ref,
|
||||
required DisplayType displayType}) {
|
||||
final mangas = ref.watch(getAllMangaStreamProvider(categoryId: categoryId));
|
||||
final sortType = ref.watch(sortLibraryMangaStateProvider)['index'] as int;
|
||||
return Scaffold(
|
||||
body: mangas.when(
|
||||
data: (data) {
|
||||
final entries = _filterMangas(
|
||||
final entries = _filterAndSortMangas(
|
||||
data: data,
|
||||
downloadFilterType: downloadFilterType,
|
||||
unreadFilterType: unreadFilterType,
|
||||
startedFilterType: startedFilterType,
|
||||
bookmarkedFilterType: bookmarkedFilterType);
|
||||
bookmarkedFilterType: bookmarkedFilterType,
|
||||
sortType: sortType);
|
||||
if (entries.isNotEmpty) {
|
||||
final entriesManga = reverse ? entries.reversed.toList() : entries;
|
||||
return displayType == DisplayType.list
|
||||
|
|
@ -417,17 +433,19 @@ class _LibraryScreenState extends ConsumerState<LibraryScreen>
|
|||
required DisplayType displayType,
|
||||
required WidgetRef ref,
|
||||
bool withouCategories = false}) {
|
||||
final sortType = ref.watch(sortLibraryMangaStateProvider)['index'] as int;
|
||||
final manga = withouCategories
|
||||
? ref.watch(getAllMangaWithoutCategoriesStreamProvider)
|
||||
: ref.watch(getAllMangaStreamProvider(categoryId: null));
|
||||
return manga.when(
|
||||
data: (data) {
|
||||
final entries = _filterMangas(
|
||||
final entries = _filterAndSortMangas(
|
||||
data: data,
|
||||
downloadFilterType: downloadFilterType,
|
||||
unreadFilterType: unreadFilterType,
|
||||
startedFilterType: startedFilterType,
|
||||
bookmarkedFilterType: bookmarkedFilterType);
|
||||
bookmarkedFilterType: bookmarkedFilterType,
|
||||
sortType: sortType);
|
||||
if (entries.isNotEmpty) {
|
||||
final entriesManga = reverse ? entries.reversed.toList() : entries;
|
||||
return displayType == DisplayType.list
|
||||
|
|
@ -459,13 +477,15 @@ class _LibraryScreenState extends ConsumerState<LibraryScreen>
|
|||
);
|
||||
}
|
||||
|
||||
List<Manga> _filterMangas(
|
||||
List<Manga> _filterAndSortMangas(
|
||||
{required List<Manga> data,
|
||||
required int downloadFilterType,
|
||||
required int unreadFilterType,
|
||||
required int startedFilterType,
|
||||
required int bookmarkedFilterType}) {
|
||||
return data
|
||||
required int bookmarkedFilterType,
|
||||
required int sortType}) {
|
||||
List<Manga>? mangas;
|
||||
mangas = data
|
||||
.where((element) {
|
||||
List list = [];
|
||||
if (downloadFilterType == 1) {
|
||||
|
|
@ -539,6 +559,59 @@ class _LibraryScreenState extends ConsumerState<LibraryScreen>
|
|||
.contains(_textEditingController.text.toLowerCase())
|
||||
: true)
|
||||
.toList();
|
||||
|
||||
if (sortType == 0) {
|
||||
mangas.sort(
|
||||
(a, b) {
|
||||
return a.name!.compareTo(b.name!);
|
||||
},
|
||||
);
|
||||
} else if (sortType == 1) {
|
||||
mangas.sort(
|
||||
(a, b) {
|
||||
return a.lastRead!.compareTo(b.lastRead!);
|
||||
},
|
||||
);
|
||||
} else if (sortType == 2) {
|
||||
mangas.sort(
|
||||
(a, b) {
|
||||
return a.lastUpdate!.compareTo(b.lastUpdate!);
|
||||
},
|
||||
);
|
||||
} else if (sortType == 3) {
|
||||
mangas.sort(
|
||||
(a, b) {
|
||||
return a.lastUpdate!.compareTo(b.lastUpdate!);
|
||||
},
|
||||
);
|
||||
} else if (sortType == 4) {
|
||||
mangas.sort(
|
||||
(a, b) {
|
||||
return a.chapters
|
||||
.where((element) => !element.isRead!)
|
||||
.toList()
|
||||
.length
|
||||
.compareTo(b.chapters
|
||||
.where((element) => !element.isRead!)
|
||||
.toList()
|
||||
.length);
|
||||
},
|
||||
);
|
||||
} else if (sortType == 5) {
|
||||
mangas.sort(
|
||||
(a, b) {
|
||||
return a.chapters.first.dateUpload!
|
||||
.compareTo(b.chapters.first.dateUpload!);
|
||||
},
|
||||
);
|
||||
} else if (sortType == 6) {
|
||||
mangas.sort(
|
||||
(a, b) {
|
||||
return a.dateAdded!.compareTo(b.dateAdded!);
|
||||
},
|
||||
);
|
||||
}
|
||||
return mangas;
|
||||
}
|
||||
|
||||
_showDraggableMenu() {
|
||||
|
|
@ -551,7 +624,7 @@ class _LibraryScreenState extends ConsumerState<LibraryScreen>
|
|||
uiType: DraggableMenuUiType.softModern,
|
||||
expandable: true,
|
||||
expandedHeight: mediaHeight(context, 0.8),
|
||||
maxHeight: mediaHeight(context, 0.5),
|
||||
maxHeight: mediaHeight(context, 0.6),
|
||||
minimizeBeforeFastDrag: true,
|
||||
child: DefaultTabController(
|
||||
length: 3,
|
||||
|
|
@ -628,24 +701,25 @@ class _LibraryScreenState extends ConsumerState<LibraryScreen>
|
|||
);
|
||||
}),
|
||||
Consumer(builder: (context, ref, chil) {
|
||||
final reverse =
|
||||
ref.watch(libraryReverseListStateProvider);
|
||||
|
||||
final reverse = ref
|
||||
.read(sortLibraryMangaStateProvider.notifier)
|
||||
.isReverse();
|
||||
final reverseChapter =
|
||||
ref.watch(sortLibraryMangaStateProvider);
|
||||
return Column(
|
||||
children: [
|
||||
ListTile(
|
||||
onTap: () {
|
||||
ref
|
||||
.read(libraryReverseListStateProvider
|
||||
.notifier)
|
||||
.set(!reverse);
|
||||
},
|
||||
dense: true,
|
||||
leading: Icon(reverse
|
||||
? Icons.arrow_downward_sharp
|
||||
: Icons.arrow_upward_sharp),
|
||||
title: const Text("Alphabetically"),
|
||||
),
|
||||
for (var i = 0; i < 7; i++)
|
||||
ListTileChapterSort(
|
||||
label: _getSortNameByIndex(i),
|
||||
reverse: reverse,
|
||||
onTap: () {
|
||||
ref
|
||||
.read(sortLibraryMangaStateProvider
|
||||
.notifier)
|
||||
.set(i);
|
||||
},
|
||||
showLeading: reverseChapter['index'] == i,
|
||||
),
|
||||
],
|
||||
);
|
||||
}),
|
||||
|
|
@ -817,12 +891,29 @@ class _LibraryScreenState extends ConsumerState<LibraryScreen>
|
|||
))));
|
||||
}
|
||||
|
||||
String _getSortNameByIndex(int index) {
|
||||
if (index == 0) {
|
||||
return "AlphabeticalLy";
|
||||
} else if (index == 1) {
|
||||
return "Last read";
|
||||
} else if (index == 2) {
|
||||
return "Last update check";
|
||||
} else if (index == 3) {
|
||||
return "Unread count";
|
||||
} else if (index == 4) {
|
||||
return "Total chapters";
|
||||
} else if (index == 5) {
|
||||
return "Latest chapter";
|
||||
}
|
||||
return "Date added";
|
||||
}
|
||||
|
||||
AppBar _appBar(
|
||||
bool isNotFiltering, bool showNumbersOfItems, int numberOfItems) {
|
||||
return AppBar(
|
||||
elevation: 0,
|
||||
backgroundColor: Colors.transparent,
|
||||
title: isSearch
|
||||
title: _isSearch
|
||||
? null
|
||||
: Row(
|
||||
children: [
|
||||
|
|
@ -851,14 +942,14 @@ class _LibraryScreenState extends ConsumerState<LibraryScreen>
|
|||
],
|
||||
),
|
||||
actions: [
|
||||
isSearch
|
||||
_isSearch
|
||||
? SeachFormTextField(
|
||||
onChanged: (value) {
|
||||
setState(() {});
|
||||
},
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
isSearch = false;
|
||||
_isSearch = false;
|
||||
});
|
||||
_textEditingController.clear();
|
||||
},
|
||||
|
|
@ -872,7 +963,7 @@ class _LibraryScreenState extends ConsumerState<LibraryScreen>
|
|||
splashRadius: 20,
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
isSearch = true;
|
||||
_isSearch = true;
|
||||
});
|
||||
_textEditingController.clear();
|
||||
},
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@ class GetAllMangaStreamProvider extends AutoDisposeStreamProvider<List<Manga>> {
|
|||
}
|
||||
|
||||
String _$getAllMangaWithoutCategoriesStreamHash() =>
|
||||
r'76230abaa3a6394c56b3ec90b6a4af812f6ebfb5';
|
||||
r'6fc216e2a14edb3a0323b358ef3749a75007e8b5';
|
||||
|
||||
/// See also [getAllMangaWithoutCategoriesStream].
|
||||
@ProviderFor(getAllMangaWithoutCategoriesStream)
|
||||
|
|
|
|||
|
|
@ -1,25 +1,8 @@
|
|||
import 'dart:developer';
|
||||
|
||||
import 'package:mangayomi/models/manga.dart';
|
||||
import 'package:mangayomi/providers/hive_provider.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
part 'library_state_provider.g.dart';
|
||||
|
||||
@riverpod
|
||||
class LibraryReverseListState extends _$LibraryReverseListState {
|
||||
@override
|
||||
bool build() {
|
||||
return ref
|
||||
.watch(hiveBoxSettingsProvider)
|
||||
.get('libraryReverseList', defaultValue: false)!;
|
||||
}
|
||||
|
||||
void set(bool value) {
|
||||
state = value;
|
||||
ref.watch(hiveBoxSettingsProvider).put('libraryReverseList', value);
|
||||
}
|
||||
}
|
||||
|
||||
@riverpod
|
||||
class LibraryDisplayTypeState extends _$LibraryDisplayTypeState {
|
||||
@override
|
||||
|
|
@ -139,7 +122,7 @@ class MangaFilterUnreadState extends _$MangaFilterUnreadState {
|
|||
}
|
||||
}
|
||||
|
||||
update() {
|
||||
update() {
|
||||
if (state == 0) {
|
||||
final data = mangaList.where((element) {
|
||||
List list = [];
|
||||
|
|
@ -425,3 +408,30 @@ class LibraryShowContinueReadingButtonState
|
|||
.put('libraryShowContinueReadingButton', value);
|
||||
}
|
||||
}
|
||||
|
||||
@riverpod
|
||||
class SortLibraryMangaState extends _$SortLibraryMangaState {
|
||||
@override
|
||||
dynamic build() {
|
||||
return ref.watch(hiveBoxSettingsProvider).get("sortLibraryMangaMap",
|
||||
defaultValue: {"reverse": false, "index": 2});
|
||||
}
|
||||
|
||||
void update(bool reverse, int index) {
|
||||
var value = {
|
||||
"reverse": state['index'] == index ? !reverse : reverse,
|
||||
"index": index
|
||||
};
|
||||
ref.watch(hiveBoxSettingsProvider).put("sortLibraryMangaMap", value);
|
||||
state = value;
|
||||
}
|
||||
|
||||
void set(int index) {
|
||||
final reverse = isReverse();
|
||||
update(reverse, index);
|
||||
}
|
||||
|
||||
bool isReverse() {
|
||||
return state["reverse"];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,23 +6,6 @@ part of 'library_state_provider.dart';
|
|||
// RiverpodGenerator
|
||||
// **************************************************************************
|
||||
|
||||
String _$libraryReverseListStateHash() =>
|
||||
r'5d9037f95ffe332019dd1d3d08b0db06d798738c';
|
||||
|
||||
/// See also [LibraryReverseListState].
|
||||
@ProviderFor(LibraryReverseListState)
|
||||
final libraryReverseListStateProvider =
|
||||
AutoDisposeNotifierProvider<LibraryReverseListState, bool>.internal(
|
||||
LibraryReverseListState.new,
|
||||
name: r'libraryReverseListStateProvider',
|
||||
debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product')
|
||||
? null
|
||||
: _$libraryReverseListStateHash,
|
||||
dependencies: null,
|
||||
allTransitiveDependencies: null,
|
||||
);
|
||||
|
||||
typedef _$LibraryReverseListState = AutoDisposeNotifier<bool>;
|
||||
String _$libraryDisplayTypeStateHash() =>
|
||||
r'746bd6dac3600802c3ab5751b3c1def881274b3a';
|
||||
|
||||
|
|
@ -642,4 +625,21 @@ final libraryShowContinueReadingButtonStateProvider =
|
|||
);
|
||||
|
||||
typedef _$LibraryShowContinueReadingButtonState = AutoDisposeNotifier<bool>;
|
||||
String _$sortLibraryMangaStateHash() =>
|
||||
r'81abfe6c2841cf7b25301928d88f8af80cd480fd';
|
||||
|
||||
/// See also [SortLibraryMangaState].
|
||||
@ProviderFor(SortLibraryMangaState)
|
||||
final sortLibraryMangaStateProvider =
|
||||
AutoDisposeNotifierProvider<SortLibraryMangaState, dynamic>.internal(
|
||||
SortLibraryMangaState.new,
|
||||
name: r'sortLibraryMangaStateProvider',
|
||||
debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product')
|
||||
? null
|
||||
: _$sortLibraryMangaStateHash,
|
||||
dependencies: null,
|
||||
allTransitiveDependencies: null,
|
||||
);
|
||||
|
||||
typedef _$SortLibraryMangaState = AutoDisposeNotifier<dynamic>;
|
||||
// ignore_for_file: unnecessary_raw_strings, subtype_of_sealed_class, invalid_use_of_internal_member, do_not_use_environment, prefer_const_constructors, public_member_api_docs, avoid_private_typedef_functions
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
import 'dart:developer';
|
||||
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:draggable_menu/draggable_menu.dart';
|
||||
import 'package:draggable_scrollbar/draggable_scrollbar.dart';
|
||||
|
|
@ -7,8 +5,6 @@ import 'package:flutter/material.dart';
|
|||
import 'package:flutter/rendering.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:isar/isar.dart';
|
||||
import 'package:mangayomi/main.dart';
|
||||
import 'package:mangayomi/models/chapter.dart';
|
||||
import 'package:mangayomi/models/manga.dart';
|
||||
import 'package:mangayomi/providers/hive_provider.dart';
|
||||
|
|
@ -23,9 +19,7 @@ import 'package:mangayomi/views/manga/detail/readmore.dart';
|
|||
import 'package:mangayomi/views/manga/detail/widgets/chapter_filter_list_tile_widget.dart';
|
||||
import 'package:mangayomi/views/manga/detail/widgets/chapter_list_tile_widget.dart';
|
||||
import 'package:mangayomi/views/manga/detail/widgets/chapter_sort_list_tile_widget.dart';
|
||||
import 'package:mangayomi/views/manga/download/providers/download_provider.dart';
|
||||
import 'package:mangayomi/views/widgets/error_text.dart';
|
||||
import 'package:mangayomi/views/widgets/progress_center.dart';
|
||||
|
||||
class MangaDetailView extends ConsumerStatefulWidget {
|
||||
final Function(bool) isExtended;
|
||||
|
|
@ -66,17 +60,17 @@ class _MangaDetailViewState extends ConsumerState<MangaDetailView>
|
|||
Widget build(BuildContext context) {
|
||||
final isLongPressed = ref.watch(isLongPressedStateProvider);
|
||||
final chapterNameList = ref.watch(chaptersListStateProvider);
|
||||
bool reverse = ref.watch(
|
||||
reverseChapterStateProvider(mangaId: widget.manga!.id!))["reverse"];
|
||||
bool reverse = ref
|
||||
.watch(sortChapterStateProvider(mangaId: widget.manga!.id!))["reverse"];
|
||||
final filterUnread =
|
||||
ref.watch(chapterFilterUnreadStateProvider(mangaId: widget.manga!.id!));
|
||||
final filterBookmarked = ref.watch(
|
||||
chapterFilterBookmarkedStateProvider(mangaId: widget.manga!.id!));
|
||||
final filterDownloaded = ref.watch(
|
||||
chapterFilterDownloadedStateProvider(mangaId: widget.manga!.id!));
|
||||
final sortChapter = ref.watch(
|
||||
reverseChapterStateProvider(mangaId: widget.manga!.id!))['index']
|
||||
as int;
|
||||
final sortChapter =
|
||||
ref.watch(sortChapterStateProvider(mangaId: widget.manga!.id!))['index']
|
||||
as int;
|
||||
final chapters =
|
||||
ref.watch(getChaptersStreamProvider(mangaId: widget.manga!.id!));
|
||||
return NotificationListener<UserScrollNotification>(
|
||||
|
|
@ -91,45 +85,12 @@ class _MangaDetailViewState extends ConsumerState<MangaDetailView>
|
|||
},
|
||||
child: chapters.when(
|
||||
data: (data) {
|
||||
List<Chapter> chapterList = data
|
||||
.where((element) => filterUnread == 1
|
||||
? element.isRead == false
|
||||
: filterUnread == 2
|
||||
? element.isRead == true
|
||||
: true)
|
||||
.where((element) => filterBookmarked == 1
|
||||
? element.isBookmarked == true
|
||||
: filterBookmarked == 2
|
||||
? element.isBookmarked == false
|
||||
: true)
|
||||
.where((element) {
|
||||
final modelChapDownload = ref
|
||||
.watch(hiveBoxMangaDownloadsProvider)
|
||||
.get("${element.mangaId}/${element.id}", defaultValue: null);
|
||||
return filterDownloaded == 1
|
||||
? modelChapDownload != null &&
|
||||
modelChapDownload.isDownload == true
|
||||
: filterDownloaded == 2
|
||||
? !(modelChapDownload != null &&
|
||||
modelChapDownload.isDownload == true)
|
||||
: true;
|
||||
}).toList();
|
||||
List<Chapter> chapters =
|
||||
sortChapter == 1 ? chapterList.reversed.toList() : chapterList;
|
||||
if (sortChapter == 0) {
|
||||
chapters.sort(
|
||||
(a, b) {
|
||||
return a.scanlator!.compareTo(b.scanlator!) |
|
||||
a.dateUpload!.compareTo(b.dateUpload!);
|
||||
},
|
||||
);
|
||||
} else if (sortChapter == 2) {
|
||||
chapters.sort(
|
||||
(a, b) {
|
||||
return a.dateUpload!.compareTo(b.dateUpload!);
|
||||
},
|
||||
);
|
||||
}
|
||||
List<Chapter> chapters = _filterAndSortChapter(
|
||||
data: data,
|
||||
filterUnread: filterUnread,
|
||||
filterBookmarked: filterBookmarked,
|
||||
filterDownloaded: filterDownloaded,
|
||||
sortChapter: sortChapter);
|
||||
return _buildWidget(
|
||||
chapters: chapters,
|
||||
reverse: reverse,
|
||||
|
|
@ -149,100 +110,153 @@ class _MangaDetailViewState extends ConsumerState<MangaDetailView>
|
|||
));
|
||||
}
|
||||
|
||||
List<Chapter> _filterAndSortChapter(
|
||||
{required List<Chapter> data,
|
||||
required int filterUnread,
|
||||
required int filterBookmarked,
|
||||
required int filterDownloaded,
|
||||
required int sortChapter}) {
|
||||
List<Chapter>? chapterList;
|
||||
chapterList = data
|
||||
.where((element) => filterUnread == 1
|
||||
? element.isRead == false
|
||||
: filterUnread == 2
|
||||
? element.isRead == true
|
||||
: true)
|
||||
.where((element) => filterBookmarked == 1
|
||||
? element.isBookmarked == true
|
||||
: filterBookmarked == 2
|
||||
? element.isBookmarked == false
|
||||
: true)
|
||||
.where((element) {
|
||||
final modelChapDownload = ref
|
||||
.watch(hiveBoxMangaDownloadsProvider)
|
||||
.get("${element.mangaId}/${element.id}", defaultValue: null);
|
||||
return filterDownloaded == 1
|
||||
? modelChapDownload != null && modelChapDownload.isDownload == true
|
||||
: filterDownloaded == 2
|
||||
? !(modelChapDownload != null &&
|
||||
modelChapDownload.isDownload == true)
|
||||
: true;
|
||||
}).toList();
|
||||
List<Chapter> chapters =
|
||||
sortChapter == 1 ? chapterList.reversed.toList() : chapterList;
|
||||
if (sortChapter == 0) {
|
||||
chapters.sort(
|
||||
(a, b) {
|
||||
return a.scanlator!.compareTo(b.scanlator!) |
|
||||
a.dateUpload!.compareTo(b.dateUpload!);
|
||||
},
|
||||
);
|
||||
} else if (sortChapter == 2) {
|
||||
chapters.sort(
|
||||
(a, b) {
|
||||
return a.dateUpload!.compareTo(b.dateUpload!);
|
||||
},
|
||||
);
|
||||
}
|
||||
return chapterList;
|
||||
}
|
||||
|
||||
Widget _buildWidget(
|
||||
{required List<Chapter> chapters,
|
||||
required bool reverse,
|
||||
required List<Chapter> chapterList,
|
||||
required bool isLongPressed}) {
|
||||
return Scaffold(
|
||||
extendBodyBehindAppBar: true,
|
||||
appBar: PreferredSize(
|
||||
preferredSize: Size.fromHeight(AppBar().preferredSize.height),
|
||||
child: Consumer(
|
||||
builder: (context, ref, child) {
|
||||
final isNotFiltering = ref.watch(
|
||||
chapterFilterResultStateProvider(
|
||||
mangaId: widget.manga!.id!));
|
||||
final isLongPressed = ref.watch(isLongPressedStateProvider);
|
||||
// final chapterList = ref.watch(chaptersListStateProvider);
|
||||
return isLongPressed
|
||||
? Container(
|
||||
color: Theme.of(context).scaffoldBackgroundColor,
|
||||
child: AppBar(
|
||||
title: Text(chapterList.length.toString()),
|
||||
backgroundColor:
|
||||
primaryColor(context).withOpacity(0.2),
|
||||
leading: IconButton(
|
||||
onPressed: () {
|
||||
ref
|
||||
.read(chaptersListStateProvider.notifier)
|
||||
.clear();
|
||||
|
||||
ref
|
||||
.read(isLongPressedStateProvider.notifier)
|
||||
.update(!isLongPressed);
|
||||
},
|
||||
icon: const Icon(Icons.clear)),
|
||||
actions: [
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
for (var chapter in chapters) {
|
||||
return Stack(
|
||||
children: [Consumer(builder:(context, ref, child) {
|
||||
return Positioned(
|
||||
top: 0,
|
||||
child:ref.watch(offetProvider) == 0.0? Stack(
|
||||
children: [
|
||||
cachedNetworkImage(
|
||||
headers: headers(widget.manga!.source!),
|
||||
imageUrl: widget.manga!.imageUrl!,
|
||||
width: mediaWidth(context, 1),
|
||||
height: 410,
|
||||
fit: BoxFit.cover),
|
||||
Container(
|
||||
width: mediaWidth(context, 1),
|
||||
height: 465,
|
||||
color: Theme.of(context)
|
||||
.scaffoldBackgroundColor
|
||||
.withOpacity(0.9),
|
||||
),
|
||||
],
|
||||
):Container(),);
|
||||
},),
|
||||
|
||||
Scaffold(
|
||||
backgroundColor: Colors.transparent,
|
||||
extendBodyBehindAppBar: true,
|
||||
appBar: PreferredSize(
|
||||
preferredSize: Size.fromHeight(AppBar().preferredSize.height),
|
||||
child: Consumer(
|
||||
builder: (context, ref, child) {
|
||||
final isNotFiltering = ref.watch(
|
||||
chapterFilterResultStateProvider(
|
||||
mangaId: widget.manga!.id!));
|
||||
final isLongPressed = ref.watch(isLongPressedStateProvider);
|
||||
return isLongPressed
|
||||
? Container(
|
||||
color: Theme.of(context).scaffoldBackgroundColor,
|
||||
child: AppBar(
|
||||
title: Text(chapterList.length.toString()),
|
||||
backgroundColor:
|
||||
primaryColor(context).withOpacity(0.2),
|
||||
leading: IconButton(
|
||||
onPressed: () {
|
||||
ref
|
||||
.read(chaptersListStateProvider
|
||||
.notifier)
|
||||
.selectAll(chapter);
|
||||
}
|
||||
},
|
||||
icon: const Icon(Icons.select_all)),
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
if (chapters.length ==
|
||||
chapterList.length) {
|
||||
for (var chapter in chapters) {
|
||||
ref
|
||||
.read(chaptersListStateProvider
|
||||
.notifier)
|
||||
.selectSome(chapter);
|
||||
}
|
||||
.read(
|
||||
chaptersListStateProvider.notifier)
|
||||
.clear();
|
||||
|
||||
ref
|
||||
.read(
|
||||
isLongPressedStateProvider.notifier)
|
||||
.update(false);
|
||||
} else {
|
||||
for (var chapter in chapters) {
|
||||
ref
|
||||
.read(chaptersListStateProvider
|
||||
.notifier)
|
||||
.selectSome(chapter);
|
||||
}
|
||||
}
|
||||
},
|
||||
icon: const Icon(Icons.flip_to_back_rounded)),
|
||||
],
|
||||
),
|
||||
)
|
||||
: Stack(
|
||||
children: [
|
||||
Positioned(
|
||||
top: 0,
|
||||
child: Stack(
|
||||
children: [
|
||||
cachedNetworkImage(
|
||||
headers: headers(widget.manga!.source!),
|
||||
imageUrl: widget.manga!.imageUrl!,
|
||||
width: mediaWidth(context, 1),
|
||||
height: 410,
|
||||
fit: BoxFit.cover),
|
||||
Container(
|
||||
width: mediaWidth(context, 1),
|
||||
height: 465,
|
||||
color: Theme.of(context)
|
||||
.scaffoldBackgroundColor
|
||||
.withOpacity(0.9),
|
||||
),
|
||||
],
|
||||
)),
|
||||
AppBar(
|
||||
.update(!isLongPressed);
|
||||
},
|
||||
icon: const Icon(Icons.clear)),
|
||||
actions: [
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
for (var chapter in chapters) {
|
||||
ref
|
||||
.read(chaptersListStateProvider
|
||||
.notifier)
|
||||
.selectAll(chapter);
|
||||
}
|
||||
},
|
||||
icon: const Icon(Icons.select_all)),
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
if (chapters.length ==
|
||||
chapterList.length) {
|
||||
for (var chapter in chapters) {
|
||||
ref
|
||||
.read(chaptersListStateProvider
|
||||
.notifier)
|
||||
.selectSome(chapter);
|
||||
}
|
||||
ref
|
||||
.read(isLongPressedStateProvider
|
||||
.notifier)
|
||||
.update(false);
|
||||
} else {
|
||||
for (var chapter in chapters) {
|
||||
ref
|
||||
.read(chaptersListStateProvider
|
||||
.notifier)
|
||||
.selectSome(chapter);
|
||||
}
|
||||
}
|
||||
},
|
||||
icon:
|
||||
const Icon(Icons.flip_to_back_rounded)),
|
||||
],
|
||||
),
|
||||
)
|
||||
: AppBar(
|
||||
title: ref.watch(offetProvider) > 200
|
||||
? Text(
|
||||
widget.manga!.name!,
|
||||
|
|
@ -285,13 +299,10 @@ class _MangaDetailViewState extends ConsumerState<MangaDetailView>
|
|||
},
|
||||
onSelected: (value) {}),
|
||||
],
|
||||
)
|
||||
],
|
||||
);
|
||||
},
|
||||
)),
|
||||
body: SafeArea(
|
||||
child: DraggableScrollbar(
|
||||
);
|
||||
},
|
||||
)),
|
||||
body: DraggableScrollbar(
|
||||
heightScrollThumb: 48.0,
|
||||
backgroundColor: primaryColor(context),
|
||||
scrollThumbBuilder:
|
||||
|
|
@ -329,70 +340,76 @@ class _MangaDetailViewState extends ConsumerState<MangaDetailView>
|
|||
chapter: chapters[indexx],
|
||||
chapterList: chapterList,
|
||||
);
|
||||
}))),
|
||||
bottomNavigationBar: AnimatedContainer(
|
||||
curve: Curves.easeIn,
|
||||
decoration: BoxDecoration(
|
||||
color: primaryColor(context).withOpacity(0.2),
|
||||
borderRadius: const BorderRadius.only(
|
||||
topLeft: Radius.circular(20), topRight: Radius.circular(20))),
|
||||
duration: const Duration(milliseconds: 100),
|
||||
height: isLongPressed ? 70 : 0,
|
||||
width: mediaWidth(context, 1),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
Expanded(
|
||||
child: SizedBox(
|
||||
height: 70,
|
||||
child: ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
elevation: 0, backgroundColor: Colors.transparent),
|
||||
onPressed: () {
|
||||
ref
|
||||
.read(chapterSetIsBookmarkStateProvider(
|
||||
manga: widget.manga!)
|
||||
.notifier)
|
||||
.set();
|
||||
},
|
||||
child: const Icon(Icons.bookmark_add_outlined)),
|
||||
),
|
||||
})),
|
||||
bottomNavigationBar: AnimatedContainer(
|
||||
curve: Curves.easeIn,
|
||||
decoration: BoxDecoration(
|
||||
color: primaryColor(context).withOpacity(0.2),
|
||||
borderRadius: const BorderRadius.only(
|
||||
topLeft: Radius.circular(20),
|
||||
topRight: Radius.circular(20))),
|
||||
duration: const Duration(milliseconds: 100),
|
||||
height: isLongPressed ? 70 : 0,
|
||||
width: mediaWidth(context, 1),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
Expanded(
|
||||
child: SizedBox(
|
||||
height: 70,
|
||||
child: ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
elevation: 0,
|
||||
backgroundColor: Colors.transparent),
|
||||
onPressed: () {
|
||||
ref
|
||||
.read(chapterSetIsBookmarkStateProvider(
|
||||
manga: widget.manga!)
|
||||
.notifier)
|
||||
.set();
|
||||
},
|
||||
child: const Icon(Icons.bookmark_add_outlined)),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: SizedBox(
|
||||
height: 70,
|
||||
child: ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
elevation: 0,
|
||||
backgroundColor: Colors.transparent),
|
||||
onPressed: () {
|
||||
ref
|
||||
.read(chapterSetIsReadStateProvider(
|
||||
manga: widget.manga!)
|
||||
.notifier)
|
||||
.set();
|
||||
},
|
||||
child: const Icon(Icons.done_all_sharp)),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: SizedBox(
|
||||
height: 70,
|
||||
child: ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
elevation: 0,
|
||||
backgroundColor: Colors.transparent),
|
||||
onPressed: () {
|
||||
ref
|
||||
.read(chapterSetDownloadStateProvider(
|
||||
manga: widget.manga!)
|
||||
.notifier)
|
||||
.set();
|
||||
},
|
||||
child: const Icon(Icons.download_outlined)),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
Expanded(
|
||||
child: SizedBox(
|
||||
height: 70,
|
||||
child: ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
elevation: 0, backgroundColor: Colors.transparent),
|
||||
onPressed: () {
|
||||
ref
|
||||
.read(chapterSetIsReadStateProvider(
|
||||
manga: widget.manga!)
|
||||
.notifier)
|
||||
.set();
|
||||
},
|
||||
child: const Icon(Icons.done_all_sharp)),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: SizedBox(
|
||||
height: 70,
|
||||
child: ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
elevation: 0, backgroundColor: Colors.transparent),
|
||||
onPressed: () {
|
||||
ref
|
||||
.read(chapterSetDownloadStateProvider(
|
||||
manga: widget.manga!)
|
||||
.notifier)
|
||||
.set();
|
||||
},
|
||||
child: const Icon(Icons.download_outlined)),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
));
|
||||
)),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
_showDraggableMenu() {
|
||||
|
|
@ -469,26 +486,22 @@ class _MangaDetailViewState extends ConsumerState<MangaDetailView>
|
|||
}),
|
||||
Consumer(builder: (context, ref, chil) {
|
||||
final reverse = ref
|
||||
.read(reverseChapterStateProvider(
|
||||
.read(sortChapterStateProvider(
|
||||
mangaId: widget.manga!.id!)
|
||||
.notifier)
|
||||
.isReverse();
|
||||
final reverseChapter = ref.watch(
|
||||
reverseChapterStateProvider(
|
||||
sortChapterStateProvider(
|
||||
mangaId: widget.manga!.id!));
|
||||
return Column(
|
||||
children: [
|
||||
for (var i = 0; i < 3; i++)
|
||||
ListTileChapterSort(
|
||||
label: i == 0
|
||||
? "By source"
|
||||
: i == 1
|
||||
? "By chapter number"
|
||||
: "By upload date",
|
||||
label: _getSortNameByIndex(i),
|
||||
reverse: reverse,
|
||||
onTap: () {
|
||||
ref
|
||||
.read(reverseChapterStateProvider(
|
||||
.read(sortChapterStateProvider(
|
||||
mangaId: widget.manga!.id!)
|
||||
.notifier)
|
||||
.set(i);
|
||||
|
|
@ -502,6 +515,7 @@ class _MangaDetailViewState extends ConsumerState<MangaDetailView>
|
|||
return Column(
|
||||
children: [
|
||||
RadioListTile(
|
||||
dense: true,
|
||||
title: const Text("Source title"),
|
||||
value: "e",
|
||||
groupValue: "e",
|
||||
|
|
@ -509,6 +523,7 @@ class _MangaDetailViewState extends ConsumerState<MangaDetailView>
|
|||
onChanged: (value) {},
|
||||
),
|
||||
RadioListTile(
|
||||
dense: true,
|
||||
title: const Text("Chapter number"),
|
||||
value: "ej",
|
||||
groupValue: "e",
|
||||
|
|
@ -528,158 +543,175 @@ class _MangaDetailViewState extends ConsumerState<MangaDetailView>
|
|||
);
|
||||
}
|
||||
|
||||
String _getSortNameByIndex(int index) {
|
||||
if (index == 0) {
|
||||
return "By source";
|
||||
} else if (index == 1) {
|
||||
return "By chapter number";
|
||||
}
|
||||
return "By upload date";
|
||||
}
|
||||
|
||||
Widget _bodyContainer({required int chapterLength}) {
|
||||
return Stack(
|
||||
return Column(
|
||||
children: [
|
||||
Positioned(
|
||||
top: 0,
|
||||
child: cachedNetworkImage(
|
||||
headers: headers(widget.manga!.source!),
|
||||
imageUrl: widget.manga!.imageUrl!,
|
||||
width: mediaWidth(context, 1),
|
||||
height: 300,
|
||||
fit: BoxFit.cover)),
|
||||
Container(
|
||||
height: 300,
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).scaffoldBackgroundColor,
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.topCenter,
|
||||
end: Alignment.bottomCenter,
|
||||
colors: [
|
||||
Theme.of(context).scaffoldBackgroundColor.withOpacity(0.9),
|
||||
Color(Theme.of(context).scaffoldBackgroundColor.value)
|
||||
],
|
||||
stops: const [0, .35],
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: AppBar().preferredSize.height,
|
||||
),
|
||||
Column(
|
||||
Stack(
|
||||
children: [
|
||||
SizedBox(
|
||||
height: 180,
|
||||
child: Stack(
|
||||
children: [
|
||||
_titles(),
|
||||
_coverCard(),
|
||||
],
|
||||
Positioned(
|
||||
top: 0,
|
||||
child: cachedNetworkImage(
|
||||
headers: headers(widget.manga!.source!),
|
||||
imageUrl: widget.manga!.imageUrl!,
|
||||
width: mediaWidth(context, 1),
|
||||
height: 300,
|
||||
fit: BoxFit.cover)),
|
||||
Container(
|
||||
height: 300,
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).scaffoldBackgroundColor,
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.topCenter,
|
||||
end: Alignment.bottomCenter,
|
||||
colors: [
|
||||
Theme.of(context).scaffoldBackgroundColor.withOpacity(0.9),
|
||||
Color(Theme.of(context).scaffoldBackgroundColor.value)
|
||||
],
|
||||
stops: const [0, .35],
|
||||
),
|
||||
),
|
||||
),
|
||||
_actionConstructor(),
|
||||
Container(
|
||||
color: Theme.of(context).scaffoldBackgroundColor,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
if (widget.manga!.description != null)
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: ReadMoreWidget(
|
||||
text: widget.manga!.description!,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
_expanded = value;
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12),
|
||||
child: _expanded
|
||||
? Wrap(
|
||||
children: [
|
||||
for (var i = 0;
|
||||
i < widget.manga!.genre!.length;
|
||||
i++)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
left: 2, right: 2, bottom: 5),
|
||||
child: SizedBox(
|
||||
height: 30,
|
||||
child: ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
elevation: 0,
|
||||
backgroundColor:
|
||||
Colors.grey.withOpacity(0.2),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius:
|
||||
BorderRadius.circular(5))),
|
||||
onPressed: () {},
|
||||
child: Text(
|
||||
widget.manga!.genre![i],
|
||||
style: TextStyle(
|
||||
fontSize: 11.5,
|
||||
color: isLight(context)
|
||||
? Colors.black
|
||||
: Colors.white),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
: SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
for (var i = 0;
|
||||
i < widget.manga!.genre!.length;
|
||||
i++)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
left: 2, right: 2, bottom: 5),
|
||||
child: SizedBox(
|
||||
height: 30,
|
||||
child: ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
elevation: 0,
|
||||
backgroundColor:
|
||||
Colors.grey.withOpacity(0.2),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius:
|
||||
BorderRadius.circular(
|
||||
5))),
|
||||
onPressed: () {},
|
||||
child: Text(
|
||||
widget.manga!.genre![i],
|
||||
style: TextStyle(
|
||||
fontSize: 11.5,
|
||||
color: isLight(context)
|
||||
? Colors.black
|
||||
: Colors.white),
|
||||
Column(
|
||||
children: [
|
||||
SizedBox(
|
||||
height: 180,
|
||||
child: Stack(
|
||||
children: [
|
||||
_titles(),
|
||||
_coverCard(),
|
||||
],
|
||||
),
|
||||
),
|
||||
_actionConstructor(),
|
||||
Container(
|
||||
color: Theme.of(context).scaffoldBackgroundColor,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
if (widget.manga!.description != null)
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: ReadMoreWidget(
|
||||
text: widget.manga!.description!,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
_expanded = value;
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12),
|
||||
child: _expanded
|
||||
? Wrap(
|
||||
children: [
|
||||
for (var i = 0;
|
||||
i < widget.manga!.genre!.length;
|
||||
i++)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
left: 2, right: 2, bottom: 5),
|
||||
child: SizedBox(
|
||||
height: 30,
|
||||
child: ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
elevation: 0,
|
||||
backgroundColor: Colors.grey
|
||||
.withOpacity(0.2),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius:
|
||||
BorderRadius.circular(
|
||||
5))),
|
||||
onPressed: () {},
|
||||
child: Text(
|
||||
widget.manga!.genre![i],
|
||||
style: TextStyle(
|
||||
fontSize: 11.5,
|
||||
color: isLight(context)
|
||||
? Colors.black
|
||||
: Colors.white),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
)),
|
||||
// log
|
||||
Column(
|
||||
children: [
|
||||
//Description
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Padding(
|
||||
padding:
|
||||
const EdgeInsets.symmetric(horizontal: 8),
|
||||
child: Text(
|
||||
'$chapterLength chapters',
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.bold),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
],
|
||||
)
|
||||
: SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
for (var i = 0;
|
||||
i < widget.manga!.genre!.length;
|
||||
i++)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
left: 2, right: 2, bottom: 5),
|
||||
child: SizedBox(
|
||||
height: 30,
|
||||
child: ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
elevation: 0,
|
||||
backgroundColor: Colors.grey
|
||||
.withOpacity(0.2),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius:
|
||||
BorderRadius.circular(
|
||||
5))),
|
||||
onPressed: () {},
|
||||
child: Text(
|
||||
widget.manga!.genre![i],
|
||||
style: TextStyle(
|
||||
fontSize: 11.5,
|
||||
color: isLight(context)
|
||||
? Colors.black
|
||||
: Colors.white),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
)),
|
||||
// log
|
||||
Column(
|
||||
children: [
|
||||
//Description
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Padding(
|
||||
padding:
|
||||
const EdgeInsets.symmetric(horizontal: 8),
|
||||
child: Text(
|
||||
'$chapterLength chapters',
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.bold),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ import 'package:isar/isar.dart';
|
|||
import 'package:mangayomi/main.dart';
|
||||
import 'package:mangayomi/models/category.dart';
|
||||
import 'package:mangayomi/views/history/providers/isar_providers.dart';
|
||||
import 'package:mangayomi/views/manga/detail/providers/isar_providers.dart';
|
||||
import 'package:mangayomi/views/manga/reader/providers/push_router.dart';
|
||||
import 'package:mangayomi/models/manga.dart';
|
||||
import 'package:mangayomi/utils/colors.dart';
|
||||
|
|
@ -20,10 +19,8 @@ import 'package:mangayomi/views/widgets/progress_center.dart';
|
|||
|
||||
class MangaDetailsView extends ConsumerStatefulWidget {
|
||||
final Manga manga;
|
||||
final Function(bool) isFavorite;
|
||||
const MangaDetailsView({
|
||||
super.key,
|
||||
required this.isFavorite,
|
||||
required this.manga,
|
||||
});
|
||||
|
||||
|
|
@ -32,35 +29,9 @@ class MangaDetailsView extends ConsumerStatefulWidget {
|
|||
}
|
||||
|
||||
class _MangaDetailsViewState extends ConsumerState<MangaDetailsView> {
|
||||
bool isFavorite = false;
|
||||
bool _isOk = false;
|
||||
bool isGplay = false;
|
||||
_checkFavorite(bool i) async {
|
||||
if (!_isOk) {
|
||||
await Future.delayed(const Duration(milliseconds: 30));
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
widget.isFavorite(i);
|
||||
isFavorite = i;
|
||||
_isOk = true;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_setFavorite(bool i) async {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
widget.isFavorite(i);
|
||||
isFavorite = i;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final history = ref.watch(getAllHistoryStreamProvider);
|
||||
_checkFavorite(widget.manga.favorite);
|
||||
return Scaffold(
|
||||
floatingActionButton: ref.watch(isLongPressedStateProvider) == true
|
||||
? null
|
||||
|
|
@ -113,7 +84,7 @@ class _MangaDetailsViewState extends ConsumerState<MangaDetailsView> {
|
|||
duration:
|
||||
const Duration(milliseconds: 200),
|
||||
child: const Text(
|
||||
"Continue",
|
||||
"Resume",
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
fontSize: 14, color: Colors.white),
|
||||
|
|
@ -224,12 +195,12 @@ class _MangaDetailsViewState extends ConsumerState<MangaDetailsView> {
|
|||
backgroundColor:
|
||||
Theme.of(context).scaffoldBackgroundColor,
|
||||
elevation: 0),
|
||||
onPressed: () async {
|
||||
_setFavorite(false);
|
||||
onPressed: () {
|
||||
final model = widget.manga;
|
||||
await isar.writeTxn(() async {
|
||||
isar.writeTxnSync(() {
|
||||
model.favorite = false;
|
||||
await isar.mangas.put(model);
|
||||
model.dateAdded = 0;
|
||||
isar.mangas.putSync(model);
|
||||
});
|
||||
},
|
||||
child: Column(
|
||||
|
|
@ -264,11 +235,11 @@ class _MangaDetailsViewState extends ConsumerState<MangaDetailsView> {
|
|||
if (checkCategoryList) {
|
||||
_openCategory(widget.manga);
|
||||
} else {
|
||||
_setFavorite(true);
|
||||
final model = widget.manga;
|
||||
await isar.writeTxn(() async {
|
||||
isar.writeTxnSync(() {
|
||||
model.favorite = true;
|
||||
await isar.mangas.put(model);
|
||||
model.dateAdded = DateTime.now().millisecondsSinceEpoch;
|
||||
isar.mangas.putSync(model);
|
||||
});
|
||||
}
|
||||
},
|
||||
|
|
@ -368,7 +339,6 @@ class _MangaDetailsViewState extends ConsumerState<MangaDetailsView> {
|
|||
),
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
_setFavorite(true);
|
||||
final model = widget.manga;
|
||||
await isar.writeTxn(() async {
|
||||
model.favorite = true;
|
||||
|
|
|
|||
|
|
@ -25,7 +25,6 @@ class MangaReaderDetail extends ConsumerStatefulWidget {
|
|||
}
|
||||
|
||||
class _MangaReaderDetailState extends ConsumerState<MangaReaderDetail> {
|
||||
bool _isFavorite = false;
|
||||
@override
|
||||
void initState() {
|
||||
SystemChrome.setPreferredOrientations([
|
||||
|
|
@ -51,60 +50,54 @@ class _MangaReaderDetailState extends ConsumerState<MangaReaderDetail> {
|
|||
data: (modelManga) {
|
||||
return RefreshIndicator(
|
||||
onRefresh: () async {
|
||||
if (_isFavorite) {
|
||||
bool isOk = false;
|
||||
ref
|
||||
.watch(getMangaDetailProvider(
|
||||
imageUrl: modelManga.imageUrl!,
|
||||
lang: modelManga.lang!,
|
||||
title: modelManga.name!,
|
||||
source: modelManga.source!,
|
||||
url: modelManga.link!)
|
||||
.future)
|
||||
.then((value) async {
|
||||
if (value.chapters.isNotEmpty &&
|
||||
value.chapters.length > modelManga.chapters.length) {
|
||||
await isar.writeTxn(() async {
|
||||
int newChapsIndex =
|
||||
value.chapters.length - modelManga.chapters.length;
|
||||
for (var i = 0; i < newChapsIndex; i++) {
|
||||
final chapters = Chapter(
|
||||
name: value.chapters[i].name,
|
||||
url: value.chapters[i].url,
|
||||
dateUpload: value.chapters[i].dateUpload,
|
||||
isBookmarked: false,
|
||||
scanlator: value.chapters[i].scanlator,
|
||||
isRead: false,
|
||||
lastPageRead: '',
|
||||
mangaId: modelManga.id)
|
||||
..manga.value = modelManga;
|
||||
await isar.chapters.put(chapters);
|
||||
await chapters.manga.save();
|
||||
}
|
||||
});
|
||||
}
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
isOk = true;
|
||||
});
|
||||
}
|
||||
});
|
||||
await Future.doWhile(() async {
|
||||
await Future.delayed(const Duration(seconds: 1));
|
||||
if (isOk == true) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
}
|
||||
bool isOk = false;
|
||||
ref
|
||||
.watch(getMangaDetailProvider(
|
||||
imageUrl: modelManga.imageUrl!,
|
||||
lang: modelManga.lang!,
|
||||
title: modelManga.name!,
|
||||
source: modelManga.source!,
|
||||
url: modelManga.link!)
|
||||
.future)
|
||||
.then((value) async {
|
||||
if (value.chapters.isNotEmpty &&
|
||||
value.chapters.length > modelManga.chapters.length) {
|
||||
await isar.writeTxn(() async {
|
||||
int newChapsIndex =
|
||||
value.chapters.length - modelManga.chapters.length;
|
||||
modelManga.lastUpdate = DateTime.now().millisecondsSinceEpoch;
|
||||
for (var i = 0; i < newChapsIndex; i++) {
|
||||
final chapters = Chapter(
|
||||
name: value.chapters[i].name,
|
||||
url: value.chapters[i].url,
|
||||
dateUpload: value.chapters[i].dateUpload,
|
||||
isBookmarked: false,
|
||||
scanlator: value.chapters[i].scanlator,
|
||||
isRead: false,
|
||||
lastPageRead: '',
|
||||
mangaId: modelManga.id)
|
||||
..manga.value = modelManga;
|
||||
await isar.chapters.put(chapters);
|
||||
await chapters.manga.save();
|
||||
}
|
||||
});
|
||||
}
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
isOk = true;
|
||||
});
|
||||
}
|
||||
});
|
||||
await Future.doWhile(() async {
|
||||
await Future.delayed(const Duration(seconds: 1));
|
||||
if (isOk == true) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
},
|
||||
child: MangaDetailsView(
|
||||
manga: modelManga!,
|
||||
isFavorite: (value) {
|
||||
setState(() {
|
||||
_isFavorite = value;
|
||||
});
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
|
|
|
|||
|
|
@ -98,10 +98,10 @@ class IsExtendedState extends _$IsExtendedState {
|
|||
}
|
||||
|
||||
@riverpod
|
||||
class ReverseChapterState extends _$ReverseChapterState {
|
||||
class SortChapterState extends _$SortChapterState {
|
||||
@override
|
||||
dynamic build({required int mangaId}) {
|
||||
return ref.watch(hiveBoxSettingsProvider).get("$mangaId-reverseChapterMap",
|
||||
return ref.watch(hiveBoxSettingsProvider).get("$mangaId-sortChapterMap",
|
||||
defaultValue: {"reverse": false, "index": 2});
|
||||
}
|
||||
|
||||
|
|
@ -110,33 +110,13 @@ class ReverseChapterState extends _$ReverseChapterState {
|
|||
"reverse": state['index'] == index ? !reverse : reverse,
|
||||
"index": index
|
||||
};
|
||||
ref.watch(hiveBoxSettingsProvider).put("$mangaId-reverseChapterMap", value);
|
||||
ref.watch(hiveBoxSettingsProvider).put("$mangaId-sortChapterMap", value);
|
||||
state = value;
|
||||
}
|
||||
|
||||
void set(int index) {
|
||||
final reverse = ref
|
||||
.read(reverseChapterStateProvider(mangaId: mangaId).notifier)
|
||||
.isReverse();
|
||||
final sortBySource = ref.watch(sortBySourceStateProvider(mangaId: mangaId));
|
||||
final sortByChapterNumber =
|
||||
ref.watch(sortByChapterNumberStateProvider(mangaId: mangaId));
|
||||
final sortByUploadDate =
|
||||
ref.watch(sortByUploadDateStateProvider(mangaId: mangaId));
|
||||
final reverse = isReverse();
|
||||
update(reverse, index);
|
||||
if (index == 0) {
|
||||
ref
|
||||
.read(sortBySourceStateProvider(mangaId: mangaId).notifier)
|
||||
.update(!sortBySource);
|
||||
} else if (index == 1) {
|
||||
ref
|
||||
.read(sortByChapterNumberStateProvider(mangaId: mangaId).notifier)
|
||||
.update(!sortByChapterNumber);
|
||||
} else {
|
||||
ref
|
||||
.read(sortByUploadDateStateProvider(mangaId: mangaId).notifier)
|
||||
.update(!sortByUploadDate);
|
||||
}
|
||||
}
|
||||
|
||||
bool isReverse() {
|
||||
|
|
@ -260,20 +240,20 @@ class ChapterFilterResultState extends _$ChapterFilterResultState {
|
|||
Manga mangaWithNewChapValue(
|
||||
{required Manga manga, required List<Chapter>? chapters}) {
|
||||
return Manga(
|
||||
imageUrl: manga.imageUrl,
|
||||
name: manga.name,
|
||||
genre: manga.genre,
|
||||
author: manga.author,
|
||||
description: manga.description,
|
||||
status: manga.status,
|
||||
favorite: manga.favorite,
|
||||
link: manga.link,
|
||||
source: manga.source,
|
||||
lang: manga.lang,
|
||||
dateAdded: manga.dateAdded,
|
||||
lastUpdate: manga.lastUpdate,
|
||||
categories: manga.categories,
|
||||
lastRead: manga.lastRead);
|
||||
imageUrl: manga.imageUrl,
|
||||
name: manga.name,
|
||||
genre: manga.genre,
|
||||
author: manga.author,
|
||||
description: manga.description,
|
||||
status: manga.status,
|
||||
favorite: manga.favorite,
|
||||
link: manga.link,
|
||||
source: manga.source,
|
||||
lang: manga.lang,
|
||||
dateAdded: manga.dateAdded,
|
||||
lastUpdate: manga.lastUpdate,
|
||||
categories: manga.categories,
|
||||
);
|
||||
}
|
||||
|
||||
@riverpod
|
||||
|
|
@ -336,54 +316,3 @@ class ChapterSetDownloadState extends _$ChapterSetDownloadState {
|
|||
ref.read(chaptersListStateProvider.notifier).clear();
|
||||
}
|
||||
}
|
||||
|
||||
@riverpod
|
||||
class SortByUploadDateState extends _$SortByUploadDateState {
|
||||
@override
|
||||
bool build({required int mangaId}) {
|
||||
return ref
|
||||
.watch(hiveBoxSettingsProvider)
|
||||
.get("$mangaId-sortByUploadDateChapter", defaultValue: false);
|
||||
}
|
||||
|
||||
void update(bool value) {
|
||||
ref
|
||||
.watch(hiveBoxSettingsProvider)
|
||||
.put("$mangaId-sortByUploadDateChapter", value);
|
||||
state = value;
|
||||
}
|
||||
}
|
||||
|
||||
@riverpod
|
||||
class SortBySourceState extends _$SortBySourceState {
|
||||
@override
|
||||
bool build({required int mangaId}) {
|
||||
return ref
|
||||
.watch(hiveBoxSettingsProvider)
|
||||
.get("$mangaId-sortBySourceChapter", defaultValue: false);
|
||||
}
|
||||
|
||||
void update(bool value) {
|
||||
ref
|
||||
.watch(hiveBoxSettingsProvider)
|
||||
.put("$mangaId-sortBySourceChapter", value);
|
||||
state = value;
|
||||
}
|
||||
}
|
||||
|
||||
@riverpod
|
||||
class SortByChapterNumberState extends _$SortByChapterNumberState {
|
||||
@override
|
||||
bool build({required int mangaId}) {
|
||||
return ref
|
||||
.watch(hiveBoxSettingsProvider)
|
||||
.get("$mangaId-sortByChapterNumberChapter", defaultValue: false);
|
||||
}
|
||||
|
||||
void update(bool value) {
|
||||
ref
|
||||
.watch(hiveBoxSettingsProvider)
|
||||
.put("$mangaId-sortByChapterNumberChapter", value);
|
||||
state = value;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -71,8 +71,7 @@ final isExtendedStateProvider =
|
|||
);
|
||||
|
||||
typedef _$IsExtendedState = AutoDisposeNotifier<bool>;
|
||||
String _$reverseChapterStateHash() =>
|
||||
r'8e3db99ef54d27d37e9af35ef9d822a4f5dc6eaf';
|
||||
String _$sortChapterStateHash() => r'38b241e06866613a0c34d306da0d855f57af3862';
|
||||
|
||||
/// Copied from Dart SDK
|
||||
class _SystemHash {
|
||||
|
|
@ -95,7 +94,7 @@ class _SystemHash {
|
|||
}
|
||||
}
|
||||
|
||||
abstract class _$ReverseChapterState
|
||||
abstract class _$SortChapterState
|
||||
extends BuildlessAutoDisposeNotifier<dynamic> {
|
||||
late final int mangaId;
|
||||
|
||||
|
|
@ -104,27 +103,27 @@ abstract class _$ReverseChapterState
|
|||
});
|
||||
}
|
||||
|
||||
/// See also [ReverseChapterState].
|
||||
@ProviderFor(ReverseChapterState)
|
||||
const reverseChapterStateProvider = ReverseChapterStateFamily();
|
||||
/// See also [SortChapterState].
|
||||
@ProviderFor(SortChapterState)
|
||||
const sortChapterStateProvider = SortChapterStateFamily();
|
||||
|
||||
/// See also [ReverseChapterState].
|
||||
class ReverseChapterStateFamily extends Family<dynamic> {
|
||||
/// See also [ReverseChapterState].
|
||||
const ReverseChapterStateFamily();
|
||||
/// See also [SortChapterState].
|
||||
class SortChapterStateFamily extends Family<dynamic> {
|
||||
/// See also [SortChapterState].
|
||||
const SortChapterStateFamily();
|
||||
|
||||
/// See also [ReverseChapterState].
|
||||
ReverseChapterStateProvider call({
|
||||
/// See also [SortChapterState].
|
||||
SortChapterStateProvider call({
|
||||
required int mangaId,
|
||||
}) {
|
||||
return ReverseChapterStateProvider(
|
||||
return SortChapterStateProvider(
|
||||
mangaId: mangaId,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
ReverseChapterStateProvider getProviderOverride(
|
||||
covariant ReverseChapterStateProvider provider,
|
||||
SortChapterStateProvider getProviderOverride(
|
||||
covariant SortChapterStateProvider provider,
|
||||
) {
|
||||
return call(
|
||||
mangaId: provider.mangaId,
|
||||
|
|
@ -143,33 +142,33 @@ class ReverseChapterStateFamily extends Family<dynamic> {
|
|||
_allTransitiveDependencies;
|
||||
|
||||
@override
|
||||
String? get name => r'reverseChapterStateProvider';
|
||||
String? get name => r'sortChapterStateProvider';
|
||||
}
|
||||
|
||||
/// See also [ReverseChapterState].
|
||||
class ReverseChapterStateProvider
|
||||
extends AutoDisposeNotifierProviderImpl<ReverseChapterState, dynamic> {
|
||||
/// See also [ReverseChapterState].
|
||||
ReverseChapterStateProvider({
|
||||
/// See also [SortChapterState].
|
||||
class SortChapterStateProvider
|
||||
extends AutoDisposeNotifierProviderImpl<SortChapterState, dynamic> {
|
||||
/// See also [SortChapterState].
|
||||
SortChapterStateProvider({
|
||||
required this.mangaId,
|
||||
}) : super.internal(
|
||||
() => ReverseChapterState()..mangaId = mangaId,
|
||||
from: reverseChapterStateProvider,
|
||||
name: r'reverseChapterStateProvider',
|
||||
() => SortChapterState()..mangaId = mangaId,
|
||||
from: sortChapterStateProvider,
|
||||
name: r'sortChapterStateProvider',
|
||||
debugGetCreateSourceHash:
|
||||
const bool.fromEnvironment('dart.vm.product')
|
||||
? null
|
||||
: _$reverseChapterStateHash,
|
||||
dependencies: ReverseChapterStateFamily._dependencies,
|
||||
: _$sortChapterStateHash,
|
||||
dependencies: SortChapterStateFamily._dependencies,
|
||||
allTransitiveDependencies:
|
||||
ReverseChapterStateFamily._allTransitiveDependencies,
|
||||
SortChapterStateFamily._allTransitiveDependencies,
|
||||
);
|
||||
|
||||
final int mangaId;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return other is ReverseChapterStateProvider && other.mangaId == mangaId;
|
||||
return other is SortChapterStateProvider && other.mangaId == mangaId;
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
@ -182,7 +181,7 @@ class ReverseChapterStateProvider
|
|||
|
||||
@override
|
||||
dynamic runNotifierBuild(
|
||||
covariant ReverseChapterState notifier,
|
||||
covariant SortChapterState notifier,
|
||||
) {
|
||||
return notifier.build(
|
||||
mangaId: mangaId,
|
||||
|
|
@ -881,297 +880,4 @@ class ChapterSetDownloadStateProvider
|
|||
);
|
||||
}
|
||||
}
|
||||
|
||||
String _$sortByUploadDateStateHash() =>
|
||||
r'5dd31fd2ee8fbaa5f3f5c8e2397842fa60af8b46';
|
||||
|
||||
abstract class _$SortByUploadDateState
|
||||
extends BuildlessAutoDisposeNotifier<bool> {
|
||||
late final int mangaId;
|
||||
|
||||
bool build({
|
||||
required int mangaId,
|
||||
});
|
||||
}
|
||||
|
||||
/// See also [SortByUploadDateState].
|
||||
@ProviderFor(SortByUploadDateState)
|
||||
const sortByUploadDateStateProvider = SortByUploadDateStateFamily();
|
||||
|
||||
/// See also [SortByUploadDateState].
|
||||
class SortByUploadDateStateFamily extends Family<bool> {
|
||||
/// See also [SortByUploadDateState].
|
||||
const SortByUploadDateStateFamily();
|
||||
|
||||
/// See also [SortByUploadDateState].
|
||||
SortByUploadDateStateProvider call({
|
||||
required int mangaId,
|
||||
}) {
|
||||
return SortByUploadDateStateProvider(
|
||||
mangaId: mangaId,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
SortByUploadDateStateProvider getProviderOverride(
|
||||
covariant SortByUploadDateStateProvider provider,
|
||||
) {
|
||||
return call(
|
||||
mangaId: provider.mangaId,
|
||||
);
|
||||
}
|
||||
|
||||
static const Iterable<ProviderOrFamily>? _dependencies = null;
|
||||
|
||||
@override
|
||||
Iterable<ProviderOrFamily>? get dependencies => _dependencies;
|
||||
|
||||
static const Iterable<ProviderOrFamily>? _allTransitiveDependencies = null;
|
||||
|
||||
@override
|
||||
Iterable<ProviderOrFamily>? get allTransitiveDependencies =>
|
||||
_allTransitiveDependencies;
|
||||
|
||||
@override
|
||||
String? get name => r'sortByUploadDateStateProvider';
|
||||
}
|
||||
|
||||
/// See also [SortByUploadDateState].
|
||||
class SortByUploadDateStateProvider
|
||||
extends AutoDisposeNotifierProviderImpl<SortByUploadDateState, bool> {
|
||||
/// See also [SortByUploadDateState].
|
||||
SortByUploadDateStateProvider({
|
||||
required this.mangaId,
|
||||
}) : super.internal(
|
||||
() => SortByUploadDateState()..mangaId = mangaId,
|
||||
from: sortByUploadDateStateProvider,
|
||||
name: r'sortByUploadDateStateProvider',
|
||||
debugGetCreateSourceHash:
|
||||
const bool.fromEnvironment('dart.vm.product')
|
||||
? null
|
||||
: _$sortByUploadDateStateHash,
|
||||
dependencies: SortByUploadDateStateFamily._dependencies,
|
||||
allTransitiveDependencies:
|
||||
SortByUploadDateStateFamily._allTransitiveDependencies,
|
||||
);
|
||||
|
||||
final int mangaId;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return other is SortByUploadDateStateProvider && other.mangaId == mangaId;
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode {
|
||||
var hash = _SystemHash.combine(0, runtimeType.hashCode);
|
||||
hash = _SystemHash.combine(hash, mangaId.hashCode);
|
||||
|
||||
return _SystemHash.finish(hash);
|
||||
}
|
||||
|
||||
@override
|
||||
bool runNotifierBuild(
|
||||
covariant SortByUploadDateState notifier,
|
||||
) {
|
||||
return notifier.build(
|
||||
mangaId: mangaId,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
String _$sortBySourceStateHash() => r'b254edd8c935aafd1cb41e4841134d177b58ba62';
|
||||
|
||||
abstract class _$SortBySourceState extends BuildlessAutoDisposeNotifier<bool> {
|
||||
late final int mangaId;
|
||||
|
||||
bool build({
|
||||
required int mangaId,
|
||||
});
|
||||
}
|
||||
|
||||
/// See also [SortBySourceState].
|
||||
@ProviderFor(SortBySourceState)
|
||||
const sortBySourceStateProvider = SortBySourceStateFamily();
|
||||
|
||||
/// See also [SortBySourceState].
|
||||
class SortBySourceStateFamily extends Family<bool> {
|
||||
/// See also [SortBySourceState].
|
||||
const SortBySourceStateFamily();
|
||||
|
||||
/// See also [SortBySourceState].
|
||||
SortBySourceStateProvider call({
|
||||
required int mangaId,
|
||||
}) {
|
||||
return SortBySourceStateProvider(
|
||||
mangaId: mangaId,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
SortBySourceStateProvider getProviderOverride(
|
||||
covariant SortBySourceStateProvider provider,
|
||||
) {
|
||||
return call(
|
||||
mangaId: provider.mangaId,
|
||||
);
|
||||
}
|
||||
|
||||
static const Iterable<ProviderOrFamily>? _dependencies = null;
|
||||
|
||||
@override
|
||||
Iterable<ProviderOrFamily>? get dependencies => _dependencies;
|
||||
|
||||
static const Iterable<ProviderOrFamily>? _allTransitiveDependencies = null;
|
||||
|
||||
@override
|
||||
Iterable<ProviderOrFamily>? get allTransitiveDependencies =>
|
||||
_allTransitiveDependencies;
|
||||
|
||||
@override
|
||||
String? get name => r'sortBySourceStateProvider';
|
||||
}
|
||||
|
||||
/// See also [SortBySourceState].
|
||||
class SortBySourceStateProvider
|
||||
extends AutoDisposeNotifierProviderImpl<SortBySourceState, bool> {
|
||||
/// See also [SortBySourceState].
|
||||
SortBySourceStateProvider({
|
||||
required this.mangaId,
|
||||
}) : super.internal(
|
||||
() => SortBySourceState()..mangaId = mangaId,
|
||||
from: sortBySourceStateProvider,
|
||||
name: r'sortBySourceStateProvider',
|
||||
debugGetCreateSourceHash:
|
||||
const bool.fromEnvironment('dart.vm.product')
|
||||
? null
|
||||
: _$sortBySourceStateHash,
|
||||
dependencies: SortBySourceStateFamily._dependencies,
|
||||
allTransitiveDependencies:
|
||||
SortBySourceStateFamily._allTransitiveDependencies,
|
||||
);
|
||||
|
||||
final int mangaId;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return other is SortBySourceStateProvider && other.mangaId == mangaId;
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode {
|
||||
var hash = _SystemHash.combine(0, runtimeType.hashCode);
|
||||
hash = _SystemHash.combine(hash, mangaId.hashCode);
|
||||
|
||||
return _SystemHash.finish(hash);
|
||||
}
|
||||
|
||||
@override
|
||||
bool runNotifierBuild(
|
||||
covariant SortBySourceState notifier,
|
||||
) {
|
||||
return notifier.build(
|
||||
mangaId: mangaId,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
String _$sortByChapterNumberStateHash() =>
|
||||
r'c3f088a3235a0c0305b8c33376fa430950902fc6';
|
||||
|
||||
abstract class _$SortByChapterNumberState
|
||||
extends BuildlessAutoDisposeNotifier<bool> {
|
||||
late final int mangaId;
|
||||
|
||||
bool build({
|
||||
required int mangaId,
|
||||
});
|
||||
}
|
||||
|
||||
/// See also [SortByChapterNumberState].
|
||||
@ProviderFor(SortByChapterNumberState)
|
||||
const sortByChapterNumberStateProvider = SortByChapterNumberStateFamily();
|
||||
|
||||
/// See also [SortByChapterNumberState].
|
||||
class SortByChapterNumberStateFamily extends Family<bool> {
|
||||
/// See also [SortByChapterNumberState].
|
||||
const SortByChapterNumberStateFamily();
|
||||
|
||||
/// See also [SortByChapterNumberState].
|
||||
SortByChapterNumberStateProvider call({
|
||||
required int mangaId,
|
||||
}) {
|
||||
return SortByChapterNumberStateProvider(
|
||||
mangaId: mangaId,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
SortByChapterNumberStateProvider getProviderOverride(
|
||||
covariant SortByChapterNumberStateProvider provider,
|
||||
) {
|
||||
return call(
|
||||
mangaId: provider.mangaId,
|
||||
);
|
||||
}
|
||||
|
||||
static const Iterable<ProviderOrFamily>? _dependencies = null;
|
||||
|
||||
@override
|
||||
Iterable<ProviderOrFamily>? get dependencies => _dependencies;
|
||||
|
||||
static const Iterable<ProviderOrFamily>? _allTransitiveDependencies = null;
|
||||
|
||||
@override
|
||||
Iterable<ProviderOrFamily>? get allTransitiveDependencies =>
|
||||
_allTransitiveDependencies;
|
||||
|
||||
@override
|
||||
String? get name => r'sortByChapterNumberStateProvider';
|
||||
}
|
||||
|
||||
/// See also [SortByChapterNumberState].
|
||||
class SortByChapterNumberStateProvider
|
||||
extends AutoDisposeNotifierProviderImpl<SortByChapterNumberState, bool> {
|
||||
/// See also [SortByChapterNumberState].
|
||||
SortByChapterNumberStateProvider({
|
||||
required this.mangaId,
|
||||
}) : super.internal(
|
||||
() => SortByChapterNumberState()..mangaId = mangaId,
|
||||
from: sortByChapterNumberStateProvider,
|
||||
name: r'sortByChapterNumberStateProvider',
|
||||
debugGetCreateSourceHash:
|
||||
const bool.fromEnvironment('dart.vm.product')
|
||||
? null
|
||||
: _$sortByChapterNumberStateHash,
|
||||
dependencies: SortByChapterNumberStateFamily._dependencies,
|
||||
allTransitiveDependencies:
|
||||
SortByChapterNumberStateFamily._allTransitiveDependencies,
|
||||
);
|
||||
|
||||
final int mangaId;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return other is SortByChapterNumberStateProvider &&
|
||||
other.mangaId == mangaId;
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode {
|
||||
var hash = _SystemHash.combine(0, runtimeType.hashCode);
|
||||
hash = _SystemHash.combine(hash, mangaId.hashCode);
|
||||
|
||||
return _SystemHash.finish(hash);
|
||||
}
|
||||
|
||||
@override
|
||||
bool runNotifierBuild(
|
||||
covariant SortByChapterNumberState notifier,
|
||||
) {
|
||||
return notifier.build(
|
||||
mangaId: mangaId,
|
||||
);
|
||||
}
|
||||
}
|
||||
// ignore_for_file: unnecessary_raw_strings, subtype_of_sealed_class, invalid_use_of_internal_member, do_not_use_environment, prefer_const_constructors, public_member_api_docs, avoid_private_typedef_functions
|
||||
|
|
|
|||
|
|
@ -106,6 +106,11 @@ class ReaderController extends _$ReaderController {
|
|||
void setMangaHistoryUpdate() {
|
||||
final incognitoMode = ref.watch(incognitoModeStateProvider);
|
||||
if (!incognitoMode) {
|
||||
isar.writeTxnSync(() {
|
||||
Manga? manga = chapter.manga.value;
|
||||
manga!.lastRead = DateTime.now().millisecondsSinceEpoch;
|
||||
isar.mangas.putSync(manga);
|
||||
});
|
||||
History? history;
|
||||
|
||||
final empty =
|
||||
|
|
|
|||
|
|
@ -28,16 +28,16 @@ class MangaImageCardWidget extends StatelessWidget {
|
|||
return GestureDetector(
|
||||
onTap: () {
|
||||
final manga = Manga(
|
||||
imageUrl: getMangaDetailModel!.imageUrl,
|
||||
name: getMangaDetailModel!.name,
|
||||
genre: getMangaDetailModel!.genre,
|
||||
author: getMangaDetailModel!.author,
|
||||
status: getMangaDetailModel!.status,
|
||||
description: getMangaDetailModel!.description,
|
||||
link: getMangaDetailModel!.url,
|
||||
source: getMangaDetailModel!.source,
|
||||
lang: lang,
|
||||
);
|
||||
imageUrl: getMangaDetailModel!.imageUrl,
|
||||
name: getMangaDetailModel!.name,
|
||||
genre: getMangaDetailModel!.genre,
|
||||
author: getMangaDetailModel!.author,
|
||||
status: getMangaDetailModel!.status,
|
||||
description: getMangaDetailModel!.description,
|
||||
link: getMangaDetailModel!.url,
|
||||
source: getMangaDetailModel!.source,
|
||||
lang: lang,
|
||||
lastUpdate: DateTime.now().millisecondsSinceEpoch);
|
||||
|
||||
final empty = isar.mangas
|
||||
.filter()
|
||||
|
|
|
|||
Loading…
Reference in a new issue