Vaani/lib/db/available_boxes.dart

38 lines
1.3 KiB
Dart
Raw Normal View History

2024-05-08 05:03:49 -04:00
import 'package:flutter/foundation.dart' show immutable;
2025-12-22 15:04:04 +08:00
import 'package:hive_ce/hive.dart';
import 'package:vaani/features/per_book_settings/models/book_settings.dart';
import 'package:vaani/features/settings/models/models.dart';
2024-05-08 05:03:49 -04:00
@immutable
2026-01-13 11:56:49 +08:00
class HiveBoxes {
const HiveBoxes._();
static late final Box<dynamic> basicBox;
2025-12-24 18:02:24 +08:00
2024-05-08 05:03:49 -04:00
/// Box for storing user preferences as [AppSettings]
2026-01-13 11:56:49 +08:00
static late final Box<AppSettings> userPrefsBox;
2024-05-08 05:03:49 -04:00
/// Box for storing [ApiSettings]
2026-01-13 11:56:49 +08:00
static late final Box<ApiSettings> apiSettingsBox;
2024-05-08 05:03:49 -04:00
/// stores the a list of [AudiobookShelfServer]
2026-01-13 11:56:49 +08:00
static late final Box<AudiobookShelfServer> serverBox;
2024-05-08 05:03:49 -04:00
/// stores the a list of [AuthenticatedUser]
2026-01-13 11:56:49 +08:00
static late final Box<AuthenticatedUser> authenticatedUserBox;
/// stores the a list of [BookSettings]
2026-01-13 11:56:49 +08:00
static late final Box<BookSettings> individualBookSettingsBox;
static Future<void> init() async {
basicBox = await Hive.openBox('basicTypes');
userPrefsBox = await Hive.openBox<AppSettings>('userPrefs');
apiSettingsBox = await Hive.openBox<ApiSettings>('apiSettings');
serverBox =
await Hive.openBox<AudiobookShelfServer>('audiobookShelfServer');
authenticatedUserBox =
await Hive.openBox<AuthenticatedUser>('authenticatedUser');
individualBookSettingsBox =
await Hive.openBox<BookSettings>('bookSettings');
}
2024-05-08 05:03:49 -04:00
}