This commit is contained in:
J. A. Messias 2024-12-06 10:00:41 -03:00
parent 4925433c92
commit 3080eac50b
19 changed files with 175 additions and 111 deletions

View File

@ -25,4 +25,4 @@ class OrderFilterModalModel extends FlutterFlowModel<OrderFilterModalWidget> {
textFieldFocusNode?.dispose();
textController?.dispose();
}
}
}

View File

@ -4,7 +4,6 @@ import 'package:hub/components/molecular_components/order_filter_modal/order_fil
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 'package:hub/shared/helpers/storage/storage_helper.dart';
// ignore: unused_import
import 'package:hub/shared/utils/limited_text_size.dart';
@ -29,22 +28,22 @@ class _OrderFilterModalWidgetState extends State<OrderFilterModalWidget> {
late Map<String, dynamic> selected;
final List<Map<String, String>> adresseeTypeOptions = [
{
'title': FFLocalizations.of(StorageHelper().context!).getVariableText(enText: 'Resident', ptText: 'Morador'),
'title': FFLocalizations.of(navigatorKey.currentContext!).getVariableText(enText: 'Resident', ptText: 'Morador'),
'value': 'MOR'
},
{
'title': FFLocalizations.of(StorageHelper().context!).getVariableText(enText: 'Property', ptText: 'Propriedade'),
'title': FFLocalizations.of(navigatorKey.currentContext!).getVariableText(enText: 'Property', ptText: 'Propriedade'),
'value': 'PRO'
},
];
final List<Map<String, String>> statusOptions = [
{
'title': FFLocalizations.of(StorageHelper().context!)
'title': FFLocalizations.of(navigatorKey.currentContext!)
.getVariableText(ptText: 'Aguardando Retirada', enText: 'Waiting for Pickup'),
'value': 'notPickedUp'
},
{
'title': FFLocalizations.of(StorageHelper().context!).getVariableText(ptText: 'Retirado', enText: 'Picked Up'),
'title': FFLocalizations.of(navigatorKey.currentContext!).getVariableText(ptText: 'Retirado', enText: 'Picked Up'),
'value': 'pickedUp'
},
];
@ -232,4 +231,4 @@ class _OrderFilterModalWidgetState extends State<OrderFilterModalWidget> {
),
);
}
}
}

View File

@ -42,8 +42,11 @@ class _HomePageWidgetState extends State<HomePageWidget> {
Widget build(BuildContext context) {
return Builder(
builder: (context) {
// LocalsRepositoryImpl.license.add(false);
// context.read<LocalProfileBloc>().add(LocalProfileEvent());
// context.read<MenuBloc>().add(MenuEvent());
LocalsRepositoryImpl.license.add(true);
// context.read<LocalProfileBloc>().updateProfile(context);
return Scaffold(
key: scaffoldKey,
backgroundColor: FlutterFlowTheme.of(context).primaryBackground,

View File

@ -123,10 +123,7 @@ GoRouter createRouter(AppStateNotifier appStateNotifier) {
);
}),
FFRoute(name: 'homePage', path: '/homePage', builder: (context, params) {
log('params: $params');
final Future<bool> Function(BuildContext context)? update = params.getParam('update', ParamType.Function);
log('update: $update');
return HomePageWidget(key: UniqueKey(), update: update);
}),

View File

@ -192,11 +192,15 @@ class _AppState extends State<App> with WidgetsBindingObserver {
@override
void didChangeAppLifecycleState(AppLifecycleState state) async {
if (state == AppLifecycleState.detached) {
final isLogged = await StorageHelper().get(SecureStorageKey.isLogged.value);
log('isLogged: $isLogged');
if (isLogged.toBoolean()) {
LocalsRepositoryImpl.license.add(false);
final response = await LocalsRepositoryImpl().update(context);
LocalsRepositoryImpl.license.add(response);
await FirebaseMessagingService().updateDeviceToken();
}
}
}
@override

View File

@ -36,11 +36,11 @@ class _PackageOrderPage extends State<PackageOrderPage> {
List<dynamic> _orderList = [];
final Map<String, String> filter = {
'adresseeType': 'PRO',
'adresseeType': '.*',
'status': 'notPickedUp',
};
String _adresseeType = 'PRO';
String _adresseeType = '.*';
String _status = 'notPickedUp';
late BehaviorSubject<Map<String, String>> _selectedTypeSubject;
@ -64,7 +64,7 @@ class _PackageOrderPage extends State<PackageOrderPage> {
}
Future<void> initDatabase() async {
cliUUID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? '';
cliUUID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value) ?? '');
}
@override
@ -224,7 +224,7 @@ class _PackageOrderPage extends State<PackageOrderPage> {
return AppBar(
backgroundColor: FlutterFlowTheme.of(context).primaryBackground,
automaticallyImplyLeading: false,
title: Text(FFLocalizations.of(context).getVariableText(enText: 'Orders', ptText: 'Encomendas'),
title: Text(FFLocalizations.of(context).getVariableText(enText: 'My Orders', ptText: 'Minhas Encomendas'),
style: FlutterFlowTheme.of(context).headlineMedium.override(
fontFamily: 'Nunito',
color: FlutterFlowTheme.of(context).primaryText,
@ -412,9 +412,8 @@ class _PackageOrderPage extends State<PackageOrderPage> {
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: FlutterFlowTheme.of(context).primaryBackground,
appBar: _appBar(context),
body: _appBody(context),
);
}
}
}

View File

@ -3,6 +3,7 @@ import 'dart:developer';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:hub/shared/components/molecules/locals/index.dart';
import 'package:hub/shared/components/molecules/menu/presentation/blocs/menu_bloc.dart';
import 'package:hub/shared/components/molecules/modules/index.dart';
import 'package:hub/shared/helpers/storage/base_storage.dart';
import 'package:hub/shared/helpers/storage/storage_helper.dart';
@ -23,18 +24,34 @@ class LocalsRepositoryImpl implements LocalsRepository {
@override
Future<bool> update(BuildContext context) async {
bool response = false;
while (!response) {
response = await remoteDataSource.processLocals(context);
if (!response) {
await StorageHelper().set(KeychainStorageKey.clientUUID.value, '');
const String errorMsg = 'Erro ao atualizar locais';
await DialogUtil.error(context, errorMsg);
try {
while (!response) {
response = await remoteDataSource.processLocals(context);
if (!response) {
await _handleUpdateError(context);
}
}
await _notifyBlocs(context);
} catch (e) {
log('Error updating locals: $e');
await _handleUpdateError(context);
}
context.read<LocalProfileBloc>().add(LocalProfileEvent());
return response;
}
Future<void> _handleUpdateError(BuildContext context) async {
await StorageHelper().set(KeychainStorageKey.clientUUID.value, '');
const String errorMsg = 'Erro ao atualizar locais';
await DialogUtil.error(context, errorMsg);
}
Future<void> _notifyBlocs(BuildContext context) async {
LocalsRepositoryImpl.license.add(false);
context.read<LocalProfileBloc>().add(LocalProfileEvent());
context.read<MenuBloc>().add(MenuEvent());
LocalsRepositoryImpl.license.add(true);
}
@override
Future<void> unlinkLocal(BuildContext context) {
return remoteDataSource.detachLocal(context);

View File

@ -36,7 +36,6 @@ class LocalProfileBloc extends Bloc<LocalProfileEvent, LocalProfileState> {
}
Future<void> _onLocalProfileEvent(LocalProfileEvent event, Emitter<LocalProfileState> emit) async {
log('LocalProfileBloc: _onLocalProfileEvent');
final cliName = (await StorageHelper().get(KeychainStorageKey.clientName.value)) ?? '';
final ownerName = (await StorageHelper().get(KeychainStorageKey.ownerName.value)) ?? '';
final cliUUID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? '';

View File

@ -22,17 +22,16 @@ class MenuRepositoryImpl implements MenuRepository {
Future<List<MenuItem?>> generateMenuEntries(List<MenuEntry> menuEntries, EnumMenuItem item) async {
log('Generating menu entries for $item');
List<MenuItem?> entries = [];
final bool isNewVersion = await StorageHelper().get(KeychainStorageKey.isNewVersion.value).then((v) => v.toBoolean());
// final bool isNewVersion = await StorageHelper().get(KeychainStorageKey.isNewVersion.value).then((v) => v.toBoolean());
try {
for (var entry in menuEntries) {
log('Processing entry: ${entry.key}');
final bool isDefault = await menuDataSource.processDisplayDefault(item, entry, entries);
if (isDefault) continue;
final licenseValue = await LicenseRepositoryImpl().getLicense(entry.key);
if (licenseValue != null) {
final licenseMap = await stringToMap(licenseValue);
final display = await processDisplay(licenseMap, isNewVersion);
final display = EnumDisplay.fromString(licenseMap['display']);
final startDate = licenseMap['startDate'] ?? '';
final expirationDate = licenseMap['expirationDate'] ?? '';
final isStarted = await menuDataSource.processStartDate(startDate, entry);
@ -57,13 +56,9 @@ class MenuRepositoryImpl implements MenuRepository {
}
Future<EnumDisplay> processDisplay(Map<String, dynamic> module, bool isNewVersion) async {
const keysToCheck = [
LicenseKeys.residents,
LicenseKeys.vehicles,
LicenseKeys.openedVisits
];
if (isNewVersion && keysToCheck.any((key) => module['key'] == key.value)) {
if (await _shouldUpdateDisplay(module, isNewVersion)) {
final displayValue = module['display'] == EnumDisplay.active ? 'VISIVEL' : 'INVISIVEL';
await LicenseLocalDataSourceImpl().setDisplayByKey(['FRE-HUB-ABOUT-PROPERTY'], displayValue);
return EnumDisplay.fromString(displayValue);
@ -72,5 +67,14 @@ class MenuRepositoryImpl implements MenuRepository {
return EnumDisplay.fromString(module['display']);
}
Future<bool> _shouldUpdateDisplay(Map<String, dynamic> module, bool isNewVersion) async {
const keysToCheck = [
LicenseKeys.residents,
LicenseKeys.vehicles,
LicenseKeys.openedVisits
];
return isNewVersion && keysToCheck.any((key) => module['key'] == key.value);
}
}

View File

@ -33,24 +33,21 @@ class MenuBloc extends Bloc<MenuEvent, MenuState> {
final MenuView style;
final EnumMenuItem item;
final List<MenuEntry> entries;
late StreamSubscription<void> _completer;
late StreamSubscription<bool> _completer;
MenuBloc({required this.style, required this.item, required this.entries}) : super(MenuState()) {
on<MenuEvent>(_onMenuEvent);
_completer = LicenseRemoteDataSourceImpl().streamCompleterController.listen((_) {
_completer = LocalsRepositoryImpl.license.stream.listen((v) {
add(MenuEvent());
});
}
}
Future<void> _onMenuEvent(MenuEvent event, Emitter<MenuState> emit) async {
Future<void> _onMenuEvent(MenuEvent event, Emitter<MenuState> emit) async {
await LicenseRemoteDataSourceImpl().waitForSaveCompletion();
final List<MenuItem?> NewEntries = await MenuRepositoryImpl().generateMenuEntries(entries, item);
emit(state.copyWith(menuEntries: NewEntries));
}
final List<MenuItem?> newEntries = await MenuRepositoryImpl().generateMenuEntries(entries, item);
emit(state.copyWith(menuEntries: newEntries));
}
@override
Future<void> close() {

View File

@ -1,7 +1,8 @@
const String tableLicense = 'license';
String get createLicenseTable => '''
class LicenseConstants {
static String get createLicenseTable => '''
CREATE TABLE IF NOT EXISTS $tableLicense (
key TEXT UNIQUE,
display TEXT,
@ -11,9 +12,9 @@
);
''';
String get deleteLicenseTable => 'DROP TABLE IF EXISTS $tableLicense;';
static String get deleteLicenseTable => 'DROP TABLE IF EXISTS $tableLicense;';
String get updatePetsHistoryTrigger => '''
static String get updatePetsHistoryTrigger => '''
CREATE TRIGGER update_fre_hub_pets_history
AFTER INSERT ON $tableLicense
WHEN NEW.key = 'FRE-HUB-PETS'
@ -23,15 +24,35 @@
END;
''';
String get dropPetsHistoryTrigger => 'DROP TRIGGER IF EXISTS update_fre_hub_pets_history;';
static String get dropPetsHistoryTrigger => 'DROP TRIGGER IF EXISTS update_fre_hub_pets_history;';
String get updateDisplayTrigger => '''
static String get updateDisplayTrigger => '''
CREATE TRIGGER update_display_trigger
AFTER UPDATE ON $tableLicense
WHEN NEW.key IN ('FRE-HUB-OPENED-VISITS', 'FRE-HUB-VEHICLES', 'FRE-HUB-RESIDENTS')
BEGIN
INSERT OR REPLACE INTO $tableLicense (key, display, expirationDate, startDate, quantity)
VALUES (
'FRE-HUB-ABOUT-PROPERTY',
CASE
WHEN (SELECT COUNT(*) FROM $tableLicense WHERE key IN ('FRE-HUB-OPENED-VISITS', 'FRE-HUB-VEHICLES', 'FRE-HUB-RESIDENTS') AND display = 'VISIVEL') > 0
THEN 'VISIVEL'
ELSE 'INVISIVEL'
END,
NULL, NULL, NULL
);
END;
''';
static String get dropUpdateDisplayTrigger => 'DROP TRIGGER IF EXISTS update_display_trigger;';
static String get insertDisplayTrigger => '''
CREATE TRIGGER insert_display_trigger
AFTER INSERT ON $tableLicense
WHEN NEW.key IN ('FRE-HUB-OPENED-VISITS', 'FRE-HUB-VEHICLES', 'FRE-HUB-RESIDENTS')
BEGIN
UPDATE $tableLicense
SET display =
SET display =
CASE
WHEN (SELECT COUNT(*) FROM $tableLicense WHERE key IN ('FRE-HUB-OPENED-VISITS', 'FRE-HUB-VEHICLES', 'FRE-HUB-RESIDENTS') AND display = 'VISIVEL') > 0
THEN 'VISIVEL'
@ -41,17 +62,23 @@
END;
''';
String get dropDisplayTrigger => 'DROP TRIGGER IF EXISTS update_display_trigger;';
static String get dropInsertDisplayTrigger => 'DROP TRIGGER IF EXISTS insert_display_trigger;';
String get updatePeopleDisplayTrigger => '''
CREATE TRIGGER update_people_display_trigger
AFTER UPDATE ON $tableLicense
WHEN NEW.key = 'FRE-HUB-ABOUT-PROPERTY' AND NEW.display = 'VISIVEL'
BEGIN
UPDATE $tableLicense
SET display = 'INVISIVEL'
WHERE key = 'FRE-HUB-PEOPLE';
END;
static String get updatePeopleDisplayTrigger => '''
CREATE TRIGGER update_people_display_trigger
AFTER UPDATE ON $tableLicense
WHEN NEW.key IN ('FRE-HUB-OPENED-VISITS', 'FRE-HUB-VEHICLES', 'FRE-HUB-RESIDENTS')
BEGIN
UPDATE $tableLicense
SET display =
CASE
WHEN (SELECT COUNT(*) FROM $tableLicense WHERE key IN ('FRE-HUB-OPENED-VISITS', 'FRE-HUB-VEHICLES', 'FRE-HUB-RESIDENTS') AND display = 'VISIVEL') > 0
THEN 'VISIVEL'
ELSE 'INVISIVEL'
END
WHERE key = 'FRE-HUB-ABOUT-PROPERTY';
END;
''';
String get dropPeopleDisplayTrigger => 'DROP TRIGGER IF EXISTS update_people_display_trigger;';
static String get dropPeopleDisplayTrigger => 'DROP TRIGGER IF EXISTS update_people_display_trigger;';
}

View File

@ -34,7 +34,6 @@ class LicenseLocalDataSourceImpl implements LicenseLocalDataSource {
if (keys.isEmpty) return;
final validKeys = keys.where((key) => key.isNotEmpty).toList();
for (var key in validKeys) {
log('Setting display: $key : $display');
await set(key, {
'display': display,
'expirationDate': '',
@ -58,7 +57,6 @@ class LicenseLocalDataSourceImpl implements LicenseLocalDataSource {
return null;
}
log('Getting StartDate: ${response.toString()}');
return response.toString();
}
@ -68,19 +66,11 @@ class LicenseLocalDataSourceImpl implements LicenseLocalDataSource {
value as Map<String, dynamic>;
if (value.isEmpty) return;
if (key == 'null') return;
log('Setting: ${value['key']} : ${value['display']}');
await DatabaseStorage.database.insert(
tableLicense,
{
'key': key,
'display': value['display'],
'expirationDate': value['expirationDate'],
'startDate': value['startDate'],
'quantity': value['quantity'],
},
conflictAlgorithm: ConflictAlgorithm.replace);
await DatabaseStorage.database.rawInsert(
'INSERT OR REPLACE INTO $tableLicense (key, display, expirationDate, startDate, quantity) VALUES (?, ?, ?, ?, ?)',
[key, value['display'], value['expirationDate'], value['startDate'], value['quantity']],
);
return;
}
@ -92,5 +82,7 @@ class LicenseLocalDataSourceImpl implements LicenseLocalDataSource {
@override
Future<void> clear() async {
await DatabaseStorage.database.delete(tableLicense);
await DatabaseStorage.database.rawDelete(
'DELETE FROM sqlite_sequence WHERE name = "$tableLicense"');
}
}

View File

@ -23,8 +23,7 @@ class LicenseRemoteDataSourceImpl implements LicenseRemoteDataSource {
LicenseRemoteDataSourceImpl._internal();
final StreamController<void> completerController = StreamController<void>.broadcast();
Stream<void> get streamCompleterController => completerController.stream;
@override
@ -46,19 +45,16 @@ class LicenseRemoteDataSourceImpl implements LicenseRemoteDataSource {
.where((module) => module.display == ModuleStatus.inactive.key)
.map((module) => module.key)
.toList();
log('Módulos inativos: $inactiveModuleKey');
final List<String> activeModuleKey = license.modules
.where((module) => module.display == ModuleStatus.active.key)
.map((module) => module.key)
.toList();
log('Módulos ativos: $activeModuleKey');
final List<String> disabledModuleKey = license.modules
.where((module) => module.display == ModuleStatus.disabled.key)
.map((module) => module.key)
.toList();
log('Módulos desabilitados: $disabledModuleKey');
await LicenseLocalDataSourceImpl().setDisplayByKey(inactiveModuleKey, 'INVISIVEL');
await LicenseLocalDataSourceImpl().setDisplayByKey(activeModuleKey, 'VISIVEL');
@ -95,18 +91,13 @@ class LicenseRemoteDataSourceImpl implements LicenseRemoteDataSource {
return true;
}
log('Valores: ${LicenseKeys.values.map((e) => e.value).toList()}');
List<Future<void>> saveOperations = [];
for (var element in responseBody) {
log('Elemento: ${element['key']}');
if (licenseContainsKey(element['key'])) {
log('Salvando licença: ${element['key']}');
saveOperations.add(_saveModule(element));
}
}
await Future.wait(saveOperations);
final String? v = await LicenseRepositoryImpl().getLicense(LicenseKeys.property.value);
log('Licenças obtidas: $v');
return true;
} catch (e, s) {
log('Erro ao obter licenças: $e', stackTrace: s);
@ -120,13 +111,11 @@ class LicenseRemoteDataSourceImpl implements LicenseRemoteDataSource {
}
static bool licenseContainsKey(final String key) {
log('licenseContainsKey: $key');
return LicenseKeys.values.map((e) => e.value).toList().contains(key);
}
static Future<void> _saveModule(final dynamic body) async {
log('Salvando módulo: ${body['key']}');
if (body is! Map<String, dynamic>) return;
await LicenseRepositoryImpl().setLicense(body['key'], body);
}

View File

@ -198,7 +198,7 @@ class License {
),
Module(
key: LicenseKeys.property.value,
display: isNewVersionWithModule ? ModuleStatus.inactive.key : ModuleStatus.inactive.key,
display: isNewVersionWithModule ? ModuleStatus.active.key : ModuleStatus.inactive.key,
expirationDate: '',
startDate: '',
quantity: 0,

View File

@ -1,7 +1,7 @@
const String tableKeychain = 'keychain';
String get createKeychainTable => '''
CREATE TABLE $tableKeychain (
CREATE TABLE IF NOT EXISTS $tableKeychain (
key TEXT UNIQUE,
value TEXT,
type TEXT,

View File

@ -6,8 +6,8 @@ import 'package:path/path.dart';
import 'dart:developer';
class DatabaseStorage {
static final String _dbName = 'database.db';
static final int _dbVersion = 2;
static const String _dbName = 'database.db';
static const int _dbVersion = 2;
static final DatabaseStorage instance = DatabaseStorage._internal();
factory DatabaseStorage() => instance;
@ -21,49 +21,76 @@ class DatabaseStorage {
return _database!;
}
bool isInitialized = false;
static bool isInitialized = false;
Future<void> init() async {
if (isInitialized) return;
_database = await openDatabase(
join(await getDatabasesPath(), _dbName),
version: _dbVersion,
onCreate: _onCreate,
onUpgrade: _onUpgrade,
onDowngrade: _onDowngrade,
onOpen: _onOpen,
onConfigure: _onConfigure,
singleInstance: true,
);
await LicenseRepositoryImpl().updateLicense();
isInitialized = true;
}
Future<void> _onConfigure(Database database) async {
print('Configuring database...');
}
Future<void> _onOpen(Database database) async {
print('Opening database...');
await _executePragmas(database);
}
Future<void> _onCreate(Database database, int version) async {
log('Creating database...');
await database.execute(createKeychainTable);
await database.execute(createLicenseTable);
if (version >= 2) {
await database.execute(updatePetsHistoryTrigger);
await database.execute(updatePeopleDisplayTrigger);
}
print('Creating database...');
await _createTables(database, version);
}
Future<void> _onUpgrade(Database database, int oldVersion, int newVersion) async {
log('Upgrading database from version $oldVersion to $newVersion...');
print('Upgrading database from version $oldVersion to $newVersion...');
if (oldVersion < 2 && newVersion >= 2) {
await database.execute(createLicenseTable);
await database.execute(updatePetsHistoryTrigger);
await database.execute(updatePeopleDisplayTrigger);
await _createTables(database, newVersion);
}
}
Future<void> _onDowngrade(Database database, int oldVersion, int newVersion) async {
log('Downgrading database from version $oldVersion to $newVersion...');
print('Downgrading database from version $oldVersion to $newVersion...');
if (oldVersion >= 2 && newVersion < 2) {
await database.execute(deleteLicenseTable);
await database.execute(dropPeopleDisplayTrigger);
await database.execute(dropPetsHistoryTrigger);
await _dropTables(database);
}
}
Future<void> _executePragmas(Database database) async {
// await database.execute('PRAGMA journal_mode = WAL;');
await database.execute('PRAGMA synchronous = NORMAL;');
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);
}
}

View File

@ -59,6 +59,9 @@ class KeychainHelper implements BaseStorage {
Future<void> clearAll() async {
try {
await DatabaseStorage.database.delete(tableKeychain);
await DatabaseStorage.database.rawDelete(
'DELETE FROM sqlite_sequence WHERE name = "$tableKeychain"');
} catch (e, s) {
log('() => clearAll keychain: $e', stackTrace: s);
}

View File

@ -1,3 +1,5 @@
import 'dart:developer';
import 'package:flutter/cupertino.dart';
import 'package:hub/shared/helpers/storage/base_storage.dart';
import 'package:hub/shared/helpers/storage/keychain_storage.dart';
@ -25,6 +27,7 @@ class StorageHelper {
String? isFirstRun = await SharedPreferencesStorage.instance.get(SharedPreferencesKey.isFirstRun.value);
if (isFirstRun != 'false') {
log('First run');
await SharedPreferencesStorage.instance.set(SharedPreferencesKey.isFirstRun.value, false);
await SecureStorage.instance.set(SecureStorageKey.isLogged.value, false);
}

View File

@ -3,6 +3,8 @@ import 'dart:developer';
import 'package:flutter/material.dart';
import 'package:hub/features/home/presentation/pages/home_page.dart';
import 'package:hub/flutter_flow/nav/nav.dart';
import 'package:hub/shared/components/molecules/modules/data/repositories/license_repository_impl.dart';
import 'package:hub/shared/helpers/database/database_helper.dart';
import 'package:hub/shared/helpers/storage/base_storage.dart';
import 'package:hub/shared/helpers/storage/storage_helper.dart';
@ -147,7 +149,9 @@ class AuthenticationService {
await StorageHelper().clean(Storage.databaseStorage);
await StorageHelper().clean(Storage.secureStorage);
await StorageHelper().clean(Storage.databaseStorage);
await LicenseRepositoryImpl().cleanLicense();
DatabaseStorage.isInitialized = false;
await StorageHelper().init();
context.go('/welcomePage', extra: extra);
}