Merge branch 'main' into fix/fd-784
This commit is contained in:
commit
194db60045
|
@ -60,11 +60,16 @@ class _CustomInputUtilState extends State<CustomInputUtil> {
|
|||
validator: widget.validator,
|
||||
autofocus: widget.autoFocus,
|
||||
focusNode: widget.focusNode,
|
||||
onChanged: (_) => EasyDebounce.debounce(
|
||||
'${widget.controller}',
|
||||
const Duration(milliseconds: 500),
|
||||
() => setState(() {}),
|
||||
),
|
||||
onChanged: (value) {
|
||||
EasyDebounce.debounce(
|
||||
'${widget.controller}',
|
||||
const Duration(milliseconds: 500),
|
||||
() => setState(() {}),
|
||||
);
|
||||
if (widget.onChanged != null) {
|
||||
widget.onChanged!(value); // Chamar o callback
|
||||
}
|
||||
},
|
||||
textInputAction: widget.textInputAction,
|
||||
obscureText: false,
|
||||
decoration: InputDecoration(
|
||||
|
|
|
@ -14,13 +14,13 @@ class MediaUploadButtonUtil extends StatefulWidget {
|
|||
final String labelText;
|
||||
FFUploadedFile? uploadedFiles;
|
||||
|
||||
MediaUploadButtonUtil(
|
||||
{Key? key,
|
||||
required this.onUploadComplete,
|
||||
required this.isUploading,
|
||||
required this.labelText,
|
||||
this.uploadedFiles})
|
||||
: super(key: key);
|
||||
MediaUploadButtonUtil({
|
||||
Key? key,
|
||||
required this.onUploadComplete,
|
||||
required this.isUploading,
|
||||
required this.labelText,
|
||||
this.uploadedFiles,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<MediaUploadButtonUtil> createState() => _MediaUploadButtonUtilState();
|
||||
|
|
|
@ -47,7 +47,6 @@ class _HomePageWidgetState extends State<HomePageWidget> {
|
|||
final errorMsg = response.jsonBody['error_msg'];
|
||||
|
||||
if (error == false) {
|
||||
log(response.jsonBody.toString());
|
||||
AppState().whatsapp = response.jsonBody['whatsapp'] ?? false;
|
||||
AppState().provisional = response.jsonBody['provisional'] ?? false;
|
||||
AppState().pets = response.jsonBody['pet'] ?? false;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -12,6 +12,11 @@ import '/custom_code/actions/index.dart' as actions;
|
|||
class PetsPageModel extends FlutterFlowModel<PetsPageWidget> {
|
||||
late final TabController tabBarController;
|
||||
VoidCallback? onUpdatePet;
|
||||
VoidCallback? onRegisterPet;
|
||||
VoidCallback? safeSetState;
|
||||
|
||||
final GlobalKey<FormState> registerFormKey = GlobalKey<FormState>();
|
||||
final GlobalKey<FormState> updateFormKey = GlobalKey<FormState>();
|
||||
|
||||
ApiCallResponse? petsResponse;
|
||||
int? petId;
|
||||
|
@ -149,7 +154,7 @@ class PetsPageModel extends FlutterFlowModel<PetsPageWidget> {
|
|||
|
||||
// Validador do formulário
|
||||
bool isFormValid(BuildContext context) {
|
||||
if (uploadedLocalFile == null) {
|
||||
if (uploadedLocalFile == null || uploadedLocalFile!.bytes!.isEmpty) {
|
||||
return false;
|
||||
}
|
||||
if (textControllerName.text.isEmpty ||
|
||||
|
@ -170,7 +175,9 @@ class PetsPageModel extends FlutterFlowModel<PetsPageWidget> {
|
|||
dropDownValue1 == '') {
|
||||
return false;
|
||||
}
|
||||
if (dropDownValue2 == null) {
|
||||
if (dropDownValue2 == null ||
|
||||
dropDownValue2!.isEmpty ||
|
||||
dropDownValue2 == '') {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -196,7 +203,8 @@ class PetsPageModel extends FlutterFlowModel<PetsPageWidget> {
|
|||
size: dropDownValue2!,
|
||||
)
|
||||
.then((response) {
|
||||
if (response.jsonBody['error'] == true) {
|
||||
if (response.jsonBody['error'] == true ||
|
||||
isFormValid(buildContext!) == false) {
|
||||
DialogUtil.error(buildContext!,
|
||||
jsonDecode(response.jsonBody['error_msg'])[0]['message']);
|
||||
}
|
||||
|
@ -206,11 +214,8 @@ class PetsPageModel extends FlutterFlowModel<PetsPageWidget> {
|
|||
enText: 'Pet successfully updated',
|
||||
ptText: 'Pet atualizado com sucesso',
|
||||
));
|
||||
clearFields();
|
||||
onUpdatePet?.call();
|
||||
switchTab(1);
|
||||
}).catchError((error) {
|
||||
log(error.toString());
|
||||
DialogUtil.errorDefault(buildContext!);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -234,30 +239,42 @@ class PetsPageModel extends FlutterFlowModel<PetsPageWidget> {
|
|||
)
|
||||
.then((response) {
|
||||
if (response.jsonBody['error'] == true) {
|
||||
DialogUtil.error(buildContext!,
|
||||
jsonDecode(response.jsonBody['error_msg'])[0]['message']);
|
||||
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',
|
||||
);
|
||||
}
|
||||
}
|
||||
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();
|
||||
}
|
||||
DialogUtil.success(
|
||||
buildContext!,
|
||||
FFLocalizations.of(buildContext!).getVariableText(
|
||||
enText: 'Pet successfully registered',
|
||||
ptText: 'Pet cadastrado com sucesso',
|
||||
));
|
||||
clearFields();
|
||||
onUpdatePet?.call();
|
||||
}).catchError((error) {
|
||||
DialogUtil.errorDefault(buildContext!);
|
||||
});
|
||||
}
|
||||
|
||||
void switchTab(int index) {
|
||||
tabBarController.animateTo(index);
|
||||
if (index == 1) handleEditingChanged(false);
|
||||
onUpdatePet?.call();
|
||||
}
|
||||
|
||||
void handleUploadComplete(FFUploadedFile uploadedFile) {
|
||||
uploadedLocalFile = uploadedFile;
|
||||
safeSetState?.call();
|
||||
}
|
||||
|
||||
void handleEditingChanged(bool editing) {
|
||||
|
@ -267,13 +284,19 @@ class PetsPageModel extends FlutterFlowModel<PetsPageWidget> {
|
|||
|
||||
void clearFields() {
|
||||
uploadedLocalFile = null;
|
||||
textControllerName.text = '';
|
||||
textControllerSpecies.text = '';
|
||||
textControllerRace.text = '';
|
||||
textControllerColor.text = '';
|
||||
textControllerData.text = '';
|
||||
textControllerObservation.text = '';
|
||||
dropDownValueController1 = FormFieldController<String>('');
|
||||
dropDownValueController2 = FormFieldController<String>('');
|
||||
|
||||
textControllerName?.clear();
|
||||
textControllerName?.clear();
|
||||
textControllerSpecies?.clear();
|
||||
textControllerRace?.clear();
|
||||
textControllerColor?.clear();
|
||||
textControllerData?.clear();
|
||||
textControllerObservation?.clear();
|
||||
|
||||
dropDownValue1 = null;
|
||||
dropDownValue2 = null;
|
||||
|
||||
dropDownValueController1 = FormFieldController<String>(null);
|
||||
dropDownValueController2 = FormFieldController<String>(null);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,7 +51,6 @@ class PetsPageWidget extends StatefulWidget {
|
|||
class _PetsPageWidgetState extends State<PetsPageWidget>
|
||||
with SingleTickerProviderStateMixin {
|
||||
late PetsPageModel _model;
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
|
@ -59,7 +58,17 @@ class _PetsPageWidgetState extends State<PetsPageWidget>
|
|||
_model = PetsPageModel();
|
||||
_model.tabBarController = TabController(length: 2, vsync: this);
|
||||
_model.onUpdatePet = () {
|
||||
setState(() {});
|
||||
safeSetState(() {
|
||||
_model.clearFields();
|
||||
});
|
||||
};
|
||||
_model.onRegisterPet = () {
|
||||
safeSetState(() {
|
||||
_model.clearFields();
|
||||
});
|
||||
};
|
||||
_model.safeSetState = () {
|
||||
safeSetState(() {});
|
||||
};
|
||||
|
||||
widget.pet != null ? _model.isEditing = true : _model.isEditing = false;
|
||||
|
@ -199,7 +208,7 @@ class _PetsPageWidgetState extends State<PetsPageWidget>
|
|||
),
|
||||
),
|
||||
Form(
|
||||
key: _formKey,
|
||||
key: _model.registerFormKey,
|
||||
autovalidateMode: AutovalidateMode.onUserInteraction,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
|
@ -227,6 +236,7 @@ class _PetsPageWidgetState extends State<PetsPageWidget>
|
|||
.getVariableText(ptText: 'Nome', enText: 'Name'),
|
||||
suffixIcon: Symbols.format_color_text,
|
||||
haveMaxLength: true,
|
||||
onChanged: (value) => setState(() {}),
|
||||
maxLength: 80,
|
||||
),
|
||||
Padding(
|
||||
|
@ -243,6 +253,7 @@ class _PetsPageWidgetState extends State<PetsPageWidget>
|
|||
enText: 'e.g. Dog, Cat, Parrot'),
|
||||
suffixIcon: Symbols.sound_detection_dog_barking,
|
||||
haveMaxLength: true,
|
||||
onChanged: (value) => setState(() {}),
|
||||
maxLength: 80,
|
||||
),
|
||||
),
|
||||
|
@ -260,6 +271,7 @@ class _PetsPageWidgetState extends State<PetsPageWidget>
|
|||
enText: 'e.g. Labrador, Poodle, Siamese, Persian'),
|
||||
suffixIcon: Icons.pets_outlined,
|
||||
haveMaxLength: true,
|
||||
onChanged: (value) => setState(() {}),
|
||||
maxLength: 80,
|
||||
),
|
||||
),
|
||||
|
@ -277,6 +289,7 @@ class _PetsPageWidgetState extends State<PetsPageWidget>
|
|||
enText: 'e.g. Black, Yellow, White'),
|
||||
suffixIcon: Symbols.palette,
|
||||
haveMaxLength: true,
|
||||
onChanged: (value) => setState(() {}),
|
||||
maxLength: 80,
|
||||
),
|
||||
),
|
||||
|
@ -614,6 +627,7 @@ class _PetsPageWidgetState extends State<PetsPageWidget>
|
|||
enText: 'Write your observations here...'),
|
||||
suffixIcon: Icons.text_fields,
|
||||
haveMaxLength: true,
|
||||
onChanged: (value) => setState(() {}),
|
||||
maxLength: 250,
|
||||
),
|
||||
Padding(
|
||||
|
@ -657,7 +671,7 @@ class _PetsPageWidgetState extends State<PetsPageWidget>
|
|||
),
|
||||
),
|
||||
Form(
|
||||
key: _formKey,
|
||||
key: _model.updateFormKey,
|
||||
autovalidateMode: AutovalidateMode.onUserInteraction,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
|
@ -685,6 +699,7 @@ class _PetsPageWidgetState extends State<PetsPageWidget>
|
|||
.getVariableText(ptText: 'Nome', enText: 'Name'),
|
||||
suffixIcon: Symbols.format_color_text,
|
||||
haveMaxLength: true,
|
||||
onChanged: (value) => setState(() {}),
|
||||
maxLength: 80,
|
||||
),
|
||||
Padding(
|
||||
|
@ -701,6 +716,7 @@ class _PetsPageWidgetState extends State<PetsPageWidget>
|
|||
enText: 'e.g. Dog, Cat, Parrot'),
|
||||
suffixIcon: Symbols.sound_detection_dog_barking,
|
||||
haveMaxLength: true,
|
||||
onChanged: (value) => setState(() {}),
|
||||
maxLength: 80,
|
||||
),
|
||||
),
|
||||
|
@ -718,6 +734,7 @@ class _PetsPageWidgetState extends State<PetsPageWidget>
|
|||
enText: 'e.g. Labrador, Poodle, Siamese, Persian'),
|
||||
suffixIcon: Icons.pets_outlined,
|
||||
haveMaxLength: true,
|
||||
onChanged: (value) => setState(() {}),
|
||||
maxLength: 80,
|
||||
),
|
||||
),
|
||||
|
@ -735,6 +752,7 @@ class _PetsPageWidgetState extends State<PetsPageWidget>
|
|||
enText: 'e.g. Black, Yellow, White'),
|
||||
suffixIcon: Symbols.palette,
|
||||
haveMaxLength: true,
|
||||
onChanged: (value) => setState(() {}),
|
||||
maxLength: 80,
|
||||
),
|
||||
),
|
||||
|
@ -1075,6 +1093,7 @@ class _PetsPageWidgetState extends State<PetsPageWidget>
|
|||
suffixIcon: Icons.text_fields,
|
||||
haveMaxLength: true,
|
||||
maxLength: 250,
|
||||
onChanged: (value) => setState(() {}),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(70, 20, 70, 30),
|
||||
|
|
|
@ -488,7 +488,6 @@ class PreferencesPageModel with ChangeNotifier {
|
|||
);
|
||||
}
|
||||
}).catchError((err) {
|
||||
log(err.toString());
|
||||
context.pop();
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
|
|
|
@ -20,7 +20,6 @@ class ValidatorUtil {
|
|||
}
|
||||
|
||||
static String toISO8601(String format, String value) {
|
||||
log('value: $value');
|
||||
DateFormat dateFormat = DateFormat(format);
|
||||
DateTime dateTime = dateFormat.parse(value);
|
||||
|
||||
|
@ -28,7 +27,6 @@ class ValidatorUtil {
|
|||
}
|
||||
|
||||
static String toISO8601USA(String format, String value) {
|
||||
log('value: $value');
|
||||
DateFormat dateFormat = DateFormat(format);
|
||||
DateTime dateTime = dateFormat.parse(value);
|
||||
String date = dateTime.toIso8601String() + 'Z';
|
||||
|
@ -45,7 +43,6 @@ class ValidatorUtil {
|
|||
}
|
||||
|
||||
static String formatDateTimePicker(String dateTime) {
|
||||
log('dateTime: $dateTime');
|
||||
List<String> parts = dateTime.split(' ');
|
||||
String datePart = parts[0];
|
||||
List<String> dateParts = datePart.split('-');
|
||||
|
|
Loading…
Reference in New Issue