Merge branch 'main' into fix/fd-392
This commit is contained in:
commit
07059d9bad
|
@ -1,6 +1,6 @@
|
||||||
import UIKit
|
import UIKit
|
||||||
|
|
||||||
import Flutter
|
import Flutter
|
||||||
|
import flutter_secure_storage
|
||||||
|
|
||||||
@main
|
@main
|
||||||
@objc class AppDelegate: FlutterAppDelegate {
|
@objc class AppDelegate: FlutterAppDelegate {
|
||||||
|
@ -9,6 +9,11 @@ import Flutter
|
||||||
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
|
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
|
||||||
) -> Bool {
|
) -> Bool {
|
||||||
GeneratedPluginRegistrant.register(with: self)
|
GeneratedPluginRegistrant.register(with: self)
|
||||||
|
|
||||||
|
// Configurar o Keychain para remover dados quando o app for desinstalado
|
||||||
|
let secureStorage = FlutterSecureStoragePlugin()
|
||||||
|
secureStorage.setAccessibility(.whenPasscodeSetThisDeviceOnly)
|
||||||
|
|
||||||
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
|
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -4,6 +4,7 @@ import 'package:csv/csv.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||||||
import 'package:local_auth/local_auth.dart';
|
import 'package:local_auth/local_auth.dart';
|
||||||
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
import 'package:synchronized/synchronized.dart';
|
import 'package:synchronized/synchronized.dart';
|
||||||
|
|
||||||
class AppState extends ChangeNotifier {
|
class AppState extends ChangeNotifier {
|
||||||
|
@ -112,6 +113,7 @@ class AppState extends ChangeNotifier {
|
||||||
_deviceDescription = await secureStorage.getString('deviceDescription') ??
|
_deviceDescription = await secureStorage.getString('deviceDescription') ??
|
||||||
_deviceDescription;
|
_deviceDescription;
|
||||||
});
|
});
|
||||||
|
await loadFirstRun();
|
||||||
}
|
}
|
||||||
|
|
||||||
void update(VoidCallback callback) {
|
void update(VoidCallback callback) {
|
||||||
|
@ -275,7 +277,11 @@ class AppState extends ChangeNotifier {
|
||||||
AppState().deleteTokenAPNS();
|
AppState().deleteTokenAPNS();
|
||||||
AppState().deleteContext();
|
AppState().deleteContext();
|
||||||
secureStorage.deleteAll();
|
secureStorage.deleteAll();
|
||||||
|
|
||||||
AppState().isLogged = false;
|
AppState().isLogged = false;
|
||||||
|
AppState().setFirstRun(false);
|
||||||
|
|
||||||
|
AppState().update(() {});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -173,11 +173,13 @@ class UpdatePet {
|
||||||
'name': name,
|
'name': name,
|
||||||
'species': species,
|
'species': species,
|
||||||
'breed': breed,
|
'breed': breed,
|
||||||
'color': color,
|
if (color != '') 'color': color,
|
||||||
'birthdayDate': ValidatorUtil.toISO8601USA('dd/MM/yyyy', birthdayDate!),
|
if (birthdayDate != '')
|
||||||
|
'birthdayDate':
|
||||||
|
ValidatorUtil.toISO8601USA('dd/MM/yyyy', birthdayDate!),
|
||||||
'gender': gender,
|
'gender': gender,
|
||||||
'size': size,
|
'size': size,
|
||||||
'notes': notes,
|
if (notes != '') 'notes': notes,
|
||||||
},
|
},
|
||||||
bodyType: BodyType.X_WWW_FORM_URL_ENCODED,
|
bodyType: BodyType.X_WWW_FORM_URL_ENCODED,
|
||||||
returnBody: true,
|
returnBody: true,
|
||||||
|
|
|
@ -23,7 +23,7 @@ class SubmitButtonUtil extends StatelessWidget {
|
||||||
width: 250.0,
|
width: 250.0,
|
||||||
height: 36.0,
|
height: 36.0,
|
||||||
disabledColor: FlutterFlowTheme.of(context).customColor5,
|
disabledColor: FlutterFlowTheme.of(context).customColor5,
|
||||||
padding: const EdgeInsetsDirectional.fromSTEB(80.0, 0.0, 80.0, 0.0),
|
padding: const EdgeInsetsDirectional.fromSTEB(0.0, 0.0, 0.0, 0.0),
|
||||||
iconPadding: const EdgeInsetsDirectional.fromSTEB(0.0, 0.0, 0.0, 0.0),
|
iconPadding: const EdgeInsetsDirectional.fromSTEB(0.0, 0.0, 0.0, 0.0),
|
||||||
color: FlutterFlowTheme.of(context).primary,
|
color: FlutterFlowTheme.of(context).primary,
|
||||||
textStyle: FlutterFlowTheme.of(context).titleSmall.override(
|
textStyle: FlutterFlowTheme.of(context).titleSmall.override(
|
||||||
|
|
|
@ -98,13 +98,21 @@ class _CardItemTemplateComponentWidgetState
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _generateImage() {
|
Widget _generateImage() {
|
||||||
CachedNetworkImage.evictFromCache(widget.imagePath ?? '');
|
// CachedNetworkImage.evictFromCache(widget.imagePath ?? '');
|
||||||
return ClipRRect(
|
return ClipRRect(
|
||||||
borderRadius: BorderRadius.circular(20),
|
borderRadius: BorderRadius.circular(20),
|
||||||
child: CachedNetworkImage(
|
child: CachedNetworkImage(
|
||||||
fadeInDuration: const Duration(milliseconds: 500),
|
fadeInDuration: const Duration(milliseconds: 500),
|
||||||
fadeOutDuration: const Duration(milliseconds: 500),
|
fadeOutDuration: const Duration(milliseconds: 500),
|
||||||
imageUrl: widget.imagePath ?? '',
|
imageUrl: widget.imagePath ?? '',
|
||||||
|
placeholder: (context, url) => const Center(
|
||||||
|
child: CircularProgressIndicator(
|
||||||
|
valueColor: AlwaysStoppedAnimation<Color>(
|
||||||
|
Color(0xFF1AAB5F),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
errorWidget: (context, url, error) => const Icon(Icons.error),
|
||||||
fit: BoxFit.cover,
|
fit: BoxFit.cover,
|
||||||
width: 90,
|
width: 90,
|
||||||
height: 90,
|
height: 90,
|
||||||
|
|
|
@ -65,7 +65,7 @@ class _DetailsComponentWidgetState extends State<DetailsComponentWidget> {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
context.watch<AppState>();
|
context.watch<AppState>();
|
||||||
CachedNetworkImage.evictFromCache(widget.imagePath ?? '');
|
// CachedNetworkImage.evictFromCache(widget.imagePath ?? '');
|
||||||
|
|
||||||
return Container(
|
return Container(
|
||||||
constraints: BoxConstraints(
|
constraints: BoxConstraints(
|
||||||
|
|
|
@ -31,6 +31,10 @@ Future<void> initializeApp() async {
|
||||||
final appState = AppState();
|
final appState = AppState();
|
||||||
await appState.initializePersistedState();
|
await appState.initializePersistedState();
|
||||||
|
|
||||||
|
if (AppState().firstRun == true) {
|
||||||
|
AppState().deleteAll();
|
||||||
|
}
|
||||||
|
|
||||||
await Firebase.initializeApp();
|
await Firebase.initializeApp();
|
||||||
await NotificationService.initialize();
|
await NotificationService.initialize();
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:developer';
|
import 'dart:developer';
|
||||||
|
import 'package:cached_network_image/cached_network_image.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:http/http.dart';
|
import 'package:http/http.dart';
|
||||||
import 'package:hub/backend/api_requests/api_calls.dart';
|
import 'package:hub/backend/api_requests/api_calls.dart';
|
||||||
|
@ -270,10 +271,9 @@ class PetsPageModel extends FlutterFlowModel<PetsPageWidget> {
|
||||||
Future<void> updatePet() async {
|
Future<void> updatePet() async {
|
||||||
var img = await actions.convertImageFileToBase64(uploadedLocalFile!);
|
var img = await actions.convertImageFileToBase64(uploadedLocalFile!);
|
||||||
img = "base64;jpeg,$img";
|
img = "base64;jpeg,$img";
|
||||||
await PhpGroup.updatePet
|
await PhpGroup.updatePet.call(
|
||||||
.call(
|
|
||||||
petID: petId,
|
petID: petId,
|
||||||
image: img,
|
image: imgBase64,
|
||||||
birthdayDate: textControllerData!.text,
|
birthdayDate: textControllerData!.text,
|
||||||
color: textControllerColor!.text,
|
color: textControllerColor!.text,
|
||||||
breed: textControllerRace!.text,
|
breed: textControllerRace!.text,
|
||||||
|
@ -282,29 +282,39 @@ class PetsPageModel extends FlutterFlowModel<PetsPageWidget> {
|
||||||
gender: dropDownValue1!,
|
gender: dropDownValue1!,
|
||||||
notes: textControllerObservation!.text,
|
notes: textControllerObservation!.text,
|
||||||
size: dropDownValue2!,
|
size: dropDownValue2!,
|
||||||
)
|
);
|
||||||
.then((response) {
|
|
||||||
if (response.jsonBody['error'] == true ||
|
if (response.jsonBody['error'] == false) {
|
||||||
isFormValid(buildContext!) == false) {
|
|
||||||
DialogUtil.error(buildContext!,
|
|
||||||
jsonDecode(response.jsonBody['error_msg'])[0]['message']);
|
|
||||||
}
|
|
||||||
DialogUtil.success(
|
DialogUtil.success(
|
||||||
buildContext!,
|
buildContext!,
|
||||||
FFLocalizations.of(buildContext!).getVariableText(
|
FFLocalizations.of(buildContext!).getVariableText(
|
||||||
enText: 'Pet successfully updated',
|
enText: 'Pet successfully updated',
|
||||||
ptText: 'Pet atualizado com sucesso',
|
ptText: 'Pet atualizado com sucesso',
|
||||||
));
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
CachedNetworkImage.evictFromCache(url);
|
||||||
onUpdatePet?.call();
|
onUpdatePet?.call();
|
||||||
switchTab(1);
|
switchTab(1);
|
||||||
});
|
} else {
|
||||||
|
String errorMessage;
|
||||||
|
try {
|
||||||
|
errorMessage =
|
||||||
|
jsonDecode(response.jsonBody['error_msg'])[0]['message'].toString();
|
||||||
|
} catch (e) {
|
||||||
|
errorMessage = FFLocalizations.of(buildContext!).getVariableText(
|
||||||
|
enText: 'Failed to update pet',
|
||||||
|
ptText: 'Falha ao atualizar o pet',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
DialogUtil.error(buildContext!, errorMessage);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> registerPet() async {
|
Future<void> registerPet() async {
|
||||||
var img = await actions.convertImageFileToBase64(uploadedLocalFile!);
|
var img = await actions.convertImageFileToBase64(uploadedLocalFile!);
|
||||||
img = "base64;jpeg,$img";
|
img = "base64;jpeg,$img";
|
||||||
await PhpGroup.registerPet
|
await PhpGroup.registerPet.call(
|
||||||
.call(
|
|
||||||
image: img,
|
image: img,
|
||||||
birthdayDate: textControllerData!.text,
|
birthdayDate: textControllerData!.text,
|
||||||
color: textControllerColor!.text,
|
color: textControllerColor!.text,
|
||||||
|
@ -314,35 +324,34 @@ class PetsPageModel extends FlutterFlowModel<PetsPageWidget> {
|
||||||
gender: dropDownValue1!,
|
gender: dropDownValue1!,
|
||||||
size: dropDownValue2!,
|
size: dropDownValue2!,
|
||||||
notes: textControllerObservation!.text,
|
notes: textControllerObservation!.text,
|
||||||
)
|
);
|
||||||
.then((response) {
|
|
||||||
if (response.jsonBody['error'] == true) {
|
if (response.jsonBody['error'] == false) {
|
||||||
String errorMessage = '';
|
DialogUtil.success(
|
||||||
try {
|
buildContext!,
|
||||||
errorMessage = jsonDecode(response.jsonBody['error_msg'])[0]
|
FFLocalizations.of(buildContext!).getVariableText(
|
||||||
['message']
|
enText: 'Pet successfully registered',
|
||||||
.toString();
|
ptText: 'Pet cadastrado com sucesso',
|
||||||
} catch (e) {
|
),
|
||||||
errorMessage = 'An error occurred.';
|
);
|
||||||
if (response.jsonBody['error_msg'] ==
|
onRegisterPet?.call();
|
||||||
"Limite de Cadastro de Pet Atingido.") {
|
} else {
|
||||||
errorMessage = FFLocalizations.of(buildContext!).getVariableText(
|
String errorMessage;
|
||||||
enText: 'Pet registration limit reached',
|
try {
|
||||||
ptText: 'Limite de cadastro de pets atingido',
|
errorMessage =
|
||||||
);
|
jsonDecode(response.jsonBody['error_msg'])[0]['message'].toString();
|
||||||
}
|
} catch (e) {
|
||||||
|
if (response.jsonBody['error_msg'] ==
|
||||||
|
"Limite de Cadastro de Pet Atingido.") {
|
||||||
|
errorMessage = FFLocalizations.of(buildContext!).getVariableText(
|
||||||
|
enText: 'Pet registration limit reached',
|
||||||
|
ptText: 'Limite de cadastro de pets atingido',
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
DialogUtil.errorDefault(buildContext!);
|
||||||
}
|
}
|
||||||
DialogUtil.error(buildContext!, errorMessage);
|
|
||||||
} else if (response.jsonBody['error'] == false) {
|
|
||||||
DialogUtil.success(
|
|
||||||
buildContext!,
|
|
||||||
FFLocalizations.of(buildContext!).getVariableText(
|
|
||||||
enText: 'Pet successfully registered',
|
|
||||||
ptText: 'Pet cadastrado com sucesso',
|
|
||||||
));
|
|
||||||
onRegisterPet?.call();
|
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void switchTab(int index) {
|
void switchTab(int index) {
|
||||||
|
|
Loading…
Reference in New Issue