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: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().isLogged = true;
|
||||
|
||||
bool _haveLocal = await checkLocals(context: context, model: model);
|
||||
print(await checkLocals(context: context, model: model));
|
||||
AppState().haveLocal = _haveLocal;
|
||||
|
||||
await toggleApp(context, AppState().haveLocal);
|
||||
AppState().haveLocal =
|
||||
await checkLocals(context: context, model: model);
|
||||
} else {
|
||||
if (PhpGroup.loginCall.msg((loginCall?.jsonBody ?? '')) == null) {
|
||||
DialogUtil.errorDefault(context);
|
||||
|
@ -320,7 +316,7 @@ Future toggleApp(BuildContext context, bool haveLocal) async {
|
|||
),
|
||||
},
|
||||
);
|
||||
else
|
||||
else if (haveLocal == false)
|
||||
context.goNamed(
|
||||
'receptionPage',
|
||||
extra: <String, dynamic>{
|
||||
|
@ -390,24 +386,22 @@ Future<bool> checkLocals({
|
|||
required BuildContext context,
|
||||
required FlutterFlowModel model,
|
||||
}) async {
|
||||
bool itemFound = false;
|
||||
var modalResult;
|
||||
final response = await PhpGroup.getLocalsCall.call(
|
||||
devUUID: AppState().devUUID,
|
||||
userUUID: AppState().userUUID,
|
||||
);
|
||||
log(response.jsonBody.toString());
|
||||
|
||||
<<<<<<< HEAD
|
||||
// Verificação rápida de erro para evitar processamento desnecessário.
|
||||
if (response.jsonBody['error']) {
|
||||
DialogUtil.errorDefault(context);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Uso eficiente de coleções para verificar a condição desejada.
|
||||
final String uuid = cliUUID ?? AppState().cliUUID;
|
||||
final bool itemFound =
|
||||
response.jsonBody['locais'].any((local) => local['CLI_ID'] == uuid);
|
||||
if (itemFound) {
|
||||
if (response.jsonBody['locais']
|
||||
.any((local) => local['CLU_STATUS'] == "A")) {
|
||||
return true;
|
||||
}
|
||||
List<dynamic> locals = response.jsonBody['locais'] ?? [];
|
||||
if (locals != null && locals.isEmpty) {
|
||||
await toggleApp(context, false);
|
||||
return false;
|
||||
} else if (locals.where((local) => local['CLU_STATUS'] != 'A').isNotEmpty) {
|
||||
await showModalBottomSheet(
|
||||
isScrollControlled: true,
|
||||
backgroundColor: Colors.transparent,
|
||||
|
@ -419,57 +413,9 @@ Future<bool> checkLocals({
|
|||
child: const BottomArrowLinkedLocalsComponentWidget(),
|
||||
),
|
||||
); // Chamada oti
|
||||
return false;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
=======
|
||||
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;
|
||||
} 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
|
||||
await toggleApp(context, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
Future answersRequest(BuildContext context, String? ref, String? task,
|
||||
|
|
|
@ -159,6 +159,9 @@ class AppState extends ChangeNotifier {
|
|||
await _safeInitAsync(() async {
|
||||
_whatsapp = await secureStorage.getBool('whatsapp') ?? _whatsapp;
|
||||
});
|
||||
await _safeInitAsync(() async {
|
||||
_haveLocal = await secureStorage.getBool('ff_have_local') ?? _haveLocal;
|
||||
});
|
||||
}
|
||||
|
||||
void update(VoidCallback callback) {
|
||||
|
@ -412,7 +415,7 @@ class AppState extends ChangeNotifier {
|
|||
bool get haveLocal => _haveLocal;
|
||||
set haveLocal(bool value) {
|
||||
_haveLocal = value;
|
||||
secureStorage.setBool('ff_local', value);
|
||||
secureStorage.setBool('ff_have_local', value);
|
||||
}
|
||||
|
||||
void deleteIsLogged() {
|
||||
|
|
|
@ -4,12 +4,8 @@ import 'package:flutter/material.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/message_history_page/message_history_page_widget.dart';
|
||||
<<<<<<< HEAD
|
||||
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/no_connection_page/no_connection_page.dart';
|
||||
>>>>>>> main
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import '/backend/schema/structs/index.dart';
|
||||
|
@ -85,21 +81,9 @@ GoRouter createRouter(AppStateNotifier appStateNotifier) => GoRouter(
|
|||
params.isEmpty ? const HomePageWidget() : const HomePageWidget(),
|
||||
),
|
||||
FFRoute(
|
||||
<<<<<<< HEAD
|
||||
name: 'receptionPage',
|
||||
path: '/receptionPage',
|
||||
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(
|
||||
name: 'messageHistoryPage',
|
||||
path: '/messageHistoryPage',
|
||||
|
|
|
@ -28,7 +28,6 @@ class _HomePageWidgetState extends State<HomePageWidget> {
|
|||
bool localStatus = false;
|
||||
final scaffoldKey = GlobalKey<ScaffoldState>();
|
||||
|
||||
<<<<<<< HEAD
|
||||
Future<void> checkLocalStatus() async {
|
||||
localStatus = await checkLocals(
|
||||
context: context,
|
||||
|
@ -36,8 +35,6 @@ class _HomePageWidgetState extends State<HomePageWidget> {
|
|||
);
|
||||
}
|
||||
|
||||
=======
|
||||
>>>>>>> main
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
@ -80,7 +77,6 @@ class _HomePageWidgetState extends State<HomePageWidget> {
|
|||
localStatus = await checkLocals(
|
||||
context: context,
|
||||
model: _model,
|
||||
safeSetState: safeSetState,
|
||||
);
|
||||
|
||||
if (AppState().cliUUID.isEmpty) {
|
||||
|
|
|
@ -65,18 +65,7 @@ class PreferencesPageWidget extends StatelessWidget {
|
|||
Expanded(
|
||||
flex: 2,
|
||||
child: ListView.builder(
|
||||
<<<<<<< HEAD
|
||||
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),
|
||||
physics: const AlwaysScrollableScrollPhysics(),
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
|
|
|
@ -66,7 +66,7 @@ packages:
|
|||
source: hosted
|
||||
version: "2.0.3"
|
||||
bloc:
|
||||
dependency: "direct main"
|
||||
dependency: transitive
|
||||
description:
|
||||
name: bloc
|
||||
sha256: "106842ad6569f0b60297619e9e0b1885c2fb9bf84812935490e6c5275777804e"
|
||||
|
|
Loading…
Reference in New Issue