WIP
This commit is contained in:
parent
ac26e0ddac
commit
624f00cc1f
|
@ -24,6 +24,7 @@ class _PetsHistoryScreenState extends State<PetsHistoryScreen>
|
|||
final int _pageSize = 10;
|
||||
bool _hasData = false;
|
||||
bool _loading = false;
|
||||
int count = 0;
|
||||
|
||||
late Future<void> _petsFuture;
|
||||
List<dynamic> _petsWrap = [];
|
||||
|
@ -61,7 +62,8 @@ class _PetsHistoryScreenState extends State<PetsHistoryScreen>
|
|||
page: _pageNumber,
|
||||
);
|
||||
|
||||
final List<dynamic> pets = response.jsonBody['pets'] ?? [];
|
||||
final List<dynamic> pets = response.jsonBody['pets']['list'] ?? [];
|
||||
safeSetState(() => count = response.jsonBody['pets']['count'] ?? 0);
|
||||
|
||||
if (pets != null && pets.isNotEmpty) {
|
||||
setState(() {
|
||||
|
@ -95,6 +97,7 @@ class _PetsHistoryScreenState extends State<PetsHistoryScreen>
|
|||
void _loadMore() {
|
||||
if (_hasData == true) {
|
||||
_pageNumber++;
|
||||
|
||||
_petsFuture = _fetchVisits();
|
||||
}
|
||||
}
|
||||
|
@ -151,7 +154,7 @@ class _PetsHistoryScreenState extends State<PetsHistoryScreen>
|
|||
AppState().petAmountRegister == 0
|
||||
? FFLocalizations.of(context).getVariableText(
|
||||
ptText: "Ilimitado", enText: "Unlimited")
|
||||
: "${FFLocalizations.of(context).getVariableText(ptText: "Quantidade de Pets: ", enText: "Amount of Pets: ")}${_petsWrap.length}/${AppState().petAmountRegister}",
|
||||
: "${FFLocalizations.of(context).getVariableText(ptText: "Quantidade de Pets: ", enText: "Amount of Pets: ")}${count}/${AppState().petAmountRegister}",
|
||||
textAlign: TextAlign.right,
|
||||
),
|
||||
);
|
||||
|
@ -256,7 +259,8 @@ class _PetsHistoryScreenState extends State<PetsHistoryScreen>
|
|||
safeSetState(() {
|
||||
_pageNumber = 1;
|
||||
_petsWrap = [];
|
||||
_petsFuture = _fetchVisits();
|
||||
_petsFuture =
|
||||
_fetchVisits().then((value) => value!.jsonBody['pets'] ?? []);
|
||||
});
|
||||
}).catchError((e, s) {
|
||||
DialogUtil.errorDefault(context);
|
||||
|
|
|
@ -209,12 +209,8 @@ class PetsPageModel extends FlutterFlowModel<PetsPageWidget> {
|
|||
enText: 'Pet successfully updated',
|
||||
ptText: 'Pet atualizado com sucesso',
|
||||
));
|
||||
clearFields();
|
||||
onUpdatePet?.call();
|
||||
switchTab(1);
|
||||
}).onError((error, stack) {
|
||||
log(error.toString());
|
||||
DialogUtil.errorDefault(buildContext!);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -240,17 +236,15 @@ class PetsPageModel extends FlutterFlowModel<PetsPageWidget> {
|
|||
if (response.jsonBody['error'] == true) {
|
||||
DialogUtil.error(buildContext!,
|
||||
jsonDecode(response.jsonBody['error_msg'])[0]['message']);
|
||||
} else if (response.jsonBody['error'] == false) {
|
||||
DialogUtil.success(
|
||||
buildContext!,
|
||||
FFLocalizations.of(buildContext!).getVariableText(
|
||||
enText: 'Pet successfully registered',
|
||||
ptText: 'Pet cadastrado com sucesso',
|
||||
));
|
||||
onRegisterPet?.call();
|
||||
}
|
||||
DialogUtil.success(
|
||||
buildContext!,
|
||||
FFLocalizations.of(buildContext!).getVariableText(
|
||||
enText: 'Pet successfully registered',
|
||||
ptText: 'Pet cadastrado com sucesso',
|
||||
));
|
||||
clearFields();
|
||||
onRegisterPet?.call();
|
||||
}).onError((error, stack) {
|
||||
DialogUtil.errorDefault(buildContext!);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -270,23 +264,13 @@ class PetsPageModel extends FlutterFlowModel<PetsPageWidget> {
|
|||
|
||||
void clearFields() {
|
||||
uploadedLocalFile = null;
|
||||
textControllerName!.clear();
|
||||
textControllerName!.clearComposing();
|
||||
|
||||
textControllerSpecies!.clear();
|
||||
textControllerSpecies!.clearComposing();
|
||||
|
||||
textControllerRace!.clear();
|
||||
textControllerRace!.clearComposing();
|
||||
|
||||
textControllerColor!.clear();
|
||||
textControllerColor!.clearComposing();
|
||||
|
||||
textControllerData!.clear();
|
||||
textControllerData!.clearComposing();
|
||||
|
||||
textControllerObservation!.clear();
|
||||
textControllerObservation!.clearComposing();
|
||||
textControllerName?.clear();
|
||||
textControllerSpecies?.clear();
|
||||
textControllerRace?.clear();
|
||||
textControllerColor?.clear();
|
||||
textControllerData?.clear();
|
||||
textControllerObservation?.clear();
|
||||
|
||||
dropDownValue1 = null;
|
||||
dropDownValue2 = null;
|
||||
|
|
|
@ -59,12 +59,15 @@ class _PetsPageWidgetState extends State<PetsPageWidget>
|
|||
_model = PetsPageModel();
|
||||
_model.tabBarController = TabController(length: 2, vsync: this);
|
||||
_model.onUpdatePet = () {
|
||||
setState(() {});
|
||||
Form.of(context).reset();
|
||||
safeSetState(() {
|
||||
_model.clearFields();
|
||||
// _formKey.currentState?.reset();
|
||||
});
|
||||
};
|
||||
_model.onRegisterPet = () {
|
||||
setState(() {});
|
||||
Form.of(context).reset();
|
||||
safeSetState(() {
|
||||
_model.clearFields();
|
||||
});
|
||||
};
|
||||
|
||||
widget.pet != null ? _model.isEditing = true : _model.isEditing = false;
|
||||
|
|
Loading…
Reference in New Issue