WIP
This commit is contained in:
parent
8e5d40ff2f
commit
ee4c257710
|
@ -58,28 +58,25 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
|
|||
BuildContext context, MenuItem item, List<Module> options) async {
|
||||
List<MenuEntry?> entries = [];
|
||||
Future<MenuEntry?> addMenuEntry(
|
||||
IconData icon, String enText, String ptText, Function() action) async {
|
||||
IconData icon, String text, Function() action) async {
|
||||
entries.add(
|
||||
item == MenuItem.button
|
||||
? MenuButtonWidget(
|
||||
icon: icon,
|
||||
action: action,
|
||||
title: FFLocalizations.of(context)
|
||||
.getVariableText(enText: enText, ptText: ptText),
|
||||
title: text,
|
||||
safeSetState: safeSetState)
|
||||
: item == MenuItem.card
|
||||
? MenuCardItem(
|
||||
icon: icon,
|
||||
action: action,
|
||||
title: FFLocalizations.of(context)
|
||||
.getVariableText(enText: enText, ptText: ptText),
|
||||
title: text,
|
||||
safeSetState: safeSetState)
|
||||
: item == MenuItem.tile
|
||||
? MenuCardItem(
|
||||
icon: icon,
|
||||
action: action,
|
||||
title: FFLocalizations.of(context)
|
||||
.getVariableText(enText: enText, ptText: ptText),
|
||||
title: text,
|
||||
safeSetState: safeSetState)
|
||||
: null,
|
||||
);
|
||||
|
@ -91,18 +88,19 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
|
|||
log('Module: ${opt.value} - License: $v');
|
||||
switch (v) {
|
||||
case 'VISIVEL':
|
||||
addMenuEntry(Icons.engineering_outlined, 'Schedule Providers',
|
||||
'Agendar Prestadores', () async {
|
||||
await open(context, '/provisionalSchedule');
|
||||
await addMenuEntry(opt.icon, opt.name, () async {
|
||||
await open(context, opt.route);
|
||||
});
|
||||
break;
|
||||
case 'BLOQUEADO':
|
||||
DialogUnavailable.unavailableFeature(context);
|
||||
await addMenuEntry(opt.icon, opt.name, () async {
|
||||
await DialogUnavailable.unavailableFeature(context);
|
||||
});
|
||||
break;
|
||||
case 'INVISIVEL':
|
||||
break;
|
||||
default:
|
||||
throw Exception('Invalid license value');
|
||||
break;
|
||||
}
|
||||
safeSetState();
|
||||
}
|
||||
|
@ -136,129 +134,6 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
|
|||
() async => await AuthenticationService.signOut(context));
|
||||
}
|
||||
|
||||
Future openDeliverySchedule(BuildContext context) async {
|
||||
final bool isProvisional =
|
||||
await StorageHelper().g(KeychainStorageKey.provisional.value) == 'true';
|
||||
if (isProvisional == true) {
|
||||
context.push(
|
||||
'/deliverySchedule',
|
||||
extra: <String, dynamic>{
|
||||
kTransitionInfoKey: const TransitionInfo(
|
||||
hasTransition: false,
|
||||
transitionType: PageTransitionType.scale,
|
||||
alignment: Alignment.bottomCenter,
|
||||
),
|
||||
},
|
||||
);
|
||||
} else {
|
||||
DialogUnavailable.unavailableFeature(context);
|
||||
}
|
||||
}
|
||||
|
||||
Future openProvisionalSchedule(BuildContext context) async {
|
||||
final isProvisional =
|
||||
await StorageHelper().g(KeychainStorageKey.provisional.value) == 'true';
|
||||
if (isProvisional == true) {
|
||||
context.push(
|
||||
'/provisionalSchedule',
|
||||
extra: <String, dynamic>{
|
||||
kTransitionInfoKey: const TransitionInfo(
|
||||
hasTransition: false,
|
||||
transitionType: PageTransitionType.scale,
|
||||
alignment: Alignment.bottomCenter,
|
||||
),
|
||||
},
|
||||
);
|
||||
} else {
|
||||
DialogUnavailable.unavailableFeature(context);
|
||||
}
|
||||
}
|
||||
|
||||
Future openFastPassSchedule(BuildContext context) async {
|
||||
final isWpp =
|
||||
await StorageHelper().g(KeychainStorageKey.whatsapp.value) == 'true';
|
||||
if (isWpp) {
|
||||
context.push(
|
||||
'/fastPassPage',
|
||||
extra: <String, dynamic>{
|
||||
kTransitionInfoKey: const TransitionInfo(
|
||||
hasTransition: false,
|
||||
transitionType: PageTransitionType.scale,
|
||||
alignment: Alignment.bottomCenter,
|
||||
),
|
||||
},
|
||||
);
|
||||
} else {
|
||||
DialogUnavailable.unavailableFeature(context);
|
||||
}
|
||||
}
|
||||
|
||||
Future showSchedules(BuildContext context) async {
|
||||
final routesListStr = <String>[
|
||||
'scheduleProvisionalVisitPage',
|
||||
'fastPassPage',
|
||||
'scheduleCompleteVisitPage',
|
||||
];
|
||||
final iconsListIcon = <IconData>[
|
||||
Icons.date_range_rounded,
|
||||
Icons.date_range_rounded,
|
||||
Icons.date_range_rounded,
|
||||
];
|
||||
final nameListStr = <String>[
|
||||
FFLocalizations.of(context).getVariableText(
|
||||
ptText: 'Visita\nProvisória',
|
||||
enText: 'Provisional\nSchedule',
|
||||
),
|
||||
FFLocalizations.of(context).getVariableText(
|
||||
ptText: 'Visita\nRápida',
|
||||
enText: 'Fast\nSchedule',
|
||||
),
|
||||
FFLocalizations.of(context).getVariableText(
|
||||
ptText: 'Visita\nCompleta',
|
||||
enText: 'Complete\nSchedule',
|
||||
),
|
||||
];
|
||||
await showAdaptiveDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return Padding(
|
||||
padding: MediaQuery.viewInsetsOf(context),
|
||||
child: OptionSelectionModalWidget(
|
||||
routesListStr: routesListStr,
|
||||
iconsListIcon: iconsListIcon,
|
||||
nameListStr: nameListStr,
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Future openVisitorsRegister(BuildContext context) async {
|
||||
context.push(
|
||||
'/registerVisitorPage',
|
||||
extra: <String, dynamic>{
|
||||
kTransitionInfoKey: const TransitionInfo(
|
||||
hasTransition: false,
|
||||
transitionType: PageTransitionType.scale,
|
||||
alignment: Alignment.bottomCenter,
|
||||
),
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Future openPoepleOnTheProperty(BuildContext context) async {
|
||||
context.push(
|
||||
'/peopleOnThePropertyPage',
|
||||
extra: <String, dynamic>{
|
||||
kTransitionInfoKey: const TransitionInfo(
|
||||
hasTransition: false,
|
||||
transitionType: PageTransitionType.scale,
|
||||
alignment: Alignment.bottomCenter,
|
||||
),
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> Logout(BuildContext context) async {
|
||||
final String title = FFLocalizations.of(context).getVariableText(
|
||||
ptText: 'Sair',
|
||||
|
@ -272,7 +147,7 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
|
|||
() async => await AuthenticationService.signOut(context));
|
||||
}
|
||||
|
||||
Future openPreferencesSettings(BuildContext context) async {
|
||||
Future settings(BuildContext context) async {
|
||||
context.push(
|
||||
'/preferencesSettings',
|
||||
extra: <String, dynamic>{
|
||||
|
@ -285,13 +160,9 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
|
|||
);
|
||||
}
|
||||
|
||||
Future openMyOrders(BuildContext context) async {
|
||||
final isWpp =
|
||||
await StorageHelper().g(KeychainStorageKey.whatsapp.value) == 'true';
|
||||
;
|
||||
if (isWpp) {
|
||||
Future about(BuildContext context) async {
|
||||
context.push(
|
||||
'/packageOrder',
|
||||
'/aboutProperty',
|
||||
extra: <String, dynamic>{
|
||||
kTransitionInfoKey: const TransitionInfo(
|
||||
hasTransition: false,
|
||||
|
@ -300,146 +171,5 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
|
|||
),
|
||||
},
|
||||
);
|
||||
} else {
|
||||
DialogUnavailable.unavailableFeature(context);
|
||||
}
|
||||
}
|
||||
|
||||
Future openReservations(BuildContext context) async {
|
||||
final isWpp =
|
||||
await StorageHelper().g(KeychainStorageKey.whatsapp.value) == 'true';
|
||||
;
|
||||
if (isWpp) {
|
||||
context.push(
|
||||
'/reservation',
|
||||
extra: <String, dynamic>{
|
||||
kTransitionInfoKey: const TransitionInfo(
|
||||
hasTransition: false,
|
||||
transitionType: PageTransitionType.scale,
|
||||
alignment: Alignment.bottomCenter,
|
||||
),
|
||||
},
|
||||
);
|
||||
} else {
|
||||
DialogUnavailable.unavailableFeature(context);
|
||||
}
|
||||
}
|
||||
|
||||
Future showHistories(BuildContext context) async {
|
||||
await showAdaptiveDialog(
|
||||
// isScrollControlled: true,
|
||||
// backgroundColor: Colors.transparent,
|
||||
// enableDrag: false,
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return Padding(
|
||||
padding: MediaQuery.viewInsetsOf(context),
|
||||
child: OptionSelectionModalWidget(
|
||||
routesListStr: const <String>[
|
||||
'liberationHistory',
|
||||
'acessHistoryPage',
|
||||
'scheduleCompleteVisitPage',
|
||||
'messageHistoryPage'
|
||||
],
|
||||
iconsListIcon: const <IconData>[
|
||||
Icons.history_rounded,
|
||||
Icons.history_rounded,
|
||||
Icons.history_rounded,
|
||||
Icons.history_rounded,
|
||||
],
|
||||
nameListStr: <String>[
|
||||
FFLocalizations.of(context).getVariableText(
|
||||
ptText: 'Histórico\nde Liberação',
|
||||
enText: 'Liberation\nHistory',
|
||||
),
|
||||
FFLocalizations.of(context).getVariableText(
|
||||
ptText: 'Histórico\nde Acesso',
|
||||
enText: 'Access\nHistory',
|
||||
),
|
||||
FFLocalizations.of(context).getVariableText(
|
||||
ptText: 'Histórico\nde Visita',
|
||||
enText: 'Visit\nHistory',
|
||||
),
|
||||
FFLocalizations.of(context).getVariableText(
|
||||
ptText: 'Histórico\nde Mensagens',
|
||||
enText: 'Message\nHistory',
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Future openLiberationsHistory(BuildContext context) async {
|
||||
context.push(
|
||||
'/liberationHistory',
|
||||
extra: <String, dynamic>{
|
||||
kTransitionInfoKey: const TransitionInfo(
|
||||
hasTransition: false,
|
||||
transitionType: PageTransitionType.scale,
|
||||
alignment: Alignment.bottomCenter,
|
||||
),
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Future openAccessHistory(BuildContext context) async {
|
||||
context.push(
|
||||
'/acessHistoryPage',
|
||||
extra: <String, dynamic>{
|
||||
kTransitionInfoKey: const TransitionInfo(
|
||||
hasTransition: false,
|
||||
transitionType: PageTransitionType.scale,
|
||||
alignment: Alignment.bottomCenter,
|
||||
),
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Future openVisitsHistory(BuildContext context) async {
|
||||
context.push(
|
||||
'/scheduleCompleteVisitPage',
|
||||
extra: <String, dynamic>{
|
||||
kTransitionInfoKey: const TransitionInfo(
|
||||
hasTransition: false,
|
||||
transitionType: PageTransitionType.scale,
|
||||
alignment: Alignment.bottomCenter,
|
||||
),
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Future openMessagesHistory(BuildContext context) async {
|
||||
context.push(
|
||||
'/messageHistoryPage',
|
||||
extra: <String, dynamic>{
|
||||
kTransitionInfoKey: const TransitionInfo(
|
||||
hasTransition: false,
|
||||
transitionType: PageTransitionType.scale,
|
||||
alignment: Alignment.bottomCenter,
|
||||
),
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Future openPetsRegister(BuildContext context) async {
|
||||
bool isPet =
|
||||
await StorageHelper().g(KeychainStorageKey.pets.value) == 'true';
|
||||
;
|
||||
if (isPet) {
|
||||
context.push(
|
||||
'/petsPage',
|
||||
extra: <String, dynamic>{
|
||||
kTransitionInfoKey: const TransitionInfo(
|
||||
hasTransition: false,
|
||||
transitionType: PageTransitionType.scale,
|
||||
alignment: Alignment.bottomCenter,
|
||||
),
|
||||
},
|
||||
);
|
||||
} else {
|
||||
DialogUnavailable.unavailableFeature(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,8 +32,8 @@ class _MenuComponentWidgetState extends State<MenuComponentWidget> {
|
|||
@override
|
||||
void didChangeDependencies() async {
|
||||
super.didChangeDependencies();
|
||||
widget.model.menuEntries =
|
||||
await widget.model.generateMenuEntries(context, widget.model.item, widget.model.menuOptions);
|
||||
widget.model.menuEntries = await widget.model.generateMenuEntries(
|
||||
context, widget.model.item, widget.model.menuOptions);
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
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';
|
||||
|
||||
|
@ -19,6 +22,7 @@ enum ActiveModuleKey {
|
|||
providerSchedule,
|
||||
deliverySchedule,
|
||||
fastPass,
|
||||
qrCode,
|
||||
}
|
||||
|
||||
extension InactiveModuleKeyExtension on InactiveModuleKey {
|
||||
|
@ -57,6 +61,8 @@ extension ActiveModuleKeyExtension on ActiveModuleKey {
|
|||
return 'FRE-HUB-AGE-PROV-DELIVERY';
|
||||
case ActiveModuleKey.fastPass:
|
||||
return 'FRE-HUB-FASTPASS';
|
||||
case ActiveModuleKey.qrCode:
|
||||
return 'FRE-HUB-QRCODE';
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
|
@ -111,11 +117,135 @@ extension LicenseKeyExtension on Module {
|
|||
return 'FRE-HUB-AGE-PROV-DELIVERY';
|
||||
case Module.fastPass:
|
||||
return 'FRE-HUB-FASTPASS';
|
||||
case Module.qrCode:
|
||||
return 'FRE-HUB-QRCODE';
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
String get name {
|
||||
switch (this) {
|
||||
case Module.messages:
|
||||
return FFLocalizations.of(key.currentContext!).getVariableText(
|
||||
ptText: 'Mensagens',
|
||||
enText: 'Messages',
|
||||
);
|
||||
case Module.liberations:
|
||||
return FFLocalizations.of(key.currentContext!).getVariableText(
|
||||
ptText: 'Liberar',
|
||||
enText: 'Liberations',
|
||||
);
|
||||
case Module.reservations:
|
||||
return FFLocalizations.of(key.currentContext!).getVariableText(
|
||||
ptText: 'Reservas',
|
||||
enText: 'Reservations',
|
||||
);
|
||||
case Module.access:
|
||||
return FFLocalizations.of(key.currentContext!).getVariableText(
|
||||
ptText: 'Acessos',
|
||||
enText: 'Access',
|
||||
);
|
||||
case Module.openedVisits:
|
||||
return FFLocalizations.of(key.currentContext!).getVariableText(
|
||||
ptText: 'Visitas Abertas',
|
||||
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.orders:
|
||||
return FFLocalizations.of(key.currentContext!).getVariableText(
|
||||
ptText: 'Encomendas',
|
||||
enText: '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: 'QR Code',
|
||||
enText: 'QR Code',
|
||||
);
|
||||
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.message;
|
||||
case Module.liberations:
|
||||
return Icons.lock_open;
|
||||
case Module.reservations:
|
||||
return Icons.calendar_today;
|
||||
case Module.access:
|
||||
return Icons.access_time;
|
||||
case Module.openedVisits:
|
||||
return Icons.people;
|
||||
case Module.vehicles:
|
||||
return Icons.directions_car;
|
||||
case Module.residents:
|
||||
return Icons.person;
|
||||
case Module.pets:
|
||||
return Icons.pets;
|
||||
case Module.orders:
|
||||
return Icons.shopping_cart;
|
||||
case Module.completeSchedule:
|
||||
return Icons.schedule;
|
||||
case Module.providerSchedule:
|
||||
return Icons.engineering_outlined;
|
||||
case Module.deliverySchedule:
|
||||
return Icons.delivery_dining;
|
||||
case Module.fastPass:
|
||||
return Icons.fastfood;
|
||||
case Module.qrCode:
|
||||
return Icons.qr_code;
|
||||
case Module.settings:
|
||||
return Icons.settings;
|
||||
case Module.logout:
|
||||
return Icons.logout;
|
||||
}
|
||||
}
|
||||
|
||||
String get route {
|
||||
switch (this) {
|
||||
case Module.messages:
|
||||
|
|
|
@ -17,8 +17,10 @@ class LicenseService {
|
|||
LicenseService._internal();
|
||||
|
||||
static Future<void> setupLicense(Database database) async {
|
||||
await LicenseHelper.insertLicenseFoo(InactiveModuleKey.values.map((e) => e.value).toList(), 'INVISIVEL');
|
||||
await LicenseHelper.insertLicenseFoo(ActiveModuleKey.values.map((e) => e.value).toList(), 'VISIVEL');
|
||||
await LicenseHelper.insertLicenseFoo(
|
||||
InactiveModuleKey.values.map((e) => e.value).toList(), 'INVISIVEL');
|
||||
await LicenseHelper.insertLicenseFoo(
|
||||
ActiveModuleKey.values.map((e) => e.value).toList(), 'VISIVEL');
|
||||
}
|
||||
|
||||
static Future<void> initLicenseService() async {
|
||||
|
@ -68,6 +70,7 @@ class LicenseService {
|
|||
}
|
||||
return true;
|
||||
} catch (e) {
|
||||
log('Erro ao obter licenças: $e');
|
||||
await setupLicense(DatabaseStorage.database);
|
||||
return true;
|
||||
}
|
||||
|
@ -78,9 +81,11 @@ class LicenseService {
|
|||
}
|
||||
|
||||
static Future<void> _saveModule(final dynamic body) async {
|
||||
if (body is Map<String, dynamic>) log('Salvando módulo: ${body.toString()}');
|
||||
if (body is Map<String, dynamic>)
|
||||
log('Salvando módulo: ${body.toString()}');
|
||||
// if (body is Map<String, dynamic>) await StorageHelper().s(body['key'], '');
|
||||
if (body is Map<String, dynamic>) await StorageHelper().s(body['key'], body);
|
||||
if (body is Map<String, dynamic>)
|
||||
await StorageHelper().s(body['key'], body);
|
||||
// StorageHelper.getInstance(Storage.SQLiteStorage).set(key, value);
|
||||
}
|
||||
|
||||
|
|
|
@ -34,13 +34,15 @@ class LocalizationService {
|
|||
enText: 'Verify your connection',
|
||||
ptText: 'Verifique sua conexão',
|
||||
);
|
||||
await DialogUtil.error(context, errorMsg).whenComplete(() => selectLocal(context, response));
|
||||
await DialogUtil.error(context, errorMsg)
|
||||
.whenComplete(() => selectLocal(context, response));
|
||||
return;
|
||||
}
|
||||
|
||||
final List<dynamic> locals = response.jsonBody['locais'] ?? [];
|
||||
final bool isEmpty = locals.isEmpty;
|
||||
final bool isActive = locals.where((local) => local['CLU_STATUS'] != 'B').isNotEmpty;
|
||||
final bool isActive =
|
||||
locals.where((local) => local['CLU_STATUS'] != 'B').isNotEmpty;
|
||||
final bool isEnable = !isEmpty && isActive;
|
||||
|
||||
if (isEnable) {
|
||||
|
@ -72,7 +74,8 @@ class LocalizationService {
|
|||
enText: 'Verify your connection',
|
||||
ptText: 'Verifique sua conexão',
|
||||
);
|
||||
await DialogUtil.error(context, errorMsg).whenComplete(() => selectLocal(context, response));
|
||||
await DialogUtil.error(context, errorMsg)
|
||||
.whenComplete(() => selectLocal(context, response));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -83,7 +86,8 @@ class LocalizationService {
|
|||
final bool isInactived = await _isInactived(locals);
|
||||
final bool isPending = _isPending(locals);
|
||||
final bool isUnique = locals.length == 1;
|
||||
final bool isBlocked = locals.where((local) => local['CLU_STATUS'] == 'B').isNotEmpty;
|
||||
final bool isBlocked =
|
||||
locals.where((local) => local['CLU_STATUS'] == 'B').isNotEmpty;
|
||||
final bool isEnabled = isUnique && isActive;
|
||||
final bool isDisabled = isUnique && isBlocked;
|
||||
final bool isUnselected = await _isUnselected();
|
||||
|
@ -123,7 +127,8 @@ class LocalizationService {
|
|||
enText: 'Error getting locals, verify your connection',
|
||||
ptText: 'Erro ao obter locais, verifique sua conexão',
|
||||
);
|
||||
await DialogUtil.error(context, errorMsg).whenComplete(() => selectLocal(context, null));
|
||||
await DialogUtil.error(context, errorMsg)
|
||||
.whenComplete(() => selectLocal(context, null));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -138,7 +143,8 @@ class LocalizationService {
|
|||
final GetLocalsCall callback = PhpGroup.getLocalsCall;
|
||||
response = await callback.call();
|
||||
final String errorMsg = response.jsonBody['error_msg'];
|
||||
await DialogUtil.error(context, errorMsg).whenComplete(() => selectLocal(context, response));
|
||||
await DialogUtil.error(context, errorMsg)
|
||||
.whenComplete(() => selectLocal(context, response));
|
||||
return false;
|
||||
} else if (response.jsonBody == null) {
|
||||
final GetLocalsCall callback = PhpGroup.getLocalsCall;
|
||||
|
@ -147,15 +153,16 @@ class LocalizationService {
|
|||
enText: 'Verify your connection',
|
||||
ptText: 'Verifique sua conexão',
|
||||
);
|
||||
await DialogUtil.error(context, errorMsg).whenComplete(() => selectLocal(context, response));
|
||||
await DialogUtil.error(context, errorMsg)
|
||||
.whenComplete(() => selectLocal(context, response));
|
||||
return false;
|
||||
} else {
|
||||
final bool isNewVersion = await _updateStorageUtil(response.jsonBody);
|
||||
if (!isNewVersion) {
|
||||
// final bool isNewVersion = await _updateStorageUtil(response.jsonBody);
|
||||
// if (!isNewVersion) {
|
||||
await LicenseService.setupLicense(DatabaseStorage.database);
|
||||
return false;
|
||||
}
|
||||
return await LicenseService.fetchLicenses();
|
||||
// }
|
||||
// return await LicenseService.fetchLicenses();
|
||||
}
|
||||
} catch (e, s) {
|
||||
log('() => stack processData: $s');
|
||||
|
@ -164,12 +171,14 @@ class LocalizationService {
|
|||
enText: 'Error getting data, verify your connection',
|
||||
ptText: 'Erro ao obter dados, verifique sua conexão',
|
||||
);
|
||||
await DialogUtil.error(context, errorMsg).whenComplete(() => selectLocal(context, null));
|
||||
await DialogUtil.error(context, errorMsg)
|
||||
.whenComplete(() => selectLocal(context, null));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static Future<bool> selectLocal(BuildContext context, ApiCallResponse? response) async {
|
||||
static Future<bool> selectLocal(
|
||||
BuildContext context, ApiCallResponse? response) async {
|
||||
return await showModalBottomSheet(
|
||||
isScrollControlled: true,
|
||||
backgroundColor: Colors.transparent,
|
||||
|
@ -233,10 +242,13 @@ class LocalizationService {
|
|||
}
|
||||
|
||||
static void _handleError(BuildContext context, String errorMsg) async {
|
||||
final String devUUID = await StorageHelper().g(KeychainStorageKey.devUUID.value) ?? '';
|
||||
final String userUUID = await StorageHelper().g(KeychainStorageKey.userUUID.value) ?? '';
|
||||
final String devUUID =
|
||||
await StorageHelper().g(KeychainStorageKey.devUUID.value) ?? '';
|
||||
final String userUUID =
|
||||
await StorageHelper().g(KeychainStorageKey.userUUID.value) ?? '';
|
||||
final bool isAuthenticated = userUUID.isNotEmpty && devUUID.isNotEmpty;
|
||||
final bool isDevLinked = !errorMsg.contains('Esse dispositivo nao pertence a esse usuario');
|
||||
final bool isDevLinked =
|
||||
!errorMsg.contains('Esse dispositivo nao pertence a esse usuario');
|
||||
log('() => isLinked: $errorMsg');
|
||||
log('() => isLinked: $errorMsg');
|
||||
if (!isAuthenticated) {
|
||||
|
@ -256,15 +268,20 @@ class LocalizationService {
|
|||
await DialogUtil.warning(context, errorMsg);
|
||||
return;
|
||||
}
|
||||
await DialogUtil.error(context, errorMsg).whenComplete(() async => await selectLocal(context, null));
|
||||
await DialogUtil.error(context, errorMsg)
|
||||
.whenComplete(() async => await selectLocal(context, null));
|
||||
}
|
||||
|
||||
static Future<bool> _handleUnavailable(BuildContext context, List<dynamic> locals) async {
|
||||
static Future<bool> _handleUnavailable(
|
||||
BuildContext context, List<dynamic> locals) async {
|
||||
log('() => isUnavailable');
|
||||
try {
|
||||
await StorageHelper().s(KeychainStorageKey.clientUUID.value, locals[0]['CLI_ID']);
|
||||
await StorageHelper().s(KeychainStorageKey.ownerUUID.value, locals[0]['CLU_OWNER_ID']);
|
||||
await StorageHelper().s(KeychainStorageKey.clientName.value, locals[0]['CLI_NOME']);
|
||||
await StorageHelper()
|
||||
.s(KeychainStorageKey.clientUUID.value, locals[0]['CLI_ID']);
|
||||
await StorageHelper()
|
||||
.s(KeychainStorageKey.ownerUUID.value, locals[0]['CLU_OWNER_ID']);
|
||||
await StorageHelper()
|
||||
.s(KeychainStorageKey.clientName.value, locals[0]['CLI_NOME']);
|
||||
var response = await PhpGroup.resopndeVinculo.call(tarefa: 'A');
|
||||
if (response.jsonBody['error'] == true) {
|
||||
await StorageHelper().s(KeychainStorageKey.clientUUID.value, '');
|
||||
|
@ -272,21 +289,28 @@ class LocalizationService {
|
|||
await StorageHelper().s(KeychainStorageKey.clientName.value, '');
|
||||
return false;
|
||||
}
|
||||
if (response.jsonBody['error'] == false) return await processData(context).then((value) => value);
|
||||
if (response.jsonBody['error'] == false)
|
||||
return await processData(context).then((value) => value);
|
||||
} catch (e, s) {
|
||||
await DialogUtil.errorDefault(context);
|
||||
LogUtil.requestAPIFailed('responderVinculo.php', '', 'Responder Vínculo', e, s);
|
||||
LogUtil.requestAPIFailed(
|
||||
'responderVinculo.php', '', 'Responder Vínculo', e, s);
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static Future<bool> _handleEnabled(BuildContext context, dynamic local) async {
|
||||
static Future<bool> _handleEnabled(
|
||||
BuildContext context, dynamic local) async {
|
||||
log('() => isEnabled');
|
||||
await StorageHelper().s(KeychainStorageKey.clientUUID.value, local['CLI_ID']);
|
||||
await StorageHelper().s(KeychainStorageKey.ownerUUID.value, local['CLU_OWNER_ID']);
|
||||
await StorageHelper().s(KeychainStorageKey.clientName.value, local['CLI_NOME']);
|
||||
await StorageHelper().s(KeychainStorageKey.userName.value, local['USU_NOME']);
|
||||
await StorageHelper()
|
||||
.s(KeychainStorageKey.clientUUID.value, local['CLI_ID']);
|
||||
await StorageHelper()
|
||||
.s(KeychainStorageKey.ownerUUID.value, local['CLU_OWNER_ID']);
|
||||
await StorageHelper()
|
||||
.s(KeychainStorageKey.clientName.value, local['CLI_NOME']);
|
||||
await StorageHelper()
|
||||
.s(KeychainStorageKey.userName.value, local['USU_NOME']);
|
||||
return await processData(context);
|
||||
}
|
||||
|
||||
|
@ -298,19 +322,24 @@ class LocalizationService {
|
|||
}
|
||||
|
||||
static Future<bool> _updateStorageUtil(Map<String, dynamic> jsonBody) async {
|
||||
await StorageHelper().s(KeychainStorageKey.whatsapp.value, jsonBody['whatsapp'] != null && jsonBody['whatsapp']);
|
||||
await StorageHelper()
|
||||
.s(KeychainStorageKey.provisional.value, jsonBody['provisional'] != null && jsonBody['provisional']);
|
||||
await StorageHelper().s(KeychainStorageKey.pets.value, jsonBody['pet'] != null && jsonBody['pet']);
|
||||
await StorageHelper().s(KeychainStorageKey.whatsapp.value,
|
||||
jsonBody['whatsapp'] != null && jsonBody['whatsapp']);
|
||||
await StorageHelper().s(KeychainStorageKey.provisional.value,
|
||||
jsonBody['provisional'] != null && jsonBody['provisional']);
|
||||
await StorageHelper().s(KeychainStorageKey.pets.value,
|
||||
jsonBody['pet'] != null && jsonBody['pet']);
|
||||
await StorageHelper().s(
|
||||
KeychainStorageKey.petAmount.value,
|
||||
jsonBody['petAmountRegister'] != null && jsonBody['petAmountRegister'].toString().isEmpty
|
||||
jsonBody['petAmountRegister'] != null &&
|
||||
jsonBody['petAmountRegister'].toString().isEmpty
|
||||
? '0'
|
||||
: jsonBody['petAmountRegister'].toString());
|
||||
await StorageHelper().s(KeychainStorageKey.userName.value, jsonBody['visitado']['VDO_NOME']);
|
||||
await StorageHelper()
|
||||
.s(KeychainStorageKey.isNewVersion.value, jsonBody['newVersion'] != null && jsonBody['newVersion']);
|
||||
return jsonBody['newVersion'] != null && jsonBody['newVersion'];
|
||||
.s(KeychainStorageKey.userName.value, jsonBody['visitado']['VDO_NOME']);
|
||||
await StorageHelper().s(KeychainStorageKey.isNewVersion.value,
|
||||
jsonBody['newVersion'] != null && jsonBody['newVersion']);
|
||||
log('() => isNewVersion: ${jsonBody['newVersion']}');
|
||||
return jsonBody['newVersion'] == true;
|
||||
}
|
||||
|
||||
static bool _isActive(List<dynamic> locals) {
|
||||
|
@ -318,30 +347,44 @@ class LocalizationService {
|
|||
}
|
||||
|
||||
static Future<bool> _isInactived(List<dynamic> locals) async {
|
||||
String cliUUID = (await StorageHelper().g(KeychainStorageKey.clientUUID.value)) ?? '';
|
||||
return locals.where((local) => local['CLI_ID'] != cliUUID && local['CLU_STATUS'] == 'A').isNotEmpty;
|
||||
String cliUUID =
|
||||
(await StorageHelper().g(KeychainStorageKey.clientUUID.value)) ?? '';
|
||||
return locals
|
||||
.where(
|
||||
(local) => local['CLI_ID'] != cliUUID && local['CLU_STATUS'] == 'A')
|
||||
.isNotEmpty;
|
||||
}
|
||||
|
||||
static bool _isPending(List<dynamic> locals) {
|
||||
return locals.where((local) => local['CLU_STATUS'] != 'B' && local['CLU_STATUS'] != 'A').isNotEmpty;
|
||||
return locals
|
||||
.where(
|
||||
(local) => local['CLU_STATUS'] != 'B' && local['CLU_STATUS'] != 'A')
|
||||
.isNotEmpty;
|
||||
}
|
||||
|
||||
static Future<bool> _isUnselected() async {
|
||||
String cliUUID = (await StorageHelper().g(KeychainStorageKey.clientUUID.value)) ?? '';
|
||||
String cliName = (await StorageHelper().g(KeychainStorageKey.clientName.value)) ?? '';
|
||||
String ownerUUID = (await StorageHelper().g(KeychainStorageKey.ownerUUID.value)) ?? '';
|
||||
String cliUUID =
|
||||
(await StorageHelper().g(KeychainStorageKey.clientUUID.value)) ?? '';
|
||||
String cliName =
|
||||
(await StorageHelper().g(KeychainStorageKey.clientName.value)) ?? '';
|
||||
String ownerUUID =
|
||||
(await StorageHelper().g(KeychainStorageKey.ownerUUID.value)) ?? '';
|
||||
return cliUUID.isEmpty && cliName.isEmpty && ownerUUID.isEmpty;
|
||||
}
|
||||
|
||||
static Future<bool> _isSelected(bool isInactived) async {
|
||||
String cliUUID = (await StorageHelper().g(KeychainStorageKey.clientUUID.value)) ?? '';
|
||||
String cliName = (await StorageHelper().g(KeychainStorageKey.clientName.value)) ?? '';
|
||||
String cliUUID =
|
||||
(await StorageHelper().g(KeychainStorageKey.clientUUID.value)) ?? '';
|
||||
String cliName =
|
||||
(await StorageHelper().g(KeychainStorageKey.clientName.value)) ?? '';
|
||||
return cliUUID.isNotEmpty && cliName.isNotEmpty && isInactived;
|
||||
}
|
||||
|
||||
static Future<bool> _isAvailable() async {
|
||||
String cliUUID = (await StorageHelper().g(KeychainStorageKey.clientUUID.value)) ?? '';
|
||||
String cliName = (await StorageHelper().g(KeychainStorageKey.clientName.value)) ?? '';
|
||||
String cliUUID =
|
||||
(await StorageHelper().g(KeychainStorageKey.clientUUID.value)) ?? '';
|
||||
String cliName =
|
||||
(await StorageHelper().g(KeychainStorageKey.clientName.value)) ?? '';
|
||||
return cliUUID.isNotEmpty && cliName.isNotEmpty;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue