WIP
This commit is contained in:
parent
bbce257283
commit
8632656647
|
@ -1,7 +1,7 @@
|
|||
import 'package:easy_debounce/easy_debounce.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:hub/features/authentication/index.dart';
|
||||
import 'package:hub/features/auth/index.dart';
|
||||
import 'package:hub/flutter_flow/nav/nav.dart';
|
||||
import 'package:hub/shared/utils/limited_text_size.dart';
|
||||
import 'package:hub/shared/utils/validator_util.dart';
|
||||
|
|
|
@ -4,7 +4,7 @@ import 'package:flutter_animate/flutter_animate.dart';
|
|||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:hub/components/atomic_components/shared_components_atoms/atom_image_svg_theme.dart';
|
||||
import 'package:hub/components/atomic_components/term_of_use/atom_terms_of_use.dart';
|
||||
import 'package:hub/features/authentication/index.dart';
|
||||
import 'package:hub/features/auth/index.dart';
|
||||
import 'package:hub/shared/utils/dialog_util.dart';
|
||||
import 'package:hub/shared/utils/limited_text_size.dart';
|
||||
import 'package:hub/shared/utils/log_util.dart';
|
||||
|
|
|
@ -4,7 +4,7 @@ import 'package:flutter_animate/flutter_animate.dart';
|
|||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:hub/components/atomic_components/shared_components_atoms/atom_image_svg_theme.dart';
|
||||
import 'package:hub/components/atomic_components/term_of_use/atom_terms_of_use.dart';
|
||||
import 'package:hub/features/authentication/index.dart';
|
||||
import 'package:hub/features/auth/index.dart';
|
||||
import 'package:hub/features/storage/index.dart';
|
||||
|
||||
import 'package:hub/shared/utils/limited_text_size.dart';
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:hub/features/backend/index.dart';
|
||||
import 'package:hub/features/locals/index.dart';
|
||||
import 'package:hub/features/modules/data/repositories/license_repository_impl.dart';
|
||||
import 'package:hub/features/local/index.dart';
|
||||
import 'package:hub/features/module/data/repositories/license_repository_impl.dart';
|
||||
import 'package:hub/features/storage/index.dart';
|
||||
|
||||
import 'package:hub/flutter_flow/nav/nav.dart';
|
||||
|
@ -153,7 +153,7 @@ class AuthenticationService {
|
|||
await StorageHelper().clean(Storage.secureStorage);
|
||||
await LicenseRepositoryImpl().cleanLicense();
|
||||
DatabaseService.isInitialized = false;
|
||||
await StorageHelper().init();
|
||||
await DatabaseService.instance.init();
|
||||
|
||||
context.go('/welcomePage', extra: extra);
|
||||
}
|
|
@ -3,7 +3,7 @@ import 'dart:convert';
|
|||
import 'dart:developer';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:hub/features/notifications/index.dart';
|
||||
import 'package:hub/features/notification/index.dart';
|
||||
import 'package:hub/features/storage/index.dart';
|
||||
|
||||
import 'package:hub/shared/utils/log_util.dart';
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import 'dart:async';
|
||||
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:hub/features/locals/index.dart';
|
||||
import 'package:hub/features/local/index.dart';
|
||||
import 'package:hub/features/storage/index.dart';
|
||||
|
||||
import 'index.dart';
|
||||
|
|
|
@ -7,7 +7,7 @@ import 'package:hub/features/menu/index.dart';
|
|||
import 'package:hub/flutter_flow/flutter_flow_icon_button.dart';
|
||||
import 'package:hub/flutter_flow/flutter_flow_theme.dart';
|
||||
import 'package:hub/flutter_flow/flutter_flow_util.dart';
|
||||
import 'package:hub/features/locals/index.dart';
|
||||
import 'package:hub/features/local/index.dart';
|
||||
|
||||
class HomePageWidget extends StatefulWidget {
|
||||
const HomePageWidget(this.update, {super.key});
|
||||
|
|
|
@ -3,11 +3,11 @@ import 'package:flutter/material.dart';
|
|||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:hub/features/home/index.dart';
|
||||
import 'package:hub/features/menu/index.dart';
|
||||
import 'package:hub/features/modules/data/index.dart';
|
||||
import 'package:hub/features/module/data/index.dart';
|
||||
|
||||
import 'package:hub/flutter_flow/flutter_flow_theme.dart';
|
||||
import 'package:hub/flutter_flow/flutter_flow_util.dart';
|
||||
import 'package:hub/features/locals/index.dart';
|
||||
import 'package:hub/features/local/index.dart';
|
||||
|
||||
class DrawerWidget extends StatelessWidget {
|
||||
const DrawerWidget({super.key});
|
||||
|
|
|
@ -0,0 +1,74 @@
|
|||
import 'dart:developer';
|
||||
|
||||
import 'package:hub/features/storage/constants/locals_constants.dart';
|
||||
import 'package:hub/features/storage/index.dart';
|
||||
import 'package:sqflite/sqflite.dart';
|
||||
|
||||
abstract class LocalsLocalDataSource implements BaseStorage {}
|
||||
|
||||
class LocalsLocalDataSourceImpl implements LocalsLocalDataSource {
|
||||
static final LocalsLocalDataSourceImpl _instance =
|
||||
LocalsLocalDataSourceImpl._internal();
|
||||
factory LocalsLocalDataSourceImpl() => _instance;
|
||||
LocalsLocalDataSourceImpl._internal();
|
||||
|
||||
bool _isInitialized = false;
|
||||
|
||||
@override
|
||||
Future<void> init() async {
|
||||
if (_isInitialized) return;
|
||||
await DatabaseService.instance.init();
|
||||
_isInitialized = true;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<String?> get(String key) async {
|
||||
final String? local =
|
||||
await StorageHelper().get(ProfileStorageKey.clientUUID.key);
|
||||
var response = await DatabaseService.database.query(
|
||||
LocalsConstants.tableLocalsKeychain,
|
||||
where: 'key = ? AND local = ?',
|
||||
whereArgs: [key, local]);
|
||||
if (response.isEmpty) {
|
||||
return null;
|
||||
}
|
||||
return response.first['value'].toString();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> set<T>(String key, T value) async {
|
||||
var date = DateTime.now().toIso8601String();
|
||||
final String? local =
|
||||
await StorageHelper().get(ProfileStorageKey.clientUUID.key);
|
||||
await DatabaseService.database.insert(
|
||||
LocalsConstants.tableLocalsKeychain,
|
||||
{
|
||||
'key': key,
|
||||
'value': value.toString(),
|
||||
'type': 'local',
|
||||
'updateAt': date,
|
||||
'resolvedAt': date,
|
||||
'createdAt': date,
|
||||
'locals': local
|
||||
},
|
||||
conflictAlgorithm: ConflictAlgorithm.replace);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> delete(String key) async {
|
||||
final String? local =
|
||||
await StorageHelper().get(ProfileStorageKey.clientUUID.key);
|
||||
await DatabaseService.database.delete(LocalsConstants.tableLocalsKeychain,
|
||||
where: 'key = ? AND local = ?', whereArgs: [key, local]);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> clearAll() async {
|
||||
try {
|
||||
await DatabaseService.database
|
||||
.delete(LocalsConstants.tableLocalsKeychain);
|
||||
} catch (e, s) {
|
||||
log('() => clearAll keychain: $e', stackTrace: s);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -4,14 +4,14 @@ import 'dart:developer';
|
|||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:hub/components/organism_components/bottom_arrow_linked_locals_component/bottom_arrow_linked_locals_component_widget.dart';
|
||||
import 'package:hub/features/authentication/index.dart';
|
||||
import 'package:hub/features/auth/index.dart';
|
||||
import 'package:hub/features/backend/index.dart';
|
||||
import 'package:hub/features/modules/data/index.dart';
|
||||
import 'package:hub/features/module/data/index.dart';
|
||||
import 'package:hub/features/storage/index.dart';
|
||||
import 'package:hub/flutter_flow/flutter_flow_util.dart';
|
||||
import 'package:hub/flutter_flow/internationalization.dart';
|
||||
import 'package:hub/flutter_flow/nav/nav.dart';
|
||||
import 'package:hub/features/locals/index.dart';
|
||||
import 'package:hub/features/local/index.dart';
|
||||
import 'package:hub/shared/utils/snackbar_util.dart';
|
||||
|
||||
abstract class LocalsRemoteDataSource {
|
|
@ -2,10 +2,10 @@ import 'dart:developer';
|
|||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:hub/features/locals/index.dart';
|
||||
import 'package:hub/features/local/index.dart';
|
||||
import 'package:hub/features/menu/index.dart';
|
||||
import 'package:hub/features/modules/data/index.dart';
|
||||
import 'package:hub/features/notifications/index.dart';
|
||||
import 'package:hub/features/module/data/index.dart';
|
||||
import 'package:hub/features/notification/index.dart';
|
||||
import 'package:hub/features/storage/index.dart';
|
||||
|
||||
import 'package:hub/shared/utils/dialog_util.dart';
|
||||
|
@ -32,10 +32,16 @@ class LocalsRepositoryImpl implements LocalsRepository {
|
|||
}
|
||||
|
||||
Future<void> select(BuildContext context) async {
|
||||
await localDataSource.unlinkLocal();
|
||||
await unselect();
|
||||
await update(context);
|
||||
}
|
||||
|
||||
Future<void> unselect() async {
|
||||
await StorageHelper().set(ProfileStorageKey.clientUUID.key, '');
|
||||
await StorageHelper().set(ProfileStorageKey.clientName.key, '');
|
||||
await StorageHelper().set(ProfileStorageKey.ownerName.key, '');
|
||||
}
|
||||
|
||||
Future<void> check(BuildContext context) async {
|
||||
final String? cliUUID =
|
||||
await StorageHelper().get(ProfileStorageKey.clientUUID.key);
|
|
@ -6,7 +6,7 @@ import 'package:flutter/material.dart';
|
|||
import 'package:hub/features/storage/index.dart';
|
||||
import 'package:hub/flutter_flow/flutter_flow_model.dart';
|
||||
import 'package:hub/flutter_flow/nav/nav.dart';
|
||||
import 'package:hub/features/locals/index.dart';
|
||||
import 'package:hub/features/local/index.dart';
|
||||
|
||||
class LocalProfileEvent {}
|
||||
|
|
@ -2,11 +2,11 @@ import 'package:cached_network_image/cached_network_image.dart';
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:hub/features/modules/index.dart';
|
||||
import 'package:hub/features/module/index.dart';
|
||||
import 'package:hub/flutter_flow/custom_functions.dart';
|
||||
import 'package:hub/flutter_flow/flutter_flow_theme.dart';
|
||||
import 'package:hub/flutter_flow/flutter_flow_util.dart';
|
||||
import 'package:hub/features/locals/index.dart';
|
||||
import 'package:hub/features/local/index.dart';
|
||||
|
||||
class LocalProfileComponentWidget extends StatefulWidget {
|
||||
const LocalProfileComponentWidget({super.key});
|
|
@ -4,7 +4,7 @@ import 'package:flutter/material.dart';
|
|||
import 'package:hub/features/backend/index.dart';
|
||||
import 'package:hub/features/storage/index.dart';
|
||||
import 'package:hub/flutter_flow/internationalization.dart';
|
||||
import 'package:hub/features/locals/index.dart';
|
||||
import 'package:hub/features/local/index.dart';
|
||||
|
||||
import 'package:hub/shared/utils/dialog_util.dart';
|
||||
import 'package:hub/shared/utils/log_util.dart';
|
|
@ -1,13 +0,0 @@
|
|||
import 'package:hub/features/storage/index.dart';
|
||||
|
||||
abstract class LocalsLocalDataSource {
|
||||
Future<void> unlinkLocal();
|
||||
}
|
||||
|
||||
class LocalsLocalDataSourceImpl {
|
||||
Future<void> unlinkLocal() async {
|
||||
await StorageHelper().set(ProfileStorageKey.clientUUID.key, '');
|
||||
await StorageHelper().set(ProfileStorageKey.clientName.key, '');
|
||||
await StorageHelper().set(ProfileStorageKey.ownerName.key, '');
|
||||
}
|
||||
}
|
|
@ -1,14 +1,13 @@
|
|||
import 'dart:developer';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:hub/features/authentication/index.dart';
|
||||
import 'package:hub/features/auth/index.dart';
|
||||
import 'package:hub/features/menu/index.dart';
|
||||
import 'package:hub/features/module/index.dart';
|
||||
import 'package:hub/flutter_flow/nav/nav.dart';
|
||||
import 'package:hub/shared/extensions/dialog_extensions.dart';
|
||||
import 'package:hub/shared/utils/path_util.dart';
|
||||
|
||||
import '../../../modules/domain/entities/index.dart';
|
||||
|
||||
abstract class MenuLocalDataSource {
|
||||
Future<MenuItem?> addMenuEntry(EnumMenuItem item, List<MenuItem?> entries,
|
||||
IconData icon, String text, Function() action);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import 'dart:developer';
|
||||
|
||||
import 'package:hub/features/menu/index.dart';
|
||||
import 'package:hub/features/modules/index.dart';
|
||||
import 'package:hub/features/module/index.dart';
|
||||
import 'package:hub/flutter_flow/custom_functions.dart';
|
||||
|
||||
class MenuRepositoryImpl implements MenuRepository {
|
||||
|
|
|
@ -2,8 +2,8 @@ import 'dart:async';
|
|||
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:hub/features/menu/index.dart';
|
||||
import 'package:hub/features/modules/index.dart';
|
||||
import 'package:hub/features/locals/index.dart';
|
||||
import 'package:hub/features/module/index.dart';
|
||||
import 'package:hub/features/local/index.dart';
|
||||
|
||||
class MenuEvent {}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:hub/features/modules/index.dart';
|
||||
import 'package:hub/features/module/index.dart';
|
||||
import 'package:hub/flutter_flow/internationalization.dart';
|
||||
import 'package:hub/flutter_flow/nav/nav.dart';
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import 'package:hub/features/locals/index.dart';
|
||||
import 'package:hub/features/local/index.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:hub/features/menu/index.dart';
|
||||
import 'package:hub/features/modules/index.dart';
|
||||
import 'package:hub/features/module/index.dart';
|
||||
|
||||
import 'package:hub/shared/utils/loading_util.dart';
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import 'package:hub/features/modules/index.dart';
|
||||
import 'package:hub/features/module/index.dart';
|
||||
import 'package:hub/features/storage/index.dart';
|
||||
import 'package:hub/shared/extensions/string_extensions.dart';
|
||||
|
|
@ -4,8 +4,8 @@ import 'dart:async';
|
|||
import 'dart:developer';
|
||||
|
||||
import 'package:hub/features/backend/index.dart';
|
||||
import 'package:hub/features/locals/data/repositories/locals_repository_impl.dart';
|
||||
import 'package:hub/features/modules/index.dart';
|
||||
import 'package:hub/features/local/data/repositories/locals_repository_impl.dart';
|
||||
import 'package:hub/features/module/index.dart';
|
||||
|
||||
import 'package:sqflite/sqflite.dart';
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
import 'dart:developer';
|
||||
|
||||
import 'package:hub/features/modules/data/data_sources/index.dart';
|
||||
import 'package:hub/features/modules/domain/index.dart';
|
||||
import 'package:hub/features/module/data/data_sources/index.dart';
|
||||
import 'package:hub/features/module/domain/index.dart';
|
||||
import 'package:hub/features/storage/index.dart';
|
||||
import 'package:sqflite/sqflite.dart';
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
import 'package:hub/features/modules/index.dart';
|
||||
import 'package:hub/features/module/index.dart';
|
||||
|
||||
enum ModuleStatus { active, inactive, disabled }
|
||||
|
|
@ -2,7 +2,7 @@ import 'dart:developer';
|
|||
|
||||
import 'package:firebase_messaging/firebase_messaging.dart';
|
||||
import 'package:hub/features/backend/index.dart';
|
||||
import 'package:hub/features/storage/data/index.dart';
|
||||
import 'package:hub/features/storage/index.dart';
|
||||
|
||||
import 'package:hub/shared/utils/log_util.dart';
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
import 'dart:developer';
|
||||
|
||||
import 'package:hub/features/storage/constants/profile_constants.dart';
|
||||
import 'package:hub/features/storage/index.dart';
|
||||
import 'package:hub/shared/constants/index.dart';
|
||||
|
||||
|
@ -7,11 +8,11 @@ import 'package:sqflite/sqflite.dart';
|
|||
|
||||
abstract class ProfileLocalDataSource implements DatabaseStorage {}
|
||||
|
||||
class ProfileLocalDataSourceImpl implements BaseStorage {
|
||||
ProfileLocalDataSourceImpl._();
|
||||
|
||||
static final ProfileLocalDataSourceImpl instance =
|
||||
ProfileLocalDataSourceImpl._();
|
||||
class ProfileLocalDataSourceImpl implements ProfileLocalDataSource {
|
||||
static final ProfileLocalDataSourceImpl _instance =
|
||||
ProfileLocalDataSourceImpl._internal();
|
||||
factory ProfileLocalDataSourceImpl() => _instance;
|
||||
ProfileLocalDataSourceImpl._internal();
|
||||
|
||||
bool _isInitialized = false;
|
||||
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
export 'locals_constants.dart';
|
||||
export 'profile_constants.dart';
|
|
@ -0,0 +1,17 @@
|
|||
class LocalsConstants {
|
||||
static const String tableLocalsKeychain = 'LocalsKeychain';
|
||||
|
||||
static String get createLocalsTable => '''
|
||||
CREATE TABLE IF NOT EXISTS $tableLocalsKeychain (
|
||||
key TEXT,
|
||||
value TEXT,
|
||||
type TEXT,
|
||||
updateAt TEXT,
|
||||
resolvedAt TEXT,
|
||||
createdAt TEXT,
|
||||
local TEXT
|
||||
);
|
||||
''';
|
||||
static String get deleteLocalsTable =>
|
||||
'DROP TABLE IF EXISTS $tableLocalsKeychain;';
|
||||
}
|
|
@ -18,7 +18,7 @@ enum ProfileStorageKey implements DatabaseStorageKey {
|
|||
|
||||
static const String table = 'profileTable';
|
||||
|
||||
static List<String> get values =>
|
||||
static List<String> get keys =>
|
||||
ProfileStorageKey.values.map((e) => e.key).toList();
|
||||
}
|
||||
|
||||
|
@ -42,6 +42,6 @@ enum LocalsStorageKey implements DatabaseStorageKey {
|
|||
|
||||
static const String table = 'LocalsStorageKey';
|
||||
|
||||
static List<String> get values =>
|
||||
static List<String> get keys =>
|
||||
LocalsStorageKey.values.map((e) => e.key).toList();
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
export 'database_storage.dart';
|
||||
export 'secure_storage.dart';
|
||||
export 'shared_storage.dart';
|
||||
export 'database_storage_key.dart';
|
||||
export 'secure_storage_key.dart';
|
||||
export 'shared_storage_key.dart';
|
||||
export 'storage.dart';
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import 'package:hub/features/local/index.dart';
|
||||
import 'package:hub/features/profile/index.dart';
|
||||
import 'package:hub/features/storage/index.dart';
|
||||
|
||||
|
@ -11,20 +12,28 @@ class DatabaseStorage implements BaseStorage {
|
|||
// bool _isInitialized = false;
|
||||
|
||||
static BaseStorage getInstanceByKey(String key) {
|
||||
if (ProfileStorageKey.values.contains(key))
|
||||
return ProfileLocalDataSourceImpl.instance(key);
|
||||
else //if (LocalsStorageKey.values.contains(key));
|
||||
return LocalsStorageKey.instance(key);
|
||||
if (ProfileStorageKey.keys.contains(key)) //
|
||||
{
|
||||
return ProfileLocalDataSourceImpl();
|
||||
} else //if (LocalsStorageKey.values.contains(key))
|
||||
{
|
||||
return LocalsLocalDataSourceImpl();
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> clearAll() => throw UnimplementedError();
|
||||
Future<void> clearAll() => //
|
||||
throw UnimplementedError();
|
||||
@override
|
||||
Future<void> delete(String key) => throw UnimplementedError();
|
||||
Future<void> delete(String key) async =>
|
||||
await getInstanceByKey(key).delete(key);
|
||||
@override
|
||||
Future<String?> get(String key) => throw UnimplementedError();
|
||||
Future<String?> get(String key) async => //
|
||||
await getInstanceByKey(key).get(key);
|
||||
@override
|
||||
Future<void> init() => throw UnimplementedError();
|
||||
Future<void> init() async => //
|
||||
await DatabaseService.instance.init();
|
||||
@override
|
||||
Future<void> set<T>(String key, T value) => throw UnimplementedError();
|
||||
Future<void> set<T>(String key, T value) async =>
|
||||
await getInstanceByKey(key).set(key, value);
|
||||
}
|
||||
|
|
|
@ -3,3 +3,4 @@ export 'enums/index.dart';
|
|||
export 'helpers/index.dart';
|
||||
export 'repositories/index.dart';
|
||||
export 'services/index.dart';
|
||||
export 'constants/index.dart';
|
||||
|
|
|
@ -20,7 +20,7 @@ class StorageHelper implements StorageRepository {
|
|||
Future<void> init() async {
|
||||
await SecureStorage.instance.init();
|
||||
await SharedPreferencesStorage.instance.init();
|
||||
await ProfileLocalDataSourceImpl.instance.init();
|
||||
await DatabaseStorage.instance.init();
|
||||
|
||||
String? isFirstRun = await SharedPreferencesStorage.instance
|
||||
.get(SharedPreferencesKey.isFirstRun.value);
|
||||
|
@ -45,7 +45,10 @@ class StorageHelper implements StorageRepository {
|
|||
}
|
||||
|
||||
static BaseStorage getInstanceByKey(String key) {
|
||||
if (SecureStorageKey.values.map((e) => e.value).toList().contains(key)) {
|
||||
if (SecureStorageKey.values //
|
||||
.map((e) => e.value)
|
||||
.toList()
|
||||
.contains(key)) {
|
||||
return SecureStorage.instance;
|
||||
} else if (SharedPreferencesKey.values
|
||||
.map((e) => e.value)
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
import 'package:hub/features/modules/index.dart';
|
||||
import 'package:hub/features/module/index.dart';
|
||||
import 'package:hub/features/storage/index.dart';
|
||||
import 'package:hub/shared/constants/index.dart';
|
||||
import 'package:sqflite/sqflite.dart';
|
||||
import 'package:path/path.dart';
|
||||
|
||||
class DatabaseService {
|
||||
static const String _dbName = 'database.db';
|
||||
static const int _dbVersion = 2;
|
||||
static const int _dbVersion = 3;
|
||||
|
||||
static final DatabaseService instance = DatabaseService._internal();
|
||||
factory DatabaseService() => instance;
|
||||
|
@ -48,14 +49,21 @@ class DatabaseService {
|
|||
|
||||
Future<void> _onCreate(Database database, int version) async {
|
||||
print('Creating database...');
|
||||
await _createTables(database, version);
|
||||
await database.execute(createKeychainTable);
|
||||
_onUpgrade(database, 1, _dbVersion);
|
||||
}
|
||||
|
||||
Future<void> _onUpgrade(
|
||||
Database database, int oldVersion, int newVersion) async {
|
||||
print('Upgrading database from version $oldVersion to $newVersion...');
|
||||
if (oldVersion < 2 && newVersion >= 2) {
|
||||
await _createTables(database, newVersion);
|
||||
await database.execute(LicenseConstants.updatePetsHistoryTrigger);
|
||||
await database.execute(LicenseConstants.updateDisplayTrigger);
|
||||
await database.execute(LicenseConstants.insertDisplayTrigger);
|
||||
await database.execute(LicenseConstants.updatePeopleDisplayTrigger);
|
||||
}
|
||||
if (oldVersion < 3 && newVersion >= 3) {
|
||||
await database.execute(LocalsConstants.createLocalsTable);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -63,7 +71,14 @@ class DatabaseService {
|
|||
Database database, int oldVersion, int newVersion) async {
|
||||
print('Downgrading database from version $oldVersion to $newVersion...');
|
||||
if (oldVersion >= 2 && newVersion < 2) {
|
||||
await _dropTables(database);
|
||||
await database.execute(LicenseConstants.deleteLicenseTable);
|
||||
await database.execute(LicenseConstants.dropPeopleDisplayTrigger);
|
||||
await database.execute(LicenseConstants.dropInsertDisplayTrigger);
|
||||
await database.execute(LicenseConstants.dropUpdateDisplayTrigger);
|
||||
await database.execute(LicenseConstants.dropPetsHistoryTrigger);
|
||||
}
|
||||
if (oldVersion >= 3 && newVersion > 3) {
|
||||
await database.execute(LocalsConstants.deleteLocalsTable);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -73,23 +88,4 @@ class DatabaseService {
|
|||
// await database.execute('PRAGMA temp_store = MEMORY;');
|
||||
// await database.execute('PRAGMA foreign_keys = ON;');
|
||||
}
|
||||
|
||||
Future<void> _createTables(Database database, int version) async {
|
||||
await database.execute(createKeychainTable);
|
||||
await database.execute(LicenseConstants.createLicenseTable);
|
||||
if (version >= 2) {
|
||||
await database.execute(LicenseConstants.updatePetsHistoryTrigger);
|
||||
await database.execute(LicenseConstants.updateDisplayTrigger);
|
||||
await database.execute(LicenseConstants.insertDisplayTrigger);
|
||||
await database.execute(LicenseConstants.updatePeopleDisplayTrigger);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _dropTables(Database database) async {
|
||||
await database.execute(LicenseConstants.deleteLicenseTable);
|
||||
await database.execute(LicenseConstants.dropPeopleDisplayTrigger);
|
||||
await database.execute(LicenseConstants.dropInsertDisplayTrigger);
|
||||
await database.execute(LicenseConstants.dropUpdateDisplayTrigger);
|
||||
await database.execute(LicenseConstants.dropPetsHistoryTrigger);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
|||
import 'package:hub/features/backend/index.dart';
|
||||
import 'package:hub/features/history/index.dart';
|
||||
import 'package:hub/features/home/index.dart';
|
||||
import 'package:hub/features/locals/index.dart';
|
||||
import 'package:hub/features/local/index.dart';
|
||||
import 'package:hub/features/menu/index.dart';
|
||||
import 'package:hub/features/property/index.dart';
|
||||
import 'package:hub/features/storage/index.dart';
|
||||
|
|
|
@ -7,13 +7,12 @@ import 'package:flutter/foundation.dart';
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_web_plugins/url_strategy.dart';
|
||||
import 'package:hub/features/notifications/index.dart';
|
||||
import 'package:hub/features/notification/index.dart';
|
||||
import 'package:hub/features/storage/index.dart';
|
||||
import 'package:hub/flutter_flow/flutter_flow_theme.dart';
|
||||
import 'package:hub/flutter_flow/flutter_flow_util.dart';
|
||||
import 'package:hub/flutter_flow/nav/nav.dart';
|
||||
|
||||
import 'features/storage/index.dart';
|
||||
|
||||
Future<void> initializeApp() async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
await _initializeTracking();
|
||||
|
|
|
@ -6,7 +6,8 @@ import 'package:firebase_crashlytics/firebase_crashlytics.dart';
|
|||
import 'package:firebase_messaging/firebase_messaging.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||
import 'package:hub/features/notifications/index.dart';
|
||||
import 'package:hub/features/notification/index.dart';
|
||||
import 'package:hub/features/storage/index.dart';
|
||||
import 'package:hub/flutter_flow/flutter_flow_theme.dart';
|
||||
import 'package:hub/flutter_flow/internationalization.dart';
|
||||
import 'package:hub/flutter_flow/nav/nav.dart';
|
||||
|
@ -14,7 +15,6 @@ import 'package:hub/flutter_flow/nav/nav.dart';
|
|||
import 'package:responsive_framework/responsive_framework.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
import 'features/storage/index.dart';
|
||||
import 'initialization.dart';
|
||||
|
||||
final GlobalKey<NavigatorState> navigatorKey = GlobalKey<NavigatorState>();
|
||||
|
|
|
@ -2,7 +2,7 @@ import 'package:easy_debounce/easy_debounce.dart';
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_animate/flutter_animate.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:hub/features/authentication/index.dart';
|
||||
import 'package:hub/features/auth/index.dart';
|
||||
import 'package:hub/features/storage/index.dart';
|
||||
import 'package:hub/flutter_flow/nav/nav.dart';
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ import 'package:flutter/material.dart';
|
|||
import 'package:http/http.dart';
|
||||
import 'package:hub/components/templates_components/details_component/details_component_widget.dart';
|
||||
import 'package:hub/features/backend/index.dart';
|
||||
import 'package:hub/features/storage/data/index.dart';
|
||||
import 'package:hub/features/storage/index.dart';
|
||||
import 'package:hub/flutter_flow/flutter_flow_theme.dart';
|
||||
import 'package:hub/flutter_flow/flutter_flow_util.dart';
|
||||
import 'package:hub/flutter_flow/flutter_flow_widgets.dart';
|
||||
|
|
|
@ -2,12 +2,12 @@ import 'dart:developer';
|
|||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:hub/components/templates_components/change_passs_qr_code_pass_key_template_component/change_pass_widget.dart';
|
||||
import 'package:hub/features/authentication/index.dart';
|
||||
import 'package:hub/features/auth/index.dart';
|
||||
import 'package:hub/features/backend/index.dart';
|
||||
import 'package:hub/features/storage/index.dart';
|
||||
import 'package:hub/flutter_flow/flutter_flow_util.dart';
|
||||
import 'package:hub/flutter_flow/nav/nav.dart';
|
||||
import 'package:hub/features/locals/index.dart';
|
||||
import 'package:hub/features/local/index.dart';
|
||||
|
||||
import 'package:hub/shared/utils/path_util.dart';
|
||||
import 'package:share_plus/share_plus.dart';
|
||||
|
|
|
@ -5,15 +5,15 @@ import 'package:flutter/material.dart';
|
|||
import 'package:google_fonts/google_fonts.dart';
|
||||
|
||||
import 'package:hub/components/atomic_components/shared_components_atoms/atom_image_svg_theme.dart';
|
||||
import 'package:hub/features/authentication/index.dart';
|
||||
import 'package:hub/features/auth/index.dart';
|
||||
import 'package:hub/features/backend/index.dart';
|
||||
import 'package:hub/features/notifications/index.dart';
|
||||
import 'package:hub/features/notification/index.dart';
|
||||
import 'package:hub/features/storage/index.dart';
|
||||
import 'package:hub/flutter_flow/flutter_flow_theme.dart';
|
||||
import 'package:hub/flutter_flow/flutter_flow_util.dart';
|
||||
import 'package:hub/flutter_flow/flutter_flow_widgets.dart';
|
||||
import 'package:hub/pages/reception_page/reception_page_model.dart';
|
||||
import 'package:hub/features/locals/index.dart';
|
||||
import 'package:hub/features/local/index.dart';
|
||||
|
||||
import 'package:hub/shared/utils/limited_text_size.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
export 'keychain_constants.dart';
|
Loading…
Reference in New Issue