WIP
This commit is contained in:
parent
f63dd994cf
commit
06bf6caadd
|
@ -1,12 +1,10 @@
|
||||||
import 'dart:developer';
|
import 'dart:developer';
|
||||||
|
|
||||||
|
import 'package:hub/features/storage/index.dart';
|
||||||
import 'package:hub/shared/constants/index.dart';
|
import 'package:hub/shared/constants/index.dart';
|
||||||
|
|
||||||
import 'package:sqflite/sqflite.dart';
|
import 'package:sqflite/sqflite.dart';
|
||||||
|
|
||||||
import '../../../storage/application/service/database_service.dart';
|
|
||||||
import '../../../storage/domain/entities/base_storage.dart';
|
|
||||||
|
|
||||||
abstract class ProfileLocalDataSource {
|
abstract class ProfileLocalDataSource {
|
||||||
Future<void> init();
|
Future<void> init();
|
||||||
Future<String?> get(String key);
|
Future<String?> get(String key);
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
export 'service/index.dart';
|
export 'services/index.dart';
|
||||||
|
|
|
@ -1,6 +1,23 @@
|
||||||
import 'package:hub/features/storage/index.dart';
|
import 'package:hub/features/storage/index.dart';
|
||||||
|
import 'package:sqflite/sqflite.dart';
|
||||||
|
|
||||||
class DatabaseStorage implements BaseStorage {
|
class DatabaseStorage implements BaseStorage {
|
||||||
|
DatabaseStorage._();
|
||||||
|
|
||||||
|
static final DatabaseStorage instance = DatabaseStorage._();
|
||||||
|
|
||||||
|
late final Database _database;
|
||||||
|
bool _isInitialized = false;
|
||||||
|
|
||||||
|
|
||||||
|
static DatabaseStorageKey getInstanceByKey(String key) {
|
||||||
|
if (ProfileStorageKey.values.map((e) => e.value).toList().contains(key)) {
|
||||||
|
return ProfileStorageKey.instance;
|
||||||
|
} else (SharedPreferencesKey.values.map((e) => e.value).toList().contains(key)) {
|
||||||
|
return LocalsStorageKey.instance;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> clearAll() {
|
Future<void> clearAll() {
|
||||||
// TODO: implement clearAll
|
// TODO: implement clearAll
|
|
@ -1,3 +1,3 @@
|
||||||
export 'database_storage_helper.dart';
|
export 'database_data_source.dart';
|
||||||
export 'secure_storage_helper.dart';
|
export 'secure_data_source.dart';
|
||||||
export 'shared_storage_helper.dart';
|
export 'shared_data_source.dart';
|
||||||
|
|
|
@ -3,6 +3,7 @@ import 'package:hub/features/storage/index.dart';
|
||||||
abstract class DatabaseStorageKey implements IDatabaseStorage {
|
abstract class DatabaseStorageKey implements IDatabaseStorage {
|
||||||
final String key;
|
final String key;
|
||||||
const DatabaseStorageKey(this.key);
|
const DatabaseStorageKey(this.key);
|
||||||
|
List<String> get values => [];
|
||||||
}
|
}
|
||||||
|
|
||||||
class ProfileStorageKey extends DatabaseStorageKey {
|
class ProfileStorageKey extends DatabaseStorageKey {
|
||||||
|
@ -18,6 +19,20 @@ class ProfileStorageKey extends DatabaseStorageKey {
|
||||||
static const ProfileStorageKey ownerUUID = ProfileStorageKey._('fre_ownerUUID');
|
static const ProfileStorageKey ownerUUID = ProfileStorageKey._('fre_ownerUUID');
|
||||||
static const ProfileStorageKey clientName = ProfileStorageKey._('fre_cliName');
|
static const ProfileStorageKey clientName = ProfileStorageKey._('fre_cliName');
|
||||||
static const ProfileStorageKey ownerName = ProfileStorageKey._('fre_ownerName');
|
static const ProfileStorageKey ownerName = ProfileStorageKey._('fre_ownerName');
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<String> get values => [
|
||||||
|
userEmail.key,
|
||||||
|
devUUID.key,
|
||||||
|
userUUID.key,
|
||||||
|
userDevUUID.key,
|
||||||
|
status.key,
|
||||||
|
userName.key,
|
||||||
|
clientUUID.key,
|
||||||
|
ownerUUID.key,
|
||||||
|
clientName.key,
|
||||||
|
ownerName.key,
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
class LocalsStorageKey extends DatabaseStorageKey {
|
class LocalsStorageKey extends DatabaseStorageKey {
|
||||||
|
@ -35,6 +50,22 @@ class LocalsStorageKey extends DatabaseStorageKey {
|
||||||
static const LocalsStorageKey person = LocalsStorageKey._('fre_person');
|
static const LocalsStorageKey person = LocalsStorageKey._('fre_person');
|
||||||
static const LocalsStorageKey requestOSNotification = LocalsStorageKey._('fre_requestOSnotification');
|
static const LocalsStorageKey requestOSNotification = LocalsStorageKey._('fre_requestOSnotification');
|
||||||
static const LocalsStorageKey isNewVersion = LocalsStorageKey._('fre_isNewVersion');
|
static const LocalsStorageKey isNewVersion = LocalsStorageKey._('fre_isNewVersion');
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<String> get values => [
|
||||||
|
petAmount.key,
|
||||||
|
whatsapp.key,
|
||||||
|
provisional.key,
|
||||||
|
pets.key,
|
||||||
|
local.key,
|
||||||
|
notify.key,
|
||||||
|
fingerprint.key,
|
||||||
|
access.key,
|
||||||
|
panic.key,
|
||||||
|
person.key,
|
||||||
|
requestOSNotification.key,
|
||||||
|
isNewVersion.key,
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
// enum DatabaseStorageKey implements IDatabaseStorage {
|
// enum DatabaseStorageKey implements IDatabaseStorage {
|
||||||
|
|
|
@ -38,7 +38,7 @@ class StorageHelper {
|
||||||
case Storage.sharedPreferences:
|
case Storage.sharedPreferences:
|
||||||
return SharedPreferencesStorage.instance;
|
return SharedPreferencesStorage.instance;
|
||||||
default:
|
default:
|
||||||
return ProfileLocalDataSourceImpl.instance;
|
return DatabaseStorage.instance;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
abstract class StorageRepository {}
|
Loading…
Reference in New Issue