improve ui

This commit is contained in:
nyne
2024-10-26 19:39:12 +08:00
parent e64b69d818
commit 96bf3688d0
12 changed files with 112 additions and 84 deletions

View File

@@ -116,6 +116,7 @@ mixin _AppRouteTransitionMixin<T> on PageRoute<T> {
route.fullscreenDialog ||
route.animation!.status != AnimationStatus.completed ||
route.secondaryAnimation!.status != AnimationStatus.dismissed ||
!route.popGestureEnabled ||
route.navigator!.userGestureInProgress) {
return false;
}

View File

@@ -728,28 +728,32 @@ class ComicSourceParser {
return retryZone(func);
};
addFolder = (name) async {
try {
await JsEngine().runCode("""
if(_checkExists("favorites.addFolder")) {
addFolder = (name) async {
try {
await JsEngine().runCode("""
ComicSource.sources.$_key.favorites.addFolder(${jsonEncode(name)})
""");
return const Res(true);
} catch (e, s) {
Log.error("Network", "$e\n$s");
return Res.error(e.toString());
}
};
deleteFolder = (key) async {
try {
await JsEngine().runCode("""
return const Res(true);
} catch (e, s) {
Log.error("Network", "$e\n$s");
return Res.error(e.toString());
}
};
}
if(_checkExists("favorites.deleteFolder")) {
deleteFolder = (key) async {
try {
await JsEngine().runCode("""
ComicSource.sources.$_key.favorites.deleteFolder(${jsonEncode(key)})
""");
return const Res(true);
} catch (e, s) {
Log.error("Network", "$e\n$s");
return Res.error(e.toString());
}
};
return const Res(true);
} catch (e, s) {
Log.error("Network", "$e\n$s");
return Res.error(e.toString());
}
};
}
}
return FavoriteData(

View File

@@ -153,6 +153,8 @@ class HistoryManager with ChangeNotifier {
Map<String, bool>? _cachedHistory;
static const _kMaxHistoryLength = 200;
Future<void> init() async {
_db = sqlite3.open("${App.dataPath}/history.db");
@@ -176,6 +178,12 @@ class HistoryManager with ChangeNotifier {
///
/// This function would be called when user start reading.
Future<void> addHistory(History newItem) async {
while(count() >= _kMaxHistoryLength) {
_db.execute("""
delete from history
where time == (select min(time) from history);
""");
}
_db.execute("""
insert or replace into history (id, title, subtitle, cover, time, type, ep, page, readEpisode, max_page)
values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?);
@@ -207,6 +215,7 @@ class HistoryManager with ChangeNotifier {
where id == ? and type == ?;
""", [id, type.value]);
updateCache();
notifyListeners();
}
Future<History?> find(String id, ComicType type) async {