429 lines
12 KiB
Dart
429 lines
12 KiB
Dart
import 'dart:developer';
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:hub/flutter_flow/internationalization.dart';
|
|
import 'package:hub/flutter_flow/nav/nav.dart';
|
|
import 'package:hub/shared/helpers/database/database_helper.dart';
|
|
import 'package:sqflite/sqflite.dart';
|
|
|
|
enum InactiveModuleKey {
|
|
residents,
|
|
vehicles,
|
|
openedVisits,
|
|
petsHistory,
|
|
}
|
|
|
|
extension InactiveModuleKeyExtension on InactiveModuleKey {
|
|
String get value {
|
|
switch (this) {
|
|
case InactiveModuleKey.openedVisits:
|
|
return 'FRE-HUB-OPENED-VISITS';
|
|
case InactiveModuleKey.vehicles:
|
|
return 'FRE-HUB-VEHICLES';
|
|
case InactiveModuleKey.residents:
|
|
return 'FRE-HUB-RESIDENTS';
|
|
case InactiveModuleKey.petsHistory:
|
|
return 'FRE-HUB-PETS-HISTORY';
|
|
default:
|
|
return '';
|
|
}
|
|
}
|
|
}
|
|
|
|
enum DisabledModuleKey {
|
|
fastPass,
|
|
}
|
|
|
|
extension DisabledModuleKeyExtension on DisabledModuleKey {
|
|
String get value {
|
|
switch (this) {
|
|
case DisabledModuleKey.fastPass:
|
|
return 'FRE-HUB-FASTPASS';
|
|
default:
|
|
return '';
|
|
}
|
|
}
|
|
}
|
|
|
|
enum ActiveModuleKey {
|
|
messages,
|
|
liberations,
|
|
reservations,
|
|
access,
|
|
pets,
|
|
orders,
|
|
completeSchedule,
|
|
providerSchedule,
|
|
deliverySchedule,
|
|
qrCode,
|
|
visitors,
|
|
peopleOnTheProperty,
|
|
settings,
|
|
logout,
|
|
}
|
|
|
|
extension ActiveModuleKeyExtension on ActiveModuleKey {
|
|
String get value {
|
|
switch (this) {
|
|
case ActiveModuleKey.messages:
|
|
return 'FRE-HUB-MESSAGES';
|
|
case ActiveModuleKey.liberations:
|
|
return 'FRE-HUB-LIBERATIONS';
|
|
case ActiveModuleKey.reservations:
|
|
return 'FRE-HUB-RESERVATIONS';
|
|
case ActiveModuleKey.access:
|
|
return 'FRE-HUB-ACCESS';
|
|
case ActiveModuleKey.pets:
|
|
return 'FRE-HUB-PETS';
|
|
case ActiveModuleKey.orders:
|
|
return 'FRE-HUB-ORDERS';
|
|
case ActiveModuleKey.completeSchedule:
|
|
return 'FRE-HUB-COMPLETE-SCHEDULE';
|
|
case ActiveModuleKey.providerSchedule:
|
|
return 'FRE-HUB-AGE-PROV-PRESTADOR';
|
|
case ActiveModuleKey.deliverySchedule:
|
|
return 'FRE-HUB-AGE-PROV-DELIVERY';
|
|
case ActiveModuleKey.visitors:
|
|
return 'FRE-HUB-VISITORS';
|
|
case ActiveModuleKey.qrCode:
|
|
return 'FRE-HUB-QRCODE';
|
|
case ActiveModuleKey.peopleOnTheProperty:
|
|
return 'FRE-HUB-PEOPLE';
|
|
default:
|
|
return '';
|
|
}
|
|
}
|
|
}
|
|
|
|
enum Module {
|
|
providerSchedule,
|
|
deliverySchedule,
|
|
fastPass,
|
|
completeSchedule,
|
|
orders,
|
|
reservations,
|
|
visitors,
|
|
vehicles,
|
|
residents,
|
|
openedVisits,
|
|
qrCode,
|
|
pets,
|
|
access,
|
|
liberations,
|
|
messages,
|
|
aboutProperty,
|
|
petsHistory,
|
|
peopleOnTheProperty,
|
|
settings,
|
|
logout,
|
|
}
|
|
|
|
extension LicenseKeyExtension on Module {
|
|
String get value {
|
|
switch (this) {
|
|
case Module.messages:
|
|
return 'FRE-HUB-MESSAGES';
|
|
case Module.liberations:
|
|
return 'FRE-HUB-LIBERATIONS';
|
|
case Module.reservations:
|
|
return 'FRE-HUB-RESERVATIONS';
|
|
case Module.access:
|
|
return 'FRE-HUB-ACCESS';
|
|
case Module.openedVisits:
|
|
return 'FRE-HUB-OPENED-VISITS';
|
|
case Module.vehicles:
|
|
return 'FRE-HUB-VEHICLES';
|
|
case Module.residents:
|
|
return 'FRE-HUB-RESIDENTS';
|
|
case Module.pets:
|
|
return 'FRE-HUB-PETS';
|
|
case Module.orders:
|
|
return 'FRE-HUB-ORDERS';
|
|
case Module.completeSchedule:
|
|
return 'FRE-HUB-COMPLETE-SCHEDULE';
|
|
case Module.providerSchedule:
|
|
return 'FRE-HUB-AGE-PROV-PRESTADOR';
|
|
case Module.deliverySchedule:
|
|
return 'FRE-HUB-AGE-PROV-DELIVERY';
|
|
case Module.aboutProperty:
|
|
return 'FRE-HUB-PROPERTY';
|
|
case Module.fastPass:
|
|
return 'FRE-HUB-FASTPASS';
|
|
case Module.visitors:
|
|
return 'FRE-HUB-VISITORS';
|
|
case Module.qrCode:
|
|
return 'FRE-HUB-QRCODE';
|
|
case Module.peopleOnTheProperty:
|
|
return 'FRE-HUB-PEOPLE';
|
|
case Module.petsHistory:
|
|
return 'FRE-HUB-PETS-HISTORY';
|
|
default:
|
|
return '';
|
|
}
|
|
}
|
|
|
|
String get name {
|
|
switch (this) {
|
|
case Module.messages:
|
|
return FFLocalizations.of(key.currentContext!).getVariableText(
|
|
ptText: 'Consultar Mensagens',
|
|
enText: 'Messages History',
|
|
);
|
|
case Module.liberations:
|
|
return FFLocalizations.of(key.currentContext!).getVariableText(
|
|
ptText: 'Consultar Liberações',
|
|
enText: 'Liberations History',
|
|
);
|
|
case Module.reservations:
|
|
return FFLocalizations.of(key.currentContext!).getVariableText(
|
|
ptText: 'Reservas',
|
|
enText: 'Reservations',
|
|
);
|
|
case Module.access:
|
|
return FFLocalizations.of(key.currentContext!).getVariableText(
|
|
ptText: 'Consultar Acessos',
|
|
enText: 'Access History',
|
|
);
|
|
case Module.openedVisits:
|
|
return FFLocalizations.of(key.currentContext!).getVariableText(
|
|
ptText: 'Visitas em Aberto',
|
|
enText: 'Opened Visits',
|
|
);
|
|
case Module.vehicles:
|
|
return FFLocalizations.of(key.currentContext!).getVariableText(
|
|
ptText: 'Veículos',
|
|
enText: 'Vehicles',
|
|
);
|
|
case Module.residents:
|
|
return FFLocalizations.of(key.currentContext!).getVariableText(
|
|
ptText: 'Moradores',
|
|
enText: 'Residents',
|
|
);
|
|
case Module.pets:
|
|
return FFLocalizations.of(key.currentContext!).getVariableText(
|
|
ptText: 'Pets',
|
|
enText: 'Pets',
|
|
);
|
|
case Module.petsHistory:
|
|
return FFLocalizations.of(key.currentContext!).getVariableText(
|
|
ptText: 'Pets',
|
|
enText: 'Pets',
|
|
);
|
|
case Module.peopleOnTheProperty:
|
|
return FFLocalizations.of(key.currentContext!).getVariableText(
|
|
ptText: 'Pessoas na Propriedade',
|
|
enText: 'People on the Property',
|
|
);
|
|
case Module.orders:
|
|
return FFLocalizations.of(key.currentContext!).getVariableText(
|
|
ptText: 'Minhas Encomendas',
|
|
enText: 'My Orders',
|
|
);
|
|
case Module.completeSchedule:
|
|
return FFLocalizations.of(key.currentContext!).getVariableText(
|
|
ptText: 'Agenda Completa',
|
|
enText: 'Complete Schedule',
|
|
);
|
|
case Module.providerSchedule:
|
|
return FFLocalizations.of(key.currentContext!).getVariableText(
|
|
ptText: 'Agendar Prestadores',
|
|
enText: 'Schedule Providers',
|
|
);
|
|
case Module.deliverySchedule:
|
|
return FFLocalizations.of(key.currentContext!).getVariableText(
|
|
ptText: 'Agendar Delivery',
|
|
enText: 'Schedule Delivery',
|
|
);
|
|
case Module.fastPass:
|
|
return FFLocalizations.of(key.currentContext!).getVariableText(
|
|
ptText: 'Fast Pass',
|
|
enText: 'Fast Pass',
|
|
);
|
|
case Module.qrCode:
|
|
return FFLocalizations.of(key.currentContext!).getVariableText(
|
|
ptText: 'QRCode de Acesso',
|
|
enText: 'Access QRCode',
|
|
);
|
|
case Module.visitors:
|
|
return FFLocalizations.of(key.currentContext!).getVariableText(
|
|
ptText: 'Cadastrar Visitantes',
|
|
enText: 'Register Visitors',
|
|
);
|
|
case Module.aboutProperty:
|
|
return FFLocalizations.of(key.currentContext!).getVariableText(
|
|
ptText: 'Sobre a Propriedade',
|
|
enText: 'About the Property',
|
|
);
|
|
case Module.settings:
|
|
return FFLocalizations.of(key.currentContext!).getVariableText(
|
|
ptText: 'Configurações',
|
|
enText: 'Settings',
|
|
);
|
|
case Module.logout:
|
|
return FFLocalizations.of(key.currentContext!).getVariableText(
|
|
ptText: 'Sair',
|
|
enText: 'Logout',
|
|
);
|
|
}
|
|
}
|
|
|
|
IconData get icon {
|
|
switch (this) {
|
|
case Module.messages:
|
|
return Icons.chat_outlined;
|
|
case Module.liberations:
|
|
return Icons.how_to_reg_outlined;
|
|
case Module.reservations:
|
|
return Icons.event_available;
|
|
case Module.access:
|
|
return Icons.transfer_within_a_station_outlined;
|
|
case Module.openedVisits:
|
|
return Icons.perm_contact_calendar;
|
|
case Module.vehicles:
|
|
return Icons.directions_car;
|
|
case Module.residents:
|
|
return Icons.groups;
|
|
case Module.pets:
|
|
return Icons.pets;
|
|
case Module.petsHistory:
|
|
return Icons.pets;
|
|
case Module.peopleOnTheProperty:
|
|
return Icons.groups;
|
|
case Module.orders:
|
|
return Icons.inventory_2_outlined;
|
|
case Module.completeSchedule:
|
|
return Icons.event;
|
|
case Module.providerSchedule:
|
|
return Icons.engineering_outlined;
|
|
case Module.deliverySchedule:
|
|
return Icons.sports_motorsports_outlined;
|
|
case Module.fastPass:
|
|
return Icons.attach_email_outlined;
|
|
case Module.qrCode:
|
|
return Icons.qr_code;
|
|
case Module.visitors:
|
|
return Icons.person_add_alt_1_outlined;
|
|
case Module.aboutProperty:
|
|
return Icons.home;
|
|
case Module.settings:
|
|
return Icons.settings;
|
|
case Module.logout:
|
|
return Icons.logout;
|
|
}
|
|
}
|
|
|
|
String get route {
|
|
switch (this) {
|
|
case Module.messages:
|
|
return '/messageHistoryPage';
|
|
case Module.liberations:
|
|
return '/liberationHistory';
|
|
case Module.reservations:
|
|
return '/reservation';
|
|
case Module.access:
|
|
return '/acessHistoryPage';
|
|
case Module.openedVisits:
|
|
return '/visitsOnThePropertyPage';
|
|
case Module.vehicles:
|
|
return '/vehiclesOnThePropertyPage';
|
|
case Module.residents:
|
|
return '/residentsOnThePropertyPage';
|
|
case Module.pets:
|
|
return '/petsPage';
|
|
case Module.petsHistory:
|
|
return '/petsHistoryPage';
|
|
case Module.peopleOnTheProperty:
|
|
return '/peopleOnThePropertyPage';
|
|
case Module.orders:
|
|
return '/packageOrder';
|
|
case Module.completeSchedule:
|
|
return '/scheduleCompleteVisitPage';
|
|
case Module.providerSchedule:
|
|
return '/provisionalSchedule';
|
|
case Module.aboutProperty:
|
|
return '/aboutProperty';
|
|
case Module.deliverySchedule:
|
|
return '/deliverySchedule';
|
|
case Module.fastPass:
|
|
return '/fastPassPage';
|
|
case Module.qrCode:
|
|
return '/qrCodePage';
|
|
case Module.visitors:
|
|
return '/registerVisitorPage';
|
|
case Module.settings:
|
|
return '/preferencesSettings';
|
|
case Module.logout:
|
|
return '/WelcomePage';
|
|
default:
|
|
return '';
|
|
}
|
|
}
|
|
}
|
|
|
|
class LicenseHelper {
|
|
static final LicenseHelper _instance = LicenseHelper._internal();
|
|
|
|
factory LicenseHelper() => _instance;
|
|
|
|
LicenseHelper._internal();
|
|
|
|
static const String tableLicense = 'license';
|
|
|
|
static String get createTableQuery => '''
|
|
CREATE TABLE $tableLicense (
|
|
key TEXT UNIQUE,
|
|
display TEXT,
|
|
expirationDate TEXT,
|
|
startDate TEXT,
|
|
quantity TEXT
|
|
);
|
|
''';
|
|
|
|
Future<void> init() async {
|
|
await DatabaseStorage.instance.init();
|
|
}
|
|
|
|
Future<void> setByKey(final List<String> key, final String display) async {
|
|
for (var element in key) {
|
|
await s(element, {
|
|
'display': display,
|
|
'expirationDate': '',
|
|
'startDate': '',
|
|
'quantity': '',
|
|
});
|
|
}
|
|
}
|
|
|
|
Future<String?> g(String key) async {
|
|
var response = await DatabaseStorage.database.query(tableLicense, where: 'key = ?', whereArgs: [key], columns: ['display']);
|
|
if (response.isEmpty) {
|
|
return null;
|
|
}
|
|
return response.first['display'].toString();
|
|
}
|
|
|
|
Future<void> s<T>(String key, T value) async {
|
|
log('setLicense($key, $value)');
|
|
value as Map<String, dynamic>;
|
|
|
|
await DatabaseStorage.database.insert(
|
|
tableLicense,
|
|
{
|
|
'key': key,
|
|
'display': value['display'],
|
|
'expirationDate': value['expirationDate'],
|
|
'startDate': value['startDate'],
|
|
'quantity': value['quantity'],
|
|
},
|
|
conflictAlgorithm: ConflictAlgorithm.replace);
|
|
}
|
|
|
|
Future<void> d(String key) async {
|
|
await DatabaseStorage.database.delete(tableLicense, where: 'key = ?', whereArgs: [key]);
|
|
}
|
|
|
|
Future<void> c() async {
|
|
await DatabaseStorage.database.delete(tableLicense);
|
|
}
|
|
}
|