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 {
|
BuildContext context, MenuItem item, List<Module> options) async {
|
||||||
List<MenuEntry?> entries = [];
|
List<MenuEntry?> entries = [];
|
||||||
Future<MenuEntry?> addMenuEntry(
|
Future<MenuEntry?> addMenuEntry(
|
||||||
IconData icon, String enText, String ptText, Function() action) async {
|
IconData icon, String text, Function() action) async {
|
||||||
entries.add(
|
entries.add(
|
||||||
item == MenuItem.button
|
item == MenuItem.button
|
||||||
? MenuButtonWidget(
|
? MenuButtonWidget(
|
||||||
icon: icon,
|
icon: icon,
|
||||||
action: action,
|
action: action,
|
||||||
title: FFLocalizations.of(context)
|
title: text,
|
||||||
.getVariableText(enText: enText, ptText: ptText),
|
|
||||||
safeSetState: safeSetState)
|
safeSetState: safeSetState)
|
||||||
: item == MenuItem.card
|
: item == MenuItem.card
|
||||||
? MenuCardItem(
|
? MenuCardItem(
|
||||||
icon: icon,
|
icon: icon,
|
||||||
action: action,
|
action: action,
|
||||||
title: FFLocalizations.of(context)
|
title: text,
|
||||||
.getVariableText(enText: enText, ptText: ptText),
|
|
||||||
safeSetState: safeSetState)
|
safeSetState: safeSetState)
|
||||||
: item == MenuItem.tile
|
: item == MenuItem.tile
|
||||||
? MenuCardItem(
|
? MenuCardItem(
|
||||||
icon: icon,
|
icon: icon,
|
||||||
action: action,
|
action: action,
|
||||||
title: FFLocalizations.of(context)
|
title: text,
|
||||||
.getVariableText(enText: enText, ptText: ptText),
|
|
||||||
safeSetState: safeSetState)
|
safeSetState: safeSetState)
|
||||||
: null,
|
: null,
|
||||||
);
|
);
|
||||||
|
@ -91,18 +88,19 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
|
||||||
log('Module: ${opt.value} - License: $v');
|
log('Module: ${opt.value} - License: $v');
|
||||||
switch (v) {
|
switch (v) {
|
||||||
case 'VISIVEL':
|
case 'VISIVEL':
|
||||||
addMenuEntry(Icons.engineering_outlined, 'Schedule Providers',
|
await addMenuEntry(opt.icon, opt.name, () async {
|
||||||
'Agendar Prestadores', () async {
|
await open(context, opt.route);
|
||||||
await open(context, '/provisionalSchedule');
|
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case 'BLOQUEADO':
|
case 'BLOQUEADO':
|
||||||
DialogUnavailable.unavailableFeature(context);
|
await addMenuEntry(opt.icon, opt.name, () async {
|
||||||
|
await DialogUnavailable.unavailableFeature(context);
|
||||||
|
});
|
||||||
break;
|
break;
|
||||||
case 'INVISIVEL':
|
case 'INVISIVEL':
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw Exception('Invalid license value');
|
break;
|
||||||
}
|
}
|
||||||
safeSetState();
|
safeSetState();
|
||||||
}
|
}
|
||||||
|
@ -136,129 +134,6 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
|
||||||
() async => await AuthenticationService.signOut(context));
|
() 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 {
|
Future<void> Logout(BuildContext context) async {
|
||||||
final String title = FFLocalizations.of(context).getVariableText(
|
final String title = FFLocalizations.of(context).getVariableText(
|
||||||
ptText: 'Sair',
|
ptText: 'Sair',
|
||||||
|
@ -272,7 +147,7 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
|
||||||
() async => await AuthenticationService.signOut(context));
|
() async => await AuthenticationService.signOut(context));
|
||||||
}
|
}
|
||||||
|
|
||||||
Future openPreferencesSettings(BuildContext context) async {
|
Future settings(BuildContext context) async {
|
||||||
context.push(
|
context.push(
|
||||||
'/preferencesSettings',
|
'/preferencesSettings',
|
||||||
extra: <String, dynamic>{
|
extra: <String, dynamic>{
|
||||||
|
@ -285,95 +160,9 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future openMyOrders(BuildContext context) async {
|
Future about(BuildContext context) async {
|
||||||
final isWpp =
|
|
||||||
await StorageHelper().g(KeychainStorageKey.whatsapp.value) == 'true';
|
|
||||||
;
|
|
||||||
if (isWpp) {
|
|
||||||
context.push(
|
|
||||||
'/packageOrder',
|
|
||||||
extra: <String, dynamic>{
|
|
||||||
kTransitionInfoKey: const TransitionInfo(
|
|
||||||
hasTransition: false,
|
|
||||||
transitionType: PageTransitionType.scale,
|
|
||||||
alignment: Alignment.bottomCenter,
|
|
||||||
),
|
|
||||||
},
|
|
||||||
);
|
|
||||||
} 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(
|
context.push(
|
||||||
'/liberationHistory',
|
'/aboutProperty',
|
||||||
extra: <String, dynamic>{
|
extra: <String, dynamic>{
|
||||||
kTransitionInfoKey: const TransitionInfo(
|
kTransitionInfoKey: const TransitionInfo(
|
||||||
hasTransition: false,
|
hasTransition: false,
|
||||||
|
@ -383,63 +172,4 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
@override
|
||||||
void didChangeDependencies() async {
|
void didChangeDependencies() async {
|
||||||
super.didChangeDependencies();
|
super.didChangeDependencies();
|
||||||
widget.model.menuEntries =
|
widget.model.menuEntries = await widget.model.generateMenuEntries(
|
||||||
await widget.model.generateMenuEntries(context, widget.model.item, widget.model.menuOptions);
|
context, widget.model.item, widget.model.menuOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
import 'dart:developer';
|
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:hub/shared/helpers/database/database_helper.dart';
|
||||||
import 'package:sqflite/sqflite.dart';
|
import 'package:sqflite/sqflite.dart';
|
||||||
|
|
||||||
|
@ -19,6 +22,7 @@ enum ActiveModuleKey {
|
||||||
providerSchedule,
|
providerSchedule,
|
||||||
deliverySchedule,
|
deliverySchedule,
|
||||||
fastPass,
|
fastPass,
|
||||||
|
qrCode,
|
||||||
}
|
}
|
||||||
|
|
||||||
extension InactiveModuleKeyExtension on InactiveModuleKey {
|
extension InactiveModuleKeyExtension on InactiveModuleKey {
|
||||||
|
@ -57,6 +61,8 @@ extension ActiveModuleKeyExtension on ActiveModuleKey {
|
||||||
return 'FRE-HUB-AGE-PROV-DELIVERY';
|
return 'FRE-HUB-AGE-PROV-DELIVERY';
|
||||||
case ActiveModuleKey.fastPass:
|
case ActiveModuleKey.fastPass:
|
||||||
return 'FRE-HUB-FASTPASS';
|
return 'FRE-HUB-FASTPASS';
|
||||||
|
case ActiveModuleKey.qrCode:
|
||||||
|
return 'FRE-HUB-QRCODE';
|
||||||
default:
|
default:
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
@ -111,11 +117,135 @@ extension LicenseKeyExtension on Module {
|
||||||
return 'FRE-HUB-AGE-PROV-DELIVERY';
|
return 'FRE-HUB-AGE-PROV-DELIVERY';
|
||||||
case Module.fastPass:
|
case Module.fastPass:
|
||||||
return 'FRE-HUB-FASTPASS';
|
return 'FRE-HUB-FASTPASS';
|
||||||
|
case Module.qrCode:
|
||||||
|
return 'FRE-HUB-QRCODE';
|
||||||
default:
|
default:
|
||||||
return '';
|
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 {
|
String get route {
|
||||||
switch (this) {
|
switch (this) {
|
||||||
case Module.messages:
|
case Module.messages:
|
||||||
|
|
|
@ -17,8 +17,10 @@ class LicenseService {
|
||||||
LicenseService._internal();
|
LicenseService._internal();
|
||||||
|
|
||||||
static Future<void> setupLicense(Database database) async {
|
static Future<void> setupLicense(Database database) async {
|
||||||
await LicenseHelper.insertLicenseFoo(InactiveModuleKey.values.map((e) => e.value).toList(), 'INVISIVEL');
|
await LicenseHelper.insertLicenseFoo(
|
||||||
await LicenseHelper.insertLicenseFoo(ActiveModuleKey.values.map((e) => e.value).toList(), 'VISIVEL');
|
InactiveModuleKey.values.map((e) => e.value).toList(), 'INVISIVEL');
|
||||||
|
await LicenseHelper.insertLicenseFoo(
|
||||||
|
ActiveModuleKey.values.map((e) => e.value).toList(), 'VISIVEL');
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<void> initLicenseService() async {
|
static Future<void> initLicenseService() async {
|
||||||
|
@ -68,6 +70,7 @@ class LicenseService {
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
log('Erro ao obter licenças: $e');
|
||||||
await setupLicense(DatabaseStorage.database);
|
await setupLicense(DatabaseStorage.database);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -78,9 +81,11 @@ class LicenseService {
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<void> _saveModule(final dynamic body) async {
|
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'], '');
|
||||||
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);
|
// StorageHelper.getInstance(Storage.SQLiteStorage).set(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,13 +34,15 @@ class LocalizationService {
|
||||||
enText: 'Verify your connection',
|
enText: 'Verify your connection',
|
||||||
ptText: 'Verifique sua conexão',
|
ptText: 'Verifique sua conexão',
|
||||||
);
|
);
|
||||||
await DialogUtil.error(context, errorMsg).whenComplete(() => selectLocal(context, response));
|
await DialogUtil.error(context, errorMsg)
|
||||||
|
.whenComplete(() => selectLocal(context, response));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<dynamic> locals = response.jsonBody['locais'] ?? [];
|
final List<dynamic> locals = response.jsonBody['locais'] ?? [];
|
||||||
final bool isEmpty = locals.isEmpty;
|
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;
|
final bool isEnable = !isEmpty && isActive;
|
||||||
|
|
||||||
if (isEnable) {
|
if (isEnable) {
|
||||||
|
@ -72,7 +74,8 @@ class LocalizationService {
|
||||||
enText: 'Verify your connection',
|
enText: 'Verify your connection',
|
||||||
ptText: 'Verifique sua conexão',
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,7 +86,8 @@ class LocalizationService {
|
||||||
final bool isInactived = await _isInactived(locals);
|
final bool isInactived = await _isInactived(locals);
|
||||||
final bool isPending = _isPending(locals);
|
final bool isPending = _isPending(locals);
|
||||||
final bool isUnique = locals.length == 1;
|
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 isEnabled = isUnique && isActive;
|
||||||
final bool isDisabled = isUnique && isBlocked;
|
final bool isDisabled = isUnique && isBlocked;
|
||||||
final bool isUnselected = await _isUnselected();
|
final bool isUnselected = await _isUnselected();
|
||||||
|
@ -123,7 +127,8 @@ class LocalizationService {
|
||||||
enText: 'Error getting locals, verify your connection',
|
enText: 'Error getting locals, verify your connection',
|
||||||
ptText: 'Erro ao obter locais, verifique sua conexão',
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -138,7 +143,8 @@ class LocalizationService {
|
||||||
final GetLocalsCall callback = PhpGroup.getLocalsCall;
|
final GetLocalsCall callback = PhpGroup.getLocalsCall;
|
||||||
response = await callback.call();
|
response = await callback.call();
|
||||||
final String errorMsg = response.jsonBody['error_msg'];
|
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;
|
return false;
|
||||||
} else if (response.jsonBody == null) {
|
} else if (response.jsonBody == null) {
|
||||||
final GetLocalsCall callback = PhpGroup.getLocalsCall;
|
final GetLocalsCall callback = PhpGroup.getLocalsCall;
|
||||||
|
@ -147,15 +153,16 @@ class LocalizationService {
|
||||||
enText: 'Verify your connection',
|
enText: 'Verify your connection',
|
||||||
ptText: 'Verifique sua conexão',
|
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;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
final bool isNewVersion = await _updateStorageUtil(response.jsonBody);
|
// final bool isNewVersion = await _updateStorageUtil(response.jsonBody);
|
||||||
if (!isNewVersion) {
|
// if (!isNewVersion) {
|
||||||
await LicenseService.setupLicense(DatabaseStorage.database);
|
await LicenseService.setupLicense(DatabaseStorage.database);
|
||||||
return false;
|
return false;
|
||||||
}
|
// }
|
||||||
return await LicenseService.fetchLicenses();
|
// return await LicenseService.fetchLicenses();
|
||||||
}
|
}
|
||||||
} catch (e, s) {
|
} catch (e, s) {
|
||||||
log('() => stack processData: $s');
|
log('() => stack processData: $s');
|
||||||
|
@ -164,12 +171,14 @@ class LocalizationService {
|
||||||
enText: 'Error getting data, verify your connection',
|
enText: 'Error getting data, verify your connection',
|
||||||
ptText: 'Erro ao obter dados, verifique sua conexão',
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<bool> selectLocal(BuildContext context, ApiCallResponse? response) async {
|
static Future<bool> selectLocal(
|
||||||
|
BuildContext context, ApiCallResponse? response) async {
|
||||||
return await showModalBottomSheet(
|
return await showModalBottomSheet(
|
||||||
isScrollControlled: true,
|
isScrollControlled: true,
|
||||||
backgroundColor: Colors.transparent,
|
backgroundColor: Colors.transparent,
|
||||||
|
@ -233,10 +242,13 @@ class LocalizationService {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _handleError(BuildContext context, String errorMsg) async {
|
static void _handleError(BuildContext context, String errorMsg) async {
|
||||||
final String devUUID = await StorageHelper().g(KeychainStorageKey.devUUID.value) ?? '';
|
final String devUUID =
|
||||||
final String userUUID = await StorageHelper().g(KeychainStorageKey.userUUID.value) ?? '';
|
await StorageHelper().g(KeychainStorageKey.devUUID.value) ?? '';
|
||||||
|
final String userUUID =
|
||||||
|
await StorageHelper().g(KeychainStorageKey.userUUID.value) ?? '';
|
||||||
final bool isAuthenticated = userUUID.isNotEmpty && devUUID.isNotEmpty;
|
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');
|
||||||
log('() => isLinked: $errorMsg');
|
log('() => isLinked: $errorMsg');
|
||||||
if (!isAuthenticated) {
|
if (!isAuthenticated) {
|
||||||
|
@ -256,15 +268,20 @@ class LocalizationService {
|
||||||
await DialogUtil.warning(context, errorMsg);
|
await DialogUtil.warning(context, errorMsg);
|
||||||
return;
|
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');
|
log('() => isUnavailable');
|
||||||
try {
|
try {
|
||||||
await StorageHelper().s(KeychainStorageKey.clientUUID.value, locals[0]['CLI_ID']);
|
await StorageHelper()
|
||||||
await StorageHelper().s(KeychainStorageKey.ownerUUID.value, locals[0]['CLU_OWNER_ID']);
|
.s(KeychainStorageKey.clientUUID.value, locals[0]['CLI_ID']);
|
||||||
await StorageHelper().s(KeychainStorageKey.clientName.value, locals[0]['CLI_NOME']);
|
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');
|
var response = await PhpGroup.resopndeVinculo.call(tarefa: 'A');
|
||||||
if (response.jsonBody['error'] == true) {
|
if (response.jsonBody['error'] == true) {
|
||||||
await StorageHelper().s(KeychainStorageKey.clientUUID.value, '');
|
await StorageHelper().s(KeychainStorageKey.clientUUID.value, '');
|
||||||
|
@ -272,21 +289,28 @@ class LocalizationService {
|
||||||
await StorageHelper().s(KeychainStorageKey.clientName.value, '');
|
await StorageHelper().s(KeychainStorageKey.clientName.value, '');
|
||||||
return false;
|
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) {
|
} catch (e, s) {
|
||||||
await DialogUtil.errorDefault(context);
|
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;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<bool> _handleEnabled(BuildContext context, dynamic local) async {
|
static Future<bool> _handleEnabled(
|
||||||
|
BuildContext context, dynamic local) async {
|
||||||
log('() => isEnabled');
|
log('() => isEnabled');
|
||||||
await StorageHelper().s(KeychainStorageKey.clientUUID.value, local['CLI_ID']);
|
await StorageHelper()
|
||||||
await StorageHelper().s(KeychainStorageKey.ownerUUID.value, local['CLU_OWNER_ID']);
|
.s(KeychainStorageKey.clientUUID.value, local['CLI_ID']);
|
||||||
await StorageHelper().s(KeychainStorageKey.clientName.value, local['CLI_NOME']);
|
await StorageHelper()
|
||||||
await StorageHelper().s(KeychainStorageKey.userName.value, local['USU_NOME']);
|
.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);
|
return await processData(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -298,19 +322,24 @@ class LocalizationService {
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<bool> _updateStorageUtil(Map<String, dynamic> jsonBody) async {
|
static Future<bool> _updateStorageUtil(Map<String, dynamic> jsonBody) async {
|
||||||
await StorageHelper().s(KeychainStorageKey.whatsapp.value, jsonBody['whatsapp'] != null && jsonBody['whatsapp']);
|
await StorageHelper().s(KeychainStorageKey.whatsapp.value,
|
||||||
await StorageHelper()
|
jsonBody['whatsapp'] != null && jsonBody['whatsapp']);
|
||||||
.s(KeychainStorageKey.provisional.value, jsonBody['provisional'] != null && jsonBody['provisional']);
|
await StorageHelper().s(KeychainStorageKey.provisional.value,
|
||||||
await StorageHelper().s(KeychainStorageKey.pets.value, jsonBody['pet'] != null && jsonBody['pet']);
|
jsonBody['provisional'] != null && jsonBody['provisional']);
|
||||||
|
await StorageHelper().s(KeychainStorageKey.pets.value,
|
||||||
|
jsonBody['pet'] != null && jsonBody['pet']);
|
||||||
await StorageHelper().s(
|
await StorageHelper().s(
|
||||||
KeychainStorageKey.petAmount.value,
|
KeychainStorageKey.petAmount.value,
|
||||||
jsonBody['petAmountRegister'] != null && jsonBody['petAmountRegister'].toString().isEmpty
|
jsonBody['petAmountRegister'] != null &&
|
||||||
|
jsonBody['petAmountRegister'].toString().isEmpty
|
||||||
? '0'
|
? '0'
|
||||||
: jsonBody['petAmountRegister'].toString());
|
: jsonBody['petAmountRegister'].toString());
|
||||||
await StorageHelper().s(KeychainStorageKey.userName.value, jsonBody['visitado']['VDO_NOME']);
|
|
||||||
await StorageHelper()
|
await StorageHelper()
|
||||||
.s(KeychainStorageKey.isNewVersion.value, jsonBody['newVersion'] != null && jsonBody['newVersion']);
|
.s(KeychainStorageKey.userName.value, jsonBody['visitado']['VDO_NOME']);
|
||||||
return jsonBody['newVersion'] != null && jsonBody['newVersion'];
|
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) {
|
static bool _isActive(List<dynamic> locals) {
|
||||||
|
@ -318,30 +347,44 @@ class LocalizationService {
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<bool> _isInactived(List<dynamic> locals) async {
|
static Future<bool> _isInactived(List<dynamic> locals) async {
|
||||||
String cliUUID = (await StorageHelper().g(KeychainStorageKey.clientUUID.value)) ?? '';
|
String cliUUID =
|
||||||
return locals.where((local) => local['CLI_ID'] != cliUUID && local['CLU_STATUS'] == 'A').isNotEmpty;
|
(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) {
|
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 {
|
static Future<bool> _isUnselected() async {
|
||||||
String cliUUID = (await StorageHelper().g(KeychainStorageKey.clientUUID.value)) ?? '';
|
String cliUUID =
|
||||||
String cliName = (await StorageHelper().g(KeychainStorageKey.clientName.value)) ?? '';
|
(await StorageHelper().g(KeychainStorageKey.clientUUID.value)) ?? '';
|
||||||
String ownerUUID = (await StorageHelper().g(KeychainStorageKey.ownerUUID.value)) ?? '';
|
String cliName =
|
||||||
|
(await StorageHelper().g(KeychainStorageKey.clientName.value)) ?? '';
|
||||||
|
String ownerUUID =
|
||||||
|
(await StorageHelper().g(KeychainStorageKey.ownerUUID.value)) ?? '';
|
||||||
return cliUUID.isEmpty && cliName.isEmpty && ownerUUID.isEmpty;
|
return cliUUID.isEmpty && cliName.isEmpty && ownerUUID.isEmpty;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<bool> _isSelected(bool isInactived) async {
|
static Future<bool> _isSelected(bool isInactived) async {
|
||||||
String cliUUID = (await StorageHelper().g(KeychainStorageKey.clientUUID.value)) ?? '';
|
String cliUUID =
|
||||||
String cliName = (await StorageHelper().g(KeychainStorageKey.clientName.value)) ?? '';
|
(await StorageHelper().g(KeychainStorageKey.clientUUID.value)) ?? '';
|
||||||
|
String cliName =
|
||||||
|
(await StorageHelper().g(KeychainStorageKey.clientName.value)) ?? '';
|
||||||
return cliUUID.isNotEmpty && cliName.isNotEmpty && isInactived;
|
return cliUUID.isNotEmpty && cliName.isNotEmpty && isInactived;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<bool> _isAvailable() async {
|
static Future<bool> _isAvailable() async {
|
||||||
String cliUUID = (await StorageHelper().g(KeychainStorageKey.clientUUID.value)) ?? '';
|
String cliUUID =
|
||||||
String cliName = (await StorageHelper().g(KeychainStorageKey.clientName.value)) ?? '';
|
(await StorageHelper().g(KeychainStorageKey.clientUUID.value)) ?? '';
|
||||||
|
String cliName =
|
||||||
|
(await StorageHelper().g(KeychainStorageKey.clientName.value)) ?? '';
|
||||||
return cliUUID.isNotEmpty && cliName.isNotEmpty;
|
return cliUUID.isNotEmpty && cliName.isNotEmpty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue