mirror of
https://github.com/Xevion/paperless-mobile.git
synced 2025-12-10 12:07:58 -06:00
feat: Split settings, encrypted user credentials, preparations for multi user support
This commit is contained in:
47
lib/core/config/hive/custpm_adapters/theme_mode_adapter.dart
Normal file
47
lib/core/config/hive/custpm_adapters/theme_mode_adapter.dart
Normal file
@@ -0,0 +1,47 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:hive_flutter/adapters.dart';
|
||||
import 'package:paperless_mobile/core/config/hive/hive_config.dart';
|
||||
|
||||
class ThemeModeAdapter extends TypeAdapter<ThemeMode> {
|
||||
@override
|
||||
final int typeId = HiveTypeIds.themeMode;
|
||||
|
||||
@override
|
||||
ThemeMode read(BinaryReader reader) {
|
||||
switch (reader.readByte()) {
|
||||
case 0:
|
||||
return ThemeMode.system;
|
||||
case 1:
|
||||
return ThemeMode.dark;
|
||||
case 2:
|
||||
return ThemeMode.light;
|
||||
default:
|
||||
return ThemeMode.system;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void write(BinaryWriter writer, ThemeMode obj) {
|
||||
switch (obj) {
|
||||
case ThemeMode.system:
|
||||
writer.writeByte(0);
|
||||
break;
|
||||
case ThemeMode.light:
|
||||
writer.writeByte(1);
|
||||
break;
|
||||
case ThemeMode.dark:
|
||||
writer.writeByte(2);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => typeId.hashCode;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
other is ThemeModeAdapter &&
|
||||
runtimeType == other.runtimeType &&
|
||||
typeId == other.typeId;
|
||||
}
|
||||
39
lib/core/config/hive/hive_config.dart
Normal file
39
lib/core/config/hive/hive_config.dart
Normal file
@@ -0,0 +1,39 @@
|
||||
import 'package:hive_flutter/adapters.dart';
|
||||
import 'package:paperless_mobile/core/config/hive/custpm_adapters/theme_mode_adapter.dart';
|
||||
import 'package:paperless_mobile/features/login/model/authentication_information.dart';
|
||||
import 'package:paperless_mobile/features/login/model/client_certificate.dart';
|
||||
import 'package:paperless_mobile/features/settings/global_app_settings.dart';
|
||||
import 'package:paperless_mobile/features/settings/model/color_scheme_option.dart';
|
||||
import 'package:paperless_mobile/features/settings/user_app_settings.dart';
|
||||
|
||||
class HiveBoxes {
|
||||
HiveBoxes._();
|
||||
static const globalSettings = 'globalSettings';
|
||||
static const userSettings = 'userSettings';
|
||||
static const authentication = 'authentication';
|
||||
static const vault = 'vault';
|
||||
}
|
||||
|
||||
class HiveTypeIds {
|
||||
HiveTypeIds._();
|
||||
static const globalSettings = 0;
|
||||
static const userSettings = 1;
|
||||
static const themeMode = 2;
|
||||
static const colorSchemeOption = 3;
|
||||
static const authentication = 4;
|
||||
static const clientCertificate = 5;
|
||||
}
|
||||
|
||||
class HiveBoxSingleValueKey {
|
||||
HiveBoxSingleValueKey._();
|
||||
static const value = 'value';
|
||||
}
|
||||
|
||||
void registerHiveAdapters() {
|
||||
Hive.registerAdapter(ColorSchemeOptionAdapter());
|
||||
Hive.registerAdapter(ThemeModeAdapter());
|
||||
Hive.registerAdapter(GlobalAppSettingsAdapter());
|
||||
Hive.registerAdapter(UserAppSettingsAdapter());
|
||||
Hive.registerAdapter(AuthenticationInformationAdapter());
|
||||
Hive.registerAdapter(ClientCertificateAdapter());
|
||||
}
|
||||
Reference in New Issue
Block a user