WIP
This commit is contained in:
parent
a9135c5f58
commit
999215fe5e
|
@ -157,11 +157,13 @@ class UpdatePet {
|
|||
'name': name,
|
||||
'species': species,
|
||||
'breed': breed,
|
||||
'color': color,
|
||||
'birthdayDate': ValidatorUtil.toISO8601USA('dd/MM/yyyy', birthdayDate!),
|
||||
if (color != '') 'color': color,
|
||||
if (birthdayDate != '')
|
||||
'birthdayDate':
|
||||
ValidatorUtil.toISO8601USA('dd/MM/yyyy', birthdayDate!),
|
||||
'gender': gender,
|
||||
'size': size,
|
||||
'notes': notes,
|
||||
if (notes != '') 'notes': notes,
|
||||
},
|
||||
bodyType: BodyType.X_WWW_FORM_URL_ENCODED,
|
||||
returnBody: true,
|
||||
|
|
|
@ -98,13 +98,21 @@ class _CardItemTemplateComponentWidgetState
|
|||
}
|
||||
|
||||
Widget _generateImage() {
|
||||
CachedNetworkImage.evictFromCache(widget.imagePath ?? '');
|
||||
// CachedNetworkImage.evictFromCache(widget.imagePath ?? '');
|
||||
return ClipRRect(
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
child: CachedNetworkImage(
|
||||
fadeInDuration: const Duration(milliseconds: 500),
|
||||
fadeOutDuration: const Duration(milliseconds: 500),
|
||||
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,
|
||||
width: 90,
|
||||
height: 90,
|
||||
|
|
|
@ -65,7 +65,7 @@ class _DetailsComponentWidgetState extends State<DetailsComponentWidget> {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
context.watch<AppState>();
|
||||
CachedNetworkImage.evictFromCache(widget.imagePath ?? '');
|
||||
// CachedNetworkImage.evictFromCache(widget.imagePath ?? '');
|
||||
|
||||
return Container(
|
||||
constraints: BoxConstraints(
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import 'dart:developer';
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:hub/backend/api_requests/api_calls.dart';
|
||||
import 'package:hub/backend/api_requests/api_manager.dart';
|
||||
|
@ -184,15 +185,17 @@ class PetsPageModel extends FlutterFlowModel<PetsPageWidget> {
|
|||
}
|
||||
|
||||
Future<void> updatePet() async {
|
||||
var img = await actions.convertImageFileToBase64(uploadedLocalFile!);
|
||||
img = "base64;jpeg,$img";
|
||||
await PhpGroup.updatePet
|
||||
.call(
|
||||
final img = await actions.convertImageFileToBase64(uploadedLocalFile!);
|
||||
final imgBase64 = "base64;jpeg,$img";
|
||||
final url =
|
||||
'https://freaccess.com.br/freaccess/getImage.php?devUUID=${AppState().devUUID}&userUUID=${AppState().userUUID}&cliID=${AppState().cliUUID}&atividade=consultaFotoPet&petId=$petId';
|
||||
|
||||
final response = await PhpGroup.updatePet.call(
|
||||
cliID: AppState().cliUUID,
|
||||
devUUID: AppState().devUUID,
|
||||
userUUID: AppState().userUUID,
|
||||
petID: petId,
|
||||
image: img,
|
||||
image: imgBase64,
|
||||
birthdayDate: textControllerData!.text,
|
||||
color: textControllerColor!.text,
|
||||
breed: textControllerRace!.text,
|
||||
|
@ -201,33 +204,44 @@ class PetsPageModel extends FlutterFlowModel<PetsPageWidget> {
|
|||
gender: dropDownValue1!,
|
||||
notes: textControllerObservation!.text,
|
||||
size: dropDownValue2!,
|
||||
)
|
||||
.then((response) {
|
||||
if (response.jsonBody['error'] == true ||
|
||||
isFormValid(buildContext!) == false) {
|
||||
DialogUtil.error(buildContext!,
|
||||
jsonDecode(response.jsonBody['error_msg'])[0]['message']);
|
||||
}
|
||||
);
|
||||
|
||||
if (response.jsonBody['error'] == false) {
|
||||
DialogUtil.success(
|
||||
buildContext!,
|
||||
FFLocalizations.of(buildContext!).getVariableText(
|
||||
enText: 'Pet successfully updated',
|
||||
ptText: 'Pet atualizado com sucesso',
|
||||
));
|
||||
buildContext!,
|
||||
FFLocalizations.of(buildContext!).getVariableText(
|
||||
enText: 'Pet successfully updated',
|
||||
ptText: 'Pet atualizado com sucesso',
|
||||
),
|
||||
);
|
||||
|
||||
CachedNetworkImage.evictFromCache(url);
|
||||
onUpdatePet?.call();
|
||||
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 {
|
||||
var img = await actions.convertImageFileToBase64(uploadedLocalFile!);
|
||||
img = "base64;jpeg,$img";
|
||||
await PhpGroup.registerPet
|
||||
.call(
|
||||
final img = await actions.convertImageFileToBase64(uploadedLocalFile!);
|
||||
final imgBase64 = "base64;jpeg,$img";
|
||||
|
||||
final response = await PhpGroup.registerPet.call(
|
||||
cliID: AppState().cliUUID,
|
||||
devUUID: AppState().devUUID,
|
||||
userUUID: AppState().userUUID,
|
||||
image: img,
|
||||
image: imgBase64,
|
||||
birthdayDate: textControllerData!.text,
|
||||
color: textControllerColor!.text,
|
||||
breed: textControllerRace!.text,
|
||||
|
@ -236,35 +250,34 @@ class PetsPageModel extends FlutterFlowModel<PetsPageWidget> {
|
|||
gender: dropDownValue1!,
|
||||
size: dropDownValue2!,
|
||||
notes: textControllerObservation!.text,
|
||||
)
|
||||
.then((response) {
|
||||
if (response.jsonBody['error'] == true) {
|
||||
String errorMessage = '';
|
||||
try {
|
||||
errorMessage = jsonDecode(response.jsonBody['error_msg'])[0]
|
||||
['message']
|
||||
.toString();
|
||||
} catch (e) {
|
||||
errorMessage = 'An error occurred.';
|
||||
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',
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
if (response.jsonBody['error'] == false) {
|
||||
DialogUtil.success(
|
||||
buildContext!,
|
||||
FFLocalizations.of(buildContext!).getVariableText(
|
||||
enText: 'Pet successfully registered',
|
||||
ptText: 'Pet cadastrado com sucesso',
|
||||
),
|
||||
);
|
||||
onRegisterPet?.call();
|
||||
} else {
|
||||
String errorMessage;
|
||||
try {
|
||||
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) {
|
||||
|
|
Loading…
Reference in New Issue