This commit is contained in:
J. A. Messias 2024-09-13 11:18:13 -03:00
parent 3da294a09e
commit 38b126dcb6
5 changed files with 45 additions and 4 deletions

View File

@ -54,6 +54,36 @@ class PhpGroup {
static UpdatePet updatePet = UpdatePet();
static GetPets getPets = GetPets();
static GetPetPhoto getPetPhoto = GetPetPhoto();
static UnregisterDevice unregisterDevice = UnregisterDevice();
}
class UnregisterDevice {
Future<ApiCallResponse> call({
String? devUUID = '',
String? userUUID = '',
}) async {
final baseUrl = PhpGroup.getBaseUrl();
return ApiManager.instance.makeApiCall(
callName: 'unregisterDevice',
apiUrl: '$baseUrl/unregisterDevice.php',
callType: ApiCallType.POST,
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
params: {
'devUUID': devUUID,
'userUUID': userUUID,
},
bodyType: BodyType.X_WWW_FORM_URL_ENCODED,
returnBody: true,
encodeBodyUtf8: false,
decodeUtf8: false,
cache: false,
isStreamingApi: false,
alwaysAllowBody: false,
);
}
}
class DeletePet {

View File

@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
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';
@ -196,6 +197,11 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
), () async {
AppState().deleteAll();
PhpGroup.unregisterDevice.call(
devUUID: AppState().devUUID,
userUUID: AppState().userUUID,
);
context.go(
'/welcomePage',
extra: <String, dynamic>{

View File

@ -107,6 +107,7 @@ class _CardItemTemplateComponentWidgetState
fit: BoxFit.cover,
width: 90,
height: 90,
key: Key(widget.imagePath ?? ''),
),
);
}

View File

@ -148,7 +148,10 @@ class _PetsHistoryScreenState extends State<PetsHistoryScreen>
return Padding(
padding: EdgeInsets.only(right: 30, top: 10),
child: Text(
"${_petsWrap.length}/${AppState().petAmountRegister}",
AppState().petAmountRegister == 0
? FFLocalizations.of(context).getVariableText(
ptText: "Ilimitado", enText: "Unlimited")
: "${_petsWrap.length}/${AppState().petAmountRegister}",
textAlign: TextAlign.right,
),
);

View File

@ -177,15 +177,15 @@ class PetsPageModel extends FlutterFlowModel<PetsPageWidget> {
}
Future<void> updatePet() async {
var img = await actions.convertImageFileToBase64(uploadedLocalFile!);
img = "base64;jpeg,$img";
await PhpGroup.updatePet
.call(
cliID: AppState().cliUUID,
devUUID: AppState().devUUID,
userUUID: AppState().userUUID,
petID: petId,
image: await actions.convertImageFileToBase64(
uploadedLocalFile!,
),
image: img,
birthdayDate: textControllerData!.text,
color: textControllerColor!.text,
breed: textControllerRace!.text,
@ -244,6 +244,7 @@ class PetsPageModel extends FlutterFlowModel<PetsPageWidget> {
ptText: 'Pet cadastrado com sucesso',
));
clearFields();
onUpdatePet?.call();
}).catchError((error) {
DialogUtil.errorDefault(buildContext!);
});