From 9427c0bdb275df08fba184da1fcc2219ced35217 Mon Sep 17 00:00:00 2001 From: "J. A. Messias" Date: Mon, 30 Sep 2024 10:23:59 -0300 Subject: [PATCH] WIP --- android/build.gradle | 3 +- android/settings.gradle | 2 +- lib/flutter_flow/nav/nav.dart | 4 +- lib/main.dart | 2 +- .../reception_page/reception_page_model.dart | 5 ++ .../reception_page/reception_page_widget.dart | 61 ++++++++++--------- .../reservation_page_widget.dart | 2 +- 7 files changed, 44 insertions(+), 35 deletions(-) diff --git a/android/build.gradle b/android/build.gradle index c67c3834..1e3b46cb 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -1,12 +1,13 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { + ext.kotlin_version = '1.8.10' // Replace with the latest version repositories { google() mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:7.3.1' // Use a versão do Gradle que corresponde à sua configuração - classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.10' // Kotlin Gradle plugin + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath 'com.google.gms:google-services:4.4.2' // Google Services plugin // Certifique-se de adicionar outras dependências do classpath aqui, se necessário. } diff --git a/android/settings.gradle b/android/settings.gradle index d4ad1dd5..c944fca3 100644 --- a/android/settings.gradle +++ b/android/settings.gradle @@ -23,7 +23,7 @@ plugins { id "com.google.gms.google-services" version "4.3.15" apply false // END: FlutterFire Configuration // id "org.jetbrains.kotlin.android" version "1.7.10" apply false - id "org.jetbrains.kotlin.android" version "1.7.10" apply false + id "org.jetbrains.kotlin.android" version "1.8.10" apply false diff --git a/lib/flutter_flow/nav/nav.dart b/lib/flutter_flow/nav/nav.dart index 13334eb7..27b7ae76 100644 --- a/lib/flutter_flow/nav/nav.dart +++ b/lib/flutter_flow/nav/nav.dart @@ -74,7 +74,9 @@ GoRouter createRouter(AppStateNotifier appStateNotifier) => GoRouter( FFRoute( name: '_initialize', path: '/', - builder: (context, _) => StorageUtil().isLogged + builder: (context, _) => StorageUtil().isLogged && + (StorageUtil().userUUID.isNotEmpty && + StorageUtil().userUUID.isNotEmpty) ? StorageUtil().haveLocal == true ? const HomePageWidget() : const ReceptionPageWidget() diff --git a/lib/main.dart b/lib/main.dart index 9fa5007c..893ca86c 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -55,7 +55,7 @@ Future _initializeNotificationService() async { } void _initializeUrlStrategy() { - setUrlStrategy(const PathUrlStrategy()); + setUrlStrategy(PathUrlStrategy()); } void _initializeSystemSettings() { diff --git a/lib/pages/reception_page/reception_page_model.dart b/lib/pages/reception_page/reception_page_model.dart index 8104f8b2..1e2091af 100644 --- a/lib/pages/reception_page/reception_page_model.dart +++ b/lib/pages/reception_page/reception_page_model.dart @@ -1,7 +1,12 @@ +import 'dart:developer'; +import 'dart:ffi'; + import 'package:flutter/material.dart'; import 'package:hub/app_state.dart'; +import 'package:hub/backend/api_requests/api_calls.dart'; import 'package:hub/flutter_flow/internationalization.dart'; import 'package:hub/shared/helpers/sqlite_storage_helper.dart'; +import 'package:hub/shared/utils/dialog_util.dart'; import 'package:hub/shared/utils/storage_util.dart'; import 'package:share_plus/share_plus.dart'; diff --git a/lib/pages/reception_page/reception_page_widget.dart b/lib/pages/reception_page/reception_page_widget.dart index 06d13284..6e5c655e 100644 --- a/lib/pages/reception_page/reception_page_widget.dart +++ b/lib/pages/reception_page/reception_page_widget.dart @@ -27,6 +27,27 @@ class _ReceptionPageWidgetState extends State { void initState() { super.initState(); FirebaseMessagingService().updateDeviceToken(); + () async => await processData(); + } + + Future processLocals() async { + try { + final GetLocalsCall callback = PhpGroup.getLocalsCall; + + var response = await callback.call(); + + if (response.jsonBody['error'] == false) { + List locals = response.jsonBody['locais'] ?? []; + + final locales = locals.where((local) => local['CLU_STATUS']).toList(); + + StorageUtil().haveLocal = true; + StorageUtil().context?.go('/homePage'); + if (locales.isNotEmpty) await showModalSelectLocal(); + } + } catch (e) { + // await showModalSelectLocal(); + } } Future processData() async { @@ -57,44 +78,26 @@ class _ReceptionPageWidgetState extends State { safeSetState(() {}); return; } else if (error == true) { - DialogUtil.warningDefault(context).whenComplete(() => processLocals()); + final BuildContext? context = StorageUtil().context; + if (context != null) { + DialogUtil.warningDefault(context) + .whenComplete(() => processLocals()); + } safeSetState(() {}); } return; } catch (e) { log('() => error: $e'); // Add this line to log the error - DialogUtil.warningDefault(context).whenComplete(() => processLocals()); - } - } - - Future processLocals() async { - try { - final GetLocalsCall callback = PhpGroup.getLocalsCall; - - final cliUUID = StorageUtil().cliUUID; - var response = await callback.call(); - - if (response.jsonBody['error'] == false) { - List locals = response.jsonBody['locais'] ?? []; - - final activeLocals = - locals.where((local) => local['CLU_STATUS'] == 'A').toList(); - - StorageUtil().haveLocal = true; - StorageUtil().context?.go('/homePage'); - if (activeLocals.isEmpty || cliUUID.isEmpty) { - await showModalSelectLocal(); - } else { - await processData(); - } + final BuildContext? context = StorageUtil().context; + if (context != null) { + DialogUtil.warningDefault(context).whenComplete(() => processLocals()); } - } catch (e) { - await showModalSelectLocal(); } } Future showModalSelectLocal() async { + StorageUtil().context?.go('/homePage'); await showModalBottomSheet( isScrollControlled: true, backgroundColor: Colors.transparent, @@ -107,10 +110,8 @@ class _ReceptionPageWidgetState extends State { ), ).then((_) async { StorageUtil().haveLocal = true; - StorageUtil().context?.go('/homePage'); + await processData(); }); - - await processData(); } @override diff --git a/lib/pages/reservation_page/reservation_page_widget.dart b/lib/pages/reservation_page/reservation_page_widget.dart index ffcbaec6..aca8a20d 100644 --- a/lib/pages/reservation_page/reservation_page_widget.dart +++ b/lib/pages/reservation_page/reservation_page_widget.dart @@ -58,7 +58,7 @@ class _ReservationPageWidgetState extends State { future: initVariables(), builder: (context, snapshot) { if (snapshot.connectionState == ConnectionState.waiting) { - return Center(child: CircularProgressIndicator()); + return const Center(child: CircularProgressIndicator()); } else if (snapshot.hasError || snapshot.hasData == false || snapshot.data!.isEmpty) {