Merge pull request #50 from FRE-Informatica/hotfix/lifecyclestate
Hotfix/lifecyclestate
This commit is contained in:
commit
4497df1b04
|
@ -5,6 +5,9 @@ import 'package:hub/flutter_flow/flutter_flow_theme.dart';
|
||||||
import 'package:hub/shared/utils/dialog_util.dart';
|
import 'package:hub/shared/utils/dialog_util.dart';
|
||||||
import 'package:hub/shared/utils/storage_util.dart';
|
import 'package:hub/shared/utils/storage_util.dart';
|
||||||
|
|
||||||
|
import '../../../shared/extensions/dialog_extensions.dart';
|
||||||
|
import '../../../shared/services/localization/localization_service.dart';
|
||||||
|
|
||||||
|
|
||||||
class MenuButtonWidget extends MenuEntry {
|
class MenuButtonWidget extends MenuEntry {
|
||||||
const MenuButtonWidget({
|
const MenuButtonWidget({
|
||||||
|
@ -27,6 +30,8 @@ class MenuButtonWidget extends MenuEntry {
|
||||||
|
|
||||||
class _MenuButtonWidgetState extends State<MenuButtonWidget> {
|
class _MenuButtonWidgetState extends State<MenuButtonWidget> {
|
||||||
get action => action;
|
get action => action;
|
||||||
|
bool _isProcessing = false;
|
||||||
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
@ -35,14 +40,20 @@ class _MenuButtonWidgetState extends State<MenuButtonWidget> {
|
||||||
focusColor: Colors.transparent,
|
focusColor: Colors.transparent,
|
||||||
hoverColor: Colors.transparent,
|
hoverColor: Colors.transparent,
|
||||||
highlightColor: Colors.transparent,
|
highlightColor: Colors.transparent,
|
||||||
onTap: () async {
|
onTap: _isProcessing ? null : () async {
|
||||||
final cliUUID = StorageUtil().cliUUID;
|
setState(() {
|
||||||
|
_isProcessing = true;
|
||||||
if (cliUUID.isEmpty) {
|
});
|
||||||
return DialogUtil.warningDefault(context);
|
await LocalizationService.processLocals(context).then((value) async {
|
||||||
} else {
|
if (value) {
|
||||||
await widget.action?.call();
|
await widget.action?.call();
|
||||||
|
} else {
|
||||||
|
DialogUnavailable.unavailableCredentials(context);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
setState(() {
|
||||||
|
_isProcessing = false;
|
||||||
|
});
|
||||||
},
|
},
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 0, vertical: 0),
|
padding: const EdgeInsets.symmetric(horizontal: 0, vertical: 0),
|
||||||
|
|
|
@ -3,6 +3,9 @@ import 'package:google_fonts/google_fonts.dart';
|
||||||
import 'package:hub/components/molecular_components/menu_item/menu_item.dart';
|
import 'package:hub/components/molecular_components/menu_item/menu_item.dart';
|
||||||
import 'package:hub/flutter_flow/flutter_flow_theme.dart';
|
import 'package:hub/flutter_flow/flutter_flow_theme.dart';
|
||||||
|
|
||||||
|
import '../../../shared/extensions/dialog_extensions.dart';
|
||||||
|
import '../../../shared/services/localization/localization_service.dart';
|
||||||
|
|
||||||
class MenuCardItem extends MenuEntry {
|
class MenuCardItem extends MenuEntry {
|
||||||
const MenuCardItem({
|
const MenuCardItem({
|
||||||
super.key,
|
super.key,
|
||||||
|
@ -24,6 +27,7 @@ class MenuCardItem extends MenuEntry {
|
||||||
|
|
||||||
class _MenuCardItemState extends State<MenuCardItem> {
|
class _MenuCardItemState extends State<MenuCardItem> {
|
||||||
get action => action;
|
get action => action;
|
||||||
|
bool _isProcessing = false;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
@ -32,8 +36,20 @@ class _MenuCardItemState extends State<MenuCardItem> {
|
||||||
focusColor: Colors.transparent,
|
focusColor: Colors.transparent,
|
||||||
hoverColor: Colors.transparent,
|
hoverColor: Colors.transparent,
|
||||||
highlightColor: Colors.transparent,
|
highlightColor: Colors.transparent,
|
||||||
onTap: () async {
|
onTap: _isProcessing ? null : () async {
|
||||||
|
setState(() {
|
||||||
|
_isProcessing = true;
|
||||||
|
});
|
||||||
|
await LocalizationService.processLocals(context).then((value) async {
|
||||||
|
if (value) {
|
||||||
await widget.action?.call();
|
await widget.action?.call();
|
||||||
|
} else {
|
||||||
|
DialogUnavailable.unavailableCredentials(context);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
setState(() {
|
||||||
|
_isProcessing = false;
|
||||||
|
});
|
||||||
},
|
},
|
||||||
child: Card(
|
child: Card(
|
||||||
elevation: 0,
|
elevation: 0,
|
||||||
|
|
|
@ -5,53 +5,34 @@ import 'package:hub/shared/extensions/dialog_extensions.dart';
|
||||||
import 'package:hub/shared/services/authentication/authentication_service.dart';
|
import 'package:hub/shared/services/authentication/authentication_service.dart';
|
||||||
import 'package:hub/shared/utils/storage_util.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/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 '/components/organism_components/menu_list_view_component/menu_list_view_component_widget.dart';
|
||||||
import '/flutter_flow/flutter_flow_util.dart';
|
import '/flutter_flow/flutter_flow_util.dart';
|
||||||
import 'menu_component_widget.dart' show MenuComponentWidget;
|
import 'menu_component_widget.dart' show MenuComponentWidget;
|
||||||
|
|
||||||
class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
|
class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
|
||||||
/// Local state fields for this component.
|
|
||||||
|
|
||||||
bool isGrid = false;
|
bool isGrid = false;
|
||||||
|
|
||||||
/// State fields for stateful widgets in this component.
|
|
||||||
|
|
||||||
// Model for menuListViewComponent.
|
|
||||||
late MenuListViewComponentModel menuListViewComponentModel;
|
late MenuListViewComponentModel menuListViewComponentModel;
|
||||||
|
|
||||||
// Model for menuStaggeredViewComponent.
|
|
||||||
late MenuStaggeredViewComponentModel menuStaggeredViewComponentModel;
|
late MenuStaggeredViewComponentModel menuStaggeredViewComponentModel;
|
||||||
|
|
||||||
@override
|
@override void initState(BuildContext context) {
|
||||||
void initState(BuildContext context) {
|
|
||||||
menuListViewComponentModel =
|
menuListViewComponentModel =
|
||||||
createModel(context, () => MenuListViewComponentModel());
|
createModel(context, () => MenuListViewComponentModel());
|
||||||
menuStaggeredViewComponentModel =
|
menuStaggeredViewComponentModel =
|
||||||
createModel(context, () => MenuStaggeredViewComponentModel());
|
createModel(context, () => MenuStaggeredViewComponentModel());
|
||||||
}
|
}
|
||||||
|
@override void dispose() {
|
||||||
@override
|
|
||||||
void dispose() {
|
|
||||||
menuListViewComponentModel.dispose();
|
menuListViewComponentModel.dispose();
|
||||||
menuStaggeredViewComponentModel.dispose();
|
menuStaggeredViewComponentModel.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Action blocks.
|
|
||||||
Future changeMenuStyle(BuildContext context) async {
|
Future changeMenuStyle(BuildContext context) async {
|
||||||
isGrid = !isGrid;
|
isGrid = !isGrid;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<bool> isChecked() async {
|
|
||||||
return StorageUtil().cliUUID.isNotEmpty &&
|
|
||||||
StorageUtil().cliName.isNotEmpty &&
|
|
||||||
StorageUtil().devUUID.isNotEmpty &&
|
|
||||||
StorageUtil().userUUID.isNotEmpty;
|
|
||||||
}
|
|
||||||
|
|
||||||
Future openQRCodeScanner(BuildContext context) async {
|
Future openQRCodeScanner(BuildContext context) async {
|
||||||
isChecked().then((value) {
|
|
||||||
if (value) {
|
|
||||||
context.push(
|
context.push(
|
||||||
'/qrCodePage',
|
'/qrCodePage',
|
||||||
extra: <String, dynamic>{
|
extra: <String, dynamic>{
|
||||||
|
@ -62,15 +43,8 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
} else {
|
|
||||||
DialogUnavailable.unavailableCredentials(context);
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
Future openCompleteSchedule(BuildContext context) async {
|
Future openCompleteSchedule(BuildContext context) async {
|
||||||
isChecked().then((value) {
|
|
||||||
if (value) {
|
|
||||||
context.push(
|
context.push(
|
||||||
'/scheduleCompleteVisitPage',
|
'/scheduleCompleteVisitPage',
|
||||||
extra: <String, dynamic>{
|
extra: <String, dynamic>{
|
||||||
|
@ -81,17 +55,9 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
} else {
|
|
||||||
DialogUnavailable.unavailableCredentials(context);
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
Future openDeliverySchedule(BuildContext context) async {
|
Future openDeliverySchedule(BuildContext context) async {
|
||||||
final bool isProvisional = StorageUtil().provisional;
|
final bool isProvisional = StorageUtil().provisional;
|
||||||
|
|
||||||
isChecked().then((value) {
|
|
||||||
if (value) {
|
|
||||||
if (isProvisional == true) {
|
if (isProvisional == true) {
|
||||||
context.push(
|
context.push(
|
||||||
'/deliverySchedule',
|
'/deliverySchedule',
|
||||||
|
@ -106,17 +72,9 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
|
||||||
} else {
|
} else {
|
||||||
DialogUnavailable.unavailableFeature(context);
|
DialogUnavailable.unavailableFeature(context);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
DialogUnavailable.unavailableCredentials(context);
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
Future openProvisionalSchedule(BuildContext context) async {
|
Future openProvisionalSchedule(BuildContext context) async {
|
||||||
final isProvisional = StorageUtil().provisional;
|
final isProvisional = StorageUtil().provisional;
|
||||||
|
|
||||||
isChecked().then((value) {
|
|
||||||
if (value) {
|
|
||||||
if (isProvisional == true) {
|
if (isProvisional == true) {
|
||||||
context.push(
|
context.push(
|
||||||
'/provisionalSchedule',
|
'/provisionalSchedule',
|
||||||
|
@ -131,17 +89,9 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
|
||||||
} else {
|
} else {
|
||||||
DialogUnavailable.unavailableFeature(context);
|
DialogUnavailable.unavailableFeature(context);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
DialogUnavailable.unavailableCredentials(context);
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
Future openFastPassSchedule(BuildContext context) async {
|
Future openFastPassSchedule(BuildContext context) async {
|
||||||
final isWpp = StorageUtil().whatsapp;
|
final isWpp = StorageUtil().whatsapp;
|
||||||
|
|
||||||
isChecked().then((value) {
|
|
||||||
if (value) {
|
|
||||||
if (isWpp) {
|
if (isWpp) {
|
||||||
context.push(
|
context.push(
|
||||||
'/fastPassPage',
|
'/fastPassPage',
|
||||||
|
@ -156,12 +106,7 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
|
||||||
} else {
|
} else {
|
||||||
DialogUnavailable.unavailableFeature(context);
|
DialogUnavailable.unavailableFeature(context);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
DialogUnavailable.unavailableCredentials(context);
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
Future showSchedules(BuildContext context) async {
|
Future showSchedules(BuildContext context) async {
|
||||||
final routesListStr = <String>[
|
final routesListStr = <String>[
|
||||||
'scheduleProvisionalVisitPage',
|
'scheduleProvisionalVisitPage',
|
||||||
|
@ -187,7 +132,6 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
|
||||||
enText: 'Complete\nSchedule',
|
enText: 'Complete\nSchedule',
|
||||||
),
|
),
|
||||||
];
|
];
|
||||||
|
|
||||||
await showAdaptiveDialog(
|
await showAdaptiveDialog(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (context) {
|
builder: (context) {
|
||||||
|
@ -202,10 +146,7 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future openVisitorsRegister(BuildContext context) async {
|
Future openVisitorsRegister(BuildContext context) async {
|
||||||
isChecked().then((value) {
|
|
||||||
if (value) {
|
|
||||||
context.push(
|
context.push(
|
||||||
'/registerVisitorPage',
|
'/registerVisitorPage',
|
||||||
extra: <String, dynamic>{
|
extra: <String, dynamic>{
|
||||||
|
@ -216,15 +157,8 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
} else {
|
|
||||||
DialogUnavailable.unavailableCredentials(context);
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
Future openPoepleOnTheProperty(BuildContext context) async {
|
Future openPoepleOnTheProperty(BuildContext context) async {
|
||||||
isChecked().then((value) {
|
|
||||||
if (value) {
|
|
||||||
context.push(
|
context.push(
|
||||||
'/peopleOnThePropertyPage',
|
'/peopleOnThePropertyPage',
|
||||||
extra: <String, dynamic>{
|
extra: <String, dynamic>{
|
||||||
|
@ -235,12 +169,7 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
} else {
|
|
||||||
DialogUnavailable.unavailableCredentials(context);
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
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',
|
||||||
|
@ -256,10 +185,7 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
|
||||||
content,
|
content,
|
||||||
() async => await AuthenticationService.signOut(context));
|
() async => await AuthenticationService.signOut(context));
|
||||||
}
|
}
|
||||||
|
|
||||||
Future openPreferencesSettings(BuildContext context) async {
|
Future openPreferencesSettings(BuildContext context) async {
|
||||||
isChecked().then((value) {
|
|
||||||
if (value) {
|
|
||||||
context.push(
|
context.push(
|
||||||
'/preferencesSettings',
|
'/preferencesSettings',
|
||||||
extra: <String, dynamic>{
|
extra: <String, dynamic>{
|
||||||
|
@ -270,17 +196,9 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
} else {
|
|
||||||
DialogUnavailable.unavailableCredentials(context);
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
Future openMyOrders(BuildContext context) async {
|
Future openMyOrders(BuildContext context) async {
|
||||||
final isWpp = StorageUtil().whatsapp;
|
final isWpp = StorageUtil().whatsapp;
|
||||||
|
|
||||||
isChecked().then((value) {
|
|
||||||
if (value) {
|
|
||||||
if (isWpp) {
|
if (isWpp) {
|
||||||
context.push(
|
context.push(
|
||||||
'/packageOrder',
|
'/packageOrder',
|
||||||
|
@ -295,17 +213,9 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
|
||||||
} else {
|
} else {
|
||||||
DialogUnavailable.unavailableFeature(context);
|
DialogUnavailable.unavailableFeature(context);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
DialogUnavailable.unavailableCredentials(context);
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
Future openReservations(BuildContext context) async {
|
Future openReservations(BuildContext context) async {
|
||||||
final isWpp = StorageUtil().whatsapp;
|
final isWpp = StorageUtil().whatsapp;
|
||||||
|
|
||||||
isChecked().then((value) {
|
|
||||||
if (value) {
|
|
||||||
if (isWpp) {
|
if (isWpp) {
|
||||||
context.push(
|
context.push(
|
||||||
'/reservation',
|
'/reservation',
|
||||||
|
@ -320,12 +230,7 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
|
||||||
} else {
|
} else {
|
||||||
DialogUnavailable.unavailableFeature(context);
|
DialogUnavailable.unavailableFeature(context);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
DialogUnavailable.unavailableCredentials(context);
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
Future showHistories(BuildContext context) async {
|
Future showHistories(BuildContext context) async {
|
||||||
await showAdaptiveDialog(
|
await showAdaptiveDialog(
|
||||||
// isScrollControlled: true,
|
// isScrollControlled: true,
|
||||||
|
@ -371,10 +276,7 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future openLiberationsHistory(BuildContext context) async {
|
Future openLiberationsHistory(BuildContext context) async {
|
||||||
isChecked().then((value) {
|
|
||||||
if (value) {
|
|
||||||
context.push(
|
context.push(
|
||||||
'/liberationHistory',
|
'/liberationHistory',
|
||||||
extra: <String, dynamic>{
|
extra: <String, dynamic>{
|
||||||
|
@ -385,15 +287,8 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
} else {
|
|
||||||
DialogUnavailable.unavailableCredentials(context);
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
Future openAccessHistory(BuildContext context) async {
|
Future openAccessHistory(BuildContext context) async {
|
||||||
isChecked().then((value) {
|
|
||||||
if (value) {
|
|
||||||
context.push(
|
context.push(
|
||||||
'/acessHistoryPage',
|
'/acessHistoryPage',
|
||||||
extra: <String, dynamic>{
|
extra: <String, dynamic>{
|
||||||
|
@ -404,15 +299,8 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
} else {
|
|
||||||
DialogUnavailable.unavailableCredentials(context);
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
Future openVisitsHistory(BuildContext context) async {
|
Future openVisitsHistory(BuildContext context) async {
|
||||||
isChecked().then((value) {
|
|
||||||
if (value) {
|
|
||||||
context.push(
|
context.push(
|
||||||
'/scheduleCompleteVisitPage',
|
'/scheduleCompleteVisitPage',
|
||||||
extra: <String, dynamic>{
|
extra: <String, dynamic>{
|
||||||
|
@ -423,15 +311,8 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
} else {
|
|
||||||
DialogUnavailable.unavailableCredentials(context);
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
Future openMessagesHistory(BuildContext context) async {
|
Future openMessagesHistory(BuildContext context) async {
|
||||||
isChecked().then((value) {
|
|
||||||
if (value) {
|
|
||||||
context.push(
|
context.push(
|
||||||
'/messageHistoryPage',
|
'/messageHistoryPage',
|
||||||
extra: <String, dynamic>{
|
extra: <String, dynamic>{
|
||||||
|
@ -442,17 +323,9 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
} else {
|
|
||||||
DialogUnavailable.unavailableCredentials(context);
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
Future openPetsRegister(BuildContext context) async {
|
Future openPetsRegister(BuildContext context) async {
|
||||||
bool isPet = StorageUtil().pets;
|
bool isPet = StorageUtil().pets;
|
||||||
|
|
||||||
isChecked().then((value) {
|
|
||||||
if (value) {
|
|
||||||
if (isPet) {
|
if (isPet) {
|
||||||
context.push(
|
context.push(
|
||||||
'/petsPage',
|
'/petsPage',
|
||||||
|
@ -467,9 +340,8 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
|
||||||
} else {
|
} else {
|
||||||
DialogUnavailable.unavailableFeature(context);
|
DialogUnavailable.unavailableFeature(context);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
DialogUnavailable.unavailableCredentials(context);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -287,9 +287,8 @@ class _AppState extends State<App> with WidgetsBindingObserver {
|
||||||
}
|
}
|
||||||
|
|
||||||
@override void didChangeAppLifecycleState(AppLifecycleState state) async {
|
@override void didChangeAppLifecycleState(AppLifecycleState state) async {
|
||||||
if (state == AppLifecycleState.resumed) await StorageUtil().ensureInitialization();
|
bool initialize = await StorageUtil().ensureInitialization();
|
||||||
if (state == AppLifecycleState.resumed) LocalizationService.processLocals(context);
|
if(initialize) await LocalizationService.processLocals(context);
|
||||||
else LocalizationService.processData(context);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override Widget build(BuildContext context) {
|
@override Widget build(BuildContext context) {
|
||||||
|
|
|
@ -45,6 +45,7 @@ class LocalizationService {
|
||||||
}
|
}
|
||||||
static Future<bool> processLocals(BuildContext context) async {
|
static Future<bool> processLocals(BuildContext context) async {
|
||||||
try {
|
try {
|
||||||
|
await StorageUtil().ensureInitialization();
|
||||||
final GetLocalsCall callback = PhpGroup.getLocalsCall;
|
final GetLocalsCall callback = PhpGroup.getLocalsCall;
|
||||||
final ApiCallResponse response = await callback.call();
|
final ApiCallResponse response = await callback.call();
|
||||||
final bool isError = response.jsonBody['error'];
|
final bool isError = response.jsonBody['error'];
|
||||||
|
@ -85,10 +86,8 @@ class LocalizationService {
|
||||||
return await processData(context);
|
return await processData(context);
|
||||||
} else if (isAvailable) {
|
} else if (isAvailable) {
|
||||||
log('() => isAvailable');
|
log('() => isAvailable');
|
||||||
await StorageUtil().ensureInitialization();
|
|
||||||
return await processData(context);
|
return await processData(context);
|
||||||
} else {
|
} else {
|
||||||
await StorageUtil().ensureInitialization();
|
|
||||||
if (!isUnique && !isActive) log('() => not unique and not active');
|
if (!isUnique && !isActive) log('() => not unique and not active');
|
||||||
if (!isUnique && isInactived) log('() => not unique and inactived');
|
if (!isUnique && isInactived) log('() => not unique and inactived');
|
||||||
if (!isUnique && isPending) log('() => not unique and pending');
|
if (!isUnique && isPending) log('() => not unique and pending');
|
||||||
|
@ -99,27 +98,39 @@ class LocalizationService {
|
||||||
} catch (e, s) {
|
} catch (e, s) {
|
||||||
log('() => stack: $s');
|
log('() => stack: $s');
|
||||||
log('() => catch: $e', stackTrace: 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 {
|
static Future<bool> processData(BuildContext context) async {
|
||||||
try {
|
try {
|
||||||
|
await StorageUtil().ensureInitialization();
|
||||||
final GetDadosCall callback = PhpGroup.getDadosCall;
|
final GetDadosCall callback = PhpGroup.getDadosCall;
|
||||||
var response = await callback.call();
|
var response = await callback.call();
|
||||||
final error = response.jsonBody['error'];
|
final bool error = response.jsonBody['error'];
|
||||||
|
|
||||||
if (error == false) {
|
if (error == true || error == 'true') {
|
||||||
|
final String errorMsg = response.jsonBody['error_msg'];
|
||||||
|
DialogUtil.error(context, errorMsg).whenComplete(() => selectLocal(context));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else {
|
||||||
_updateStorageUtil(response.jsonBody);
|
_updateStorageUtil(response.jsonBody);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
|
||||||
log('() => error in processData: $error');
|
|
||||||
DialogUtil.warningDefault(context).whenComplete(() => selectLocal(context));
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
} catch (e, s) {
|
} catch (e, s) {
|
||||||
log('() => stack processData: $s');
|
log('() => stack processData: $s');
|
||||||
log('() => error processData: $e', stackTrace: 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;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -195,6 +206,7 @@ class LocalizationService {
|
||||||
try {
|
try {
|
||||||
StorageUtil().cliUUID = locals[0]['CLI_ID'];
|
StorageUtil().cliUUID = locals[0]['CLI_ID'];
|
||||||
StorageUtil().ownerUUID = locals[0]['CLU_OWNER_ID'];
|
StorageUtil().ownerUUID = locals[0]['CLU_OWNER_ID'];
|
||||||
|
StorageUtil().cliName = 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) {
|
||||||
StorageUtil().cliUUID = '';
|
StorageUtil().cliUUID = '';
|
||||||
|
@ -225,7 +237,6 @@ class LocalizationService {
|
||||||
log('() => CLU_STATUS: $status');
|
log('() => CLU_STATUS: $status');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool _isActive(List<dynamic> locals) {
|
static bool _isActive(List<dynamic> locals) {
|
||||||
return locals.where((local) => local['CLU_STATUS'] == 'A').isNotEmpty;
|
return locals.where((local) => local['CLU_STATUS'] == 'A').isNotEmpty;
|
||||||
}
|
}
|
||||||
|
@ -244,18 +255,12 @@ class LocalizationService {
|
||||||
static bool _isAvailable() {
|
static bool _isAvailable() {
|
||||||
return StorageUtil().cliUUID.isNotEmpty && StorageUtil().cliName.isNotEmpty;
|
return StorageUtil().cliUUID.isNotEmpty && StorageUtil().cliName.isNotEmpty;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _updateStorageUtil(Map<String, dynamic> jsonBody) {
|
static void _updateStorageUtil(Map<String, dynamic> jsonBody) {
|
||||||
final bool whatsapp = jsonBody['whatsapp'] ?? false;
|
StorageUtil().whatsapp = jsonBody['whatsapp'] ?? false;
|
||||||
final bool provisional = jsonBody['provisional'] ?? false;
|
StorageUtil().provisional = jsonBody['provisional'] ?? false;
|
||||||
final bool pets = jsonBody['pet'] ?? false;
|
StorageUtil().pets = jsonBody['pet'] ?? false;
|
||||||
final String petAmountRegister = jsonBody['petAmountRegister'].toString().isEmpty ? '0' : jsonBody['petAmountRegister'].toString();
|
StorageUtil().petAmountRegister = jsonBody['petAmountRegister'].toString().isEmpty ? '0' : jsonBody['petAmountRegister'].toString();
|
||||||
final String name = jsonBody['visitado']['VDO_NOME'];
|
StorageUtil().userName = jsonBody['visitado']['VDO_NOME'];
|
||||||
StorageUtil().whatsapp = whatsapp;
|
|
||||||
StorageUtil().provisional = provisional;
|
|
||||||
StorageUtil().pets = pets;
|
|
||||||
StorageUtil().petAmountRegister = petAmountRegister;
|
|
||||||
StorageUtil().userName = name;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -119,20 +119,20 @@ class StorageUtil {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> ensureInitialization() async {
|
Future<bool> ensureInitialization() async {
|
||||||
try {
|
try {
|
||||||
log('StorageUtil: Starting initialization');
|
log('StorageUtil: Starting initialization');
|
||||||
|
if(!_initialized) return true;
|
||||||
|
|
||||||
|
|
||||||
await initSharedPreferences();
|
await initSharedPreferences();
|
||||||
await initSecureStorage();
|
await initSecureStorage();
|
||||||
await initSQLiteStorage();
|
await initSQLiteStorage();
|
||||||
_initialized = false;
|
if(_initialized) _initialized = false;
|
||||||
|
if(_initialized) return true;
|
||||||
|
return false;
|
||||||
} catch (e, s) {
|
} catch (e, s) {
|
||||||
log('Error initializing storage: $e');
|
log('Error initializing storage: $e');
|
||||||
LogUtil.requestAPIFailed('$UniqueKey', '$UniqueKey', 'StorageUtil', e, s);
|
LogUtil.requestAPIFailed('$UniqueKey', '$UniqueKey', 'StorageUtil', e, s);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -218,14 +218,6 @@ class StorageUtil {
|
||||||
bool get isRecovered => _isRecovered;
|
bool get isRecovered => _isRecovered;
|
||||||
set isRecovered(bool value) => _isRecovered = value;
|
set isRecovered(bool value) => _isRecovered = value;
|
||||||
|
|
||||||
String _tempMail = '';
|
|
||||||
String get tempMail => _tempMail;
|
|
||||||
set tempMail(String value) => _tempMail = value;
|
|
||||||
|
|
||||||
String _tempToken = '';
|
|
||||||
String get tempToken => _tempToken;
|
|
||||||
set tempToken(String value) => _tempToken = value;
|
|
||||||
|
|
||||||
bool _isFirstRun = true;
|
bool _isFirstRun = true;
|
||||||
bool get isFirstRun => _isFirstRun;
|
bool get isFirstRun => _isFirstRun;
|
||||||
set isFirstRun(bool value) {
|
set isFirstRun(bool value) {
|
||||||
|
|
|
@ -3,7 +3,7 @@ description: A new Flutter project.
|
||||||
|
|
||||||
publish_to: "none"
|
publish_to: "none"
|
||||||
|
|
||||||
version: 1.1.1+11
|
version: 1.1.2+13
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ">=3.0.0 <4.0.0"
|
sdk: ">=3.0.0 <4.0.0"
|
||||||
|
|
Loading…
Reference in New Issue