remove isInteractive parameter from PetsHistoryScreen widget
This commit is contained in:
parent
e355cd67fb
commit
37ad7952eb
|
@ -309,7 +309,6 @@ class _PetsHistoryScreenState extends State<PetsHistoryScreen> with TickerProvid
|
||||||
cliUUID: cliUUID,
|
cliUUID: cliUUID,
|
||||||
cliName: cliName,
|
cliName: cliName,
|
||||||
model: model,
|
model: model,
|
||||||
isInteractive: true,
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
|
@ -20,18 +20,12 @@ 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> {
|
||||||
static PetsPageModel? _instance = PetsPageModel._internal();
|
late String devUUID = '';
|
||||||
PetsPageModel._internal();
|
late String userUUID = '';
|
||||||
factory PetsPageModel() => _instance ?? PetsPageModel._internal();
|
late String cliUUID = '';
|
||||||
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;
|
||||||
|
|
||||||
late String defaultDropDownText = '';
|
|
||||||
late final TabController tabBarController;
|
late final TabController tabBarController;
|
||||||
VoidCallback? onUpdatePet;
|
VoidCallback? onUpdatePet;
|
||||||
VoidCallback? onRegisterPet;
|
VoidCallback? onRegisterPet;
|
||||||
|
@ -51,6 +45,8 @@ 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;
|
||||||
|
|
||||||
|
@ -108,9 +104,21 @@ class PetsPageModel extends FlutterFlowModel<PetsPageWidget> {
|
||||||
TextEditingController? textControllerObservation;
|
TextEditingController? textControllerObservation;
|
||||||
String? Function(BuildContext, String?)? textControllerObservationValidator;
|
String? Function(BuildContext, String?)? textControllerObservationValidator;
|
||||||
|
|
||||||
|
Future<void> initAsync() async {
|
||||||
|
defaultDropDownText = FFLocalizations.of(buildContext!).getVariableText(
|
||||||
|
enText: 'Select an option',
|
||||||
|
ptText: 'Selecione uma opção',
|
||||||
|
);
|
||||||
|
dropDownValueController1 = FormFieldController<String>(dropDownValue1 ??= defaultDropDownText);
|
||||||
|
dropDownValueController2 = FormFieldController<String>(dropDownValue2 ??= defaultDropDownText);
|
||||||
|
log('() => ): $devUUID');
|
||||||
|
|
||||||
|
safeSetState?.call();
|
||||||
|
log('() => ): $devUUID');
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState(BuildContext context) {
|
void initState(BuildContext context) {
|
||||||
resetInstance();
|
|
||||||
tabBarController = TabController(
|
tabBarController = TabController(
|
||||||
vsync: Navigator.of(context),
|
vsync: Navigator.of(context),
|
||||||
length: 2,
|
length: 2,
|
||||||
|
@ -140,49 +148,9 @@ class PetsPageModel extends FlutterFlowModel<PetsPageWidget> {
|
||||||
userUUID = await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage) ?? '';
|
userUUID = await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage) ?? '';
|
||||||
cliUUID = await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage) ?? '';
|
cliUUID = await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage) ?? '';
|
||||||
petAmountRegister = await StorageHelper().get(SQLiteStorageKey.petAmount.value, Storage.SQLiteStorage) ?? '';
|
petAmountRegister = await StorageHelper().get(SQLiteStorageKey.petAmount.value, Storage.SQLiteStorage) ?? '';
|
||||||
safeSetState?.call();
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> initAsync() async {
|
|
||||||
defaultDropDownText = FFLocalizations.of(buildContext!).getVariableText(
|
|
||||||
enText: 'Select an option',
|
|
||||||
ptText: 'Selecione uma opção',
|
|
||||||
);
|
|
||||||
dropDownValueController1 = FormFieldController<String>(dropDownValue1 ??= defaultDropDownText);
|
|
||||||
dropDownValueController2 = FormFieldController<String>(dropDownValue2 ??= defaultDropDownText);
|
|
||||||
log('() => ): $devUUID');
|
|
||||||
|
|
||||||
safeSetState?.call();
|
|
||||||
log('() => ): $devUUID');
|
|
||||||
}
|
|
||||||
|
|
||||||
@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() {
|
||||||
log('item: $item');
|
log('item: $item');
|
||||||
|
|
||||||
|
@ -222,25 +190,49 @@ class PetsPageModel extends FlutterFlowModel<PetsPageWidget> {
|
||||||
textFieldFocusObservation = FocusNode();
|
textFieldFocusObservation = FocusNode();
|
||||||
|
|
||||||
item != null ? dropDownValue1 = item['gender'] ?? '' : dropDownValue1 = '';
|
item != null ? dropDownValue1 = item['gender'] ?? '' : dropDownValue1 = '';
|
||||||
|
|
||||||
item != null ? dropDownValue2 = item['size'] ?? '' : dropDownValue2 = '';
|
item != null ? dropDownValue2 = item['size'] ?? '' : dropDownValue2 = '';
|
||||||
|
|
||||||
dropDownValueController1 = FormFieldController<String>(dropDownValue1);
|
dropDownValueController1 = FormFieldController<String>(dropDownValue1);
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -262,6 +254,7 @@ class PetsPageModel extends FlutterFlowModel<PetsPageWidget> {
|
||||||
if (dropDownValue2 == 'Selecione uma opção' || dropDownValue2 == null || dropDownValue2 == '') {
|
if (dropDownValue2 == 'Selecione uma opção' || dropDownValue2 == null || dropDownValue2 == '') {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -284,7 +277,7 @@ class PetsPageModel extends FlutterFlowModel<PetsPageWidget> {
|
||||||
);
|
);
|
||||||
|
|
||||||
if (response.jsonBody['error'] == false) {
|
if (response.jsonBody['error'] == false) {
|
||||||
DialogUtil.success(
|
await DialogUtil.success(
|
||||||
buildContext!,
|
buildContext!,
|
||||||
FFLocalizations.of(buildContext!).getVariableText(
|
FFLocalizations.of(buildContext!).getVariableText(
|
||||||
enText: 'Pet successfully updated',
|
enText: 'Pet successfully updated',
|
||||||
|
@ -305,7 +298,7 @@ class PetsPageModel extends FlutterFlowModel<PetsPageWidget> {
|
||||||
ptText: 'Falha ao atualizar o pet',
|
ptText: 'Falha ao atualizar o pet',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
DialogUtil.error(buildContext!, errorMessage);
|
await DialogUtil.error(buildContext!, errorMessage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -325,7 +318,7 @@ class PetsPageModel extends FlutterFlowModel<PetsPageWidget> {
|
||||||
);
|
);
|
||||||
|
|
||||||
if (response.jsonBody['error'] == false) {
|
if (response.jsonBody['error'] == false) {
|
||||||
DialogUtil.success(
|
await DialogUtil.success(
|
||||||
buildContext!,
|
buildContext!,
|
||||||
FFLocalizations.of(buildContext!).getVariableText(
|
FFLocalizations.of(buildContext!).getVariableText(
|
||||||
enText: 'Pet successfully registered',
|
enText: 'Pet successfully registered',
|
||||||
|
@ -337,15 +330,16 @@ 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',
|
||||||
);
|
);
|
||||||
DialogUtil.error(buildContext!, errorMessage);
|
await DialogUtil.error(buildContext!, errorMessage);
|
||||||
} else {
|
} else {
|
||||||
DialogUtil.errorDefault(buildContext!);
|
await DialogUtil.errorDefault(buildContext!);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -385,10 +379,8 @@ class PetsPageModel extends FlutterFlowModel<PetsPageWidget> {
|
||||||
// dropDownValue1 = '';
|
// dropDownValue1 = '';
|
||||||
// dropDownValue2 = '';
|
// dropDownValue2 = '';
|
||||||
|
|
||||||
// dropDownValueController1 =
|
// dropDownValueController1 = FormFieldController<String>('Selecione uma opção');
|
||||||
// FormFieldController<String>('Selecione uma opção');
|
// dropDownValueController2 = FormFieldController<String>('Selecione uma opção');
|
||||||
// dropDownValueController2 =
|
|
||||||
// FormFieldController<String>('Selecione uma opção');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget buildPetDetails({
|
Widget buildPetDetails({
|
||||||
|
@ -399,123 +391,120 @@ 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',
|
enText: 'Edit',
|
||||||
enText: 'Edit',
|
|
||||||
),
|
|
||||||
icon: const Icon(Icons.edit),
|
|
||||||
onPressed: () async {
|
|
||||||
context.pop();
|
|
||||||
|
|
||||||
model.isEditing = true;
|
|
||||||
model.item = item;
|
|
||||||
model.switchTab(0);
|
|
||||||
model.setEditForm();
|
|
||||||
// model.safeSetState!();
|
|
||||||
},
|
|
||||||
options: FFButtonOptions(
|
|
||||||
width: 100,
|
|
||||||
height: 40,
|
|
||||||
color: FlutterFlowTheme.of(context).primaryBackground,
|
|
||||||
elevation: 0,
|
|
||||||
textStyle: TextStyle(
|
|
||||||
color: FlutterFlowTheme.of(context).primaryText,
|
|
||||||
fontSize: LimitedFontSizeUtil.getNoResizeFont(context, 15),
|
|
||||||
),
|
|
||||||
splashColor: const Color.fromARGB(95, 0, 146, 5),
|
|
||||||
borderSide: BorderSide(
|
|
||||||
color: FlutterFlowTheme.of(context).primaryBackground,
|
|
||||||
width: 1,
|
|
||||||
),
|
|
||||||
// borderRadius: 12,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
|
icon: const Icon(Icons.edit),
|
||||||
|
onPressed: () async {
|
||||||
|
context.pop();
|
||||||
|
|
||||||
|
model.isEditing = true;
|
||||||
|
model.item = item;
|
||||||
|
model.switchTab(0);
|
||||||
|
model.setEditForm();
|
||||||
|
// model.safeSetState!();
|
||||||
|
},
|
||||||
|
options: FFButtonOptions(
|
||||||
|
width: 100,
|
||||||
|
height: 40,
|
||||||
|
color: FlutterFlowTheme.of(context).primaryBackground,
|
||||||
|
elevation: 0,
|
||||||
|
textStyle: TextStyle(
|
||||||
|
color: FlutterFlowTheme.of(context).primaryText,
|
||||||
|
fontSize: LimitedFontSizeUtil.getNoResizeFont(context, 15),
|
||||||
|
),
|
||||||
|
splashColor: const Color.fromARGB(95, 0, 146, 5),
|
||||||
|
borderSide: BorderSide(
|
||||||
|
color: FlutterFlowTheme.of(context).primaryBackground,
|
||||||
|
width: 1,
|
||||||
|
),
|
||||||
|
// borderRadius: 12,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
// DELETE ACTION
|
// DELETE ACTION
|
||||||
if (isInteractive)
|
FFButtonWidget(
|
||||||
FFButtonWidget(
|
text: FFLocalizations.of(context).getVariableText(
|
||||||
text: FFLocalizations.of(context).getVariableText(
|
ptText: 'Excluir',
|
||||||
ptText: 'Excluir',
|
enText: 'Delete',
|
||||||
enText: 'Delete',
|
),
|
||||||
),
|
icon: const Icon(Icons.close),
|
||||||
icon: const Icon(Icons.close),
|
onPressed: () async {
|
||||||
onPressed: () async {
|
showAlertDialog(
|
||||||
showAlertDialog(
|
context,
|
||||||
context,
|
FFLocalizations.of(context).getVariableText(
|
||||||
FFLocalizations.of(context).getVariableText(
|
ptText: 'Excluir Pet',
|
||||||
ptText: 'Excluir Pet',
|
enText: 'Delete Pet',
|
||||||
enText: 'Delete Pet',
|
),
|
||||||
),
|
FFLocalizations.of(context).getVariableText(
|
||||||
FFLocalizations.of(context).getVariableText(
|
ptText: 'Você tem certeza que deseja excluir esse pet?',
|
||||||
ptText: 'Você tem certeza que deseja excluir esse pet?',
|
enText: 'Are you sure you want to delete this pet?',
|
||||||
enText: 'Are you sure you want to delete this pet?',
|
), () async {
|
||||||
), () async {
|
int id = item['id'];
|
||||||
int id = item['id'];
|
await PhpGroup.deletePet
|
||||||
await PhpGroup.deletePet
|
.call(
|
||||||
.call(
|
petID: id,
|
||||||
petID: id,
|
)
|
||||||
)
|
.then((value) {
|
||||||
.then((value) {
|
// Navigator.pop(context, value);
|
||||||
// Navigator.pop(context, value);
|
context.pop(value);
|
||||||
context.pop(value);
|
context.pop(value);
|
||||||
context.pop(value);
|
|
||||||
|
|
||||||
if (value == false) {
|
if (value == false) {
|
||||||
showSnackbar(
|
|
||||||
context,
|
|
||||||
FFLocalizations.of(context).getVariableText(
|
|
||||||
ptText: 'Erro ao excluir pet',
|
|
||||||
enText: 'Error deleting pet',
|
|
||||||
),
|
|
||||||
true,
|
|
||||||
);
|
|
||||||
} else if (value == true) {
|
|
||||||
showSnackbar(
|
|
||||||
context,
|
|
||||||
FFLocalizations.of(context).getVariableText(
|
|
||||||
enText: 'Success deleting pet',
|
|
||||||
ptText: 'Succeso ao excluir pet',
|
|
||||||
),
|
|
||||||
false,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}).catchError((err, stack) {
|
|
||||||
context.pop();
|
|
||||||
showSnackbar(
|
showSnackbar(
|
||||||
context,
|
context,
|
||||||
FFLocalizations.of(context).getVariableText(
|
FFLocalizations.of(context).getVariableText(
|
||||||
enText: 'Error deleting pet',
|
|
||||||
ptText: 'Erro ao excluir pet',
|
ptText: 'Erro ao excluir pet',
|
||||||
|
enText: 'Error deleting pet',
|
||||||
),
|
),
|
||||||
true,
|
true,
|
||||||
);
|
);
|
||||||
});
|
} else if (value == true) {
|
||||||
|
showSnackbar(
|
||||||
|
context,
|
||||||
|
FFLocalizations.of(context).getVariableText(
|
||||||
|
enText: 'Success deleting pet',
|
||||||
|
ptText: 'Succeso ao excluir pet',
|
||||||
|
),
|
||||||
|
false,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}).catchError((err, stack) {
|
||||||
|
context.pop();
|
||||||
|
showSnackbar(
|
||||||
|
context,
|
||||||
|
FFLocalizations.of(context).getVariableText(
|
||||||
|
enText: 'Error deleting pet',
|
||||||
|
ptText: 'Erro ao excluir pet',
|
||||||
|
),
|
||||||
|
true,
|
||||||
|
);
|
||||||
});
|
});
|
||||||
},
|
});
|
||||||
options: FFButtonOptions(
|
},
|
||||||
width: 100,
|
options: FFButtonOptions(
|
||||||
height: 40,
|
width: 100,
|
||||||
color: FlutterFlowTheme.of(context).primaryBackground,
|
height: 40,
|
||||||
elevation: 0,
|
color: FlutterFlowTheme.of(context).primaryBackground,
|
||||||
textStyle: TextStyle(
|
elevation: 0,
|
||||||
color: FlutterFlowTheme.of(context).primaryText,
|
textStyle: TextStyle(
|
||||||
fontSize: LimitedFontSizeUtil.getNoResizeFont(context, 15),
|
color: FlutterFlowTheme.of(context).primaryText,
|
||||||
),
|
fontSize: LimitedFontSizeUtil.getNoResizeFont(context, 15),
|
||||||
splashColor: const Color.fromARGB(131, 255, 17, 0),
|
|
||||||
borderSide: BorderSide(
|
|
||||||
color: FlutterFlowTheme.of(context).primaryBackground,
|
|
||||||
width: 1,
|
|
||||||
),
|
|
||||||
// borderRadius: 12,
|
|
||||||
),
|
),
|
||||||
|
splashColor: const Color.fromARGB(131, 255, 17, 0),
|
||||||
|
borderSide: BorderSide(
|
||||||
|
color: FlutterFlowTheme.of(context).primaryBackground,
|
||||||
|
width: 1,
|
||||||
|
),
|
||||||
|
// borderRadius: 12,
|
||||||
),
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
// 'MIN', 'PEQ', 'MED', 'GRA', 'GIG'
|
// 'MIN', 'PEQ', 'MED', 'GRA', 'GIG'
|
||||||
labelsHashMap: Map<String, String>.from({
|
labelsHashMap: Map<String, String>.from({
|
||||||
|
|
Loading…
Reference in New Issue