This commit is contained in:
J. A. Messias 2024-09-19 10:47:55 -03:00
parent e4e6529bf5
commit d4f47c3f8a
62 changed files with 1871 additions and 2509 deletions

View File

@ -76,24 +76,7 @@ Future signInLoginAction(
final ApiCallResponse? response;
final DatabaseHelper db = DatabaseHelper();
final LoginCall callback = PhpGroup.loginCall;
final String? devUUID;
final String userUUID;
final String status;
final String userDevUUID;
final String device;
final String email;
final String passwd;
final String description;
final bool haveLocal;
final bool isLogged;
email = emailAdress!;
passwd = password!;
devUUID = await getDevUUID();
device = AppState().device;
description = randomString(
AppState().deviceDescription = randomString(
10,
10,
true,
@ -101,45 +84,50 @@ Future signInLoginAction(
false,
);
final String? devUUID;
final String userUUID;
final String status;
final String userDevUUID;
final String userName;
final String email;
final String passwd;
final bool isLogged;
email = emailAdress!;
passwd = password!;
devUUID = await getDevUUID();
if ((email != '') && (passwd != '')) {
response = await callback.call(
email: email,
password: passwd,
uuid: devUUID,
type: device,
description: description,
);
AppState().email = email;
AppState().passwd = passwd;
response = await callback.call();
if (callback.error((response.jsonBody ?? '')) == false) {
userUUID = callback.userUUID(
(response.jsonBody ?? ''),
)!;
status = callback.userStatus((response.jsonBody ?? ''))!;
userDevUUID = callback.userDeviceId((response.jsonBody ?? ''))!;
if (response.jsonBody['error'] == false) {
userUUID = response.jsonBody['uid'];
status = response.jsonBody['user']['status'];
userDevUUID = response.jsonBody['user']['dev_id'];
userName = response.jsonBody['user']['name'];
db.update('email', email, 'user');
db.update('passwd', passwd, 'user');
db.update('devUUID', devUUID, 'user');
db.update('userUUID', userUUID, 'user');
db.update('userDevUUID', userDevUUID, 'user');
db.update('status', status, 'user');
db.update('userName', userName, 'user');
callback.userName((response.jsonBody ?? ''))!;
isLogged = true;
haveLocal = await checkLocals(context: context, model: model);
AppState().haveLocal = haveLocal;
await checkLocals(context: context, model: model).then((value) {
AppState().haveLocal = value;
AppState().isLogged = isLogged;
AppState().update(() {});
toggleApp(context, haveLocal);
toggleApp(context);
});
} else {
if (callback.msg((response.jsonBody ?? '')) == null) {
if (response.jsonBody['error'] == null) {
DialogUtil.errorDefault(context);
} else {
DialogUtil.error(
context, callback.msg((response.jsonBody ?? '')).toString());
DialogUtil.error(context, response.jsonBody['error_msg'].toString());
}
}
}
@ -160,11 +148,12 @@ Future<bool> signUpRegisterAction(
String? device,
}) async {
try {
ApiCallResponse? registerCall;
ApiCallResponse? response;
if ((email != null && email != '') &&
(passwd != null && passwd != '' && passwd.length > 7) &&
(name != null && name != '')) {
registerCall = await PhpGroup.registerCall.call(
response = await PhpGroup.registerCall.call(
name: name,
password: passwd,
email: email,
@ -192,14 +181,10 @@ Future<bool> signUpRegisterAction(
),
);
if (PhpGroup.registerCall.error(
(registerCall.jsonBody ?? ''),
) ==
false) {
if (response.jsonBody['error'] == false) {
return true;
}
final errorMessage = registerCall?.jsonBody['error_msg'];
DialogUtil.error(context, errorMessage);
DialogUtil.error(context, response.jsonBody['error_msg']);
return false;
} else {
DialogUtil.errorDefault(context);
@ -224,10 +209,7 @@ Future forgotPasswdAction(
email: email,
);
if (callback.error(
(response.jsonBody ?? ''),
) !=
false) {
if (response.jsonBody['error'] != false) {
return;
}
}
@ -256,7 +238,8 @@ Future toggleSignUpPage(BuildContext context) async {
);
}
Future toggleApp(BuildContext context, bool haveLocal) async {
Future toggleApp(BuildContext context) async {
final haveLocal = AppState().haveLocal;
if (haveLocal == true) {
context.go('/homePage');
} else if (haveLocal == false) {
@ -279,22 +262,8 @@ Future<bool> visitCancelAction(BuildContext context,
required String? email}) async {
final ApiCallResponse? response;
final CancelaVisita callback = PhpGroup.cancelaVisita;
final DatabaseHelper db = DatabaseHelper();
final userUUID = await db
.get(key: 'userUUID', field: 'value')
.then((value) => value.toString());
final devUUID = await db
.get(key: 'devUUID', field: 'value')
.then((value) => value.toString());
final cliUUID = await db
.get(key: 'cliUUID', field: 'value')
.then((value) => value.toString());
response = await callback.call(
userUUID: userUUID,
devUUID: devUUID,
cliID: cliUUID,
atividade: 'cancelaVisita',
idDestino: idDestino,
idVisita: idVisita,
AccessKey: accessKey,
@ -342,16 +311,9 @@ Future<bool> checkLocals({
required FlutterFlowModel model,
}) async {
final GetLocalsCall callback = PhpGroup.getLocalsCall;
final DatabaseHelper db = DatabaseHelper();
final userUUID = await db.get(key: 'userUUID', field: 'value');
final devUUID = await db.get(key: 'devUUID', field: 'value');
final response = await callback.call(
devUUID: devUUID.toString(),
userUUID: userUUID.toString(),
);
final response = await callback.call();
// Verificação rápida de erro para evitar processamento desnecessário.
if (response.jsonBody['error']) {
DialogUtil.errorDefault(context);
return false;
@ -395,16 +357,8 @@ Future answersRequest(
required String? id}) async {
final ApiCallResponse? respondeSolicitacaoCall;
final RespondeSolicitacaoCall callback = PhpGroup.respondeSolicitacaoCall;
final DatabaseHelper db = DatabaseHelper();
final userUUID = await db.get(key: 'userUUID');
final devUUID = await db.get(key: 'devUUID');
final cliUUID = await db.get(key: 'cliUUID');
respondeSolicitacaoCall = await callback.call(
userUUID: userUUID,
devUUID: devUUID,
cliUUID: cliUUID,
atividade: 'respondeSolicitacao',
referencia: ref,
tarefa: task,
resposta: response,

View File

@ -71,19 +71,6 @@ class AppState extends ChangeNotifier {
Future initializePersistedState() async {
secureStorage = const FlutterSecureStorage();
await _safeInitAsync(() async {
_cliUUID = await secureStorage.getString('ff_cliUUID') ?? _cliUUID;
});
await _safeInitAsync(() async {
_ownerUUID = await secureStorage.getString('ff_ownerUUID') ?? _ownerUUID;
});
await _safeInitAsync(() async {
_userUUID = await secureStorage.getString('ff_userUUID') ?? _userUUID;
});
await _safeInitAsync(() async {
_devUUID = await secureStorage.getString('ff_devUUID') ?? _devUUID;
});
await _safeInitAsync(() async {
_email = await secureStorage.getString('ff_email') ?? _email;
@ -92,56 +79,17 @@ class AppState extends ChangeNotifier {
_passwd = await secureStorage.getString('ff_passwd') ?? _passwd;
});
await _safeInitAsync(() async {
_device = await secureStorage.getString('ff_device') ?? _device;
_deviceType =
await secureStorage.getString('ff_deviceType') ?? _deviceType;
});
await _safeInitAsync(() async {
_isLogged = await secureStorage.getBool('ff_isLogged') ?? _isLogged;
});
await _safeInitAsync(() async {
_local = await secureStorage.getString('ff_local') ?? _local;
});
await _safeInitAsync(() async {
_token = await secureStorage.getString('ff_token') ?? _token;
});
await _safeInitAsync(() async {
_createdAt = await secureStorage.getString('ff_createdAt') ?? _createdAt;
});
await _safeInitAsync(() async {
_updatedAt = await secureStorage.getString('ff_updatedAt') ?? _updatedAt;
});
await _safeInitAsync(() async {
_status = await secureStorage.getString('ff_status') ?? _status;
});
await _safeInitAsync(() async {
_name = await secureStorage.getString('ff_name') ?? _name;
});
await _safeInitAsync(() async {
_tokenAPNS = await secureStorage.getString('ff_tokenAPNS') ?? _tokenAPNS;
});
await _safeInitAsync(() async {
_userDevUUID =
await secureStorage.getString('ff_user_dev_id') ?? _userDevUUID;
});
await _safeInitAsync(() async {
_serialNumber =
await secureStorage.getString('ff_serialNumber') ?? _serialNumber;
});
await _safeInitAsync(() async {
_fingerprintOPT =
await secureStorage.getBool('fingerprint') ?? _fingerprintOPT;
});
await _safeInitAsync(() async {
_personOPT = await secureStorage.getBool('person') ?? _personOPT;
});
await _safeInitAsync(() async {
_passOPT = await secureStorage.getBool('pass') ?? _passOPT;
});
await _safeInitAsync(() async {
_panicOPT = await secureStorage.getBool('panic') ?? _panicOPT;
});
await _safeInitAsync(() async {
_notifyOPT = await secureStorage.getBool('notify') ?? _notifyOPT;
});
await _safeInitAsync(() async {
_accessPass = await secureStorage.getString('accessPass') ?? _accessPass;
});
@ -155,27 +103,14 @@ class AppState extends ChangeNotifier {
await _safeInitAsync(() async {
_context = await secureStorage.getObject('ff_context') ?? _context;
});
await _safeInitAsync(() async {
_provisional = await secureStorage.getBool('provisional') ?? _provisional;
});
await _safeInitAsync(() async {
_whatsapp = await secureStorage.getBool('whatsapp') ?? _whatsapp;
});
await _safeInitAsync(() async {
_pets = await secureStorage.getBool('pets') ?? _pets;
});
await _safeInitAsync(() async {
_haveLocal = await secureStorage.getBool('ff_have_local') ?? _haveLocal;
});
await _safeInitAsync(() async {
_petAmountRegister =
await secureStorage.getInt('petAmountRegister') ?? _petAmountRegister;
});
await _safeInitAsync(() async {
_isRequestOSNotification =
await secureStorage.getBool('ff_request_os_notification') ??
_isRequestOSNotification;
_deviceDescription = await secureStorage.getString('deviceDescription') ??
_deviceDescription;
});
}
@ -186,60 +121,15 @@ class AppState extends ChangeNotifier {
late FlutterSecureStorage secureStorage;
int _petAmountRegister = 0;
int get petAmountRegister => _petAmountRegister;
set petAmountRegister(int value) {
_petAmountRegister = value;
secureStorage.setInt('petAmountRegister', value);
String _deviceDescription = '';
String get deviceDescription => _deviceDescription;
set deviceDescription(String value) {
_deviceDescription = value;
secureStorage.setString('deviceDescription', value);
}
void deletePetAmountRegister() {
secureStorage.delete(key: 'petAmountRegister');
}
bool _isRequestOSNotification = false;
bool get isRequestOSNotification => _isRequestOSNotification;
set isRequestOSNotification(bool value) {
_isRequestOSNotification = value;
secureStorage.setBool('ff_request_os_notification', value);
}
void deleteIsRequestOSNotification() {
secureStorage.delete(key: 'ff_request_os_notification');
}
bool _pets = false;
bool get pets => _pets;
set pets(bool value) {
_pets = value;
secureStorage.setBool('pets', value);
}
void deletePets() {
secureStorage.delete(key: 'pets');
}
bool _whatsapp = false;
bool get whatsapp => _whatsapp;
set whatsapp(bool value) {
_whatsapp = value;
secureStorage.setBool('whatsapp', value);
}
void deleteWhatsapp() {
secureStorage.delete(key: 'whatsapp');
}
bool _provisional = false;
bool get provisional => _provisional;
set provisional(bool value) {
_provisional = value;
secureStorage.setBool('provisional', value);
}
void deleteProvisional() {
secureStorage.delete(key: 'provisional');
void deleteDeviceDescription() {
secureStorage.delete(key: 'deviceDescription');
}
BuildContext? _context;
@ -253,17 +143,6 @@ class AppState extends ChangeNotifier {
secureStorage.delete(key: 'ff_context');
}
bool _panicOPT = false;
bool get panic => _panicOPT;
set panic(bool value) {
_panicOPT = value;
secureStorage.setBool('panic', value);
}
void deletePanic() {
secureStorage.delete(key: 'panic');
}
bool? _haveLocal = null;
bool? get haveLocal => _haveLocal;
set haveLocal(bool? value) {
@ -308,88 +187,11 @@ class AppState extends ChangeNotifier {
secureStorage.delete(key: 'panicPass');
}
bool _notifyOPT = false;
bool get notify => _notifyOPT;
set notify(bool value) {
_notifyOPT = value;
secureStorage.setBool('notify', value);
}
bool _passOPT = false;
bool get pass => _passOPT;
set pass(bool value) {
_passOPT = value;
secureStorage.setBool('pass', value);
}
void deletePass() {
secureStorage.delete(key: 'pass');
}
bool _personOPT = false;
bool get person => _personOPT;
set person(bool value) {
_personOPT = value;
secureStorage.setBool('person', value);
}
void deletePerson() {
secureStorage.delete(key: 'person');
}
bool _fingerprintOPT = false;
bool get fingerprint => _fingerprintOPT;
set fingerprint(bool value) {
_fingerprintOPT = value;
secureStorage.setBool('fingerprint', value);
}
void deleteFingerprint() {
secureStorage.delete(key: 'fingerprint');
}
String _serialNumber = '';
String get serialNumber => _serialNumber;
set serialNumber(String value) {
_serialNumber = value;
secureStorage.setString('ff_serialNumber', value);
}
void deleteSerialNumber() {
secureStorage.delete(key: 'ff_serialNumber');
AppState().serialNumber = '';
}
String _cliUUID = '';
String get cliUUID => _cliUUID;
set cliUUID(String value) {
_cliUUID = value;
secureStorage.setString('ff_cliUUID', value);
}
void deleteCliUUID() {
secureStorage.delete(key: 'ff_cliUUID');
AppState().cliUUID = '';
}
String _userDevUUID = '';
String get userDevUUID => _userDevUUID;
set userDevUUID(String value) {
_userDevUUID = value;
secureStorage.setString('ff_user_dev_id', value);
}
void deleteRemoteId() {
secureStorage.delete(key: 'ff_user_dev_id');
AppState().userDevUUID = '';
}
String? _tokenAPNS = '';
String? get tokenAPNS => _tokenAPNS;
set tokenAPNS(String? value) {
_tokenAPNS = value;
// Verifica se o valor é nulo antes de tentar salvar no secureStorage
if (value != null) {
secureStorage.setString('ff_tokenAPNS', value);
} else {
@ -402,42 +204,6 @@ class AppState extends ChangeNotifier {
AppState().tokenAPNS = '';
}
String _ownerUUID = '';
String get ownerUUID => _ownerUUID;
set ownerUUID(String value) {
_ownerUUID = value;
secureStorage.setString('ff_ownerUUID', value);
}
void deleteOwnerUUID() {
secureStorage.delete(key: 'ff_ownerUUID');
AppState().ownerUUID = '';
}
String _userUUID = '';
String get userUUID => _userUUID;
set userUUID(String value) {
_userUUID = value;
secureStorage.setString('ff_userUUID', value);
}
void deleteUserUUID() {
secureStorage.delete(key: 'ff_userUUID');
AppState().userUUID = '';
}
String _devUUID = '';
String get devUUID => _devUUID;
set devUUID(String value) {
_devUUID = value;
secureStorage.setString('ff_devUUID', value);
}
void deleteDevUUID() {
secureStorage.delete(key: 'ff_devUUID');
AppState().devUUID = '';
}
String _email = '';
String get email => _email;
set email(String value) {
@ -462,16 +228,16 @@ class AppState extends ChangeNotifier {
AppState().passwd = '';
}
String _device = '';
String get device => _device;
set device(String value) {
_device = value;
secureStorage.setString('ff_device', value);
String _deviceType = '';
String get deviceType => _deviceType;
set deviceType(String value) {
_deviceType = value;
secureStorage.setString('ff_deviceType', value);
}
void deleteDevice() {
secureStorage.delete(key: 'ff_device');
AppState().device = '';
secureStorage.delete(key: 'ff_deviceType');
AppState().deviceType = '';
}
bool _isLogged = false;
@ -485,18 +251,6 @@ class AppState extends ChangeNotifier {
secureStorage.delete(key: 'ff_isLogged');
}
String _local = '';
String get local => _local;
set local(String value) {
_local = value;
secureStorage.setString('ff_local', value);
}
void deleteLocal() {
secureStorage.delete(key: 'ff_local');
AppState().local = '';
}
String _token = '';
String get token => _token;
set token(String value) {
@ -509,82 +263,17 @@ class AppState extends ChangeNotifier {
AppState().token = '';
}
String _createdAt = '';
String get createdAt => _createdAt;
set createdAt(String value) {
_createdAt = value;
secureStorage.setString('ff_createdAt', value);
}
void deleteCreatedAt() {
secureStorage.delete(key: 'ff_createdAt');
AppState().createdAt = '';
}
String _updatedAt = '';
String get updatedAt => _updatedAt;
set updatedAt(String value) {
_updatedAt = value;
secureStorage.setString('ff_updatedAt', value);
}
void deleteUpdatedAt() {
secureStorage.delete(key: 'ff_updatedAt');
AppState().updatedAt = '';
}
String _status = '';
String get status => _status;
set status(String value) {
_status = value;
secureStorage.setString('ff_status', value);
}
void deleteStatus() {
secureStorage.delete(key: 'ff_status');
AppState().status = '';
}
String _name = '';
String get name => _name;
set name(String value) {
_name = value;
secureStorage.setString('ff_name', value);
}
void deleteName() {
secureStorage.delete(key: 'ff_name');
AppState().name = '';
}
void deleteAll() {
AppState().deleteAccessPass();
AppState().deleteCliUUID();
AppState().deleteCreatedAt();
AppState().deleteDevUUID();
AppState().deleteDevice();
AppState().deleteEmail();
AppState().deleteFingerprint();
AppState().deleteFingerprintPass();
AppState().deleteIsLogged();
AppState().deleteLocal();
AppState().deleteName();
AppState().deleteOwnerUUID();
AppState().deletePass();
AppState().deletePasswd();
AppState().deletePerson();
AppState().deletePanic();
AppState().deletePanicPass();
AppState().deleteProvisional();
AppState().deleteStatus();
AppState().deleteToken();
AppState().deleteTokenAPNS();
AppState().deleteUpdatedAt();
AppState().deleteUserUUID();
AppState().deleteWhatsapp();
AppState().deleteContext();
AppState().deleteRemoteId();
AppState().deleteSerialNumber();
secureStorage.deleteAll();
AppState().isLogged = false;
}

File diff suppressed because it is too large Load Diff

View File

@ -63,17 +63,13 @@ class FirebaseMessagingService {
if (deviceToken != null) {
AppState().token = deviceToken;
final ApiCallResponse? response;
final DatabaseHelper db = DatabaseHelper();
final devUUID = await db.get(key: 'devUUID', field: 'value');
final userUUID = await db.get(key: 'userUUID', field: 'value');
response = await PhpGroup.updToken
.call(token: AppState().token, devid: devUUID, useruuid: userUUID);
response = await PhpGroup.updToken.call();
if (PhpGroup.updToken.error((response?.jsonBody ?? '')) == false) {
if (response.jsonBody['error'] == false) {
log('Token Atualizado com Sucesso!');
} else {
log('Falha ao Atualizar Token: ${response?.jsonBody}');
log('Falha ao Atualizar Token: ${response.jsonBody}');
}
} else {
log('Falha ao Pegar Token do Firebase');

View File

@ -267,9 +267,14 @@ class NotificationService {
await AwesomeNotifications()
.isNotificationAllowed()
.then((isAllowed) async {
if (!AppState().isRequestOSNotification) {
final DatabaseHelper db = DatabaseHelper();
final bool requestOSnotification = await db
.get(key: 'requestOSnotification', field: 'value')
.then((value) => value.toString() == 'true');
if (!requestOSnotification) {
if (!isAllowed) {
AppState().isRequestOSNotification = true;
await db.update('requestOSnotification', 'true', 'util');
await AwesomeNotifications().requestPermissionToSendNotifications();
}
}

View File

@ -70,10 +70,7 @@ class _BottomArrowLinkedLocalsComponentWidgetState
final userUUID = await db.get(key: 'userUUID', field: 'value');
setState(() => _loading = true);
var response = await PhpGroup.getLocalsCall.call(
devUUID: devUUID,
userUUID: userUUID,
);
var response = await PhpGroup.getLocalsCall.call();
final List<dynamic> locals = response.jsonBody['locais'] ?? [];
@ -115,12 +112,8 @@ class _BottomArrowLinkedLocalsComponentWidgetState
Future<dynamic> _fetchResponseLink(String status, String cliID) async {
try {
final DatabaseHelper db = DatabaseHelper();
final devUUID = await db.get(key: 'devUUID', field: 'value');
final userUUID = await db.get(key: 'userUUID', field: 'value');
var response = await PhpGroup.resopndeVinculo.call(
devUUID: devUUID, userUUID: userUUID, cliID: cliID, tarefa: status);
var response =
await PhpGroup.resopndeVinculo.call(tarefa: status, cliID: cliID);
if (response.jsonBody['error'] == false) {
return {

View File

@ -1,3 +1,6 @@
import 'dart:ffi';
import 'dart:math';
import 'package:hub/shared/helpers/db_helper.dart';
import '/flutter_flow/flutter_flow_util.dart';
@ -11,19 +14,21 @@ class LocalProfileComponentModel
final DatabaseHelper db = DatabaseHelper();
String cliName = '';
String cliUUID = '';
VoidCallback? setStateCallback;
@override
void initState(BuildContext context) {
init();
getData();
}
Future<void> init() async {
Future<void> getData() async {
cliName = await db
.get(key: 'cliName', field: 'value')
.then((value) => value.toString());
cliUUID = await db
.get(key: 'cliUUID', field: 'value')
.then((value) => value.toString());
setStateCallback?.call();
}
@override

View File

@ -1,6 +1,12 @@
import 'dart:developer';
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:hub/backend/api_requests/api_calls.dart';
import 'package:hub/components/organism_components/bottom_arrow_linked_locals_component/bottom_arrow_linked_locals_component_widget.dart';
import 'package:hub/shared/helpers/db_helper.dart';
import 'package:hub/shared/utils/dialog_util.dart';
import 'package:provider/provider.dart';
import '/flutter_flow/custom_functions.dart' as functions;
@ -13,10 +19,7 @@ export 'local_profile_component_model.dart';
////
class LocalProfileComponentWidget extends StatefulWidget {
LocalProfileComponentWidget({Key? key, required this.showBottomSheet})
: super(key: key);
VoidCallback showBottomSheet;
LocalProfileComponentWidget({Key? key}) : super(key: key);
@override
State<LocalProfileComponentWidget> createState() =>
@ -26,6 +29,7 @@ class LocalProfileComponentWidget extends StatefulWidget {
class _LocalProfileComponentWidgetState
extends State<LocalProfileComponentWidget> {
late LocalProfileComponentModel _model;
final DatabaseHelper db = DatabaseHelper();
@override
void setState(VoidCallback callback) {
@ -37,6 +41,18 @@ class _LocalProfileComponentWidgetState
void initState() {
super.initState();
_model = createModel(context, () => LocalProfileComponentModel());
_model.setOnUpdate(onUpdate: () => setState(() {}));
_model.setStateCallback = () => safeSetState(() {});
() async {
_model.cliUUID = await db
.get(key: 'cliUUID', field: 'value')
.then((value) => value.toString());
if (_model.cliUUID.isEmpty) {
await processLocals();
}
}();
}
@override
@ -46,6 +62,88 @@ class _LocalProfileComponentWidgetState
super.dispose();
}
Future<void> processData() async {
try {
final GetDadosCall callback = PhpGroup.getDadosCall;
var response = await callback.call();
final error = response.jsonBody['error'];
// final errorMsg = response.jsonBody['error_msg'];
if (error == false) {
final whatsapp = response.jsonBody['whatsapp'] ?? false;
final provisional = response.jsonBody['provisional'] ?? false;
final pets = response.jsonBody['pet'] ?? false;
final petAmountRegister = response.jsonBody['petAmountRegister'] ?? '0';
final name = response.jsonBody['visitado']['VDO_NOME'];
await db.update('whatsapp', whatsapp.toString(), 'local');
await db.update('provisional', provisional.toString(), 'local');
await db.update('pets', pets.toString(), 'local');
await db.update('petAmountRegister', petAmountRegister, 'local');
await db.update('name', name, 'local');
safeSetState(() {});
return;
}
DialogUtil.warningDefault(context).whenComplete(() => processLocals());
safeSetState(() {});
return;
} catch (e, s) {
DialogUtil.warningDefault(context).whenComplete(() => processLocals());
}
}
Future<void> processLocals() async {
try {
final GetLocalsCall callback = PhpGroup.getLocalsCall;
final cliUUID = await db
.get(key: 'cliUUID', field: 'value')
.then((value) => value.toString());
var response = await callback.call();
List<dynamic> locals = response.jsonBody['locais'] ?? [];
final activeLocals =
locals.where((local) => local['CLU_STATUS'] == 'A').toList();
if (activeLocals.isEmpty || cliUUID.isEmpty) {
await showModalSelectLocal();
} else {
await processData();
}
} catch (e) {
await showModalSelectLocal();
}
}
Future<void> showModalSelectLocal() async {
await showModalBottomSheet(
isScrollControlled: true,
backgroundColor: Colors.transparent,
enableDrag: false,
isDismissible: false,
context: context,
builder: (context) => Padding(
padding: MediaQuery.viewInsetsOf(context),
child: const BottomArrowLinkedLocalsComponentWidget(),
),
).then((_) async {
onUpdate();
});
await processData();
}
void onUpdate() {
safeSetState(() {
_model.getData();
});
}
@override
Widget build(BuildContext context) {
context.watch<AppState>();
@ -79,7 +177,7 @@ class _LocalProfileComponentWidgetState
hoverColor: Colors.transparent,
highlightColor: Colors.transparent,
onTap: () async {
widget.showBottomSheet();
showModalSelectLocal();
},
child: ClipRRect(
borderRadius: BorderRadius.circular(200.0),

View File

@ -3,6 +3,8 @@ import 'package:hub/backend/api_requests/api_calls.dart';
import 'package:hub/components/organism_components/menu_staggered_view_component/menu_staggered_view_component_model.dart';
import 'package:hub/flutter_flow/nav/nav.dart';
import 'package:hub/shared/extensions/dialog_extensions.dart';
import 'package:hub/shared/helpers/db_helper.dart';
import 'package:sqflite/sqflite.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';
@ -68,7 +70,12 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
}
Future deliverySchedule(BuildContext context) async {
final isProvisional = AppState().provisional;
final DatabaseHelper db = DatabaseHelper();
final bool isProvisional = await db
.get(key: 'provisional', field: 'value')
.then((value) => value.toString() == 'true') as bool;
if (isProvisional == true) {
context.push(
'/deliverySchedule',
@ -86,7 +93,11 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
}
Future provisionalSchedule(BuildContext context) async {
final isProvisional = AppState().provisional;
final DatabaseHelper db = DatabaseHelper();
final isProvisional = await db
.get(key: 'provisional', field: 'value')
.then((value) => value.toString() == 'true') as bool;
if (isProvisional == true) {
context.push(
'/provisionalSchedule',
@ -104,7 +115,10 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
}
Future fastPassAction(BuildContext context) async {
final isWpp = AppState().whatsapp;
final DatabaseHelper db = DatabaseHelper();
final isWpp = await db.get(key: 'whatsapp', field: 'value').then((value) {
return value.toString() == 'true';
}) as bool;
if (isWpp) {
context.push(
'/fastPassPage',
@ -188,6 +202,15 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
}
Future<void> signOut(BuildContext context) async {
final DatabaseHelper db = DatabaseHelper();
final userUUID = await db
.get(key: 'userUUID', field: 'value')
.then((value) => value.toString());
final devUUID = await db
.get(key: 'devUUID', field: 'value')
.then((value) => value.toString());
showAlertDialog(
context,
'Logout',
@ -195,11 +218,9 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
enText: 'Are you sure you want to logout?',
ptText: 'Tem certeza',
), () async {
PhpGroup.unregisterDevice.call(
devUUID: AppState().devUUID,
userUUID: AppState().userUUID,
);
PhpGroup.unregisterDevice.call();
AppState().deleteAll();
await db.purge();
context.go(
'/welcomePage',
@ -228,7 +249,10 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
}
Future packageOrder(BuildContext context) async {
final isWpp = AppState().whatsapp;
final DatabaseHelper db = DatabaseHelper();
final isWpp = await db.get(key: 'whatsapp', field: 'value').then((value) {
return value.toString() == 'true';
}) as bool;
if (isWpp) {
context.push(
@ -247,7 +271,10 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
}
Future reservation(BuildContext context) async {
final isWpp = AppState().whatsapp;
final DatabaseHelper db = DatabaseHelper();
final isWpp = await db.get(key: 'whatsapp', field: 'value').then((value) {
return value.toString() == 'true';
}) as bool;
if (isWpp) {
context.push(
'/reservation',
@ -363,7 +390,10 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
}
Future petsAction(BuildContext context) async {
bool isPet = AppState().pets;
final DatabaseHelper db = DatabaseHelper();
bool isPet = await db.get(key: 'pets', field: 'value').then((value) {
return value.toString() == 'true';
}) as bool;
if (isPet) {
context.push(
'/petsPage',

View File

@ -53,21 +53,6 @@ class _MenuComponentWidgetState extends State<MenuComponentWidget> {
@override
Widget build(BuildContext context) {
final DatabaseHelper db = DatabaseHelper();
final cliUUID = db
.get(key: 'cliUUID', field: 'value')
.then((value) => value.toString());
final userUUID = db
.get(key: 'userUUID', field: 'value')
.then((value) => value.toString());
final devUUID = db
.get(key: 'devUUID', field: 'value')
.then((value) => value.toString());
final provisional =
db.get(key: 'cliName', field: 'value').then((value) => value);
final whatsapp =
db.get(key: 'whatsapp', field: 'value').then((value) => value);
final options = () {
if (widget.item == MenuItem.button) {
if (_model.isGrid == true)

View File

@ -8,6 +8,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:hub/backend/api_requests/api_calls.dart';
import 'package:hub/flutter_flow/flutter_flow_theme.dart';
import 'package:hub/flutter_flow/flutter_flow_util.dart';
import 'package:hub/shared/helpers/db_helper.dart';
import 'package:provider/provider.dart';
import 'package:rxdart/rxdart.dart';
@ -338,6 +339,7 @@ class MessageWellState {
class MessageWellNotifier extends StateNotifier<MessageWellState> {
var _totalPageNumber = 1;
int get totalPageNumber => _totalPageNumber;
final DatabaseHelper db = DatabaseHelper();
set totalPageNumber(int value) {
_totalPageNumber = value;
@ -355,10 +357,6 @@ class MessageWellNotifier extends StateNotifier<MessageWellState> {
if (state.pageNumber <= totalPageNumber) {
var apiCall = GetMessagesCall();
var response = await apiCall.call(
devUUID: AppState().devUUID.toString(),
userUUID: AppState().userUUID.toString(),
cliID: AppState().cliUUID.toString(),
atividade: 'getMensagens',
pageSize: '100',
pageNumber: state.pageNumber.toString(),
tipoDestino: dropdown.value.values.first,

View File

@ -5,66 +5,65 @@ import 'package:hub/backend/api_requests/api_manager.dart';
import 'package:flutter/material.dart';
import 'package:hub/components/organism_components/schedule_visit_detail/schedule_visit_detail_widget.dart';
import 'package:hub/flutter_flow/flutter_flow_model.dart';
import 'package:hub/shared/helpers/db_helper.dart';
import 'package:intl/intl.dart';
class ScheduleVisitDetailModel
extends FlutterFlowModel<ScheduleVisitDetailWidget> {
/// State fields for stateful widgets in this component.
final DatabaseHelper db = DatabaseHelper();
late final String devUUID;
late final String userUUID;
late final String cliUUID;
// State field(s) for TextField widget.
FocusNode? textFieldFocusNode1;
TextEditingController? textController1;
String? Function(BuildContext, String?)? textController1Validator;
// State field(s) for TextField widget.
FocusNode? textFieldFocusNode2;
TextEditingController? textController2;
String? Function(BuildContext, String?)? textController2Validator;
// State field(s) for TextField widget.
FocusNode? textFieldFocusNode3;
TextEditingController? textController3;
String? Function(BuildContext, String?)? textController3Validator;
// State field(s) for TextField widget.
FocusNode? textFieldFocusNode4;
TextEditingController? textController4;
String? Function(BuildContext, String?)? textController4Validator;
// State field(s) for TextField widget.
FocusNode? textFieldFocusNode5;
TextEditingController? textController5;
String? Function(BuildContext, String?)? textController5Validator;
// State field(s) for TextField widget.
FocusNode? textFieldFocusNode6;
TextEditingController? textController6;
String? Function(BuildContext, String?)? textController6Validator;
// Stores action output result for [Backend Call - API (postScheduleVisit)] action in Icon widget.
ApiCallResponse? postScheduleVisit;
String convertDateFormat(String dateStr) {
try {
// Formato original
DateFormat originalFormat = DateFormat('d/M/y H:mm:ss');
// Novo formato
DateFormat newFormat = DateFormat('y-M-d H:mm:ss');
// Validate the input string format
if (!RegExp(r'^\d{1,2}/\d{1,2}/\d{4} \d{1,2}:\d{2}:\d{2}$')
.hasMatch(dateStr)) {
return 'Invalid date format';
}
// Converte a string para DateTime
DateTime dateTime = originalFormat.parse(dateStr);
// Converte DateTime para a nova string formatada
String formattedDate = newFormat.format(dateTime);
return formattedDate;
} catch (e) {
// Handle the exception by returning an error message or a default value
return 'Invalid date format';
}
}
@override
void initState(BuildContext context) {}
void initState(BuildContext context) {
initDB();
}
Future<void> initDB() async {
devUUID = await db.get(key: 'devUUID', field: 'value');
userUUID = await db.get(key: 'userUUID', field: 'value');
cliUUID = await db.get(key: 'cliUUID', field: 'value');
}
@override
void dispose() {

View File

@ -173,7 +173,7 @@ class _ScheduleVisitDetailWidgetState extends State<ScheduleVisitDetailWidget> {
fadeInDuration: const Duration(milliseconds: 500),
fadeOutDuration: const Duration(milliseconds: 500),
imageUrl: valueOrDefault<String>(
"https://freaccess.com.br/freaccess/getImage.php?devUUID=${AppState().devUUID}&userUUID=${AppState().userUUID}&cliID=${AppState().cliUUID}&atividade=getFoto&Documento=${getJsonField(
"https://freaccess.com.br/freaccess/getImage.php?devUUID=${_model.devUUID}&userUUID=${_model.userUUID}&cliID=${_model.cliUUID}&atividade=getFoto&Documento=${getJsonField(
visitorsDataItem,
r'''$.VTE_DOCUMENTO''',
).toString()}&tipo=E",
@ -784,9 +784,6 @@ class _ScheduleVisitDetailWidgetState extends State<ScheduleVisitDetailWidget> {
onPressed: () async {
_model.postScheduleVisit =
await PhpGroup.postScheduleVisitCall.call(
devUUID: AppState().devUUID,
userUUID: AppState().userUUID,
atividade: 'putVisita',
devDesc: widget.visitObsStr,
idVisitante: widget.visitorStrList,
dtInicio:
@ -796,7 +793,6 @@ class _ScheduleVisitDetailWidgetState extends State<ScheduleVisitDetailWidget> {
idMotivo: extractIdToStr(widget.visitResonStr!),
idNAC: extractIdToStr(widget.visitLevelStr!),
obs: widget.visitObsStr,
cliID: AppState().cliUUID,
);
if (PhpGroup.postScheduleVisitCall.error(

View File

@ -1,13 +1,36 @@
import 'package:hub/components/organism_components/up_arrow_linked_locals_component/up_arrow_linked_locals_component_widget.dart';
import 'package:hub/flutter_flow/flutter_flow_model.dart';
import 'package:flutter/material.dart';
import 'package:hub/shared/helpers/db_helper.dart';
class UpArrowLinkedLocalsComponentModel
extends FlutterFlowModel<UpArrowLinkedLocalsComponentWidget> {
final DatabaseHelper db = DatabaseHelper();
late final String devUUID;
late final String userUUID;
late final String cliUUID;
late final String cliName;
@override
void initState(BuildContext context) {}
void initState(BuildContext context) {
initDB();
}
Future<void> initDB() async {
devUUID = await db
.get(key: 'devUUID', field: 'value')
.then((value) => value.toString());
userUUID = await db
.get(key: 'userUUID', field: 'value')
.then((value) => value.toString());
cliUUID = await db
.get(key: 'cliUUID', field: 'value')
.then((value) => value.toString());
cliName = await db
.get(key: 'cliName', field: 'value')
.then((value) => value.toString());
}
@override
void dispose() {}

View File

@ -78,10 +78,7 @@ class _UpArrowLinkedLocalsComponentWidgetState
),
),
child: FutureBuilder<ApiCallResponse>(
future: PhpGroup.getLocalsCall.call(
devUUID: AppState().devUUID,
userUUID: AppState().userUUID,
),
future: PhpGroup.getLocalsCall.call(),
builder: (context, snapshot) {
// Customize what your widget looks like when it's loading.
if (!snapshot.hasData) {
@ -131,12 +128,12 @@ class _UpArrowLinkedLocalsComponentWidgetState
hoverColor: Colors.transparent,
highlightColor: Colors.transparent,
onTap: () async {
AppState().cliUUID = getJsonField(
_model.cliUUID = getJsonField(
eachLocalsItem,
r'''$.CLI_ID''',
).toString();
setState(() {});
AppState().local = getJsonField(
_model.cliName = getJsonField(
eachLocalsItem,
r'''$.CLI_NOME''',
).toString();

View File

@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:hub/flutter_flow/nav/nav.dart';
import 'package:hub/shared/helpers/db_helper.dart';
import '/backend/api_requests/api_calls.dart';
import '/flutter_flow/flutter_flow_util.dart';
@ -8,27 +9,40 @@ import 'access_notification_modal_template_component_widget.dart'
class AccessNotificationModalTemplateComponentModel
extends FlutterFlowModel<AccessNotificationModalTemplateComponentWidget> {
/// State fields for stateful widgets in this component.
final DatabaseHelper db = DatabaseHelper();
late final String devUUID;
late final String userUUID;
late final String cliUUID;
// State field(s) for TextField widget.
FocusNode? textFieldFocusNode1;
TextEditingController? textController1;
String? Function(BuildContext, String?)? textController1Validator;
// State field(s) for TextField widget.
FocusNode? textFieldFocusNode2;
TextEditingController? textController2;
String? Function(BuildContext, String?)? textController2Validator;
// State field(s) for TextField widget.
FocusNode? textFieldFocusNode3;
TextEditingController? textController3;
String? Function(BuildContext, String?)? textController3Validator;
// State field(s) for TextField widget.
FocusNode? textFieldFocusNode4;
TextEditingController? textController4;
String? Function(BuildContext, String?)? textController4Validator;
@override
void initState(BuildContext context) {}
void initState(BuildContext context) {
initDB();
}
Future<void> initDB() async {
devUUID = await db
.get(key: 'devUUID', field: 'value')
.then((value) => value.toString());
userUUID = await db
.get(key: 'userUUID', field: 'value')
.then((value) => value.toString());
cliUUID = await db
.get(key: 'cliUUID', field: 'value')
.then((value) => value.toString());
}
@override
void dispose() {
@ -45,7 +59,6 @@ class AccessNotificationModalTemplateComponentModel
textController4?.dispose();
}
/// Action blocks.
Future<bool> visitRequestComponentAction(
BuildContext context, {
required String? actionValue,
@ -56,10 +69,6 @@ class AccessNotificationModalTemplateComponentModel
ApiCallResponse? visitRequest;
visitRequest = await PhpGroup.respondeSolicitacaoCall.call(
userUUID: AppState().userUUID,
devUUID: AppState().devUUID,
cliUUID: AppState().cliUUID,
atividade: 'respondeSolicitacao',
referencia: refUUID,
tarefa: actionValue,
resposta: responseValue,

View File

@ -110,10 +110,7 @@ class _AccessNotificationModalTemplateComponentWidgetState
fadeInDuration: const Duration(milliseconds: 100),
fadeOutDuration: const Duration(milliseconds: 100),
imageUrl: valueOrDefault<String>(
// widget.type == 'O'
// ? 'https://freaccess.com.br/freaccess/getImage.php?cliID=${AppState().cliUUID}&atividade=getFoto&Documento=${widget.id}&tipo=O'
// : 'https://freaccess.com.br/freaccess/getImage.php?cliID=${AppState().cliUUID}&atividade=getFoto&Documento=${widget.id}&tipo=E',
'https://freaccess.com.br/freaccess/getImage.php?cliID=${AppState().cliUUID}&atividade=getFoto&Documento=${widget.id}&tipo=${widget.type}',
'https://freaccess.com.br/freaccess/getImage.php?cliID=${_model.cliUUID}&atividade=getFoto&Documento=${widget.id}&tipo=${widget.type}',
'https://storage.googleapis.com/flutterflow-io-6f20.appspot.com/projects/flutter-freaccess-hub-0xgz9q/assets/7ftdetkzc3s0/360_F_64676383_LdbmhiNM6Ypzb3FM4PPuFP9rHe7ri8Ju.jpg',
),
fit: BoxFit.cover,

View File

@ -1,21 +1,31 @@
import 'dart:convert';
import 'dart:developer';
import 'package:flutter/material.dart';
import 'package:http/http.dart';
import 'package:hub/actions/actions.dart';
import 'package:hub/backend/api_requests/api_calls.dart';
import 'package:hub/components/templates_components/details_component/details_component_widget.dart';
import 'package:hub/custom_code/actions/convert_to_upload_file.dart';
import 'package:hub/flutter_flow/flutter_flow_theme.dart';
import 'package:hub/flutter_flow/flutter_flow_util.dart';
import 'package:hub/flutter_flow/flutter_flow_widgets.dart';
import 'package:hub/flutter_flow/form_field_controller.dart';
import 'package:hub/flutter_flow/nav/nav.dart';
import 'package:hub/pages/pets_page/pets_page_model.dart';
import 'package:hub/shared/utils/validator_util.dart';
import 'package:share_plus/share_plus.dart';
Widget buildVisitDetails(
dynamic item,
BuildContext context,
Future<dynamic> Function(BuildContext, int, int, String, String)?
changeStatusAction) {
Widget buildVisitDetails({
required dynamic item,
required BuildContext context,
required Future<dynamic> Function(BuildContext, int, int, String, String)
changeStatusAction,
required String devUUID,
required String userUUID,
required String cliUUID,
required String cliName,
}) {
return DetailsComponentWidget(
buttons: [
if (getStatus(item['VAW_STATUS']) == status.active) // REJECT ACTION
@ -137,13 +147,13 @@ Widget buildVisitDetails(
icon: const Icon(Icons.share),
onPressed: () async {
Share.share('''
Olá, \*${item['VTE_NOME']}\*! Você foi convidado para \*${AppState().local}\*.
Olá, \*${item['VTE_NOME']}\*! Você foi convidado para \*${cliName}\*.
\*Validade do Convite\*:
- Início: ${item['VAW_DTINICIO']}
- Fim: ${item['VAW_DTFIM']}
URL do Convite: https://visita.freaccess.com.br/${item['VAW_ID']}/${AppState().cliUUID}/${item['VAW_CHAVE']}
URL do Convite: https://visita.freaccess.com.br/${item['VAW_ID']}/${cliUUID}/${item['VAW_CHAVE']}
''');
},
options: FFButtonOptions(
@ -177,7 +187,7 @@ URL do Convite: https://visita.freaccess.com.br/${item['VAW_ID']}/${AppState().c
: '',
}),
imagePath:
'https://freaccess.com.br/freaccess/getImage.php?cliID=${AppState().cliUUID}&atividade=getFoto&Documento=${item['VTE_DOCUMENTO'] ?? ''}&tipo=E',
'https://freaccess.com.br/freaccess/getImage.php?cliID=${cliUUID}&atividade=getFoto&Documento=${item['VTE_DOCUMENTO'] ?? ''}&tipo=E',
statusHashMap: [
if (getStatus(item['VAW_STATUS']) == status.active)
Map<String, Color>.from({
@ -225,11 +235,17 @@ URL do Convite: https://visita.freaccess.com.br/${item['VAW_ID']}/${AppState().c
);
}
Widget buildPetDetails(
dynamic item,
BuildContext context,
Future<dynamic> Function(BuildContext, int, int, String, String)?
changeStatusAction) {
Widget buildPetDetails({
required dynamic item,
required BuildContext context,
required Future<dynamic> Function(BuildContext, int, int, String, String)
changeStatusAction,
required String devUUID,
required String userUUID,
required String cliUUID,
required String cliName,
required PetsPageModel model,
}) {
return DetailsComponentWidget(
buttons: [
// EDIT ACTION
@ -241,11 +257,12 @@ Widget buildPetDetails(
icon: const Icon(Icons.edit),
onPressed: () async {
context.pop();
context.pop();
context.pushNamed('petsPage', extra: {
'pet': item,
});
model.isEditing = true;
model.item = item;
model.switchTab(0);
model.setEditForm();
// model.safeSetState!();
},
options: FFButtonOptions(
width: 130,
@ -284,9 +301,6 @@ Widget buildPetDetails(
int id = item['id'];
await PhpGroup.deletePet
.call(
userUUID: AppState().userUUID,
devUUID: AppState().devUUID,
cliID: AppState().cliUUID,
petID: id,
)
.then((value) {
@ -386,7 +400,7 @@ Widget buildPetDetails(
item['notes'] ?? '',
}),
imagePath:
'https://freaccess.com.br/freaccess/getImage.php?devUUID=${AppState().devUUID}&userUUID=${AppState().userUUID}&cliID=${AppState().cliUUID}&atividade=consultaFotoPet&petId=${item['id'] ?? ''}',
'https://freaccess.com.br/freaccess/getImage.php?devUUID=${devUUID}&userUUID=${userUUID}&cliID=${cliUUID}&atividade=consultaFotoPet&petId=${item['id'] ?? ''}',
statusHashMap: [
if (item['gender'] == "MAC")
Map<String, Color>.from({

View File

@ -265,9 +265,7 @@ class _ForgotPasswordTemplateComponentWidgetState
email: _model.emailAddressTextController.text,
);
if (PhpGroup.forgotPasswordCall
.error((_model.req?.jsonBody ?? '')) ==
false) {
if (_model.req?.jsonBody['error'] == false) {
await DialogUtil.success(
context,
FFLocalizations.of(context).getVariableText(
@ -276,9 +274,7 @@ class _ForgotPasswordTemplateComponentWidgetState
context.pop();
} else {
await DialogUtil.error(
context,
PhpGroup.forgotPasswordCall
.msg((_model.req?.jsonBody ?? ''))!);
context, _model.req?.jsonBody['error_msg']);
}
setState(() {});

View File

@ -4,25 +4,25 @@ import 'package:hub/backend/api_requests/api_calls.dart';
import 'package:hub/components/templates_components/liberation_history_item_details_template_component/liberation_history_item_details_template_component_widget.dart';
import 'package:hub/flutter_flow/flutter_flow_model.dart';
import 'package:hub/flutter_flow/nav/nav.dart';
import 'package:hub/shared/helpers/db_helper.dart';
class LiberationHistoryItemDetailsTemplateComponentModel
extends FlutterFlowModel<
LiberationHistoryItemDetailsTemplateComponentWidget> {
/// State fields for stateful widgets in this component.
final DatabaseHelper db = DatabaseHelper();
late final String devUUID;
late final String userUUID;
late final String cliUUID;
// State field(s) for TextField widget.
FocusNode? textFieldFocusNode1;
TextEditingController? textController1;
String? Function(BuildContext, String?)? textController1Validator;
// State field(s) for TextField widget.
FocusNode? textFieldFocusNode2;
TextEditingController? textController2;
String? Function(BuildContext, String?)? textController2Validator;
// State field(s) for TextField widget.
FocusNode? textFieldFocusNode3;
TextEditingController? textController3;
String? Function(BuildContext, String?)? textController3Validator;
// State field(s) for TextField widget.
FocusNode? textFieldFocusNode4;
TextEditingController? textController4;
String? Function(BuildContext, String?)? textController4Validator;
@ -30,6 +30,18 @@ class LiberationHistoryItemDetailsTemplateComponentModel
@override
void initState(BuildContext context) {}
Future<void> initDatabase() async {
devUUID = await db
.get(key: 'devUUID', field: 'value')
.then((value) => value.toString());
userUUID = await db
.get(key: 'userUUID', field: 'value')
.then((value) => value.toString());
cliUUID = await db
.get(key: 'cliUUID', field: 'value')
.then((value) => value.toString());
}
@override
void dispose() {
textFieldFocusNode1?.dispose();
@ -44,36 +56,4 @@ class LiberationHistoryItemDetailsTemplateComponentModel
textFieldFocusNode4?.dispose();
textController4?.dispose();
}
/// Action blocks.
Future<bool> visitRequestComponentAction(
BuildContext context, {
required String? actionValue,
required String? refUUID,
required String? responseValue,
required String? vteUUID,
}) async {
ApiCallResponse? visitRequest;
visitRequest = await PhpGroup.respondeSolicitacaoCall.call(
userUUID: AppState().userUUID,
devUUID: AppState().devUUID,
cliUUID: AppState().cliUUID,
atividade: 'respondeSolicitacao',
referencia: refUUID,
tarefa: actionValue,
resposta: responseValue,
idVisitante: vteUUID,
);
if (PhpGroup.respondeSolicitacaoCall.error(
(visitRequest.jsonBody ?? ''),
) ==
false) {
context.pop();
return true;
} else {
return false;
}
}
}

View File

@ -105,7 +105,7 @@ class _LiberationHistoryItemDetailsTemplateComponentWidgetState
fadeInDuration: const Duration(milliseconds: 100),
fadeOutDuration: const Duration(milliseconds: 100),
imageUrl: valueOrDefault<String>(
'https://freaccess.com.br/freaccess/getImage.php?devUUID=${AppState().devUUID}&userUUID=${AppState().userUUID}&cliID=${AppState().cliUUID}&atividade=getFoto&Documento=${widget.id}&tipo=E',
'https://freaccess.com.br/freaccess/getImage.php?devUUID=${_model.devUUID}&userUUID=${_model.userUUID}&cliID=${_model.cliUUID}&atividade=getFoto&Documento=${widget.id}&tipo=E',
'https://storage.googleapis.com/flutterflow-io-6f20.appspot.com/projects/flutter-freaccess-hub-0xgz9q/assets/7ftdetkzc3s0/360_F_64676383_LdbmhiNM6Ypzb3FM4PPuFP9rHe7ri8Ju.jpg',
),
fit: BoxFit.cover,

View File

@ -43,36 +43,4 @@ class MessageNotificationModalTemplateComponentModel
textFieldFocusNode4?.dispose();
textController4?.dispose();
}
/// Action blocks.
Future<bool> visitRequestComponentAction(
BuildContext context, {
required String? actionValue,
required String? refUUID,
required String? responseValue,
required String? vteUUID,
}) async {
ApiCallResponse? visitRequest;
visitRequest = await PhpGroup.respondeSolicitacaoCall.call(
userUUID: AppState().userUUID,
devUUID: AppState().devUUID,
cliUUID: AppState().cliUUID,
atividade: 'respondeSolicitacao',
referencia: refUUID,
tarefa: actionValue,
resposta: responseValue,
idVisitante: vteUUID,
);
if (PhpGroup.respondeSolicitacaoCall.error(
(visitRequest.jsonBody ?? ''),
) ==
false) {
context.pop();
return true;
} else {
return false;
}
}
}

View File

@ -13,6 +13,7 @@ class ScheduleProvisionalVisitPageModel
String userUUID = '';
String cliName = '';
String ownerUUID = '';
VoidCallback? setState;
bool toggleIdx = false;
@ -33,10 +34,7 @@ class ScheduleProvisionalVisitPageModel
void updateDocsAtIndex(int index, Function(String) updateFn) =>
docs[index] = updateFn(docs[index]);
/// State fields for stateful widgets in this page.
final formKey = GlobalKey<FormState>();
// State field(s) for personName widget.
FocusNode? personNameFocusNode;
TextEditingController? personNameTextController;
String? Function(BuildContext, String?)? personNameTextControllerValidator;
@ -44,27 +42,26 @@ class ScheduleProvisionalVisitPageModel
BuildContext context, String? val) {
if (val == null || val.isEmpty) {
return FFLocalizations.of(context).getText(
'3hqg8buh' /* Nome é Obrigatório */,
'3hqg8buh',
);
}
if (val.length > 80) {
return FFLocalizations.of(context).getText(
'l0b0zr50' /* Máximo 80 caracteres */,
'l0b0zr50',
);
}
return null;
}
// State field(s) for dateTime widget.
FocusNode? dateTimeFocusNode;
TextEditingController? dateTimeTextController;
String? Function(BuildContext, String?)? dateTimeTextControllerValidator;
String? _dateTimeTextControllerValidator(BuildContext context, String? val) {
if (val == null || val.isEmpty) {
return FFLocalizations.of(context).getText(
'uzefkuf9' /* Data / Hora é Obrigatório */,
'uzefkuf9',
);
}
@ -92,26 +89,48 @@ class ScheduleProvisionalVisitPageModel
}
DateTime? datePicked;
// State field(s) for notes widget.
FocusNode? notesFocusNode;
TextEditingController? notesTextController;
String? Function(BuildContext, String?)? notesTextControllerValidator;
// Stores action output result for [Backend Call - API (postProvVisitScheduling)] action in btnSend widget.
ApiCallResponse? provVisitSchedule;
@override
void initState(BuildContext context) {
personNameTextControllerValidator = _personNameTextControllerValidator;
dateTimeTextControllerValidator = _dateTimeTextControllerValidator;
personNameTextController ??= TextEditingController();
personNameFocusNode ??= FocusNode();
dateTimeTextController ??= TextEditingController();
dateTimeFocusNode ??= FocusNode();
notesTextController ??= TextEditingController();
notesFocusNode ??= FocusNode();
init();
}
bool isFormValid() {
if (personNameTextController.text == '' ||
personNameTextController.text.length > 80) {
return false;
}
if (dateTimeTextController.text == '') {
return false;
}
return true;
}
Future<void> init() async {
cliUUID = await db.get(key: 'cliUUID', field: 'value');
devUUID = await db.get(key: 'devUUID', field: 'value');
userUUID = await db.get(key: 'userUUID', field: 'value');
cliName = await db.get(key: 'cliName', field: 'value');
ownerUUID = await db.get(key: 'ownerUUID', field: 'value');
setState?.call();
}
@override

View File

@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:hub/components/templates_components/provisional_schedule_template/provisional_schedule_template_model.dart';
import 'package:hub/shared/helpers/db_helper.dart';
import 'package:hub/shared/utils/dialog_util.dart';
import 'package:hub/shared/utils/log_util.dart';
import 'package:provider/provider.dart';
@ -14,9 +15,7 @@ import '/flutter_flow/flutter_flow_util.dart';
import '/flutter_flow/flutter_flow_widgets.dart';
class ScheduleProvisionalVisitPageWidget extends StatefulWidget {
const ScheduleProvisionalVisitPageWidget({
super.key,
});
const ScheduleProvisionalVisitPageWidget({super.key});
@override
State<ScheduleProvisionalVisitPageWidget> createState() =>
@ -25,43 +24,22 @@ class ScheduleProvisionalVisitPageWidget extends StatefulWidget {
class _ScheduleProvisionalVisitPageWidgetState
extends State<ScheduleProvisionalVisitPageWidget> {
late ScheduleProvisionalVisitPageModel _model;
late ScheduleProvisionalVisitPageModel model;
@override
void initState() {
super.initState();
_model = createModel(context, () => ScheduleProvisionalVisitPageModel());
_model.personNameTextController ??= TextEditingController();
_model.personNameFocusNode ??= FocusNode();
_model.dateTimeTextController ??= TextEditingController();
_model.dateTimeFocusNode ??= FocusNode();
_model.notesTextController ??= TextEditingController();
_model.notesFocusNode ??= FocusNode();
model = createModel(context, () => ScheduleProvisionalVisitPageModel());
model.setState = () => safeSetState(() {});
}
@override
void dispose() {
_model.dispose();
model.dispose();
super.dispose();
}
bool _isFormValid() {
if (_model.personNameTextController.text == '' ||
_model.personNameTextController.text.length > 80) {
return false;
}
if (_model.dateTimeTextController.text == '') {
return false;
}
return true;
}
@override
Widget build(BuildContext context) {
context.watch<AppState>();
@ -78,7 +56,7 @@ class _ScheduleProvisionalVisitPageWidgetState
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Form(
key: _model.formKey,
key: model.formKey,
autovalidateMode: AutovalidateMode.onUserInteraction,
child: SingleChildScrollView(
child: Column(
@ -183,7 +161,7 @@ class _ScheduleProvisionalVisitPageWidgetState
fadeOutDuration: const Duration(
milliseconds: 200),
imageUrl:
'https://freaccess.com.br/freaccess/Images/Clients/${_model.cliUUID}.png',
'https://freaccess.com.br/freaccess/Images/Clients/${model.cliUUID}.png',
width: 35.0,
height: 35.0,
fit: BoxFit.contain,
@ -195,7 +173,7 @@ class _ScheduleProvisionalVisitPageWidgetState
padding: const EdgeInsetsDirectional
.fromSTEB(15.0, 0.0, 0.0, 0.0),
child: Text(
_model.cliName,
model.cliName,
style: FlutterFlowTheme.of(context)
.bodyMedium
.override(
@ -269,12 +247,12 @@ class _ScheduleProvisionalVisitPageWidgetState
width: double.infinity,
child: TextFormField(
controller:
_model.personNameTextController,
model.personNameTextController,
focusNode:
_model.personNameFocusNode,
model.personNameFocusNode,
onChanged: (_) =>
EasyDebounce.debounce(
'_model.personNameTextController',
'model.personNameTextController',
const Duration(milliseconds: 500),
() => setState(() {}),
),
@ -397,7 +375,7 @@ class _ScheduleProvisionalVisitPageWidgetState
),
textAlign: TextAlign.start,
maxLines: null,
validator: _model
validator: model
.personNameTextControllerValidator
.asValidator(context),
),
@ -421,12 +399,12 @@ class _ScheduleProvisionalVisitPageWidgetState
.fromSTEB(24.0, 0.0, 24.0, 0.0),
child: TextFormField(
controller:
_model.dateTimeTextController,
model.dateTimeTextController,
focusNode:
_model.dateTimeFocusNode,
model.dateTimeFocusNode,
onChanged: (_) =>
EasyDebounce.debounce(
'_model.dateTimeTextController',
'model.dateTimeTextController',
const Duration(
milliseconds: 500),
() => setState(() {}),
@ -528,7 +506,7 @@ class _ScheduleProvisionalVisitPageWidgetState
.bodyMediumFamily),
),
textAlign: TextAlign.start,
validator: _model
validator: model
.dateTimeTextControllerValidator
.asValidator(context),
),
@ -683,8 +661,7 @@ class _ScheduleProvisionalVisitPageWidgetState
if (datePickedDate != null &&
datePickedTime != null) {
safeSetState(() {
_model.datePicked =
DateTime(
model.datePicked = DateTime(
datePickedDate.year,
datePickedDate.month,
datePickedDate.day,
@ -694,18 +671,19 @@ class _ScheduleProvisionalVisitPageWidgetState
});
}
setState(() {
_model.dateTimeTextController
model.dateTimeTextController
?.text = dateTimeFormat(
"dd/MM/yyyy HH:mm:ss",
_model.datePicked,
model.datePicked,
locale: FFLocalizations.of(
context)
.languageCode,
);
_model.dateTimeTextController
model.dateTimeTextController
?.selection =
TextSelection.collapsed(
offset: _model
offset: model
.dateTimeTextController!
.text
.length);
@ -755,10 +733,10 @@ class _ScheduleProvisionalVisitPageWidgetState
child: SizedBox(
width: double.infinity,
child: TextFormField(
controller: _model
.notesTextController,
controller:
model.notesTextController,
focusNode:
_model.notesFocusNode,
model.notesFocusNode,
autofocus: false,
textInputAction:
TextInputAction.next,
@ -895,7 +873,7 @@ class _ScheduleProvisionalVisitPageWidgetState
maxLengthEnforcement:
MaxLengthEnforcement
.enforced,
validator: _model
validator: model
.notesTextControllerValidator
.asValidator(context),
),
@ -912,26 +890,21 @@ class _ScheduleProvisionalVisitPageWidgetState
),
),
FFButtonWidget(
onPressed: !_isFormValid()
onPressed: !model.isFormValid()
? null
: () async {
try {
_model.provVisitSchedule = await PhpGroup
model.provVisitSchedule = await PhpGroup
.postProvVisitSchedulingCall
.call(
devUUID: _model.devUUID,
userUUID: _model.userUUID,
cliID: _model.cliUUID,
atividade: 'putAgendamentoProv',
data: _model.dateTimeTextController.text,
motivo: _model.notesTextController.text,
nome:
_model.personNameTextController.text,
proID: _model.ownerUUID,
data: model.dateTimeTextController.text,
motivo: model.notesTextController.text,
nome: model.personNameTextController.text,
proID: model.ownerUUID,
);
if (PhpGroup.postProvVisitSchedulingCall
.error((_model.provVisitSchedule
.error((model.provVisitSchedule
?.jsonBody ??
'')) ==
false) {
@ -943,16 +916,15 @@ class _ScheduleProvisionalVisitPageWidgetState
enText:
"Provisional Scheduling Successfully Completed"));
safeSetState(() {
_model.dateTimeTextController?.clear();
model.dateTimeTextController?.clear();
_model.personNameTextController
?.clear();
_model.notesTextController?.clear();
model.personNameTextController?.clear();
model.notesTextController?.clear();
});
} else {
var message = PhpGroup
.postProvVisitSchedulingCall
.msg((_model.provVisitSchedule
.msg((model.provVisitSchedule
?.jsonBody ??
''));
if (message != null) {

View File

@ -1,6 +1,7 @@
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:hub/shared/helpers/db_helper.dart';
import 'package:hub/shared/utils/validator_util.dart';
import '/backend/api_requests/api_calls.dart';
@ -10,8 +11,11 @@ import 'regisiter_vistor_template_component_widget.dart';
class RegisiterVistorTemplateComponentModel
extends FlutterFlowModel<RegisiterVistorTemplateComponentWidget> {
/// State fields for stateful widgets in this page.
Timer? _debounceTimer;
final DatabaseHelper db = DatabaseHelper();
late final String devUUID;
late final String userUUID;
late final String cliUUID;
final unfocusNode = FocusNode();
bool isDataUploading = false;
@ -25,8 +29,6 @@ class RegisiterVistorTemplateComponentModel
_debounceTimer = Timer(time, fn);
}
// State field(s) for TextField widget.
FocusNode? textFieldFocusNode1;
TextEditingController? textController1;
@ -45,10 +47,6 @@ class RegisiterVistorTemplateComponentModel
Future<bool> getVisitanteByDocument(
String document, BuildContext context) async {
final response = await PhpGroup.getVisitorByDocCall.call(
devUUID: AppState().devUUID,
userUUID: AppState().userUUID,
cliID: AppState().cliUUID,
atividade: 'getVisitante',
documento: document,
);
@ -132,6 +130,14 @@ class RegisiterVistorTemplateComponentModel
textFieldFocusNode4 = FocusNode();
textController4 = TextEditingController();
textController4Validator = _textController4Validator;
initializeDatabase();
}
Future<void> initializeDatabase() async {
devUUID = await db.get(key: 'devUUID', field: 'value');
userUUID = await db.get(key: 'userUUID', field: 'value');
cliUUID = await db.get(key: 'cliUUID', field: 'value');
}
@override

View File

@ -845,10 +845,6 @@ class _RegisiterVistorTemplateComponentWidgetState
_model.scheduleVisitor =
await PhpGroup.postScheduleVisitorCall
.call(
devUUID: AppState().devUUID,
userUUID: AppState().userUUID,
cliID: AppState().cliUUID,
atividade: 'putVisitante',
documento: _model.textController2.text,
nome: _model.textController1.text,
tipo: _model.dropDownValue ==

View File

@ -703,7 +703,8 @@ class _SignUpTemplateComponentWidgetState
email: _model
.emailRegisterFormTextController
.text,
device: AppState().device,
device:
AppState().deviceType,
);
shouldSetState = true;
if (_model.signUp == true) {

View File

@ -1,42 +1,52 @@
import 'package:hub/shared/helpers/db_helper.dart';
import '/backend/api_requests/api_calls.dart';
import '/flutter_flow/flutter_flow_util.dart';
import 'view_visit_detail_widget.dart' show ViewVisitDetailWidget;
import 'package:flutter/material.dart';
class ViewVisitDetailModel extends FlutterFlowModel<ViewVisitDetailWidget> {
/// State fields for stateful widgets in this component.
final DatabaseHelper db = DatabaseHelper();
late final String devUUID;
late final String userUUID;
late final String cliUUID;
// Stores action output result for [Action Block - manageStatusColorAction] action in viewVisitDetail widget.
// Color? visitStatusColor;
// State field(s) for TextField widget.
FocusNode? textFieldFocusNode1;
TextEditingController? textController1;
String? Function(BuildContext, String?)? textController1Validator;
// State field(s) for TextField widget.
FocusNode? textFieldFocusNode2;
TextEditingController? textController2;
String? Function(BuildContext, String?)? textController2Validator;
// State field(s) for TextField widget.
FocusNode? textFieldFocusNode3;
TextEditingController? textController3;
String? Function(BuildContext, String?)? textController3Validator;
// State field(s) for TextField widget.
FocusNode? textFieldFocusNode4;
TextEditingController? textController4;
String? Function(BuildContext, String?)? textController4Validator;
// State field(s) for TextField widget.
FocusNode? textFieldFocusNode5;
TextEditingController? textController5;
String? Function(BuildContext, String?)? textController5Validator;
// State field(s) for TextField widget.
FocusNode? textFieldFocusNode6;
TextEditingController? textController6;
String? Function(BuildContext, String?)? textController6Validator;
// Stores action output result for [Backend Call - API (deleteVisit)] action in IconButton widget.
ApiCallResponse? deleteVisit;
@override
void initState(BuildContext context) {}
void initState(BuildContext context) {
initializeDatabase();
}
Future<void> initializeDatabase() async {
devUUID = await db
.get(key: 'devUUID', field: 'value')
.then((value) => value.toString());
userUUID = await db
.get(key: 'userUUID', field: 'value')
.then((value) => value.toString());
cliUUID = await db
.get(key: 'cliUUID', field: 'value')
.then((value) => value.toString());
}
@override
void dispose() {

View File

@ -822,10 +822,6 @@ class _ViewVisitDetailWidgetState extends State<ViewVisitDetailWidget> {
onPressed: () async {
_model.deleteVisit =
await PhpGroup.deleteVisitCall.call(
devUUID: AppState().devUUID,
userUUID: AppState().userUUID,
cliID: AppState().cliUUID,
atividade: 'cancelaVisita',
idVisita: widget.visitIdStr,
);

View File

@ -2,12 +2,15 @@ import 'package:hub/backend/api_requests/api_manager.dart';
import 'package:hub/components/templates_components/visitor_search_modal_template_component/visitor_search_modal_template_component_widget.dart';
import 'package:hub/flutter_flow/flutter_flow_model.dart';
import 'package:flutter/material.dart';
import 'package:hub/shared/helpers/db_helper.dart';
class VisitorSearchModalTemplateComponentModel
extends FlutterFlowModel<VisitorSearchModalTemplateComponentWidget> {
/// Local state fields for this component.
final DatabaseHelper db = DatabaseHelper();
late final String devUUID;
late final String userUUID;
late final String cliUUID;
List<dynamic> visitors = [];
void addToVisitors(dynamic item) => visitors.add(item);
@ -26,17 +29,27 @@ class VisitorSearchModalTemplateComponentModel
void updateDocsAtIndex(int index, Function(String) updateFn) =>
docs[index] = updateFn(docs[index]);
/// State fields for stateful widgets in this component.
// State field(s) for TextField widget.
FocusNode? textFieldFocusNode;
TextEditingController? textController;
String? Function(BuildContext, String?)? textControllerValidator;
// Stores action output result for [Backend Call - API (getVisitorByDoc)] action in TextField widget.
ApiCallResponse? getVisitorByDoc;
@override
void initState(BuildContext context) {}
void initState(BuildContext context) {
initDatabase();
}
Future<void> initDatabase() async {
devUUID = await db
.get(key: 'devUUID', field: 'value')
.then((value) => value.toString());
userUUID = await db
.get(key: 'userUUID', field: 'value')
.then((value) => value.toString());
cliUUID = await db
.get(key: 'cliUUID', field: 'value')
.then((value) => value.toString());
}
@override
void dispose() {

View File

@ -268,7 +268,7 @@ class _VisitorSearchModalTemplateComponentWidgetState
fadeOutDuration: const Duration(
milliseconds: 500),
imageUrl:
"https://freaccess.com.br/freaccess/getImage.php?devUUID=${AppState().devUUID}&userUUID=${AppState().userUUID}&cliID=${AppState().cliUUID}&atividade=getFoto&Documento=${getJsonField(
"https://freaccess.com.br/freaccess/getImage.php?devUUID=${_model.devUUID}&userUUID=${_model.userUUID}&cliID=${_model.cliUUID}&atividade=getFoto&Documento=${getJsonField(
visitorItem,
r'''$.VTE_DOCUMENTO''',
).toString()}&tipo=E",
@ -440,10 +440,6 @@ class _VisitorSearchModalTemplateComponentWidgetState
TextSelection.collapsed(offset: _model.textController!.text.length);
});
_model.getVisitorByDoc = await PhpGroup.getVisitorByDocCall.call(
devUUID: AppState().devUUID,
userUUID: AppState().userUUID,
cliID: AppState().cliUUID,
atividade: 'getVisitante',
documento: _model.textController.text,
);

View File

@ -146,9 +146,7 @@ GoRouter createRouter(AppStateNotifier appStateNotifier) => GoRouter(
FFRoute(
name: 'preferencesSettings',
path: '/preferencesSettings',
builder: (context, params) => const PreferencesPageWidget(
key: Key('preferencesSettings'),
)),
builder: (context, params) => PreferencesPageWidget()),
FFRoute(
name: 'peopleOnThePropertyPage',
path: '/peopleOnThePropertyPage',
@ -190,7 +188,7 @@ GoRouter createRouter(AppStateNotifier appStateNotifier) => GoRouter(
FFRoute(
name: 'preferencesPage',
path: '/preferencesPage',
builder: (context, params) => const PreferencesPageWidget(),
builder: (context, params) => PreferencesPageWidget(),
),
FFRoute(
name: 'packageOrder',

View File

@ -106,6 +106,8 @@ class _AppState extends State<App> {
_backgroundHandleMessage(message);
}
});
// AppState().isLogged = false;
}
void setLocale(String language) {

View File

@ -4,8 +4,14 @@ import 'package:hub/components/molecular_components/message_opt_modal/opt_modal_
import 'package:hub/flutter_flow/flutter_flow_model.dart';
import 'package:hub/flutter_flow/request_manager.dart';
import 'package:hub/pages/acess_history_page/acess_history_page_widget.dart';
import 'package:hub/shared/helpers/db_helper.dart';
class AcessHistoryPageModel extends FlutterFlowModel<AcessHistoryPageWidget> {
final DatabaseHelper db = DatabaseHelper();
late final String devUUID;
late final String userUUID;
late final String cliUUID;
final unfocusNode = FocusNode();
final _accessHistoryManager = FutureRequestManager<ApiCallResponse>();
Future<ApiCallResponse> accessHistory({
@ -23,14 +29,26 @@ class AcessHistoryPageModel extends FlutterFlowModel<AcessHistoryPageWidget> {
_accessHistoryManager.clearRequest(uniqueKey);
@override
void initState(BuildContext context) {}
void initState(BuildContext context) {
initDatabase();
}
Future<void> initDatabase() async {
devUUID = await db
.get(key: 'devUUID', field: 'value')
.then((value) => value.toString());
userUUID = await db
.get(key: 'userUUID', field: 'value')
.then((value) => value.toString());
cliUUID = await db
.get(key: 'cliUUID', field: 'value')
.then((value) => value.toString());
}
@override
void dispose() {
unfocusNode.dispose();
/// Dispose query cache managers for this widget.
clearAccessHistoryCache();
}

View File

@ -187,10 +187,6 @@ class _AcessHistoryPageWidgetState extends State<AcessHistoryPageWidget> {
try {
setState(() => _loading = true);
var response = await PhpGroup.getAccessCall.call(
devUUID: AppState().devUUID,
userUUID: AppState().userUUID,
cliID: AppState().cliUUID,
atividade: 'getAcessos',
pageSize: _pageSize.toString(),
pageNumber: _pageNumber.toString(),
pesTipo: _personType != 'E' && _personType != 'O' ? 'T' : _personType,
@ -333,7 +329,7 @@ class _AcessHistoryPageWidgetState extends State<AcessHistoryPageWidget> {
BuildContext context, dynamic accessHistoryItem) {
return CardItemTemplateComponentWidget(
imagePath:
'https://freaccess.com.br/freaccess/getImage.php?cliID=${AppState().cliUUID}&atividade=getFoto&Documento=${accessHistoryItem['PES_ID'] ?? ''}&tipo=${accessHistoryItem['PES_TIPO'] ?? ''}',
'https://freaccess.com.br/freaccess/getImage.php?cliID=${_model.cliUUID}&atividade=getFoto&Documento=${accessHistoryItem['PES_ID'] ?? ''}&tipo=${accessHistoryItem['PES_TIPO'] ?? ''}',
labelsHashMap: Map<String, String>.from({
FFLocalizations.of(context).getVariableText(
ptText: 'Nome:',
@ -392,11 +388,11 @@ class _AcessHistoryPageWidgetState extends State<AcessHistoryPageWidget> {
],
onTapCardItemAction: () async {});
}
}
String imageUrlAtomWidget(String document, String type) {
return valueOrDefault<String>(
"https://freaccess.com.br/freaccess/getImage.php?&cliID=${AppState().cliUUID}&atividade=getFoto&Documento=$document&tipo=$type",
"https://freaccess.com.br/freaccess/getImage.php?&cliID=${_model.cliUUID}&atividade=getFoto&Documento=$document&tipo=$type",
"https://storage.googleapis.com/flutterflow-io-6f20.appspot.com/projects/flutter-freaccess-hub-0xgz9q/assets/7ftdetkzc3s0/360_F_64676383_LdbmhiNM6Ypzb3FM4PPuFP9rHe7ri8Ju.jpg",
);
}
}

View File

@ -17,20 +17,15 @@ class DeliverySchedule extends StatefulWidget {
}
class _DeliveryScheduleState extends State<DeliverySchedule> {
late ScheduleProvisionalVisitPageModel _model;
final scaffoldKey = GlobalKey<ScaffoldState>();
@override
void initState() {
super.initState();
_model = createModel(context, () => ScheduleProvisionalVisitPageModel());
}
@override
void dispose() {
_model.dispose();
super.dispose();
}

View File

@ -5,21 +5,12 @@ import 'package:flutter/scheduler.dart';
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
import 'package:hub/app_state.dart';
import 'package:hub/flutter_flow/nav/nav.dart';
import 'package:hub/shared/helpers/db_helper.dart';
import 'package:hub/shared/utils/webview_util.dart';
import 'package:url_launcher/url_launcher_string.dart';
import 'package:webview_flutter/webview_flutter.dart';
class FastPassPageWidget extends StatefulWidget {
final String freToken = AppState().userUUID;
final String freUserData = "{\"name\": \"${AppState().name}\", " +
"\"email\": \"${AppState().email}\"," +
"\"dev_id\": \"${AppState().devUUID}\"," +
"\"created_at\": \"${AppState().createdAt}\"," +
"\"updated_at\": \"0000-00-00 00:00:00\"," +
"\"status\": \"A\" }";
final String clientId = AppState().cliUUID;
@override
_FastPassPageWidgetState createState() => _FastPassPageWidgetState();
}
@ -27,27 +18,63 @@ class FastPassPageWidget extends StatefulWidget {
class _FastPassPageWidgetState extends State<FastPassPageWidget> {
late InAppWebViewController _controllerIOS;
late WebViewController _controllerAll;
late String url;
late String name;
late String email;
late String userUUID;
late String created_at;
final DatabaseHelper db = DatabaseHelper();
@override
void initState() {
super.initState();
name = AppState().name;
email = AppState().email;
userUUID = AppState().userUUID;
created_at = AppState().createdAt;
url = 'https://hub.freaccess.com.br/hub/fast-pass/${widget.clientId}';
Future<Map<String, String>> initVariables() async {
final email = AppState().email;
final name = await db
.get(key: 'userName', field: 'value')
.then((value) => value.toString());
final userUUID = await db
.get(key: 'userUUID', field: 'value')
.then((value) => value.toString());
final devUUID = await db
.get(key: 'devUUID', field: 'value')
.then((value) => value.toString());
final cliUUID = await db
.get(key: 'cliUUID', field: 'value')
.then((value) => value.toString());
final createdAt = await db
.get(key: 'devUUID', field: 'createdAt')
.then((value) => value.toString());
final url = 'https://hub.freaccess.com.br/hub/fast-pass/$cliUUID';
final freUserData = "{\"name\": \"$name\", " +
"\"email\": \"$email\"," +
"\"dev_id\": \"$devUUID\"," +
"\"created_at\": \"$createdAt\"," +
"\"updated_at\": \"0000-00-00 00:00:00\"," +
"\"status\": \"A\" }";
return {
'url': url,
'name': name,
'email': email,
'userUUID': userUUID,
'devUUID': devUUID,
'createdAt': createdAt,
'cliUUID': cliUUID,
'freUserData': freUserData,
};
}
@override
Widget build(BuildContext context) {
return SafeArea(
child: Scaffold(
body: Platform.isIOS
body: FutureBuilder<Map<String, String>>(
future: initVariables(),
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return Center(child: CircularProgressIndicator());
} else if (snapshot.hasError) {
return Center(child: Text('Error: ${snapshot.error}'));
} else if (snapshot.hasData) {
final data = snapshot.data!;
final url = data['url']!;
final userUUID = data['userUUID']!;
final freUserData = data['freUserData']!;
return Platform.isIOS
? InAppWebView(
initialUrlRequest: URLRequest(url: WebUri(url)),
initialSettings: InAppWebViewSettings(
@ -60,10 +87,10 @@ class _FastPassPageWidgetState extends State<FastPassPageWidget> {
onLoadStop: (controller, url) async {
await controller.evaluateJavascript(
source:
"window.localStorage.setItem('fre-token', '\"${widget.freToken}\"')");
"window.localStorage.setItem('fre-token', '\"$userUUID\"')");
await controller.evaluateJavascript(
source:
"window.localStorage.setItem('fre-user-data', '${widget.freUserData}')");
"window.localStorage.setItem('fre-user-data', '$freUserData')");
await controller.evaluateJavascript(
source:
"window.localStorage.setItem('enableBackButton', 'true')");
@ -85,9 +112,9 @@ class _FastPassPageWidgetState extends State<FastPassPageWidget> {
onProgress: (int progress) {},
onPageStarted: (String url) {
final String token =
"localStorage.setItem('fre-token', '\"${widget.freToken}\"');";
"localStorage.setItem('fre-token', '\"$userUUID\"');";
final String data =
"localStorage.setItem('fre-user-data', '${widget.freUserData}');";
"localStorage.setItem('fre-user-data', '$freUserData');";
const String backNavigation =
"localStorage.setItem('enableBackButton', 'true');";
@ -96,13 +123,15 @@ class _FastPassPageWidgetState extends State<FastPassPageWidget> {
_controllerAll.runJavaScript(backNavigation);
},
onPageFinished: (String url) {
bool isDarkMode = SchedulerBinding.instance
.platformDispatcher.platformBrightness ==
bool isDarkMode = SchedulerBinding
.instance
.platformDispatcher
.platformBrightness ==
Brightness.dark;
if (isDarkMode) {
_controllerAll
.runJavaScript(WebviewUtil.jsEnableDarkMode);
_controllerAll.runJavaScript(
WebviewUtil.jsEnableDarkMode);
}
},
onNavigationRequest: (NavigationRequest request) {
@ -122,6 +151,11 @@ class _FastPassPageWidgetState extends State<FastPassPageWidget> {
}),
)
..loadRequest(Uri.parse(url)),
);
} else {
return Center(child: Text('Unexpected error'));
}
},
),
),
);

View File

@ -1,12 +1,20 @@
import 'package:flutter/material.dart';
import 'package:hub/app_state.dart';
import 'package:hub/components/organism_components/local_profile_component/local_profile_component_model.dart';
import 'package:hub/components/organism_components/menu_component/menu_component_model.dart';
import 'package:hub/components/organism_components/message_well_component/message_well_component_model.dart';
import 'package:hub/flutter_flow/flutter_flow_model.dart';
import 'package:hub/pages/home_page/home_page_widget.dart';
import 'package:hub/shared/helpers/db_helper.dart';
class HomePageModel extends FlutterFlowModel<HomePageWidget> {
bool isGrid = false;
final DatabaseHelper db = DatabaseHelper();
late final String devUUID;
late final String cliUUID;
late final String userUUID;
late final String userName;
late final String userEmail;
final unfocusNode = FocusNode();
FocusNode? textFieldFocusNode;
@ -16,8 +24,25 @@ class HomePageModel extends FlutterFlowModel<HomePageWidget> {
late MenuComponentModel menuComponentModel;
late MessageWellComponentModel messageWellComponentModel;
Future<void> _initVariable() async {
devUUID = await db
.get(key: 'devUUID', field: 'value')
.then((value) => value.toString());
cliUUID = await db
.get(key: 'cliUUID', field: 'value')
.then((value) => value.toString());
userUUID = await db
.get(key: 'userUUID', field: 'value')
.then((value) => value.toString());
userName = await db
.get(key: 'userName', field: 'value')
.then((value) => value.toString());
userEmail = AppState().email;
}
@override
void initState(BuildContext context) {
_initVariable();
localComponentModel =
createModel(context, () => LocalProfileComponentModel());
menuComponentModel = createModel(context, () => MenuComponentModel());

View File

@ -1,13 +1,10 @@
import 'dart:async';
import 'dart:developer';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:hub/backend/api_requests/api_calls.dart';
import 'package:hub/backend/notifications/firebase_messaging_service.dart';
import 'package:hub/backend/schema/enums/enums.dart';
import 'package:hub/components/organism_components/bottom_arrow_linked_locals_component/bottom_arrow_linked_locals_component_widget.dart';
import 'package:hub/components/organism_components/local_profile_component/local_profile_component_widget.dart';
import 'package:hub/components/organism_components/menu_component/menu_component_widget.dart';
import 'package:hub/flutter_flow/flutter_flow_icon_button.dart';
@ -15,9 +12,7 @@ import 'package:hub/flutter_flow/flutter_flow_theme.dart';
import 'package:hub/flutter_flow/flutter_flow_util.dart';
import 'package:hub/pages/home_page/home_page_model.dart';
import 'package:hub/shared/helpers/db_helper.dart';
import 'package:hub/shared/utils/dialog_util.dart';
import 'package:hub/shared/widgets/drawer_widget/drawer_widget.dart';
import 'package:sqflite/sqflite.dart';
class HomePageWidget extends StatefulWidget {
const HomePageWidget({Key? key}) : super(key: key);
@ -33,99 +28,7 @@ class _HomePageWidgetState extends State<HomePageWidget> {
final DatabaseHelper db = DatabaseHelper();
_HomePageWidgetState() {
_localProfileComponentWidget =
LocalProfileComponentWidget(showBottomSheet: showModalSelectLocal);
}
Future<void> processData() async {
try {
final GetDadosCall callback = PhpGroup.getDadosCall;
final DatabaseHelper db = DatabaseHelper();
final devUUID = await db.get(key: 'devUUID', field: 'value');
final userUUID = await db.get(key: 'userUUID', field: 'value');
final cliUUID = await db.get(key: 'cliUUID', field: 'value');
var response = await callback.call(
devUUID: devUUID,
userUUID: userUUID,
cliUUID: cliUUID,
);
final error = response.jsonBody['error'];
// final errorMsg = response.jsonBody['error_msg'];
if (error == false) {
final whatsapp = response.jsonBody['whatsapp'] ?? false;
final provisional = response.jsonBody['provisional'] ?? false;
final pets = response.jsonBody['pet'] ?? false;
final petAmountRegister = response.jsonBody['petAmountRegister'] ?? '0';
final name = response.jsonBody['visitado']['VDO_NOME'];
await db.update('whatsapp', whatsapp.toString(), 'local');
await db.update('provisional', provisional.toString(), 'local');
await db.update('pets', pets.toString(), 'local');
await db.update('petAmountRegister', petAmountRegister, 'local');
await db.update('name', name, 'local');
safeSetState(() {});
return;
}
DialogUtil.warningDefault(context).whenComplete(() => processLocals());
safeSetState(() {});
return;
} catch (e, s) {
DialogUtil.warningDefault(context).whenComplete(() => processLocals());
}
}
Future<void> processLocals() async {
try {
final GetLocalsCall callback = PhpGroup.getLocalsCall;
final devUUID = await db.get(key: 'devUUID', field: 'value');
final userUUID = await db.get(key: 'userUUID', field: 'value');
final cliUUID = await db
.get(key: 'cliUUID', field: 'value')
.then((value) => value.toString());
var response = await callback.call(
devUUID: devUUID,
userUUID: userUUID,
);
List<dynamic> locals = response.jsonBody['locais'] ?? [];
final activeLocals =
locals.where((local) => local['CLU_STATUS'] == 'A').toList();
if (activeLocals.isEmpty || cliUUID.isEmpty) {
await showModalSelectLocal();
} else {
await processData();
}
} catch (e) {
await showModalSelectLocal();
}
}
Future<void> showModalSelectLocal() async {
await showModalBottomSheet(
isScrollControlled: true,
backgroundColor: Colors.transparent,
enableDrag: false,
isDismissible: false,
context: context,
builder: (context) => Padding(
padding: MediaQuery.viewInsetsOf(context),
child: const BottomArrowLinkedLocalsComponentWidget(),
),
).then((_) async {
_model.updatePage(() => safeSetState(() {
_localProfileComponentWidget = LocalProfileComponentWidget(
showBottomSheet: showModalSelectLocal);
}));
await processData();
});
_localProfileComponentWidget = LocalProfileComponentWidget();
}
@override
@ -143,16 +46,6 @@ class _HomePageWidgetState extends State<HomePageWidget> {
FirebaseMessagingService().updateDeviceToken();
() async {
final cliUUID = await db
.get(key: 'cliUUID', field: 'value')
.then((value) => value.toString());
if (cliUUID.isEmpty) {
log('No cliUUID found');
await processLocals();
}
}();
_model.textController ??= TextEditingController();
_model.textFieldFocusNode ??= FocusNode();
}

View File

@ -2,21 +2,21 @@ import 'package:hub/backend/api_requests/api_manager.dart';
import 'package:hub/flutter_flow/flutter_flow_model.dart';
import 'package:hub/flutter_flow/request_manager.dart';
import 'package:flutter/material.dart';
import 'package:hub/pages/liberation_history/liberation_history_widget.dart';
import 'package:hub/shared/helpers/db_helper.dart';
class LiberationHistoryModel extends FlutterFlowModel<LiberationHistoryWidget> {
/// State fields for stateful widgets in this page.
final DatabaseHelper db = DatabaseHelper();
late final String devUUID;
late final String userUUID;
late final String cliUUID;
final unfocusNode = FocusNode();
// State field(s) for TextField widget.
FocusNode? textFieldFocusNode;
TextEditingController? textController;
String? Function(BuildContext, String?)? textControllerValidator;
/// Query cache managers for this widget.
final _getLiberationsManager = StreamRequestManager<ApiCallResponse>();
Stream<ApiCallResponse> getLiberations({
String? uniqueQueryKey,
@ -33,7 +33,21 @@ class LiberationHistoryModel extends FlutterFlowModel<LiberationHistoryWidget> {
_getLiberationsManager.clearRequest(uniqueKey);
@override
void initState(BuildContext context) {}
void initState(BuildContext context) {
init();
}
Future<void> init() async {
devUUID = await db
.get(key: 'devUUID', field: 'value')
.then((value) => value.toString());
userUUID = await db
.get(key: 'userUUID', field: 'value')
.then((value) => value.toString());
cliUUID = await db
.get(key: 'cliUUID', field: 'value')
.then((value) => value.toString());
}
@override
void dispose() {
@ -41,8 +55,6 @@ class LiberationHistoryModel extends FlutterFlowModel<LiberationHistoryWidget> {
textFieldFocusNode?.dispose();
textController?.dispose();
/// Dispose query cache managers for this widget.
clearGetLiberationsCache();
}
}

View File

@ -11,6 +11,7 @@ import 'package:hub/flutter_flow/flutter_flow_theme.dart';
import 'package:hub/flutter_flow/flutter_flow_util.dart';
import 'package:hub/flutter_flow/flutter_flow_widgets.dart';
import 'package:hub/flutter_flow/nav/nav.dart';
import 'package:hub/pages/liberation_history/liberation_history_model.dart';
import 'package:hub/shared/utils/dialog_util.dart';
import 'package:hub/shared/utils/log_util.dart';
import 'package:hub/shared/utils/validator_util.dart';
@ -25,6 +26,7 @@ class LiberationHistoryWidget extends StatefulWidget {
}
class _LiberationHistoryWidgetState extends State<LiberationHistoryWidget> {
late LiberationHistoryModel _model;
final scaffoldKey = GlobalKey<ScaffoldState>();
bool _hasData = false;
bool _loading = false;
@ -35,6 +37,7 @@ class _LiberationHistoryWidgetState extends State<LiberationHistoryWidget> {
@override
void initState() {
_requestFuture = _fetchRequests();
_model = createModel(context, () => LiberationHistoryModel());
super.initState();
}
@ -49,7 +52,7 @@ class _LiberationHistoryWidgetState extends State<LiberationHistoryWidget> {
}
String _imagePath(dynamic request) {
return 'https://freaccess.com.br/freaccess/getImage.php?cliID=${AppState().cliUUID}&atividade=getFoto&Documento=${request['VTE_ID'] ?? ''}&tipo=E';
return 'https://freaccess.com.br/freaccess/getImage.php?cliID=${_model.cliUUID}&atividade=getFoto&Documento=${request['VTE_ID'] ?? ''}&tipo=E';
}
Map<String, String> _labelsHashMap(dynamic request, bool details) {
@ -326,14 +329,7 @@ class _LiberationHistoryWidgetState extends State<LiberationHistoryWidget> {
Future<ApiCallResponse?> _fetchRequests() async {
try {
setState(() => _loading = true);
var response = await PhpGroup.getLiberationsCall
.call(
devUUID: AppState().devUUID,
userUUID: AppState().userUUID,
cliID: AppState().cliUUID,
atividade: 'getSolicitacoes',
)
.first;
var response = await PhpGroup.getLiberationsCall.call().first;
final List<dynamic> requests = response.jsonBody['solicitacoes'] ?? [];

View File

@ -5,16 +5,16 @@ import 'package:hub/flutter_flow/request_manager.dart';
import 'package:flutter/material.dart';
import 'package:hub/pages/message_history_page/message_history_page_widget.dart';
import 'package:hub/shared/helpers/db_helper.dart';
class MessageHistoryPageModel
extends FlutterFlowModel<MessageHistoryPageWidget> {
/// State fields for stateful widgets in this page.
///
//copyWith
final DatabaseHelper db = DatabaseHelper();
late final String devUUID;
late final String userUUID;
late final String cliUUID;
final unfocusNode = FocusNode();
// State field(s) for TextField widget.
FocusNode? textFieldFocusNode;
TextEditingController? textController;
String? Function(BuildContext, String?)? textControllerValidator;
@ -23,8 +23,6 @@ class MessageHistoryPageModel
int get tabBarCurrentIndex =>
tabBarController != null ? tabBarController!.index : 0;
/// Query cache managers for this widget.
final _getLiberationsManager = StreamRequestManager<ApiCallResponse>();
Stream<ApiCallResponse> getLiberations({
String? uniqueQueryKey,
@ -41,7 +39,21 @@ class MessageHistoryPageModel
_getLiberationsManager.clearRequest(uniqueKey);
@override
void initState(BuildContext context) {}
void initState(BuildContext context) {
init();
}
Future<void> init() async {
devUUID = await db
.get(key: 'devUUID', field: 'value')
.then((value) => value.toString());
userUUID = await db
.get(key: 'userUUID', field: 'value')
.then((value) => value.toString());
cliUUID = await db
.get(key: 'cliUUID', field: 'value')
.then((value) => value.toString());
}
@override
void dispose() {
@ -50,8 +62,6 @@ class MessageHistoryPageModel
textController?.dispose();
tabBarController?.dispose();
/// Dispose query cache managers for this widget.
clearGetLiberationsCache();
}
}

View File

@ -99,10 +99,6 @@ class _MessageHistoryPageWidgetState extends State<MessageHistoryPageWidget>
setState(() => _loading = true);
var response = await PhpGroup.getMessagesCall.call(
devUUID: AppState().devUUID.toString(),
userUUID: AppState().userUUID.toString(),
cliID: AppState().cliUUID.toString(),
atividade: 'getMensagens',
pageSize: _pageSize.toString(),
pageNumber: _pageNumber.toString(),
tipoDestino: _destinyType,

View File

@ -9,6 +9,7 @@ import 'package:hub/components/templates_components/details_component/details_co
import 'package:hub/flutter_flow/flutter_flow_icon_button.dart';
import 'package:hub/flutter_flow/flutter_flow_theme.dart';
import 'package:hub/flutter_flow/flutter_flow_util.dart';
import 'package:hub/shared/helpers/db_helper.dart';
import 'package:hub/shared/utils/dialog_util.dart';
import 'package:hub/shared/utils/log_util.dart';
import 'package:hub/shared/utils/validator_util.dart';
@ -27,6 +28,8 @@ class _PackageOrderPage extends State<PackageOrderPage> {
final int _pageSize = 10;
bool _hasData = false;
bool _loading = false;
final DatabaseHelper db = DatabaseHelper();
late final String cliUUID;
late Future<void> _orderFuture;
List<dynamic> _orderList = [];
@ -57,6 +60,13 @@ class _PackageOrderPage extends State<PackageOrderPage> {
_loadMoreOrders();
}
});
initDatabase();
}
Future<void> initDatabase() async {
cliUUID = await db
.get(key: 'cliUUID', field: 'value')
.then((value) => value.toString());
}
@override
@ -85,10 +95,6 @@ class _PackageOrderPage extends State<PackageOrderPage> {
setState(() => _loading = true);
var response = await PhpGroup.buscaEnconcomendas.call(
devUUID: AppState().devUUID,
userUUID: AppState().userUUID,
cliID: AppState().cliUUID,
atividade: 'getEncomendas',
pageSize: _pageSize.toString(),
page: _pageNumber.toString(),
adresseeType: _adresseeType == '.*' ? 'TOD' : _adresseeType,
@ -300,7 +306,7 @@ class _PackageOrderPage extends State<PackageOrderPage> {
}
String _imagePath(dynamic order) {
return '${PhpGroup.getBaseUrl()}/getImage.php?cliID=${AppState().cliUUID}&atividade=getFotoEncomenda&orderId=${order['id'] ?? ''}';
return '${PhpGroup.getBaseUrl()}/getImage.php?cliID=$cliUUID&atividade=getFotoEncomenda&orderId=${order['id'] ?? ''}';
}
Map<String, String> _labelsHashMap(dynamic order) {

View File

@ -84,12 +84,7 @@ class _PeopleOnThePropertyPageWidgetState
body: SafeArea(
top: true,
child: FutureBuilder<ApiCallResponse>(
future: PhpGroup.getPessoasLocalCall.call(
cliID: AppState().cliUUID,
ownID: AppState().ownerUUID,
devUUID: AppState().devUUID,
userUUID: AppState().userUUID,
),
future: PhpGroup.getPessoasLocalCall.call(),
builder: (context, snapshot) {
// Customize what your widget looks like when it's loading.
if (!snapshot.hasData) {

View File

@ -5,13 +5,18 @@ import 'package:hub/components/templates_components/card_item_template_component
import 'package:hub/components/templates_components/details_component/details_component_action.dart';
import 'package:hub/flutter_flow/flutter_flow_theme.dart';
import 'package:hub/flutter_flow/flutter_flow_util.dart';
import 'package:hub/pages/liberation_history/liberation_history_model.dart';
import 'package:hub/pages/pets_page/pets_page_model.dart';
import 'package:hub/pages/schedule_complete_visit_page/schedule_complete_visit_page_model.dart';
import 'package:hub/shared/helpers/db_helper.dart';
import 'package:hub/shared/utils/dialog_util.dart';
import 'package:hub/shared/utils/log_util.dart';
import 'package:hub/shared/utils/validator_util.dart';
class PetsHistoryScreen extends StatefulWidget {
PetsHistoryScreen({Key? key}) : super(key: key);
PetsHistoryScreen({Key? key, required this.model}) : super(key: key);
final PetsPageModel model;
@override
_PetsHistoryScreenState createState() => _PetsHistoryScreenState();
@ -20,6 +25,7 @@ class PetsHistoryScreen extends StatefulWidget {
class _PetsHistoryScreenState extends State<PetsHistoryScreen>
with TickerProviderStateMixin {
late ScrollController _scrollController;
int _pageNumber = 1;
final int _pageSize = 10;
bool _hasData = false;
@ -32,6 +38,7 @@ class _PetsHistoryScreenState extends State<PetsHistoryScreen>
@override
void initState() {
super.initState();
_petsFuture = _fetchVisits();
_scrollController = ScrollController()
@ -54,10 +61,6 @@ class _PetsHistoryScreenState extends State<PetsHistoryScreen>
setState(() => _loading = true);
var response = await PhpGroup.getPets.call(
devUUID: AppState().devUUID,
userUUID: AppState().userUUID,
cliID: AppState().cliUUID,
atividade: 'consultaPets',
pageSize: _pageSize,
page: _pageNumber,
);
@ -151,10 +154,10 @@ class _PetsHistoryScreenState extends State<PetsHistoryScreen>
return Padding(
padding: EdgeInsets.only(right: 30, top: 10),
child: Text(
AppState().petAmountRegister == 0
widget.model.petAmountRegister == '0'
? FFLocalizations.of(context).getVariableText(
ptText: "Ilimitado", enText: "Unlimited")
: "${FFLocalizations.of(context).getVariableText(ptText: "Quantidade de Pets: ", enText: "Amount of Pets: ")}${count}/${AppState().petAmountRegister}",
: "${FFLocalizations.of(context).getVariableText(ptText: "Quantidade de Pets: ", enText: "Amount of Pets: ")}$count/${widget.model.petAmountRegister}",
textAlign: TextAlign.right,
),
);
@ -183,7 +186,7 @@ class _PetsHistoryScreenState extends State<PetsHistoryScreen>
Widget _item(BuildContext context, dynamic uItem) {
return CardItemTemplateComponentWidget(
imagePath:
'https://freaccess.com.br/freaccess/getImage.php?devUUID=${AppState().devUUID}&userUUID=${AppState().userUUID}&cliID=${AppState().cliUUID}&atividade=consultaFotoPet&petId=${uItem['id'] ?? ''}',
'https://freaccess.com.br/freaccess/getImage.php?devUUID=${widget.model.devUUID}&userUUID=${widget.model.userUUID}&cliID=${widget.model.cliUUID}&atividade=consultaFotoPet&petId=${uItem['id'] ?? ''}',
labelsHashMap: {
'${FFLocalizations.of(context).getVariableText(ptText: "Nome", enText: "Name")}:':
uItem['name'] ?? '',
@ -242,6 +245,19 @@ class _PetsHistoryScreenState extends State<PetsHistoryScreen>
}
],
onTapCardItemAction: () async {
final DatabaseHelper db = DatabaseHelper();
final cliUUID = await db
.get(key: 'cliUUID', field: 'value')
.then((value) => value.toString());
final cliName = await db
.get(key: 'cliName', field: 'value')
.then((value) => value.toString());
final devUUID = await db
.get(key: 'devUUID', field: 'value')
.then((value) => value.toString());
final userUUID = await db
.get(key: 'userUUID', field: 'value')
.then((value) => value.toString());
await showDialog(
useSafeArea: true,
context: context,
@ -249,9 +265,14 @@ class _PetsHistoryScreenState extends State<PetsHistoryScreen>
return Dialog(
alignment: Alignment.center,
child: buildPetDetails(
uItem,
context,
changeStatusAction,
item: uItem,
context: context,
changeStatusAction: changeStatusAction,
devUUID: devUUID,
userUUID: userUUID,
cliUUID: cliUUID,
cliName: cliName,
model: widget.model,
),
);
},

View File

@ -1,19 +1,32 @@
import 'dart:convert';
import 'dart:developer';
import 'package:flutter/material.dart';
import 'package:http/http.dart';
import 'package:hub/backend/api_requests/api_calls.dart';
import 'package:hub/backend/api_requests/api_manager.dart';
import 'package:hub/custom_code/actions/convert_to_upload_file.dart';
import 'package:hub/flutter_flow/flutter_flow_util.dart';
import 'package:hub/flutter_flow/form_field_controller.dart';
import 'package:hub/pages/pets_page/pets_page_widget.dart';
import 'package:hub/shared/helpers/db_helper.dart';
import 'package:hub/shared/utils/dialog_util.dart';
import 'package:hub/shared/utils/log_util.dart';
import 'package:hub/shared/utils/validator_util.dart';
import '/custom_code/actions/index.dart' as actions;
class PetsPageModel extends FlutterFlowModel<PetsPageWidget> {
final DatabaseHelper db = DatabaseHelper();
late final String devUUID;
late final String userUUID;
late final String cliUUID;
late final String petAmountRegister;
dynamic item;
late final TabController tabBarController;
VoidCallback? onUpdatePet;
VoidCallback? onRegisterPet;
VoidCallback? safeSetState;
VoidCallback? updateImage;
final GlobalKey<FormState> registerFormKey = GlobalKey<FormState>();
final GlobalKey<FormState> updateFormKey = GlobalKey<FormState>();
@ -23,19 +36,17 @@ class PetsPageModel extends FlutterFlowModel<PetsPageWidget> {
BuildContext? buildContext;
bool isEditing = false;
// Controller para o Upload de Arquivos
bool isDataUploading = false;
FFUploadedFile? uploadedLocalFile;
FFUploadedFile? uploadedTempFile;
String? imgBase64;
// Controller para o DropDown
String? dropDownValue1;
FormFieldController<String>? dropDownValueController1;
String? dropDownValue2;
FormFieldController<String>? dropDownValueController2;
// Controller para o TextField
FocusNode? textFieldFocusName;
TextEditingController? textControllerName;
String? textControllerNameValidator(BuildContext context, String? val) {
@ -87,9 +98,25 @@ class PetsPageModel extends FlutterFlowModel<PetsPageWidget> {
TextEditingController? textControllerObservation;
String? Function(BuildContext, String?)? textControllerObservationValidator;
Future<void> initAsync() async {
devUUID = await db.get(key: 'devUUID', field: 'value').then((value) {
return value.toString();
});
userUUID = await db.get(key: 'userUUID', field: 'value').then((value) {
return value.toString();
});
cliUUID = await db.get(key: 'cliUUID', field: 'value').then((value) {
return value.toString();
});
petAmountRegister = await db
.get(key: 'petAmountRegister', field: 'value')
.then((value) => value.toString());
safeSetState?.call();
}
@override
void initState(BuildContext context) {
// Se liga! Esse é o controller do TabBar
tabBarController = TabController(
vsync: Navigator.of(context),
length: 2,
@ -97,8 +124,6 @@ class PetsPageModel extends FlutterFlowModel<PetsPageWidget> {
textFieldFocusName = FocusNode();
textControllerName = TextEditingController();
// textControllerNameValidator =
// (context, value) => _textControllerNameValidator(context, value);
textFieldFocusSpecies = FocusNode();
textControllerSpecies = TextEditingController();
@ -124,6 +149,66 @@ class PetsPageModel extends FlutterFlowModel<PetsPageWidget> {
dropDownValueController2 =
FormFieldController<String>(dropDownValue2 ??= 'Selecione uma opção');
initAsync();
}
void setEditForm() {
log('item: $item');
if (item != null) petId = item['id'];
// updateImage!();
(() async {
Response response = await get(Uri.parse(
'https://freaccess.com.br/freaccess/getImage.php?devUUID=$devUUID&userUUID=$userUUID&cliID=$cliUUID&atividade=consultaFotoPet&petId=$petId'));
String base64 = base64Encode(response.bodyBytes);
uploadedTempFile = await convertToUploadFile(base64);
updateImage?.call();
})();
textControllerName =
TextEditingController(text: item != null ? item['name'] ?? '' : '');
textFieldFocusName = FocusNode();
textControllerSpecies =
TextEditingController(text: item != null ? item['species'] ?? '' : '');
textFieldFocusSpecies = FocusNode();
textControllerRace =
TextEditingController(text: item != null ? item['breed'] ?? '' : '');
textFieldFocusRace = FocusNode();
textControllerColor =
TextEditingController(text: item != null ? item['color'] ?? '' : '');
textFieldFocusColor = FocusNode();
textControllerData = TextEditingController(
text: item != null
? item['birthdayDate'] != null
? ValidatorUtil.formatDateTimePicker(item['birthdayDate'])
: dateTimeFormat(
'dd/MM/yyyy',
DateTime.now(),
)
: dateTimeFormat(
'dd/MM/yyyy',
DateTime.now(),
));
textFieldFocusData = FocusNode();
textControllerObservation =
TextEditingController(text: item != null ? item['notes'] ?? '' : '');
textFieldFocusObservation = FocusNode();
item != null ? dropDownValue1 = item['gender'] ?? '' : dropDownValue1 = '';
item != null ? dropDownValue2 = item['size'] ?? '' : dropDownValue2 = '';
dropDownValueController1 = FormFieldController<String>(dropDownValue1);
dropDownValueController2 = FormFieldController<String>(dropDownValue2);
}
@override
@ -152,7 +237,6 @@ class PetsPageModel extends FlutterFlowModel<PetsPageWidget> {
dropDownValueController2?.dispose();
}
// Validador do formulário
bool isFormValid(BuildContext context) {
if (uploadedLocalFile == null || uploadedLocalFile!.bytes!.isEmpty) {
return false;
@ -188,9 +272,6 @@ class PetsPageModel extends FlutterFlowModel<PetsPageWidget> {
img = "base64;jpeg,$img";
await PhpGroup.updatePet
.call(
cliID: AppState().cliUUID,
devUUID: AppState().devUUID,
userUUID: AppState().userUUID,
petID: petId,
image: img,
birthdayDate: textControllerData!.text,
@ -224,9 +305,6 @@ class PetsPageModel extends FlutterFlowModel<PetsPageWidget> {
img = "base64;jpeg,$img";
await PhpGroup.registerPet
.call(
cliID: AppState().cliUUID,
devUUID: AppState().devUUID,
userUUID: AppState().userUUID,
image: img,
birthdayDate: textControllerData!.text,
color: textControllerColor!.text,
@ -270,6 +348,7 @@ class PetsPageModel extends FlutterFlowModel<PetsPageWidget> {
void switchTab(int index) {
tabBarController.animateTo(index);
if (index == 1) handleEditingChanged(false);
safeSetState?.call();
}
void handleUploadComplete(FFUploadedFile uploadedFile) {

View File

@ -55,8 +55,9 @@ class _PetsPageWidgetState extends State<PetsPageWidget>
@override
void initState() {
super.initState();
_model = PetsPageModel();
_model.tabBarController = TabController(length: 2, vsync: this);
_model = createModel(context, () => PetsPageModel());
_model.updateOnChange = true;
_model.onUpdatePet = () {
safeSetState(() {
_model.clearFields();
@ -70,10 +71,9 @@ class _PetsPageWidgetState extends State<PetsPageWidget>
_model.safeSetState = () {
safeSetState(() {});
};
widget.pet != null ? _model.isEditing = true : _model.isEditing = false;
// _handleUploadComplete(actions.convertToUploadFile())
_model.updateImage = () => setState(() {
_model.handleUploadComplete(_model.uploadedTempFile!);
});
if (widget.pet != null) {
int petId = widget.pet['id'];
@ -81,7 +81,7 @@ class _PetsPageWidgetState extends State<PetsPageWidget>
(() async {
Response response = await get(Uri.parse(
'https://freaccess.com.br/freaccess/getImage.php?devUUID=${AppState().devUUID}&userUUID=${AppState().userUUID}&cliID=${AppState().cliUUID}&atividade=consultaFotoPet&petId=$petId'));
'https://freaccess.com.br/freaccess/getImage.php?devUUID=${_model.devUUID}&userUUID=${_model.userUUID}&cliID=${_model.cliUUID}&atividade=consultaFotoPet&petId=$petId'));
String base64 = base64Encode(response.bodyBytes);
FFUploadedFile uploadedFile = await convertToUploadFile(base64);
setState(() {
@ -178,7 +178,7 @@ class _PetsPageWidgetState extends State<PetsPageWidget>
widget1: _model.isEditing
? _buildEditForm(context)
: _buildRegisterForm(context),
widget2: PetsHistoryScreen(),
widget2: PetsHistoryScreen(model: _model),
onEditingChanged: onEditingChanged,
);
}

View File

@ -1,15 +1,28 @@
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:hub/app_state.dart';
import 'package:hub/flutter_flow/flutter_flow_icon_button.dart';
import 'package:hub/flutter_flow/flutter_flow_theme.dart';
import 'package:hub/flutter_flow/flutter_flow_util.dart';
import 'package:hub/flutter_flow/internationalization.dart';
import 'package:hub/flutter_flow/nav/nav.dart';
import 'package:hub/pages/preferences_settings_page/preferences_settings_model.dart';
import 'package:hub/shared/helpers/db_helper.dart';
import 'package:provider/provider.dart';
class PreferencesPageWidget extends StatelessWidget {
const PreferencesPageWidget({super.key});
class PreferencesPageWidget extends StatefulWidget {
PreferencesPageWidget();
@override
_PreferencesPageWidgetState createState() => _PreferencesPageWidgetState();
}
class _PreferencesPageWidgetState extends State<PreferencesPageWidget> {
final DatabaseHelper db = DatabaseHelper();
@override
void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {
@ -65,7 +78,7 @@ class PreferencesPageWidget extends StatelessWidget {
Expanded(
flex: 2,
child: ListView.builder(
itemCount: 7, // Assuming 4 items for simplicity
itemCount: 7, // Assuming 7 items for simplicity
padding: const EdgeInsets.symmetric(horizontal: 20.0),
physics: const AlwaysScrollableScrollPhysics(),
itemBuilder: (BuildContext context, int index) {
@ -91,9 +104,8 @@ class PreferencesPageWidget extends StatelessWidget {
switch (index) {
case 0:
icon = Icons.fingerprint;
onPressed = () =>
model.toggleFingerprint(context); // Disable if fingerprint is false
isEnabled = AppState().fingerprint;
onPressed = () => model.toggleFingerprint(context);
isEnabled = model.fingerprint;
content = FFLocalizations.of(context).getVariableText(
ptText:
'Ative a autenticação por impressão digital para login seguro.',
@ -103,7 +115,7 @@ class PreferencesPageWidget extends StatelessWidget {
case 1:
icon = Icons.person;
onPressed = () => model.enablePerson(context);
isEnabled = AppState().person;
isEnabled = model.person;
content = FFLocalizations.of(context).getVariableText(
ptText: 'Compartilhe o código de identificação remota',
enText: 'Share the remote identification code',
@ -112,7 +124,7 @@ class PreferencesPageWidget extends StatelessWidget {
case 2:
icon = Icons.notifications;
onPressed = () => model.toggleNotify(context);
isEnabled = AppState().notify;
isEnabled = model.notify;
content = FFLocalizations.of(context).getVariableText(
ptText: 'Ative para receber sua notificação de acesso',
enText: 'Enable to receive your access notification',
@ -120,8 +132,8 @@ class PreferencesPageWidget extends StatelessWidget {
break;
case 3:
icon = Icons.lock;
// onLongPress = model.togglePass(context, model);
isEnabled = AppState().pass;
onPressed = () => model.toggleAccess(context);
isEnabled = model.access;
content = FFLocalizations.of(context).getVariableText(
ptText: 'Ative para inserir uma credencial de acesso para o QRCode',
enText: 'Enable to enter an access credential for the QRCode',
@ -129,11 +141,11 @@ class PreferencesPageWidget extends StatelessWidget {
break;
case 4:
icon = Icons.lock_clock_sharp;
// onLongPress = model.togglePass(context, model);
isEnabled = AppState().panic;
onPressed = () => model.togglePanic(context);
isEnabled = model.panic;
content = FFLocalizations.of(context).getVariableText(
ptText: 'Ative para inserir uma credencial de pânico para o QRCode',
enText: 'Enable to enter an panic credential for the QRCode',
enText: 'Enable to enter a panic credential for the QRCode',
);
break;
case 5:
@ -177,7 +189,7 @@ class PreferencesPageWidget extends StatelessWidget {
onTap: () {
switch (index) {
case 3:
model.togglePass(context);
model.toggleAccess(context);
break;
case 4:
model.togglePanic(context);
@ -197,14 +209,6 @@ class PreferencesPageWidget extends StatelessWidget {
color: isEnabled
? FlutterFlowTheme.of(context).primaryBackground
: FlutterFlowTheme.of(context).primary,
// icon: Icon(icon, color: isEnabled ? FlutterFlowTheme.of(context).primaryBackground : FlutterFlowTheme.of(context).primary, size: 40.0),
// onPressed: index != 3 ? onPressed : () {model.togglePass(context);},
// borderRadius: 20.0,
// borderWidth: 1.0,
// buttonSize: 40.0,
// fillColor: isEnabled ? FlutterFlowTheme.of(context).primary : FlutterFlowTheme.of(context).alternate,
// disabledColor: FlutterFlowTheme.of(context).alternate,
// disabledIconColor: FlutterFlowTheme.of(context).primary,
),
),
SizedBox(width: 8.0),
@ -227,4 +231,28 @@ class PreferencesPageWidget extends StatelessWidget {
),
);
}
void logout(BuildContext context) async {
showAlertDialog(
context,
'Logout',
FFLocalizations.of(context).getVariableText(
enText: 'Are you sure you want to logout?',
ptText: 'Tem certeza',
), () async {
AppState().deleteAll();
// setState(() {});
context.go(
'/welcomePage',
extra: <String, dynamic>{
kTransitionInfoKey: const TransitionInfo(
hasTransition: true,
transitionType: PageTransitionType.scale,
alignment: Alignment.bottomCenter,
),
},
);
});
}
}

View File

@ -17,20 +17,15 @@ class ProvisionalSchedule extends StatefulWidget {
}
class _ProvisionalScheduleState extends State<ProvisionalSchedule> {
late ScheduleProvisionalVisitPageModel _model;
final scaffoldKey = GlobalKey<ScaffoldState>();
@override
void initState() {
super.initState();
_model = createModel(context, () => ScheduleProvisionalVisitPageModel());
}
@override
void dispose() {
_model.dispose();
super.dispose();
}

View File

@ -2,6 +2,7 @@ import 'dart:async';
import 'package:flutter/material.dart';
import 'package:hub/flutter_flow/flutter_flow_model.dart';
import 'package:hub/pages/qr_code_page/qr_code_page_widget.dart';
import 'package:hub/shared/helpers/db_helper.dart';
class QrCodePageModel extends FlutterFlowModel<QrCodePageWidget> {
/// Local state fields for this page.
@ -11,13 +12,27 @@ class QrCodePageModel extends FlutterFlowModel<QrCodePageWidget> {
String? key = null;
DateTime? time;
final DatabaseHelper db = DatabaseHelper();
late final bool isFingerprint;
late final String userDevUUID;
/// State fields for stateful widgets in this page.
final unfocusNode = FocusNode();
@override
void initState(BuildContext context) {}
void initState(BuildContext context) {
initVariable();
}
Future<void> initVariable() async {
isFingerprint = await db
.get(key: 'fingerprint', field: 'value')
.then((value) => value.toString() == 'true');
userDevUUID = await db
.get(key: 'userDevUUID', field: 'value')
.then((value) => value.toString());
}
@override
void dispose() {

View File

@ -16,6 +16,7 @@ import 'package:hub/flutter_flow/flutter_flow_util.dart';
import 'package:hub/flutter_flow/flutter_flow_widgets.dart';
import 'package:hub/flutter_flow/nav/nav.dart';
import 'package:hub/pages/qr_code_page/qr_code_page_model.dart';
import 'package:hub/shared/helpers/db_helper.dart';
import 'package:percent_indicator/circular_percent_indicator.dart';
// import 'package:percent_indicator/percent_indicator.dart';
@ -140,14 +141,15 @@ class _QrCodePageWidgetState extends State<QrCodePageWidget>
safeSetState(() async {
_resetAnimationAndToggleAccess();
});
AppState().fingerprint
_model.isFingerprint
? await _showBiometricsAuth(context)
: await _showQrCodeBottomSheet(context);
},
child: buildQrCode(
dimension: dimension,
errorCorrectLevel: QrErrorCorrectLevel.M,
identifier: AppState().userDevUUID,
identifier: _model.userDevUUID,
pass: _model.key!,
direction: 5,
),
@ -195,7 +197,7 @@ class _QrCodePageWidgetState extends State<QrCodePageWidget>
alignment: const AlignmentDirectional(0.0, 0.0),
child: FFButtonWidget(
onPressed: () async {
AppState().fingerprint
_model.isFingerprint
? await _showBiometricsAuth(context)
: await _showQrCodeBottomSheet(context);
},

View File

@ -1,16 +1,21 @@
import 'package:flutter/material.dart';
import 'package:hub/app_state.dart';
import 'package:hub/flutter_flow/internationalization.dart';
import 'package:hub/shared/helpers/db_helper.dart';
import 'package:share_plus/share_plus.dart';
class ReceptionPageModel with ChangeNotifier {
void getIdenfifier(BuildContext context) {
Future<void> getIdenfifier(BuildContext context) async {
final DatabaseHelper db = DatabaseHelper();
final String userDevUUID = await db
.get(key: 'userDevUUID', field: 'value')
.then((value) => value.toString());
notifyListeners();
Share.share(
FFLocalizations.of(context).getVariableText(
ptText:
'Este é o meu identificador de acesso: ${AppState().userDevUUID}',
enText: 'This is my access identifier: ${AppState().userDevUUID}',
ptText: 'Este é o meu identificador de acesso: ${userDevUUID}',
enText: 'This is my access identifier: ${userDevUUID}',
),
);
}

View File

@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:hub/backend/api_requests/api_calls.dart';
import 'package:hub/components/atomic_components/shared_components_atoms/atom_image_svg_theme.dart';
import 'package:hub/flutter_flow/flutter_flow_theme.dart';
import 'package:hub/flutter_flow/flutter_flow_util.dart';
@ -141,6 +142,7 @@ class _ReceptionPageWidgetState extends State<ReceptionPageWidget> {
padding: const EdgeInsets.fromLTRB(60, 0, 60, 0),
child: FFButtonWidget(
onPressed: () async {
PhpGroup.unregisterDevice();
AppState().deleteAll();
setState(() {});

View File

@ -5,49 +5,81 @@ import 'package:flutter/scheduler.dart';
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
import 'package:hub/app_state.dart';
import 'package:hub/flutter_flow/nav/nav.dart';
import 'package:hub/shared/helpers/db_helper.dart';
import 'package:hub/shared/utils/webview_util.dart';
import 'package:sqflite/sqflite.dart';
import 'package:url_launcher/url_launcher_string.dart';
import 'package:webview_flutter/webview_flutter.dart';
class ReservationPageWidget extends StatefulWidget {
final String freToken = AppState().userUUID;
final String freUserData = "{\"name\": \"${AppState().name}\", " +
"\"email\": \"${AppState().email}\"," +
"\"dev_id\": \"${AppState().devUUID}\"," +
"\"created_at\": \"${AppState().createdAt}\"," +
"\"updated_at\": \"0000-00-00 00:00:00\"," +
"\"status\": \"A\" }";
final String clientId = AppState().cliUUID;
@override
_ReservationPageWidgetState createState() => _ReservationPageWidgetState();
}
class _ReservationPageWidgetState extends State<ReservationPageWidget> {
final DatabaseHelper db = DatabaseHelper();
late InAppWebViewController _controllerIOS;
late WebViewController _controllerAll;
late String url;
late String name;
late String email;
late String userUUID;
late String created_at;
@override
void initState() {
super.initState();
name = AppState().name;
email = AppState().email;
userUUID = AppState().userUUID;
created_at = AppState().createdAt;
url = 'https://hub.freaccess.com.br/hub/reservation/${widget.clientId}';
Future<Map<String, String>> initVariables() async {
final email = await db
.get(key: 'email', field: 'value')
.then((value) => value.toString());
final name = await db
.get(key: 'userName', field: 'value')
.then((value) => value.toString());
final userUUID = await db
.get(key: 'userUUID', field: 'value')
.then((value) => value.toString());
final devUUID = await db
.get(key: 'devUUID', field: 'value')
.then((value) => value.toString());
final createdAt = await db
.get(key: 'devUUID', field: 'createdAt')
.then((value) => value.toString());
final clientId = await db
.get(key: 'cliUUID', field: 'value')
.then((value) => value.toString());
final url = 'https://hub.freaccess.com.br/hub/reservation/$clientId';
final freUserData = "{\"name\": \"$name\", " +
"\"email\": \"$email\"," +
"\"dev_id\": \"$devUUID\"," +
"\"created_at\": \"$createdAt\"," +
"\"updated_at\": \"0000-00-00 00:00:00\"," +
"\"status\": \"A\" }";
return {
'url': url,
'name': name,
'email': email,
'userUUID': userUUID,
'devUUID': devUUID,
'createdAt': createdAt,
'clientId': clientId,
'freUserData': freUserData,
};
}
@override
Widget build(BuildContext context) {
return SafeArea(
child: Scaffold(
body: Platform.isIOS
body: FutureBuilder<Map<String, String>>(
future: initVariables(),
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return Center(child: CircularProgressIndicator());
} else if (snapshot.hasError) {
return Center(child: Text('Error: ${snapshot.error}'));
} else if (snapshot.hasData) {
final data = snapshot.data!;
final url = data['url']!;
final userUUID = data['userUUID']!;
final freUserData = data['freUserData']!;
return Platform.isIOS
? InAppWebView(
initialUrlRequest: URLRequest(url: WebUri(url)),
initialSettings: InAppWebViewSettings(
@ -60,10 +92,10 @@ class _ReservationPageWidgetState extends State<ReservationPageWidget> {
onLoadStop: (controller, url) async {
await controller.evaluateJavascript(
source:
"window.localStorage.setItem('fre-token', '\"${widget.freToken}\"')");
"window.localStorage.setItem('fre-token', '\"$userUUID\"')");
await controller.evaluateJavascript(
source:
"window.localStorage.setItem('fre-user-data', '${widget.freUserData}')");
"window.localStorage.setItem('fre-user-data', '$freUserData')");
await controller.evaluateJavascript(
source:
"window.localStorage.setItem('enableBackButton', 'true')");
@ -85,9 +117,9 @@ class _ReservationPageWidgetState extends State<ReservationPageWidget> {
onProgress: (int progress) {},
onPageStarted: (String url) {
final String token =
"localStorage.setItem('fre-token', '\"${widget.freToken}\"');";
"localStorage.setItem('fre-token', '\"$userUUID\"');";
final String data =
"localStorage.setItem('fre-user-data', '${widget.freUserData}');";
"localStorage.setItem('fre-user-data', '$freUserData');";
const String backNavigation =
"localStorage.setItem('enableBackButton', 'true');";
@ -96,13 +128,15 @@ class _ReservationPageWidgetState extends State<ReservationPageWidget> {
_controllerAll.runJavaScript(backNavigation);
},
onPageFinished: (String url) {
bool isDarkMode = SchedulerBinding.instance
.platformDispatcher.platformBrightness ==
bool isDarkMode = SchedulerBinding
.instance
.platformDispatcher
.platformBrightness ==
Brightness.dark;
if (isDarkMode) {
_controllerAll
.runJavaScript(WebviewUtil.jsEnableDarkMode);
_controllerAll.runJavaScript(
WebviewUtil.jsEnableDarkMode);
}
},
onNavigationRequest: (NavigationRequest request) {
@ -122,6 +156,11 @@ class _ReservationPageWidgetState extends State<ReservationPageWidget> {
}),
)
..loadRequest(Uri.parse(url)),
);
} else {
return Center(child: Text('Unexpected error'));
}
},
),
),
);

View File

@ -9,11 +9,17 @@ import 'package:hub/flutter_flow/request_manager.dart';
import 'package:flutter/material.dart';
import 'package:hub/pages/schedule_complete_visit_page/schedule_complete_visit_page_widget.dart';
import 'package:hub/shared/helpers/db_helper.dart';
import 'package:intl/intl.dart';
class ScheduleCompleteVisitPageModel
extends FlutterFlowModel<ScheduleCompleteVisitPageWidget> {
final _visitHistoryManager = FutureRequestManager<ApiCallResponse>();
final DatabaseHelper db = DatabaseHelper();
late final String devUUID;
late final String cliUUID;
late final String userUUID;
Future<ApiCallResponse> visitHistory({
String? uniqueQueryKey,
bool? overrideCache,
@ -187,8 +193,21 @@ class ScheduleCompleteVisitPageModel
return null;
}
Future<void> _initVariables() async {
devUUID = await db
.get(key: 'devUUID', field: 'value')
.then((value) => value.toString());
cliUUID = await db
.get(key: 'cliUUID', field: 'value')
.then((value) => value.toString());
userUUID = await db
.get(key: 'userUUID', field: 'value')
.then((value) => value.toString());
}
@override
void initState(BuildContext context) {
_initVariables();
tabBarController = TabController(
vsync: Navigator.of(context),
length: 2,

View File

@ -868,7 +868,7 @@ Widget scheduleVisit(BuildContext context,
fadeOutDuration:
const Duration(milliseconds: 500),
imageUrl:
"https://freaccess.com.br/freaccess/getImage.php?devUUID=${AppState().devUUID}&userUUID=${AppState().userUUID}&cliID=${AppState().cliUUID}&atividade=getFoto&Documento=${getJsonField(visitorListViewItem, r'''$.VTE_DOCUMENTO''').toString()}&tipo=E",
"https://freaccess.com.br/freaccess/getImage.php?devUUID=${_model.devUUID}&userUUID=${_model.userUUID}&cliID=${_model.cliUUID}&atividade=getFoto&Documento=${getJsonField(visitorListViewItem, r'''$.VTE_DOCUMENTO''').toString()}&tipo=E",
fit: BoxFit.cover,
),
),
@ -1081,12 +1081,7 @@ Widget scheduleVisit(BuildContext context,
height: 45.0,
decoration: const BoxDecoration(),
child: FutureBuilder<ApiCallResponse>(
future: PhpGroup.getDadosCall.call(
devUUID: AppState().devUUID,
userUUID: AppState().userUUID,
cliUUID: AppState().cliUUID,
atividade: 'getDados',
),
future: PhpGroup.getDadosCall.call(),
builder: (context, snapshot) {
if (!snapshot.hasData) {
return Center(
@ -1232,12 +1227,7 @@ Widget scheduleVisit(BuildContext context,
height: 45.0,
decoration: const BoxDecoration(),
child: FutureBuilder<ApiCallResponse>(
future: PhpGroup.getDadosCall.call(
devUUID: AppState().devUUID,
userUUID: AppState().userUUID,
cliUUID: AppState().cliUUID,
atividade: 'getDados',
),
future: PhpGroup.getDadosCall.call(),
builder: (context, snapshot) {
// Customize what your widget looks like when it's loading.
if (!snapshot.hasData) {
@ -1612,9 +1602,6 @@ Widget scheduleVisit(BuildContext context,
Future<void> scheduleVisit() async {
await PhpGroup.postScheduleVisitCall
.call(
devUUID: AppState().devUUID,
userUUID: AppState().userUUID,
atividade: 'putVisita',
devDesc: _model.textController3.text,
idVisitante: _model.visitorStrList,
dtInicio: _model
@ -1625,7 +1612,6 @@ Widget scheduleVisit(BuildContext context,
idMotivo: extractIdToStr(_model.dropDownValue1!),
idNAC: extractIdToStr(_model.dropDownValue2!),
obs: _model.textController3.text,
cliID: AppState().cliUUID,
)
.catchError((e) async {
await DialogUtil.errorDefault(context);
@ -1719,7 +1705,7 @@ Widget scheduleVisit(BuildContext context,
),
],
imagePath:
'https://freaccess.com.br/freaccess/getImage.php?cliID=${AppState().cliUUID}&atividade=getFoto&Documento=${_model.visitorJsonList[0]['VTE_DOCUMENTO'] ?? ''}&tipo=E',
'https://freaccess.com.br/freaccess/getImage.php?cliID=${_model.cliUUID}&atividade=getFoto&Documento=${_model.visitorJsonList[0]['VTE_DOCUMENTO'] ?? ''}&tipo=E',
labelsHashMap: {
'Nome': _model.visitorJsonList[0]['VTE_NOME'],
'Start': _model.textController1.text,

View File

@ -6,6 +6,7 @@ import 'package:hub/components/templates_components/details_component/details_co
import 'package:hub/flutter_flow/flutter_flow_theme.dart';
import 'package:hub/flutter_flow/flutter_flow_util.dart';
import 'package:hub/pages/schedule_complete_visit_page/schedule_complete_visit_page_model.dart';
import 'package:hub/shared/helpers/db_helper.dart';
import 'package:hub/shared/utils/dialog_util.dart';
import 'package:hub/shared/utils/log_util.dart';
import 'package:hub/shared/utils/validator_util.dart';
@ -19,6 +20,10 @@ class VisitHistoryWidget extends StatefulWidget {
class _VisitHistoryWidgetState extends State<VisitHistoryWidget>
with TickerProviderStateMixin {
final DatabaseHelper db = DatabaseHelper();
late final String devUUID;
late final String userUUID;
late final String cliUUID;
late ScrollController _scrollController;
int _pageNumber = 1;
final int _pageSize = 10;
@ -28,9 +33,22 @@ class _VisitHistoryWidgetState extends State<VisitHistoryWidget>
late Future<void> _visitFuture;
List<dynamic> _visitWrap = [];
Future<void> _initVariables() async {
devUUID = await db
.get(key: 'devUUID', field: 'value')
.then((value) => value.toString());
userUUID = await db
.get(key: 'userUUID', field: 'value')
.then((value) => value.toString());
cliUUID = await db
.get(key: 'cliUUID', field: 'value')
.then((value) => value.toString());
}
@override
void initState() {
super.initState();
_initVariables();
_visitFuture = _fetchVisits();
_scrollController = ScrollController()
@ -54,10 +72,6 @@ class _VisitHistoryWidgetState extends State<VisitHistoryWidget>
var response = await ScheduleCompleteVisitPageModel().visitHistory(
requestFn: () => PhpGroup.getVisitsCall.call(
devUUID: AppState().devUUID,
userUUID: AppState().userUUID,
cliID: AppState().cliUUID,
atividade: 'getVisitas',
pageSize: _pageSize,
pageNumber: _pageNumber,
),
@ -168,7 +182,7 @@ class _VisitHistoryWidgetState extends State<VisitHistoryWidget>
Widget _item(BuildContext context, dynamic visitaWrapItem) {
return CardItemTemplateComponentWidget(
imagePath:
'https://freaccess.com.br/freaccess/getImage.php?devUUID=${AppState().devUUID}&userUUID=${AppState().userUUID}&cliID=${AppState().cliUUID}&atividade=getFoto&Documento=${visitaWrapItem['VTE_DOCUMENTO'] ?? ''}&tipo=E',
'https://freaccess.com.br/freaccess/getImage.php?devUUID=$devUUID&userUUID=$userUUID&cliID=$cliUUID&atividade=getFoto&Documento=${visitaWrapItem['VTE_DOCUMENTO'] ?? ''}&tipo=E',
labelsHashMap: {
'${FFLocalizations.of(context).getVariableText(ptText: "Nome", enText: "Name")}:':
visitaWrapItem['VTE_NOME'] ?? '',
@ -230,6 +244,19 @@ class _VisitHistoryWidgetState extends State<VisitHistoryWidget>
},
],
onTapCardItemAction: () async {
final DatabaseHelper db = DatabaseHelper();
final cliUUID = await db
.get(key: 'cliUUID', field: 'value')
.then((value) => value.toString());
final cliName = await db
.get(key: 'cliName', field: 'value')
.then((value) => value.toString());
final devUUID = await db
.get(key: 'devUUID', field: 'value')
.then((value) => value.toString());
final userUUID = await db
.get(key: 'userUUID', field: 'value')
.then((value) => value.toString());
await showDialog(
useSafeArea: true,
context: context,
@ -237,9 +264,13 @@ class _VisitHistoryWidgetState extends State<VisitHistoryWidget>
return Dialog(
alignment: Alignment.center,
child: buildVisitDetails(
visitaWrapItem,
context,
changeStatusAction,
item: visitaWrapItem,
context: context,
changeStatusAction: changeStatusAction,
devUUID: devUUID,
userUUID: userUUID,
cliUUID: cliUUID,
cliName: cliName,
),
);
},

View File

@ -28,13 +28,13 @@ class _WelcomePageWidgetState extends State<WelcomePageWidget> {
// On page load action.
SchedulerBinding.instance.addPostFrameCallback((_) async {
if (isAndroid == true) {
AppState().device = 'Android';
AppState().deviceType = 'Android';
setState(() {});
} else if (isiOS == true) {
AppState().device = 'iOS';
AppState().deviceType = 'iOS';
setState(() {});
} else {
AppState().device = 'Web';
AppState().deviceType = 'Web';
setState(() {});
}
});

View File

@ -19,6 +19,22 @@ class DatabaseHelper {
return _database!;
}
Future<void> _onUpgrade(Database db, int oldVersion, int newVersion) async {
log('Upgrading database from version $oldVersion to $newVersion');
// if (oldVersion < 2) {
// // await db.execute('ALTER TABLE keychain ADD COLUMN newColumn TEXT');
// }
}
Future<void> _onDowngrade(Database db, int oldVersion, int newVersion) async {
log('Downgrading database from version $oldVersion to $newVersion');
}
Future<void> _onConfigure(Database db) async {
log('Configuring database...');
}
Future<Database> _initDatabase() async {
final path = await _getDatabasePath();
log('Database path: $path');
@ -27,6 +43,9 @@ class DatabaseHelper {
version: 1,
onCreate: _onCreate,
onOpen: _onOpen,
onUpgrade: _onUpgrade,
onDowngrade: _onDowngrade,
onConfigure: _onConfigure,
).catchError((error) {
throw error;
}).whenComplete(() => log('Database initialized'));
@ -45,23 +64,29 @@ class DatabaseHelper {
createdAt TEXT
);
''');
insert('email', '', 'user');
insert('passwd', '', 'user');
insert('devUUID', '', 'user');
insert('userUUID', '', 'user');
insert('userDevUUID', '', 'user');
insert('status', '', 'user');
insert('cliUUID', '', 'local');
insert('ownerUUID', '', 'local');
insert('cliName', '', 'local');
insert('whatsapp', '', 'local');
insert('provisional', '', 'local');
insert('pets', '', 'local');
insert('petAmountRegister', '', 'local');
// ----------------------------------------------
await insert('devUUID', '', 'user');
await insert('userUUID', '', 'user');
await insert('userDevUUID', '', 'user');
await insert('status', '', 'user');
await insert('userName', '', 'user');
// ----------------------------------------------
await insert('cliUUID', '', 'local');
await insert('ownerUUID', '', 'local');
await insert('cliName', '', 'local');
// ----------------------------------------------
await insert('whatsapp', 'false', 'util');
await insert('provisional', 'false', 'util');
await insert('pets', 'false', 'util');
await insert('local', 'false', 'util');
await insert('notify', 'false', 'util');
await insert('fingerprint', 'false', 'util');
await insert('access', 'false', 'util');
await insert('panic', 'false', 'util');
await insert('person', 'false', 'util');
await insert('requestOSnotification', 'false', 'util');
await insert('petAmountRegister', '', 'local');
// ----------------------------------------------
log('Tables created');
}
@ -173,15 +198,36 @@ class DatabaseHelper {
);
}
Future<int> delete(int id) async {
Future<int> clear(String key) async {
final db = await database;
log('Deleting with id: $id');
return await db.delete('keychain', where: 'id = ?', whereArgs: [id]);
log('Setting value of key: $key to empty string');
return await db.update(
'keychain',
{'value': ''},
where: 'key = ?',
whereArgs: [key],
);
}
Future<int> purge() async {
Future<int> delete(String key) async {
final db = await database;
log('Deleting all');
return await db.delete('keychain');
log('Deleting key: $key');
return await db.delete(
'keychain',
where: 'key = ?',
whereArgs: [key],
);
}
Future<void> purge() async {
final DatabaseHelper helper = DatabaseHelper();
await helper.deleteDatabaseDB();
await helper.database;
await database;
log('Purge');
}
}

View File

@ -58,7 +58,7 @@ class CustomDrawer extends StatelessWidget {
child: CachedNetworkImage(
imageUrl: valueOrDefault(
'assets/images/person.jpg',
'https://freaccess.com.br/freaccess/Images/Clients/${AppState().cliUUID}.png',
'https://freaccess.com.br/freaccess/Images/Clients/${model.cliUUID}.png',
),
width: 80.0,
height: 80.0,
@ -79,7 +79,7 @@ class CustomDrawer extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
convertToUppercase(AppState().name) ?? '',
convertToUppercase(model.userName) ?? '',
style: FlutterFlowTheme.of(context).bodyLarge.override(
fontFamily: 'Nunito Sans',
color: FlutterFlowTheme.of(context).primaryText,
@ -89,7 +89,7 @@ class CustomDrawer extends StatelessWidget {
),
),
Text(
AppState().email,
model.userEmail,
style: FlutterFlowTheme.of(context).bodySmall.override(
fontFamily: 'Nunito Sans',
color: FlutterFlowTheme.of(context).primaryText,