This commit is contained in:
J. A. Messias 2024-09-30 10:23:59 -03:00
parent 451c58f980
commit 9427c0bdb2
7 changed files with 44 additions and 35 deletions

View File

@ -1,12 +1,13 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules. // Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript { buildscript {
ext.kotlin_version = '1.8.10' // Replace with the latest version
repositories { repositories {
google() google()
mavenCentral() mavenCentral()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:7.3.1' // Use a versão do Gradle que corresponde à sua configuração 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 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. // Certifique-se de adicionar outras dependências do classpath aqui, se necessário.
} }

View File

@ -23,7 +23,7 @@ plugins {
id "com.google.gms.google-services" version "4.3.15" apply false id "com.google.gms.google-services" version "4.3.15" apply false
// END: FlutterFire Configuration // 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.7.10" apply false id "org.jetbrains.kotlin.android" version "1.8.10" apply false

View File

@ -74,7 +74,9 @@ GoRouter createRouter(AppStateNotifier appStateNotifier) => GoRouter(
FFRoute( FFRoute(
name: '_initialize', name: '_initialize',
path: '/', path: '/',
builder: (context, _) => StorageUtil().isLogged builder: (context, _) => StorageUtil().isLogged &&
(StorageUtil().userUUID.isNotEmpty &&
StorageUtil().userUUID.isNotEmpty)
? StorageUtil().haveLocal == true ? StorageUtil().haveLocal == true
? const HomePageWidget() ? const HomePageWidget()
: const ReceptionPageWidget() : const ReceptionPageWidget()

View File

@ -55,7 +55,7 @@ Future<void> _initializeNotificationService() async {
} }
void _initializeUrlStrategy() { void _initializeUrlStrategy() {
setUrlStrategy(const PathUrlStrategy()); setUrlStrategy(PathUrlStrategy());
} }
void _initializeSystemSettings() { void _initializeSystemSettings() {

View File

@ -1,7 +1,12 @@
import 'dart:developer';
import 'dart:ffi';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:hub/app_state.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/flutter_flow/internationalization.dart';
import 'package:hub/shared/helpers/sqlite_storage_helper.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:hub/shared/utils/storage_util.dart';
import 'package:share_plus/share_plus.dart'; import 'package:share_plus/share_plus.dart';

View File

@ -27,6 +27,27 @@ class _ReceptionPageWidgetState extends State<ReceptionPageWidget> {
void initState() { void initState() {
super.initState(); super.initState();
FirebaseMessagingService().updateDeviceToken(); FirebaseMessagingService().updateDeviceToken();
() async => await processData();
}
Future<void> processLocals() async {
try {
final GetLocalsCall callback = PhpGroup.getLocalsCall;
var response = await callback.call();
if (response.jsonBody['error'] == false) {
List<dynamic> 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<void> processData() async { Future<void> processData() async {
@ -57,44 +78,26 @@ class _ReceptionPageWidgetState extends State<ReceptionPageWidget> {
safeSetState(() {}); safeSetState(() {});
return; return;
} else if (error == true) { } else if (error == true) {
DialogUtil.warningDefault(context).whenComplete(() => processLocals()); final BuildContext? context = StorageUtil().context;
if (context != null) {
DialogUtil.warningDefault(context)
.whenComplete(() => processLocals());
}
safeSetState(() {}); safeSetState(() {});
} }
return; return;
} catch (e) { } catch (e) {
log('() => error: $e'); // Add this line to log the error log('() => error: $e'); // Add this line to log the error
DialogUtil.warningDefault(context).whenComplete(() => processLocals()); final BuildContext? context = StorageUtil().context;
} if (context != null) {
} DialogUtil.warningDefault(context).whenComplete(() => processLocals());
Future<void> processLocals() async {
try {
final GetLocalsCall callback = PhpGroup.getLocalsCall;
final cliUUID = StorageUtil().cliUUID;
var response = await callback.call();
if (response.jsonBody['error'] == false) {
List<dynamic> 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();
}
} }
} catch (e) {
await showModalSelectLocal();
} }
} }
Future<void> showModalSelectLocal() async { Future<void> showModalSelectLocal() async {
StorageUtil().context?.go('/homePage');
await showModalBottomSheet( await showModalBottomSheet(
isScrollControlled: true, isScrollControlled: true,
backgroundColor: Colors.transparent, backgroundColor: Colors.transparent,
@ -107,10 +110,8 @@ class _ReceptionPageWidgetState extends State<ReceptionPageWidget> {
), ),
).then((_) async { ).then((_) async {
StorageUtil().haveLocal = true; StorageUtil().haveLocal = true;
StorageUtil().context?.go('/homePage'); await processData();
}); });
await processData();
} }
@override @override

View File

@ -58,7 +58,7 @@ class _ReservationPageWidgetState extends State<ReservationPageWidget> {
future: initVariables(), future: initVariables(),
builder: (context, snapshot) { builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) { if (snapshot.connectionState == ConnectionState.waiting) {
return Center(child: CircularProgressIndicator()); return const Center(child: CircularProgressIndicator());
} else if (snapshot.hasError || } else if (snapshot.hasError ||
snapshot.hasData == false || snapshot.hasData == false ||
snapshot.data!.isEmpty) { snapshot.data!.isEmpty) {