mirror of
https://github.com/kodjodevf/mangayomi.git
synced 2026-04-20 19:12:04 +00:00
fix
This commit is contained in:
parent
100b478caa
commit
72a7bb719d
3 changed files with 52 additions and 59 deletions
|
|
@ -1,3 +1,5 @@
|
|||
// ignore_for_file: depend_on_referenced_packages
|
||||
import 'dart:developer';
|
||||
import 'dart:io';
|
||||
import 'package:fast_cached_network_image/fast_cached_network_image.dart';
|
||||
import 'package:flex_color_scheme/flex_color_scheme.dart';
|
||||
|
|
@ -20,18 +22,33 @@ import 'package:mangayomi/views/more/settings/appearance/providers/blend_level_s
|
|||
import 'package:mangayomi/views/more/settings/appearance/providers/flex_scheme_color_state_provider.dart';
|
||||
import 'package:mangayomi/views/more/settings/appearance/providers/theme_mode_state_provider.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:path/path.dart' as path;
|
||||
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||
|
||||
late Isar isar;
|
||||
void main() async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
await _initDB();
|
||||
runApp(const ProviderScope(child: MyApp()));
|
||||
}
|
||||
|
||||
_initDB() async {
|
||||
if (Platform.isAndroid || Platform.isIOS) {
|
||||
await Hive.initFlutter();
|
||||
await FastCachedImageConfig.init();
|
||||
} else {
|
||||
await Hive.initFlutter("Mangayomi/databases");
|
||||
await FastCachedImageConfig.init(subDir: "Mangayomi/databases");
|
||||
}
|
||||
final dir = await getApplicationDocumentsDirectory();
|
||||
if (Platform.isAndroid || Platform.isIOS) {
|
||||
isar = Isar.openSync(
|
||||
[MangaSchema, ChapterSchema, CategorySchema, HistorySchema],
|
||||
directory: dir.path,
|
||||
);
|
||||
} else {
|
||||
isar = await Isar.open(
|
||||
[MangaSchema, ChapterSchema, CategorySchema, HistorySchema],
|
||||
directory: "${dir.path}/Mangayomi/databases", name: "MangayomiDb");
|
||||
}
|
||||
await FastCachedImageConfig.init(subDir: "Mangayomi/databases");
|
||||
Hive.registerAdapter(SourceModelAdapter());
|
||||
Hive.registerAdapter(ReaderModeAdapter());
|
||||
Hive.registerAdapter(TypeSourceAdapter());
|
||||
|
|
@ -41,25 +58,23 @@ void main() async {
|
|||
await Hive.openBox<DownloadModel>(HiveConstant.hiveBoxDownloads);
|
||||
await Hive.openBox(HiveConstant.hiveBoxAppSettings);
|
||||
await Hive.openBox(HiveConstant.hiveBoxMangaInfo);
|
||||
await initIsar();
|
||||
runApp(const ProviderScope(child: MyApp()));
|
||||
}
|
||||
|
||||
initIsar() async {
|
||||
final dir = await getApplicationDocumentsDirectory();
|
||||
if (Platform.isAndroid || Platform.isIOS) {
|
||||
isar = Isar.openSync(
|
||||
[MangaSchema, ChapterSchema, CategorySchema, HistorySchema],
|
||||
directory: dir.path,
|
||||
);
|
||||
} else {
|
||||
String rootDir = path.join(Directory.current.path, '.dart_tool', 'isar');
|
||||
await Directory(rootDir).create(recursive: true);
|
||||
isar = await Isar.open(
|
||||
[MangaSchema, ChapterSchema, CategorySchema, HistorySchema],
|
||||
directory: rootDir,
|
||||
);
|
||||
}
|
||||
_iniDateFormatting() {
|
||||
initializeDateFormatting("en", null);
|
||||
initializeDateFormatting("fr", null);
|
||||
initializeDateFormatting("ar", null);
|
||||
initializeDateFormatting("es", null);
|
||||
initializeDateFormatting("pt", null);
|
||||
initializeDateFormatting("ru", null);
|
||||
initializeDateFormatting("hi", null);
|
||||
initializeDateFormatting("id", null);
|
||||
initializeDateFormatting("it", null);
|
||||
initializeDateFormatting("de", null);
|
||||
initializeDateFormatting("ja", null);
|
||||
initializeDateFormatting("zh", null);
|
||||
initializeDateFormatting("pl", null);
|
||||
initializeDateFormatting("tr", null);
|
||||
}
|
||||
|
||||
class MyApp extends ConsumerStatefulWidget {
|
||||
|
|
@ -70,26 +85,9 @@ class MyApp extends ConsumerStatefulWidget {
|
|||
}
|
||||
|
||||
class _MyAppState extends ConsumerState<MyApp> {
|
||||
_ini() {
|
||||
initializeDateFormatting("en", null);
|
||||
initializeDateFormatting("fr", null);
|
||||
initializeDateFormatting("ar", null);
|
||||
initializeDateFormatting("es", null);
|
||||
initializeDateFormatting("pt", null);
|
||||
initializeDateFormatting("ru", null);
|
||||
initializeDateFormatting("hi", null);
|
||||
initializeDateFormatting("id", null);
|
||||
initializeDateFormatting("it", null);
|
||||
initializeDateFormatting("de", null);
|
||||
initializeDateFormatting("ja", null);
|
||||
initializeDateFormatting("zh", null);
|
||||
initializeDateFormatting("pl", null);
|
||||
initializeDateFormatting("tr", null);
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
_ini();
|
||||
_iniDateFormatting();
|
||||
super.initState();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,14 +1,10 @@
|
|||
class HiveConstant {
|
||||
static String get hiveBoxManga => "manga_box_";
|
||||
static String get hiveBoxMangaInfo => "manga_box_info_";
|
||||
static String get hiveBoxMangaHistory => "_manga_box_history__";
|
||||
static String get hiveBoxMangaSource => "_manga_box_source__";
|
||||
static String get hiveBoxMangaFilter => "_manga_box_filter__";
|
||||
static String get hiveBoxAppSettings => "_app_box_settings__";
|
||||
static String get hiveBoxDownloads => "_manga_box_downloads___";
|
||||
static String get hiveBoxReaderSettings => "_reader_box_settings__";
|
||||
static String get hiveBoxReaderMode => "_readerMode_box_settings__";
|
||||
static String get hiveBoxCategories => "_manga_box_categorie__";
|
||||
static String get hiveBoxMangaInfo => "manga_box_info";
|
||||
static String get hiveBoxMangaSource => "manga_box_source";
|
||||
static String get hiveBoxAppSettings => "app_box_settings";
|
||||
static String get hiveBoxDownloads => "manga_box_downloads";
|
||||
static String get hiveBoxReaderMode => "readerMode_box_settings";
|
||||
}
|
||||
|
||||
const defaultUserAgent =
|
||||
|
|
|
|||
|
|
@ -28,18 +28,17 @@ String dateFormat(String timestamp,
|
|||
useRelativeTimesTamps &&
|
||||
relativeTimestamps != 0) {
|
||||
return 'Yesterday';
|
||||
} else if (date.isAfter(twoDaysAgo) ||
|
||||
date.isAfter(twoDaysAgo) ||
|
||||
date.isAfter(threeDaysAgo) ||
|
||||
date.isAfter(fourDaysAgo) ||
|
||||
date.isAfter(fiveDaysAgo) ||
|
||||
date.isAfter(sixDaysAgo) ||
|
||||
date.isAfter(aWeekAgo) &&
|
||||
useRelativeTimesTamps &&
|
||||
useRelativeTimesTamps &&
|
||||
relativeTimestamps == 2) {
|
||||
final difference = today.difference(date).inDays;
|
||||
return difference != 7 ? '$difference days ago' : 'A week ago';
|
||||
} else if (useRelativeTimesTamps && relativeTimestamps == 2) {
|
||||
if (date.isAfter(twoDaysAgo) ||
|
||||
date.isAfter(twoDaysAgo) ||
|
||||
date.isAfter(threeDaysAgo) ||
|
||||
date.isAfter(fourDaysAgo) ||
|
||||
date.isAfter(fiveDaysAgo) ||
|
||||
date.isAfter(sixDaysAgo) ||
|
||||
date.isAfter(aWeekAgo)) {
|
||||
final difference = today.difference(date).inDays;
|
||||
return difference != 7 ? '$difference days ago' : 'A week ago';
|
||||
}
|
||||
}
|
||||
return formatter.format(date);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue