WIP
This commit is contained in:
parent
d6c5f50a78
commit
6c71fd8f93
|
@ -5,6 +5,7 @@ import 'package:hub/shared/extensions/dialog_extensions.dart';
|
|||
import 'package:hub/shared/services/authentication/authentication_service.dart';
|
||||
import 'package:hub/shared/utils/storage_util.dart';
|
||||
|
||||
import '../../../shared/services/localization/localization_service.dart';
|
||||
import '/components/molecular_components/option_selection_modal/option_selection_modal_widget.dart';
|
||||
import '/components/organism_components/menu_list_view_component/menu_list_view_component_widget.dart';
|
||||
import '/flutter_flow/flutter_flow_util.dart';
|
||||
|
@ -42,7 +43,9 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
|
|||
isGrid = !isGrid;
|
||||
}
|
||||
|
||||
Future<bool> isChecked() async {
|
||||
Future<bool> isChecked(BuildContext context) async {
|
||||
await StorageUtil().ensureInitialization();
|
||||
await LocalizationService.processLocals(context);
|
||||
return StorageUtil().cliUUID.isNotEmpty &&
|
||||
StorageUtil().cliName.isNotEmpty &&
|
||||
StorageUtil().devUUID.isNotEmpty &&
|
||||
|
@ -50,7 +53,7 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
|
|||
}
|
||||
|
||||
Future openQRCodeScanner(BuildContext context) async {
|
||||
isChecked().then((value) {
|
||||
isChecked(context).then((value) {
|
||||
if (value) {
|
||||
context.push(
|
||||
'/qrCodePage',
|
||||
|
@ -69,7 +72,7 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
|
|||
}
|
||||
|
||||
Future openCompleteSchedule(BuildContext context) async {
|
||||
isChecked().then((value) {
|
||||
isChecked(context).then((value) {
|
||||
if (value) {
|
||||
context.push(
|
||||
'/scheduleCompleteVisitPage',
|
||||
|
@ -90,7 +93,7 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
|
|||
Future openDeliverySchedule(BuildContext context) async {
|
||||
final bool isProvisional = StorageUtil().provisional;
|
||||
|
||||
isChecked().then((value) {
|
||||
isChecked(context).then((value) {
|
||||
if (value) {
|
||||
if (isProvisional == true) {
|
||||
context.push(
|
||||
|
@ -115,7 +118,7 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
|
|||
Future openProvisionalSchedule(BuildContext context) async {
|
||||
final isProvisional = StorageUtil().provisional;
|
||||
|
||||
isChecked().then((value) {
|
||||
isChecked(context).then((value) {
|
||||
if (value) {
|
||||
if (isProvisional == true) {
|
||||
context.push(
|
||||
|
@ -140,7 +143,7 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
|
|||
Future openFastPassSchedule(BuildContext context) async {
|
||||
final isWpp = StorageUtil().whatsapp;
|
||||
|
||||
isChecked().then((value) {
|
||||
isChecked(context).then((value) {
|
||||
if (value) {
|
||||
if (isWpp) {
|
||||
context.push(
|
||||
|
@ -204,7 +207,7 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
|
|||
}
|
||||
|
||||
Future openVisitorsRegister(BuildContext context) async {
|
||||
isChecked().then((value) {
|
||||
isChecked(context).then((value) {
|
||||
if (value) {
|
||||
context.push(
|
||||
'/registerVisitorPage',
|
||||
|
@ -223,7 +226,7 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
|
|||
}
|
||||
|
||||
Future openPoepleOnTheProperty(BuildContext context) async {
|
||||
isChecked().then((value) {
|
||||
isChecked(context).then((value) {
|
||||
if (value) {
|
||||
context.push(
|
||||
'/peopleOnThePropertyPage',
|
||||
|
@ -258,7 +261,7 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
|
|||
}
|
||||
|
||||
Future openPreferencesSettings(BuildContext context) async {
|
||||
isChecked().then((value) {
|
||||
isChecked(context).then((value) {
|
||||
if (value) {
|
||||
context.push(
|
||||
'/preferencesSettings',
|
||||
|
@ -279,7 +282,7 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
|
|||
Future openMyOrders(BuildContext context) async {
|
||||
final isWpp = StorageUtil().whatsapp;
|
||||
|
||||
isChecked().then((value) {
|
||||
isChecked(context).then((value) {
|
||||
if (value) {
|
||||
if (isWpp) {
|
||||
context.push(
|
||||
|
@ -304,7 +307,7 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
|
|||
Future openReservations(BuildContext context) async {
|
||||
final isWpp = StorageUtil().whatsapp;
|
||||
|
||||
isChecked().then((value) {
|
||||
isChecked(context).then((value) {
|
||||
if (value) {
|
||||
if (isWpp) {
|
||||
context.push(
|
||||
|
@ -373,7 +376,7 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
|
|||
}
|
||||
|
||||
Future openLiberationsHistory(BuildContext context) async {
|
||||
isChecked().then((value) {
|
||||
isChecked(context).then((value) {
|
||||
if (value) {
|
||||
context.push(
|
||||
'/liberationHistory',
|
||||
|
@ -392,7 +395,7 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
|
|||
}
|
||||
|
||||
Future openAccessHistory(BuildContext context) async {
|
||||
isChecked().then((value) {
|
||||
isChecked(context).then((value) {
|
||||
if (value) {
|
||||
context.push(
|
||||
'/acessHistoryPage',
|
||||
|
@ -411,7 +414,7 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
|
|||
}
|
||||
|
||||
Future openVisitsHistory(BuildContext context) async {
|
||||
isChecked().then((value) {
|
||||
isChecked(context).then((value) {
|
||||
if (value) {
|
||||
context.push(
|
||||
'/scheduleCompleteVisitPage',
|
||||
|
@ -430,7 +433,7 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
|
|||
}
|
||||
|
||||
Future openMessagesHistory(BuildContext context) async {
|
||||
isChecked().then((value) {
|
||||
isChecked(context).then((value) {
|
||||
if (value) {
|
||||
context.push(
|
||||
'/messageHistoryPage',
|
||||
|
@ -451,7 +454,7 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
|
|||
Future openPetsRegister(BuildContext context) async {
|
||||
bool isPet = StorageUtil().pets;
|
||||
|
||||
isChecked().then((value) {
|
||||
isChecked(context).then((value) {
|
||||
if (value) {
|
||||
if (isPet) {
|
||||
context.push(
|
||||
|
|
|
@ -287,8 +287,9 @@ class _AppState extends State<App> with WidgetsBindingObserver {
|
|||
}
|
||||
|
||||
@override void didChangeAppLifecycleState(AppLifecycleState state) async {
|
||||
await StorageUtil().ensureInitialization();
|
||||
LocalizationService.processLocals(context);
|
||||
if (state == AppLifecycleState.resumed) await StorageUtil().ensureInitialization();
|
||||
if (state == AppLifecycleState.resumed) await LocalizationService.processLocals(context);
|
||||
else LocalizationService.processData(context);
|
||||
}
|
||||
|
||||
@override Widget build(BuildContext context) {
|
||||
|
|
|
@ -99,7 +99,13 @@ class LocalizationService {
|
|||
} catch (e, s) {
|
||||
log('() => stack: $s');
|
||||
log('() => catch: $e', stackTrace: s);
|
||||
return await selectLocal(context);
|
||||
// return await selectLocal(context);
|
||||
final String errorMsg = FFLocalizations.of(context).getVariableText(
|
||||
enText: 'Error getting locals, verify your connection',
|
||||
ptText: 'Erro ao obter locais, verifique sua conexão',
|
||||
);
|
||||
DialogUtil.error(context, errorMsg).whenComplete(() => selectLocal(context));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
static Future<bool> processData(BuildContext context) async {
|
||||
|
@ -119,7 +125,11 @@ class LocalizationService {
|
|||
} catch (e, s) {
|
||||
log('() => stack processData: $s');
|
||||
log('() => error processData: $e', stackTrace: s);
|
||||
DialogUtil.warningDefault(context).whenComplete(() => selectLocal(context));
|
||||
final String errorMsg = FFLocalizations.of(context).getVariableText(
|
||||
enText: 'Error getting data, verify your connection',
|
||||
ptText: 'Erro ao obter dados, verifique sua conexão',
|
||||
);
|
||||
DialogUtil.error(context, errorMsg).whenComplete(() => selectLocal(context));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -225,7 +235,6 @@ class LocalizationService {
|
|||
log('() => CLU_STATUS: $status');
|
||||
}
|
||||
}
|
||||
|
||||
static bool _isActive(List<dynamic> locals) {
|
||||
return locals.where((local) => local['CLU_STATUS'] == 'A').isNotEmpty;
|
||||
}
|
||||
|
@ -244,7 +253,6 @@ class LocalizationService {
|
|||
static bool _isAvailable() {
|
||||
return StorageUtil().cliUUID.isNotEmpty && StorageUtil().cliName.isNotEmpty;
|
||||
}
|
||||
|
||||
static void _updateStorageUtil(Map<String, dynamic> jsonBody) {
|
||||
final bool whatsapp = jsonBody['whatsapp'] ?? false;
|
||||
final bool provisional = jsonBody['provisional'] ?? false;
|
||||
|
|
Loading…
Reference in New Issue