Fix: Arrumado conflitos e alterada a logica no checkLocal
This commit is contained in:
parent
3294787d33
commit
0e6bb9a03a
|
@ -1,4 +1,4 @@
|
||||||
import 'dart:math';
|
import 'dart:developer';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
// import 'package:hub/components/organisms/bottom_arrow_linked_locals/bottom_arrow_linked_locals_component_widget.dart';
|
// import 'package:hub/components/organisms/bottom_arrow_linked_locals/bottom_arrow_linked_locals_component_widget.dart';
|
||||||
|
@ -160,12 +160,8 @@ Future singInLoginAction(
|
||||||
AppState().serialNumber = await getSerialNumber() ?? '';
|
AppState().serialNumber = await getSerialNumber() ?? '';
|
||||||
|
|
||||||
AppState().isLogged = true;
|
AppState().isLogged = true;
|
||||||
|
AppState().haveLocal =
|
||||||
bool _haveLocal = await checkLocals(context: context, model: model);
|
await checkLocals(context: context, model: model);
|
||||||
print(await checkLocals(context: context, model: model));
|
|
||||||
AppState().haveLocal = _haveLocal;
|
|
||||||
|
|
||||||
await toggleApp(context, AppState().haveLocal);
|
|
||||||
} else {
|
} else {
|
||||||
if (PhpGroup.loginCall.msg((loginCall?.jsonBody ?? '')) == null) {
|
if (PhpGroup.loginCall.msg((loginCall?.jsonBody ?? '')) == null) {
|
||||||
DialogUtil.errorDefault(context);
|
DialogUtil.errorDefault(context);
|
||||||
|
@ -320,7 +316,7 @@ Future toggleApp(BuildContext context, bool haveLocal) async {
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
else
|
else if (haveLocal == false)
|
||||||
context.goNamed(
|
context.goNamed(
|
||||||
'receptionPage',
|
'receptionPage',
|
||||||
extra: <String, dynamic>{
|
extra: <String, dynamic>{
|
||||||
|
@ -390,24 +386,22 @@ Future<bool> checkLocals({
|
||||||
required BuildContext context,
|
required BuildContext context,
|
||||||
required FlutterFlowModel model,
|
required FlutterFlowModel model,
|
||||||
}) async {
|
}) async {
|
||||||
bool itemFound = false;
|
final response = await PhpGroup.getLocalsCall.call(
|
||||||
var modalResult;
|
devUUID: AppState().devUUID,
|
||||||
|
userUUID: AppState().userUUID,
|
||||||
|
);
|
||||||
|
log(response.jsonBody.toString());
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
// Verificação rápida de erro para evitar processamento desnecessário.
|
// Verificação rápida de erro para evitar processamento desnecessário.
|
||||||
if (response.jsonBody['error']) {
|
if (response.jsonBody['error']) {
|
||||||
|
DialogUtil.errorDefault(context);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
List<dynamic> locals = response.jsonBody['locais'] ?? [];
|
||||||
// Uso eficiente de coleções para verificar a condição desejada.
|
if (locals != null && locals.isEmpty) {
|
||||||
final String uuid = cliUUID ?? AppState().cliUUID;
|
await toggleApp(context, false);
|
||||||
final bool itemFound =
|
return false;
|
||||||
response.jsonBody['locais'].any((local) => local['CLI_ID'] == uuid);
|
} else if (locals.where((local) => local['CLU_STATUS'] != 'A').isNotEmpty) {
|
||||||
if (itemFound) {
|
|
||||||
if (response.jsonBody['locais']
|
|
||||||
.any((local) => local['CLU_STATUS'] == "A")) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
await showModalBottomSheet(
|
await showModalBottomSheet(
|
||||||
isScrollControlled: true,
|
isScrollControlled: true,
|
||||||
backgroundColor: Colors.transparent,
|
backgroundColor: Colors.transparent,
|
||||||
|
@ -419,57 +413,9 @@ Future<bool> checkLocals({
|
||||||
child: const BottomArrowLinkedLocalsComponentWidget(),
|
child: const BottomArrowLinkedLocalsComponentWidget(),
|
||||||
),
|
),
|
||||||
); // Chamada oti
|
); // Chamada oti
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
=======
|
await toggleApp(context, true);
|
||||||
do {
|
|
||||||
// A chamada para a API permanece a mesma, assumindo que é necessária sempre.
|
|
||||||
final response = await PhpGroup.getLocalsCall.call(
|
|
||||||
devUUID: AppState().devUUID,
|
|
||||||
userUUID: AppState().userUUID,
|
|
||||||
);
|
|
||||||
|
|
||||||
// Verificação rápida de erro para evitar processamento desnecessário.
|
|
||||||
if (response.jsonBody['error']) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Uso eficiente de coleções para verificar a condição desejada.
|
|
||||||
final String uuid = cliUUID ?? AppState().cliUUID;
|
|
||||||
itemFound = response.jsonBody['locais'].any(
|
|
||||||
(local) => local['CLI_ID'] == uuid && local['CLU_STATUS'] == "A",
|
|
||||||
);
|
|
||||||
|
|
||||||
// Log e retorno condicional baseado no resultado da busca.
|
|
||||||
if (itemFound) {
|
|
||||||
return true;
|
return true;
|
||||||
} else {
|
|
||||||
// A chamada para showModalBottomSheet permanece, mas a atualização da UI é otimizada.
|
|
||||||
modalResult = await showModalBottomSheet(
|
|
||||||
isScrollControlled: true,
|
|
||||||
backgroundColor: Colors.transparent,
|
|
||||||
enableDrag: false,
|
|
||||||
isDismissible: false,
|
|
||||||
context: context,
|
|
||||||
builder: (context) => GestureDetector(
|
|
||||||
onTap: () => model.unfocusNode.canRequestFocus
|
|
||||||
? FocusScope.of(context).requestFocus(model.unfocusNode)
|
|
||||||
: FocusScope.of(context).unfocus(),
|
|
||||||
child: Padding(
|
|
||||||
padding: MediaQuery.viewInsetsOf(context),
|
|
||||||
child: const BottomArrowLinkedLocalsComponentWidget(),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
safeSetState(
|
|
||||||
() {}); // Chamada otimizada fora do then para evitar encadeamentos desnecessários.
|
|
||||||
}
|
|
||||||
} while (modalResult != true);
|
|
||||||
|
|
||||||
return false;
|
|
||||||
>>>>>>> main
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Future answersRequest(BuildContext context, String? ref, String? task,
|
Future answersRequest(BuildContext context, String? ref, String? task,
|
||||||
|
|
|
@ -159,6 +159,9 @@ class AppState extends ChangeNotifier {
|
||||||
await _safeInitAsync(() async {
|
await _safeInitAsync(() async {
|
||||||
_whatsapp = await secureStorage.getBool('whatsapp') ?? _whatsapp;
|
_whatsapp = await secureStorage.getBool('whatsapp') ?? _whatsapp;
|
||||||
});
|
});
|
||||||
|
await _safeInitAsync(() async {
|
||||||
|
_haveLocal = await secureStorage.getBool('ff_have_local') ?? _haveLocal;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void update(VoidCallback callback) {
|
void update(VoidCallback callback) {
|
||||||
|
@ -412,7 +415,7 @@ class AppState extends ChangeNotifier {
|
||||||
bool get haveLocal => _haveLocal;
|
bool get haveLocal => _haveLocal;
|
||||||
set haveLocal(bool value) {
|
set haveLocal(bool value) {
|
||||||
_haveLocal = value;
|
_haveLocal = value;
|
||||||
secureStorage.setBool('ff_local', value);
|
secureStorage.setBool('ff_have_local', value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void deleteIsLogged() {
|
void deleteIsLogged() {
|
||||||
|
|
|
@ -4,12 +4,8 @@ import 'package:flutter/material.dart';
|
||||||
import 'package:hub/flutter_flow/nav/nav.dart';
|
import 'package:hub/flutter_flow/nav/nav.dart';
|
||||||
import 'package:hub/pages/fast_pass_page/fast_pass_page_widget.dart';
|
import 'package:hub/pages/fast_pass_page/fast_pass_page_widget.dart';
|
||||||
import 'package:hub/pages/message_history_page/message_history_page_widget.dart';
|
import 'package:hub/pages/message_history_page/message_history_page_widget.dart';
|
||||||
<<<<<<< HEAD
|
|
||||||
import 'package:hub/pages/preferences_settings_page/preferences_settings_widget.dart';
|
import 'package:hub/pages/preferences_settings_page/preferences_settings_widget.dart';
|
||||||
import 'package:hub/pages/reception_page/reception_page_widget.dart';
|
import 'package:hub/pages/reception_page/reception_page_widget.dart';
|
||||||
=======
|
|
||||||
import 'package:hub/pages/no_connection_page/no_connection_page.dart';
|
|
||||||
>>>>>>> main
|
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
import '/backend/schema/structs/index.dart';
|
import '/backend/schema/structs/index.dart';
|
||||||
|
@ -85,21 +81,9 @@ GoRouter createRouter(AppStateNotifier appStateNotifier) => GoRouter(
|
||||||
params.isEmpty ? const HomePageWidget() : const HomePageWidget(),
|
params.isEmpty ? const HomePageWidget() : const HomePageWidget(),
|
||||||
),
|
),
|
||||||
FFRoute(
|
FFRoute(
|
||||||
<<<<<<< HEAD
|
|
||||||
name: 'receptionPage',
|
name: 'receptionPage',
|
||||||
path: '/receptionPage',
|
path: '/receptionPage',
|
||||||
builder: (context, params) => const ReceptionPageWidget()),
|
builder: (context, params) => const ReceptionPageWidget()),
|
||||||
=======
|
|
||||||
name: 'no-connection',
|
|
||||||
path: '/no-connection',
|
|
||||||
builder: (context, params) => const NoConnectionScreen(),
|
|
||||||
),
|
|
||||||
// FFRoute(
|
|
||||||
// name: 'visitHistoryPage',
|
|
||||||
// path: '/visitHistoryPage',
|
|
||||||
// builder: (context, params) => const VisitHistoryPageWidget(),
|
|
||||||
// ),
|
|
||||||
>>>>>>> main
|
|
||||||
FFRoute(
|
FFRoute(
|
||||||
name: 'messageHistoryPage',
|
name: 'messageHistoryPage',
|
||||||
path: '/messageHistoryPage',
|
path: '/messageHistoryPage',
|
||||||
|
|
|
@ -28,7 +28,6 @@ class _HomePageWidgetState extends State<HomePageWidget> {
|
||||||
bool localStatus = false;
|
bool localStatus = false;
|
||||||
final scaffoldKey = GlobalKey<ScaffoldState>();
|
final scaffoldKey = GlobalKey<ScaffoldState>();
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
Future<void> checkLocalStatus() async {
|
Future<void> checkLocalStatus() async {
|
||||||
localStatus = await checkLocals(
|
localStatus = await checkLocals(
|
||||||
context: context,
|
context: context,
|
||||||
|
@ -36,8 +35,6 @@ class _HomePageWidgetState extends State<HomePageWidget> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
=======
|
|
||||||
>>>>>>> main
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
|
@ -80,7 +77,6 @@ class _HomePageWidgetState extends State<HomePageWidget> {
|
||||||
localStatus = await checkLocals(
|
localStatus = await checkLocals(
|
||||||
context: context,
|
context: context,
|
||||||
model: _model,
|
model: _model,
|
||||||
safeSetState: safeSetState,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
if (AppState().cliUUID.isEmpty) {
|
if (AppState().cliUUID.isEmpty) {
|
||||||
|
|
|
@ -65,18 +65,7 @@ class PreferencesPageWidget extends StatelessWidget {
|
||||||
Expanded(
|
Expanded(
|
||||||
flex: 2,
|
flex: 2,
|
||||||
child: ListView.builder(
|
child: ListView.builder(
|
||||||
<<<<<<< HEAD
|
|
||||||
itemCount: 7, // Assuming 4 items for simplicity
|
itemCount: 7, // Assuming 4 items for simplicity
|
||||||
=======
|
|
||||||
// gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
|
|
||||||
// crossAxisCount: 3,
|
|
||||||
// crossAxisSpacing: 12.0,
|
|
||||||
// mainAxisSpacing: 12.0,
|
|
||||||
// childAspectRatio: 1.0,
|
|
||||||
// mainAxisExtent: 100.0,
|
|
||||||
// ),
|
|
||||||
itemCount: 8, // Assuming 4 items for simplicity
|
|
||||||
>>>>>>> main
|
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 20.0),
|
padding: const EdgeInsets.symmetric(horizontal: 20.0),
|
||||||
physics: const AlwaysScrollableScrollPhysics(),
|
physics: const AlwaysScrollableScrollPhysics(),
|
||||||
itemBuilder: (BuildContext context, int index) {
|
itemBuilder: (BuildContext context, int index) {
|
||||||
|
|
|
@ -66,7 +66,7 @@ packages:
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.0.3"
|
version: "2.0.3"
|
||||||
bloc:
|
bloc:
|
||||||
dependency: "direct main"
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: bloc
|
name: bloc
|
||||||
sha256: "106842ad6569f0b60297619e9e0b1885c2fb9bf84812935490e6c5275777804e"
|
sha256: "106842ad6569f0b60297619e9e0b1885c2fb9bf84812935490e6c5275777804e"
|
||||||
|
|
Loading…
Reference in New Issue