fix merge
This commit is contained in:
parent
9c80df47d1
commit
ac22cf25c8
|
@ -20,9 +20,14 @@ import 'package:hub/shared/utils/limited_text_size.dart';
|
||||||
import 'package:hub/shared/utils/validator_util.dart';
|
import 'package:hub/shared/utils/validator_util.dart';
|
||||||
|
|
||||||
class PetsPageModel extends FlutterFlowModel<PetsPageWidget> {
|
class PetsPageModel extends FlutterFlowModel<PetsPageWidget> {
|
||||||
late String devUUID = '';
|
static PetsPageModel? _instance = PetsPageModel._internal();
|
||||||
late String userUUID = '';
|
PetsPageModel._internal();
|
||||||
late String cliUUID = '';
|
factory PetsPageModel() => _instance ?? PetsPageModel._internal();
|
||||||
|
static void resetInstance() => _instance = null;
|
||||||
|
|
||||||
|
late final String devUUID;
|
||||||
|
late final String userUUID;
|
||||||
|
late final String cliUUID;
|
||||||
late String petAmountRegister = '0';
|
late String petAmountRegister = '0';
|
||||||
dynamic item;
|
dynamic item;
|
||||||
|
|
||||||
|
@ -45,8 +50,6 @@ class PetsPageModel extends FlutterFlowModel<PetsPageWidget> {
|
||||||
FFUploadedFile? uploadedTempFile;
|
FFUploadedFile? uploadedTempFile;
|
||||||
String? imgBase64;
|
String? imgBase64;
|
||||||
|
|
||||||
late String defaultDropDownText = '';
|
|
||||||
|
|
||||||
String? dropDownValue1;
|
String? dropDownValue1;
|
||||||
FormFieldController<String>? dropDownValueController1;
|
FormFieldController<String>? dropDownValueController1;
|
||||||
|
|
||||||
|
@ -105,27 +108,18 @@ class PetsPageModel extends FlutterFlowModel<PetsPageWidget> {
|
||||||
String? Function(BuildContext, String?)? textControllerObservationValidator;
|
String? Function(BuildContext, String?)? textControllerObservationValidator;
|
||||||
|
|
||||||
Future<void> initAsync() async {
|
Future<void> initAsync() async {
|
||||||
defaultDropDownText = FFLocalizations.of(buildContext!).getVariableText(
|
devUUID = (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? '';
|
||||||
enText: 'Select an option',
|
userUUID = (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? '';
|
||||||
ptText: 'Selecione uma opção',
|
cliUUID = (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? '';
|
||||||
);
|
petAmountRegister = await StorageHelper().get(SQLiteStorageKey.petAmount.value, Storage.SQLiteStorage) ?? '0';
|
||||||
dropDownValueController1 = FormFieldController<String>(dropDownValue1 ??= defaultDropDownText);
|
|
||||||
dropDownValueController2 = FormFieldController<String>(dropDownValue2 ??= defaultDropDownText);
|
|
||||||
log('() => ): $devUUID');
|
|
||||||
|
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) async {
|
|
||||||
devUUID = await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage) ?? '';
|
|
||||||
userUUID = await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage) ?? '';
|
|
||||||
cliUUID = await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage) ?? '';
|
|
||||||
petAmountRegister = await StorageHelper().get(SQLiteStorageKey.petAmount.value, Storage.SQLiteStorage) ?? '';
|
|
||||||
});
|
|
||||||
|
|
||||||
safeSetState?.call();
|
safeSetState?.call();
|
||||||
log('() => ): $devUUID');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState(BuildContext context) {
|
void initState(BuildContext context) {
|
||||||
|
initAsync();
|
||||||
|
resetInstance();
|
||||||
tabBarController = TabController(
|
tabBarController = TabController(
|
||||||
vsync: Navigator.of(context),
|
vsync: Navigator.of(context),
|
||||||
length: 2,
|
length: 2,
|
||||||
|
@ -149,7 +143,35 @@ class PetsPageModel extends FlutterFlowModel<PetsPageWidget> {
|
||||||
textFieldFocusObservation = FocusNode();
|
textFieldFocusObservation = FocusNode();
|
||||||
textControllerObservation = TextEditingController();
|
textControllerObservation = TextEditingController();
|
||||||
|
|
||||||
initAsync();
|
dropDownValueController1 = FormFieldController<String>(dropDownValue1 ??= 'Selecione uma opção');
|
||||||
|
|
||||||
|
dropDownValueController2 = FormFieldController<String>(dropDownValue2 ??= 'Selecione uma opção');
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
tabBarController.dispose();
|
||||||
|
|
||||||
|
textFieldFocusName?.dispose();
|
||||||
|
textControllerName?.dispose();
|
||||||
|
|
||||||
|
textFieldFocusSpecies?.dispose();
|
||||||
|
textControllerSpecies?.dispose();
|
||||||
|
|
||||||
|
textFieldFocusRace?.dispose();
|
||||||
|
textControllerRace?.dispose();
|
||||||
|
|
||||||
|
textFieldFocusColor?.dispose();
|
||||||
|
textControllerColor?.dispose();
|
||||||
|
|
||||||
|
textFieldFocusData?.dispose();
|
||||||
|
textControllerData?.dispose();
|
||||||
|
|
||||||
|
textFieldFocusObservation?.dispose();
|
||||||
|
textControllerObservation?.dispose();
|
||||||
|
|
||||||
|
dropDownValueController1?.dispose();
|
||||||
|
dropDownValueController2?.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
void setEditForm() {
|
void setEditForm() {
|
||||||
|
@ -199,65 +221,26 @@ class PetsPageModel extends FlutterFlowModel<PetsPageWidget> {
|
||||||
dropDownValueController2 = FormFieldController<String>(dropDownValue2);
|
dropDownValueController2 = FormFieldController<String>(dropDownValue2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
|
||||||
void dispose() {
|
|
||||||
tabBarController.dispose();
|
|
||||||
|
|
||||||
textFieldFocusName?.dispose();
|
|
||||||
textControllerName?.dispose();
|
|
||||||
|
|
||||||
textFieldFocusSpecies?.dispose();
|
|
||||||
textControllerSpecies?.dispose();
|
|
||||||
|
|
||||||
textFieldFocusRace?.dispose();
|
|
||||||
textControllerRace?.dispose();
|
|
||||||
|
|
||||||
textFieldFocusColor?.dispose();
|
|
||||||
textControllerColor?.dispose();
|
|
||||||
|
|
||||||
textFieldFocusData?.dispose();
|
|
||||||
textControllerData?.dispose();
|
|
||||||
|
|
||||||
textFieldFocusObservation?.dispose();
|
|
||||||
textControllerObservation?.dispose();
|
|
||||||
|
|
||||||
dropDownValueController1?.dispose();
|
|
||||||
dropDownValueController2?.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isFormValid(BuildContext context) {
|
bool isFormValid(BuildContext context) {
|
||||||
if (uploadedLocalFile == null || uploadedLocalFile!.bytes!.isEmpty) {
|
if (uploadedLocalFile == null || uploadedLocalFile!.bytes!.isEmpty) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (textControllerName.text.isEmpty || textControllerName.text.length > 80 || textControllerName.text == '') {
|
if (textControllerName!.text.isEmpty || textControllerName!.text.length > 80 || textControllerName!.text == '') {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (textControllerSpecies.text.isEmpty || textControllerSpecies.text == '') {
|
if (textControllerSpecies!.text.isEmpty || textControllerSpecies!.text == '') {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (textControllerRace.text.isEmpty || textControllerRace.text == '') {
|
if (textControllerRace!.text.isEmpty || textControllerRace!.text == '') {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dropDownValueController1!.value == defaultDropDownText ||
|
if (dropDownValue1 == null || dropDownValue1!.isEmpty || dropDownValue1 == '') {
|
||||||
dropDownValueController1!.value == '' ||
|
|
||||||
dropDownValueController1!.value == null) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (dropDownValueController2!.value == defaultDropDownText ||
|
if (dropDownValue2 == null || dropDownValue2!.isEmpty || dropDownValue2 == '') {
|
||||||
dropDownValueController2!.value == '' ||
|
|
||||||
dropDownValueController2!.value == null) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dropDownValue1 == 'Selecione uma opção' || dropDownValue1 == null || dropDownValue1 == '') {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dropDownValue2 == 'Selecione uma opção' || dropDownValue2 == null || dropDownValue2 == '') {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -280,7 +263,7 @@ class PetsPageModel extends FlutterFlowModel<PetsPageWidget> {
|
||||||
);
|
);
|
||||||
|
|
||||||
if (response.jsonBody['error'] == false) {
|
if (response.jsonBody['error'] == false) {
|
||||||
await DialogUtil.success(
|
DialogUtil.success(
|
||||||
buildContext!,
|
buildContext!,
|
||||||
FFLocalizations.of(buildContext!).getVariableText(
|
FFLocalizations.of(buildContext!).getVariableText(
|
||||||
enText: 'Pet successfully updated',
|
enText: 'Pet successfully updated',
|
||||||
|
@ -301,7 +284,7 @@ class PetsPageModel extends FlutterFlowModel<PetsPageWidget> {
|
||||||
ptText: 'Falha ao atualizar o pet',
|
ptText: 'Falha ao atualizar o pet',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
await DialogUtil.error(buildContext!, errorMessage);
|
DialogUtil.error(buildContext!, errorMessage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -321,7 +304,7 @@ class PetsPageModel extends FlutterFlowModel<PetsPageWidget> {
|
||||||
);
|
);
|
||||||
|
|
||||||
if (response.jsonBody['error'] == false) {
|
if (response.jsonBody['error'] == false) {
|
||||||
await DialogUtil.success(
|
DialogUtil.success(
|
||||||
buildContext!,
|
buildContext!,
|
||||||
FFLocalizations.of(buildContext!).getVariableText(
|
FFLocalizations.of(buildContext!).getVariableText(
|
||||||
enText: 'Pet successfully registered',
|
enText: 'Pet successfully registered',
|
||||||
|
@ -333,16 +316,15 @@ class PetsPageModel extends FlutterFlowModel<PetsPageWidget> {
|
||||||
String errorMessage;
|
String errorMessage;
|
||||||
try {
|
try {
|
||||||
errorMessage = jsonDecode(response.jsonBody['error_msg'])[0]['message'].toString();
|
errorMessage = jsonDecode(response.jsonBody['error_msg'])[0]['message'].toString();
|
||||||
await DialogUtil.error(buildContext!, errorMessage);
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (response.jsonBody['error_msg'] == "Limite de Cadastro de Pet Atingido.") {
|
if (response.jsonBody['error_msg'] == "Limite de Cadastro de Pet Atingido.") {
|
||||||
errorMessage = FFLocalizations.of(buildContext!).getVariableText(
|
errorMessage = FFLocalizations.of(buildContext!).getVariableText(
|
||||||
enText: 'Pet registration limit reached',
|
enText: 'Pet registration limit reached',
|
||||||
ptText: 'Limite de cadastro de pets atingido',
|
ptText: 'Limite de cadastro de pets atingido',
|
||||||
);
|
);
|
||||||
await DialogUtil.error(buildContext!, errorMessage);
|
DialogUtil.error(buildContext!, errorMessage);
|
||||||
} else {
|
} else {
|
||||||
await DialogUtil.errorDefault(buildContext!);
|
DialogUtil.errorDefault(buildContext!);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -382,8 +364,10 @@ class PetsPageModel extends FlutterFlowModel<PetsPageWidget> {
|
||||||
// dropDownValue1 = '';
|
// dropDownValue1 = '';
|
||||||
// dropDownValue2 = '';
|
// dropDownValue2 = '';
|
||||||
|
|
||||||
// dropDownValueController1 = FormFieldController<String>('Selecione uma opção');
|
// dropDownValueController1 =
|
||||||
// dropDownValueController2 = FormFieldController<String>('Selecione uma opção');
|
// FormFieldController<String>('Selecione uma opção');
|
||||||
|
// dropDownValueController2 =
|
||||||
|
// FormFieldController<String>('Selecione uma opção');
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget buildPetDetails({
|
Widget buildPetDetails({
|
||||||
|
@ -394,10 +378,12 @@ class PetsPageModel extends FlutterFlowModel<PetsPageWidget> {
|
||||||
required String cliUUID,
|
required String cliUUID,
|
||||||
required String cliName,
|
required String cliName,
|
||||||
required PetsPageModel model,
|
required PetsPageModel model,
|
||||||
|
bool isInteractive = true,
|
||||||
}) {
|
}) {
|
||||||
return DetailsComponentWidget(
|
return DetailsComponentWidget(
|
||||||
buttons: [
|
buttons: [
|
||||||
// EDIT ACTION
|
// EDIT ACTION
|
||||||
|
if (isInteractive)
|
||||||
FFButtonWidget(
|
FFButtonWidget(
|
||||||
text: FFLocalizations.of(context).getVariableText(
|
text: FFLocalizations.of(context).getVariableText(
|
||||||
ptText: 'Editar',
|
ptText: 'Editar',
|
||||||
|
@ -432,6 +418,7 @@ class PetsPageModel extends FlutterFlowModel<PetsPageWidget> {
|
||||||
),
|
),
|
||||||
|
|
||||||
// DELETE ACTION
|
// DELETE ACTION
|
||||||
|
if (isInteractive)
|
||||||
FFButtonWidget(
|
FFButtonWidget(
|
||||||
text: FFLocalizations.of(context).getVariableText(
|
text: FFLocalizations.of(context).getVariableText(
|
||||||
ptText: 'Excluir',
|
ptText: 'Excluir',
|
||||||
|
|
Loading…
Reference in New Issue