Fix: Arrumado o input de data e de dropdown agora está passando os parametros corretamente
This commit is contained in:
parent
0dd0990523
commit
6ba19e548c
|
@ -1,10 +1,12 @@
|
||||||
|
import 'dart:developer';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:google_fonts/google_fonts.dart';
|
import 'package:google_fonts/google_fonts.dart';
|
||||||
import 'package:hub/flutter_flow/flutter_flow_theme.dart';
|
import 'package:hub/flutter_flow/flutter_flow_theme.dart';
|
||||||
import 'package:hub/flutter_flow/flutter_flow_util.dart';
|
import 'package:hub/flutter_flow/flutter_flow_util.dart';
|
||||||
|
|
||||||
class CustomDatePickerUtil extends StatefulWidget {
|
class CustomDatePickerUtil extends StatefulWidget {
|
||||||
final TextEditingController? controller;
|
TextEditingController? controller;
|
||||||
final FocusNode? focusNode;
|
final FocusNode? focusNode;
|
||||||
final String hintText;
|
final String hintText;
|
||||||
final String dateFormat;
|
final String dateFormat;
|
||||||
|
@ -15,7 +17,7 @@ class CustomDatePickerUtil extends StatefulWidget {
|
||||||
final bool timePicker;
|
final bool timePicker;
|
||||||
final FormFieldValidator<String>? validator;
|
final FormFieldValidator<String>? validator;
|
||||||
|
|
||||||
const CustomDatePickerUtil({
|
CustomDatePickerUtil({
|
||||||
Key? key,
|
Key? key,
|
||||||
this.controller,
|
this.controller,
|
||||||
this.focusNode,
|
this.focusNode,
|
||||||
|
@ -40,13 +42,19 @@ class _CustomDatePickerState extends State<CustomDatePickerUtil> {
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
|
log('Chamou o initState');
|
||||||
_selectedDate = widget.initialDate;
|
_selectedDate = widget.initialDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _selectDate(BuildContext context) async {
|
@override
|
||||||
final DateTime? pickedDate = await showDatePicker(
|
void dispose() {
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
_selectDate(BuildContext context) async {
|
||||||
|
final pickedDate = await showDatePicker(
|
||||||
context: context,
|
context: context,
|
||||||
initialDate: _selectedDate ?? DateTime.now(),
|
initialDate: getCurrentTimestamp,
|
||||||
firstDate: widget.firstDate,
|
firstDate: widget.firstDate,
|
||||||
lastDate: widget.lastDate ?? DateTime(2100),
|
lastDate: widget.lastDate ?? DateTime(2100),
|
||||||
builder: (context, child) {
|
builder: (context, child) {
|
||||||
|
@ -131,12 +139,18 @@ class _CustomDatePickerState extends State<CustomDatePickerUtil> {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
setState(() {
|
setState(() {
|
||||||
_selectedDate = pickedDate;
|
log('Chamou o setState da datinha');
|
||||||
widget.controller?.text = dateTimeFormat(
|
_selectedDate = DateTime(
|
||||||
|
pickedDate.year,
|
||||||
|
pickedDate.month,
|
||||||
|
pickedDate.day,
|
||||||
|
);
|
||||||
|
widget.controller = TextEditingController(
|
||||||
|
text: dateTimeFormat(
|
||||||
widget.dateFormat,
|
widget.dateFormat,
|
||||||
_selectedDate,
|
_selectedDate,
|
||||||
locale: widget.locale,
|
locale: widget.locale,
|
||||||
);
|
));
|
||||||
widget.controller?.selection = TextSelection.collapsed(
|
widget.controller?.selection = TextSelection.collapsed(
|
||||||
offset: widget.controller!.text.length,
|
offset: widget.controller!.text.length,
|
||||||
);
|
);
|
||||||
|
|
|
@ -5,13 +5,14 @@ import 'package:hub/components/atomic_components/shared_components_atoms/tabview
|
||||||
import 'package:hub/flutter_flow/flutter_flow_theme.dart';
|
import 'package:hub/flutter_flow/flutter_flow_theme.dart';
|
||||||
import 'package:hub/flutter_flow/flutter_flow_util.dart';
|
import 'package:hub/flutter_flow/flutter_flow_util.dart';
|
||||||
|
|
||||||
class CustomInputUtil extends StatelessWidget {
|
class CustomInputUtil extends StatefulWidget {
|
||||||
final TextEditingController? controller;
|
final TextEditingController? controller;
|
||||||
final String? labelText;
|
final String? labelText;
|
||||||
final String? hintText;
|
final String? hintText;
|
||||||
final bool? obscureText;
|
final bool? obscureText;
|
||||||
final IconData? suffixIcon;
|
final IconData? suffixIcon;
|
||||||
final bool autoFocus;
|
final bool autoFocus;
|
||||||
|
FocusNode? focusNode;
|
||||||
final TextInputAction textInputAction;
|
final TextInputAction textInputAction;
|
||||||
final TextInputType keyboardType;
|
final TextInputType keyboardType;
|
||||||
final int maxLength;
|
final int maxLength;
|
||||||
|
@ -25,6 +26,7 @@ class CustomInputUtil extends StatelessWidget {
|
||||||
required this.hintText,
|
required this.hintText,
|
||||||
required this.suffixIcon,
|
required this.suffixIcon,
|
||||||
this.autoFocus = false,
|
this.autoFocus = false,
|
||||||
|
required this.focusNode,
|
||||||
this.textInputAction = TextInputAction.next,
|
this.textInputAction = TextInputAction.next,
|
||||||
this.keyboardType = TextInputType.text,
|
this.keyboardType = TextInputType.text,
|
||||||
this.maxLength = 80,
|
this.maxLength = 80,
|
||||||
|
@ -33,6 +35,16 @@ class CustomInputUtil extends StatelessWidget {
|
||||||
required this.haveMaxLength})
|
required this.haveMaxLength})
|
||||||
: super(key: key);
|
: super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<CustomInputUtil> createState() => _CustomInputUtilState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _CustomInputUtilState extends State<CustomInputUtil> {
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Padding(
|
return Padding(
|
||||||
|
@ -40,14 +52,15 @@ class CustomInputUtil extends StatelessWidget {
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
TextFormField(
|
TextFormField(
|
||||||
controller: controller,
|
controller: widget.controller,
|
||||||
autovalidateMode: AutovalidateMode.onUserInteraction,
|
autovalidateMode: AutovalidateMode.onUserInteraction,
|
||||||
autofocus: autoFocus,
|
autofocus: widget.autoFocus,
|
||||||
textInputAction: textInputAction,
|
focusNode: widget.focusNode,
|
||||||
|
textInputAction: widget.textInputAction,
|
||||||
obscureText: false,
|
obscureText: false,
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
isDense: true,
|
isDense: true,
|
||||||
labelText: labelText,
|
labelText: widget.labelText,
|
||||||
labelStyle: FlutterFlowTheme.of(context).labelMedium.override(
|
labelStyle: FlutterFlowTheme.of(context).labelMedium.override(
|
||||||
fontFamily: FlutterFlowTheme.of(context).labelMediumFamily,
|
fontFamily: FlutterFlowTheme.of(context).labelMediumFamily,
|
||||||
color: FlutterFlowTheme.of(context).primaryText,
|
color: FlutterFlowTheme.of(context).primaryText,
|
||||||
|
@ -55,7 +68,7 @@ class CustomInputUtil extends StatelessWidget {
|
||||||
useGoogleFonts: GoogleFonts.asMap().containsKey(
|
useGoogleFonts: GoogleFonts.asMap().containsKey(
|
||||||
FlutterFlowTheme.of(context).labelMediumFamily),
|
FlutterFlowTheme.of(context).labelMediumFamily),
|
||||||
),
|
),
|
||||||
hintText: hintText,
|
hintText: widget.hintText,
|
||||||
hintStyle: FlutterFlowTheme.of(context).labelMedium.override(
|
hintStyle: FlutterFlowTheme.of(context).labelMedium.override(
|
||||||
fontFamily: FlutterFlowTheme.of(context).labelMediumFamily,
|
fontFamily: FlutterFlowTheme.of(context).labelMediumFamily,
|
||||||
color: FlutterFlowTheme.of(context).primaryText,
|
color: FlutterFlowTheme.of(context).primaryText,
|
||||||
|
@ -92,7 +105,7 @@ class CustomInputUtil extends StatelessWidget {
|
||||||
borderRadius: BorderRadius.circular(10.0),
|
borderRadius: BorderRadius.circular(10.0),
|
||||||
),
|
),
|
||||||
suffixIcon: Icon(
|
suffixIcon: Icon(
|
||||||
suffixIcon,
|
widget.suffixIcon,
|
||||||
color: FlutterFlowTheme.of(context).accent1,
|
color: FlutterFlowTheme.of(context).accent1,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -104,10 +117,12 @@ class CustomInputUtil extends StatelessWidget {
|
||||||
FlutterFlowTheme.of(context).bodyMediumFamily),
|
FlutterFlowTheme.of(context).bodyMediumFamily),
|
||||||
),
|
),
|
||||||
maxLines: null,
|
maxLines: null,
|
||||||
maxLength: haveMaxLength ? maxLength : null,
|
maxLength: widget.haveMaxLength ? widget.maxLength : null,
|
||||||
keyboardType: keyboardType,
|
keyboardType: widget.keyboardType,
|
||||||
inputFormatters: [LengthLimitingTextInputFormatter(maxLength)],
|
inputFormatters: [
|
||||||
validator: validator,
|
LengthLimitingTextInputFormatter(widget.maxLength)
|
||||||
|
],
|
||||||
|
validator: widget.validator,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
|
import 'dart:developer';
|
||||||
|
import 'dart:math';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:google_fonts/google_fonts.dart';
|
import 'package:google_fonts/google_fonts.dart';
|
||||||
|
import 'package:hub/components/organism_components/message_well_component/message_well_component_widget.dart';
|
||||||
import 'package:hub/flutter_flow/flutter_flow_drop_down.dart';
|
import 'package:hub/flutter_flow/flutter_flow_drop_down.dart';
|
||||||
import 'package:hub/flutter_flow/flutter_flow_theme.dart';
|
import 'package:hub/flutter_flow/flutter_flow_theme.dart';
|
||||||
import 'package:hub/flutter_flow/flutter_flow_util.dart';
|
import 'package:hub/flutter_flow/flutter_flow_util.dart';
|
||||||
|
@ -10,14 +14,20 @@ class CustomSelect extends StatefulWidget {
|
||||||
final List<String> options;
|
final List<String> options;
|
||||||
final List<String> optionsLabel;
|
final List<String> optionsLabel;
|
||||||
final String hintText;
|
final String hintText;
|
||||||
final FormFieldController<String>? controller;
|
final bool isMultiSelect;
|
||||||
|
FormFieldController<String> controller;
|
||||||
|
dynamic Function(String?)? changed;
|
||||||
|
String? dropDownValue;
|
||||||
|
|
||||||
const CustomSelect({
|
CustomSelect({
|
||||||
Key? key,
|
Key? key,
|
||||||
required this.options,
|
required this.options,
|
||||||
required this.optionsLabel,
|
required this.optionsLabel,
|
||||||
required this.hintText,
|
required this.hintText,
|
||||||
this.controller,
|
required this.controller,
|
||||||
|
required this.changed,
|
||||||
|
this.dropDownValue,
|
||||||
|
this.isMultiSelect = false,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -25,12 +35,9 @@ class CustomSelect extends StatefulWidget {
|
||||||
}
|
}
|
||||||
|
|
||||||
class _CustomSelectState extends State<CustomSelect> {
|
class _CustomSelectState extends State<CustomSelect> {
|
||||||
late FormFieldController<String> _controller;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
_controller = widget.controller ?? FormFieldController<String>(null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -53,12 +60,13 @@ class _CustomSelectState extends State<CustomSelect> {
|
||||||
child: FlutterFlowDropDown<String>(
|
child: FlutterFlowDropDown<String>(
|
||||||
fillColor:
|
fillColor:
|
||||||
FlutterFlowTheme.of(context).secondaryBackground,
|
FlutterFlowTheme.of(context).secondaryBackground,
|
||||||
controller: _controller,
|
controller: widget.controller ??=
|
||||||
|
FormFieldController<String>(
|
||||||
|
widget.dropDownValue ??= ''),
|
||||||
options: widget.options,
|
options: widget.options,
|
||||||
optionLabels: widget.optionsLabel,
|
optionLabels: widget.optionsLabel,
|
||||||
onChanged: (val) {
|
onChanged: widget.changed,
|
||||||
setState(() => _controller.value = val);
|
isMultiSelect: false,
|
||||||
},
|
|
||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
height: double.infinity,
|
height: double.infinity,
|
||||||
textStyle: FlutterFlowTheme.of(context)
|
textStyle: FlutterFlowTheme.of(context)
|
||||||
|
@ -85,7 +93,6 @@ class _CustomSelectState extends State<CustomSelect> {
|
||||||
hidesUnderline: true,
|
hidesUnderline: true,
|
||||||
isOverButton: true,
|
isOverButton: true,
|
||||||
isSearchable: false,
|
isSearchable: false,
|
||||||
isMultiSelect: false,
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
@ -0,0 +1,48 @@
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:google_fonts/google_fonts.dart';
|
||||||
|
import 'package:hub/flutter_flow/flutter_flow_theme.dart';
|
||||||
|
import 'package:hub/flutter_flow/flutter_flow_widgets.dart';
|
||||||
|
import 'package:hub/flutter_flow/internationalization.dart';
|
||||||
|
|
||||||
|
class SubmitButtonUtil extends StatelessWidget {
|
||||||
|
final String labelText;
|
||||||
|
final VoidCallback onPressed;
|
||||||
|
|
||||||
|
const SubmitButtonUtil({
|
||||||
|
required this.labelText,
|
||||||
|
required this.onPressed,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return FFButtonWidget(
|
||||||
|
onPressed: onPressed,
|
||||||
|
text: labelText,
|
||||||
|
options: FFButtonOptions(
|
||||||
|
width: 250.0,
|
||||||
|
height: 36.0,
|
||||||
|
disabledColor: FlutterFlowTheme.of(context).customColor5,
|
||||||
|
padding: const EdgeInsetsDirectional.fromSTEB(80.0, 0.0, 80.0, 0.0),
|
||||||
|
iconPadding: const EdgeInsetsDirectional.fromSTEB(0.0, 0.0, 0.0, 0.0),
|
||||||
|
color: FlutterFlowTheme.of(context).primary,
|
||||||
|
textStyle: FlutterFlowTheme.of(context).titleSmall.override(
|
||||||
|
fontFamily: FlutterFlowTheme.of(context).titleSmallFamily,
|
||||||
|
color: FlutterFlowTheme.of(context).info,
|
||||||
|
letterSpacing: 0.0,
|
||||||
|
useGoogleFonts: GoogleFonts.asMap()
|
||||||
|
.containsKey(FlutterFlowTheme.of(context).titleSmallFamily),
|
||||||
|
),
|
||||||
|
borderSide: const BorderSide(
|
||||||
|
color: Colors.transparent,
|
||||||
|
width: 30.0,
|
||||||
|
),
|
||||||
|
borderRadius: const BorderRadius.only(
|
||||||
|
bottomLeft: Radius.circular(15.0),
|
||||||
|
bottomRight: Radius.circular(15.0),
|
||||||
|
topLeft: Radius.circular(15.0),
|
||||||
|
topRight: Radius.circular(15.0),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
|
@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
|
||||||
import 'package:hub/flutter_flow/flutter_flow_util.dart';
|
import 'package:hub/flutter_flow/flutter_flow_util.dart';
|
||||||
import 'package:hub/flutter_flow/form_field_controller.dart';
|
import 'package:hub/flutter_flow/form_field_controller.dart';
|
||||||
import 'package:hub/pages/pets_page/pets_page_widget.dart';
|
import 'package:hub/pages/pets_page/pets_page_widget.dart';
|
||||||
|
import 'package:hub/shared/utils/log_util.dart';
|
||||||
|
|
||||||
class PetsPageModel extends FlutterFlowModel<PetsPageWidget> {
|
class PetsPageModel extends FlutterFlowModel<PetsPageWidget> {
|
||||||
late final TabController tabBarController;
|
late final TabController tabBarController;
|
||||||
|
@ -26,14 +27,12 @@ class PetsPageModel extends FlutterFlowModel<PetsPageWidget> {
|
||||||
TextEditingController? textControllerName;
|
TextEditingController? textControllerName;
|
||||||
String? Function(BuildContext, String?)? textControllerNameValidator;
|
String? Function(BuildContext, String?)? textControllerNameValidator;
|
||||||
String? _textControllerNameValidator(BuildContext context, String? val) {
|
String? _textControllerNameValidator(BuildContext context, String? val) {
|
||||||
log('Chamou esta merda');
|
|
||||||
if (val == null || val.isEmpty) {
|
if (val == null || val.isEmpty) {
|
||||||
return FFLocalizations.of(context).getVariableText(
|
return FFLocalizations.of(context).getVariableText(
|
||||||
enText: 'This field is required',
|
enText: 'This field is required',
|
||||||
ptText: 'Este campo é obrigatório',
|
ptText: 'Este campo é obrigatório',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,9 +48,19 @@ class PetsPageModel extends FlutterFlowModel<PetsPageWidget> {
|
||||||
TextEditingController? textControllerColor;
|
TextEditingController? textControllerColor;
|
||||||
String? Function(BuildContext, String?)? textControllerColorValidator;
|
String? Function(BuildContext, String?)? textControllerColorValidator;
|
||||||
|
|
||||||
|
DateTime? selectedDate;
|
||||||
FocusNode? textFieldFocusData;
|
FocusNode? textFieldFocusData;
|
||||||
TextEditingController? textControllerData;
|
TextEditingController? textControllerData;
|
||||||
String? Function(BuildContext, String?)? textControllerDataValidator;
|
String? Function(BuildContext, String?)? textControllerDataValidator;
|
||||||
|
String? _textControllerDataValidator(BuildContext context, String? val) {
|
||||||
|
if (val == null || val.isEmpty) {
|
||||||
|
return FFLocalizations.of(context).getVariableText(
|
||||||
|
enText: 'This field is required.',
|
||||||
|
ptText: 'Este campo é obrigatório.',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
FocusNode? textFieldFocusObservation;
|
FocusNode? textFieldFocusObservation;
|
||||||
TextEditingController? textControllerObservation;
|
TextEditingController? textControllerObservation;
|
||||||
|
@ -69,12 +78,30 @@ class PetsPageModel extends FlutterFlowModel<PetsPageWidget> {
|
||||||
textControllerName = TextEditingController();
|
textControllerName = TextEditingController();
|
||||||
textControllerNameValidator =
|
textControllerNameValidator =
|
||||||
(context, value) => _textControllerNameValidator(context, value);
|
(context, value) => _textControllerNameValidator(context, value);
|
||||||
|
|
||||||
|
textFieldFocusData = FocusNode();
|
||||||
|
textControllerData = TextEditingController(
|
||||||
|
text: dateTimeFormat(
|
||||||
|
'dd/MM/yyyy',
|
||||||
|
DateTime.now(),
|
||||||
|
));
|
||||||
|
textControllerDataValidator = _textControllerDataValidator;
|
||||||
|
|
||||||
|
dropDownValueController1 =
|
||||||
|
FormFieldController<String>(dropDownValue1 ??= 'Selecione uma opção');
|
||||||
|
|
||||||
|
dropDownValueController2 =
|
||||||
|
FormFieldController<String>(dropDownValue2 ??= 'Selecione uma opção');
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
tabBarController.dispose();
|
tabBarController.dispose();
|
||||||
|
|
||||||
textFieldFocusName?.dispose();
|
textFieldFocusName?.dispose();
|
||||||
textControllerName?.dispose();
|
textControllerName?.dispose();
|
||||||
|
|
||||||
|
textFieldFocusData?.dispose();
|
||||||
|
textControllerData?.dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,16 +11,19 @@ import 'package:hub/components/atomic_components/shared_components_atoms/custom_
|
||||||
import 'package:hub/components/atomic_components/shared_components_atoms/custom_input.dart';
|
import 'package:hub/components/atomic_components/shared_components_atoms/custom_input.dart';
|
||||||
import 'package:hub/components/atomic_components/shared_components_atoms/custom_select.dart';
|
import 'package:hub/components/atomic_components/shared_components_atoms/custom_select.dart';
|
||||||
import 'package:hub/components/atomic_components/shared_components_atoms/media_upload_button.dart';
|
import 'package:hub/components/atomic_components/shared_components_atoms/media_upload_button.dart';
|
||||||
|
import 'package:hub/components/atomic_components/shared_components_atoms/submit_button.dart';
|
||||||
import 'package:hub/components/atomic_components/shared_components_atoms/tabview.dart';
|
import 'package:hub/components/atomic_components/shared_components_atoms/tabview.dart';
|
||||||
|
|
||||||
import 'package:hub/flutter_flow/flutter_flow_theme.dart';
|
import 'package:hub/flutter_flow/flutter_flow_theme.dart';
|
||||||
import 'package:hub/flutter_flow/flutter_flow_util.dart';
|
import 'package:hub/flutter_flow/flutter_flow_util.dart';
|
||||||
import 'package:hub/flutter_flow/flutter_flow_widgets.dart';
|
import 'package:hub/flutter_flow/flutter_flow_widgets.dart';
|
||||||
|
import 'package:hub/flutter_flow/form_field_controller.dart';
|
||||||
import 'package:hub/flutter_flow/internationalization.dart';
|
import 'package:hub/flutter_flow/internationalization.dart';
|
||||||
import 'package:hub/flutter_flow/nav/nav.dart';
|
import 'package:hub/flutter_flow/nav/nav.dart';
|
||||||
import 'package:hub/flutter_flow/upload_data.dart';
|
import 'package:hub/flutter_flow/upload_data.dart';
|
||||||
|
|
||||||
import 'package:hub/pages/pets_page/pets_page_model.dart';
|
import 'package:hub/pages/pets_page/pets_page_model.dart';
|
||||||
|
import 'package:sqflite/sqflite.dart';
|
||||||
|
|
||||||
class PetsPageWidget extends StatefulWidget {
|
class PetsPageWidget extends StatefulWidget {
|
||||||
PetsPageWidget({super.key});
|
PetsPageWidget({super.key});
|
||||||
|
@ -43,10 +46,44 @@ class _PetsPageWidgetState extends State<PetsPageWidget>
|
||||||
_model.textFieldFocusName ??= FocusNode();
|
_model.textFieldFocusName ??= FocusNode();
|
||||||
|
|
||||||
_model.textControllerSpecies ??= TextEditingController();
|
_model.textControllerSpecies ??= TextEditingController();
|
||||||
|
_model.textFieldFocusSpecies ??= FocusNode();
|
||||||
|
|
||||||
|
_model.textControllerRace ??= TextEditingController();
|
||||||
|
_model.textFieldFocusRace ??= FocusNode();
|
||||||
|
|
||||||
|
_model.textControllerColor ??= TextEditingController();
|
||||||
|
_model.textFieldFocusColor ??= FocusNode();
|
||||||
|
|
||||||
|
_model.textControllerData ??= TextEditingController();
|
||||||
|
_model.textFieldFocusData ??= FocusNode();
|
||||||
|
|
||||||
|
_model.textControllerObservation ??= TextEditingController();
|
||||||
|
_model.textFieldFocusObservation ??= FocusNode();
|
||||||
|
|
||||||
|
_model.dropDownValueController1 ??=
|
||||||
|
FormFieldController<String>(_model.dropDownValue1 ??= '');
|
||||||
|
|
||||||
|
_model.dropDownValueController2 ??=
|
||||||
|
FormFieldController<String>(_model.dropDownValue2 ??= '');
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
|
_model.textControllerName?.dispose();
|
||||||
|
_model.textFieldFocusName?.dispose();
|
||||||
|
|
||||||
|
_model.textControllerSpecies?.dispose();
|
||||||
|
_model.textFieldFocusSpecies?.dispose();
|
||||||
|
|
||||||
|
_model.textControllerRace?.dispose();
|
||||||
|
_model.textFieldFocusRace?.dispose();
|
||||||
|
|
||||||
|
_model.textControllerColor?.dispose();
|
||||||
|
_model.textFieldFocusColor?.dispose();
|
||||||
|
|
||||||
|
_model.textControllerData?.dispose();
|
||||||
|
_model.textFieldFocusData?.dispose();
|
||||||
|
|
||||||
_model.tabBarController.dispose();
|
_model.tabBarController.dispose();
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
@ -140,6 +177,9 @@ Widget formAddPets(BuildContext context, PetsPageModel _model,
|
||||||
controller: _model.textControllerName,
|
controller: _model.textControllerName,
|
||||||
validator:
|
validator:
|
||||||
_model.textControllerNameValidator.asValidator(context),
|
_model.textControllerNameValidator.asValidator(context),
|
||||||
|
focusNode: _model.textFieldFocusName,
|
||||||
|
autoFocus: false,
|
||||||
|
keyboardType: TextInputType.text,
|
||||||
labelText: FFLocalizations.of(context)
|
labelText: FFLocalizations.of(context)
|
||||||
.getVariableText(ptText: 'Nome', enText: 'Name'),
|
.getVariableText(ptText: 'Nome', enText: 'Name'),
|
||||||
hintText: FFLocalizations.of(context)
|
hintText: FFLocalizations.of(context)
|
||||||
|
@ -152,6 +192,7 @@ Widget formAddPets(BuildContext context, PetsPageModel _model,
|
||||||
padding: const EdgeInsets.fromLTRB(0, 0, 0, 15),
|
padding: const EdgeInsets.fromLTRB(0, 0, 0, 15),
|
||||||
child: CustomInputUtil(
|
child: CustomInputUtil(
|
||||||
controller: _model.textControllerSpecies,
|
controller: _model.textControllerSpecies,
|
||||||
|
focusNode: _model.textFieldFocusSpecies,
|
||||||
labelText: FFLocalizations.of(context).getVariableText(
|
labelText: FFLocalizations.of(context).getVariableText(
|
||||||
ptText: 'Espécie', enText: 'Species'),
|
ptText: 'Espécie', enText: 'Species'),
|
||||||
hintText: FFLocalizations.of(context).getVariableText(
|
hintText: FFLocalizations.of(context).getVariableText(
|
||||||
|
@ -164,6 +205,7 @@ Widget formAddPets(BuildContext context, PetsPageModel _model,
|
||||||
padding: const EdgeInsets.fromLTRB(0, 0, 0, 15),
|
padding: const EdgeInsets.fromLTRB(0, 0, 0, 15),
|
||||||
child: CustomInputUtil(
|
child: CustomInputUtil(
|
||||||
controller: _model.textControllerRace,
|
controller: _model.textControllerRace,
|
||||||
|
focusNode: _model.textFieldFocusRace,
|
||||||
labelText: FFLocalizations.of(context)
|
labelText: FFLocalizations.of(context)
|
||||||
.getVariableText(ptText: 'Raça', enText: 'Race'),
|
.getVariableText(ptText: 'Raça', enText: 'Race'),
|
||||||
hintText: FFLocalizations.of(context)
|
hintText: FFLocalizations.of(context)
|
||||||
|
@ -176,6 +218,7 @@ Widget formAddPets(BuildContext context, PetsPageModel _model,
|
||||||
padding: const EdgeInsets.fromLTRB(0, 0, 0, 15),
|
padding: const EdgeInsets.fromLTRB(0, 0, 0, 15),
|
||||||
child: CustomInputUtil(
|
child: CustomInputUtil(
|
||||||
controller: _model.textControllerColor,
|
controller: _model.textControllerColor,
|
||||||
|
focusNode: _model.textFieldFocusColor,
|
||||||
labelText: FFLocalizations.of(context)
|
labelText: FFLocalizations.of(context)
|
||||||
.getVariableText(ptText: 'Cor', enText: 'Color'),
|
.getVariableText(ptText: 'Cor', enText: 'Color'),
|
||||||
hintText: FFLocalizations.of(context)
|
hintText: FFLocalizations.of(context)
|
||||||
|
@ -186,22 +229,215 @@ Widget formAddPets(BuildContext context, PetsPageModel _model,
|
||||||
),
|
),
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.fromLTRB(0, 0, 0, 15),
|
padding: const EdgeInsets.fromLTRB(0, 0, 0, 15),
|
||||||
child: CustomDatePickerUtil(
|
child: Row(
|
||||||
|
mainAxisSize: MainAxisSize.max,
|
||||||
|
children: [
|
||||||
|
SizedBox(
|
||||||
|
width: MediaQuery.of(context).size.width,
|
||||||
|
height: 60.0,
|
||||||
|
child: Stack(
|
||||||
|
children: [
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsetsDirectional.fromSTEB(
|
||||||
|
24.0, 0.0, 24.0, 0.0),
|
||||||
|
child: TextFormField(
|
||||||
controller: _model.textControllerData,
|
controller: _model.textControllerData,
|
||||||
focusNode: _model.textFieldFocusData,
|
focusNode: _model.textFieldFocusData,
|
||||||
hintText: FFLocalizations.of(context).getVariableText(
|
readOnly: true,
|
||||||
ptText: 'Data de Nascimento', enText: 'Birth Date'),
|
autovalidateMode:
|
||||||
dateFormat: 'dd/MM/yyyy HH:mm:ss',
|
AutovalidateMode.onUserInteraction,
|
||||||
locale: FFLocalizations.of(context).languageCode,
|
autofocus: false,
|
||||||
firstDate: DateTime(2000),
|
obscureText: false,
|
||||||
|
decoration: InputDecoration(
|
||||||
|
isDense: true,
|
||||||
|
labelStyle: FlutterFlowTheme.of(context)
|
||||||
|
.labelMedium
|
||||||
|
.override(
|
||||||
|
fontFamily:
|
||||||
|
FlutterFlowTheme.of(context)
|
||||||
|
.labelMediumFamily,
|
||||||
|
color: FlutterFlowTheme.of(context)
|
||||||
|
.primaryText,
|
||||||
|
letterSpacing: 0.0,
|
||||||
|
useGoogleFonts: GoogleFonts.asMap()
|
||||||
|
.containsKey(
|
||||||
|
FlutterFlowTheme.of(context)
|
||||||
|
.labelMediumFamily),
|
||||||
|
),
|
||||||
|
hintText: FFLocalizations.of(context)
|
||||||
|
.getVariableText(
|
||||||
|
ptText: 'Data de Nascimento',
|
||||||
|
enText: 'Birth Date',
|
||||||
|
),
|
||||||
|
hintStyle: FlutterFlowTheme.of(context)
|
||||||
|
.labelMedium
|
||||||
|
.override(
|
||||||
|
fontFamily:
|
||||||
|
FlutterFlowTheme.of(context)
|
||||||
|
.labelMediumFamily,
|
||||||
|
color: FlutterFlowTheme.of(context)
|
||||||
|
.primaryText,
|
||||||
|
letterSpacing: 0.0,
|
||||||
|
useGoogleFonts: GoogleFonts.asMap()
|
||||||
|
.containsKey(
|
||||||
|
FlutterFlowTheme.of(context)
|
||||||
|
.labelMediumFamily),
|
||||||
|
lineHeight: 1.0,
|
||||||
|
),
|
||||||
|
enabledBorder: OutlineInputBorder(
|
||||||
|
borderSide: BorderSide(
|
||||||
|
color: FlutterFlowTheme.of(context)
|
||||||
|
.customColor6,
|
||||||
|
width: 0.5,
|
||||||
|
),
|
||||||
|
borderRadius: BorderRadius.circular(10.0),
|
||||||
|
),
|
||||||
|
focusedBorder: OutlineInputBorder(
|
||||||
|
borderSide: BorderSide(
|
||||||
|
color: FlutterFlowTheme.of(context)
|
||||||
|
.primary,
|
||||||
|
width: 0.5,
|
||||||
|
),
|
||||||
|
borderRadius: BorderRadius.circular(10.0),
|
||||||
|
),
|
||||||
|
errorBorder: OutlineInputBorder(
|
||||||
|
borderSide: BorderSide(
|
||||||
|
color:
|
||||||
|
FlutterFlowTheme.of(context).error,
|
||||||
|
width: 0.5,
|
||||||
|
),
|
||||||
|
borderRadius: BorderRadius.circular(10.0),
|
||||||
|
),
|
||||||
|
focusedErrorBorder: OutlineInputBorder(
|
||||||
|
borderSide: BorderSide(
|
||||||
|
color:
|
||||||
|
FlutterFlowTheme.of(context).error,
|
||||||
|
width: 0.5,
|
||||||
|
),
|
||||||
|
borderRadius: BorderRadius.circular(10.0),
|
||||||
|
),
|
||||||
|
suffixIcon: Icon(
|
||||||
|
Icons.date_range,
|
||||||
|
color:
|
||||||
|
FlutterFlowTheme.of(context).accent1,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
style: FlutterFlowTheme.of(context)
|
||||||
|
.bodyMedium
|
||||||
|
.override(
|
||||||
|
fontFamily: FlutterFlowTheme.of(context)
|
||||||
|
.bodyMediumFamily,
|
||||||
|
letterSpacing: 0.0,
|
||||||
|
useGoogleFonts: GoogleFonts.asMap()
|
||||||
|
.containsKey(
|
||||||
|
FlutterFlowTheme.of(context)
|
||||||
|
.bodyMediumFamily),
|
||||||
|
lineHeight: 1.8,
|
||||||
|
),
|
||||||
|
textAlign: TextAlign.start,
|
||||||
|
validator: _model.textControllerDataValidator
|
||||||
|
.asValidator(context),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsetsDirectional.fromSTEB(
|
||||||
|
24.0, 0.0, 24.0, 0.0),
|
||||||
|
child: InkWell(
|
||||||
|
splashColor: Colors.transparent,
|
||||||
|
focusColor: Colors.transparent,
|
||||||
|
hoverColor: Colors.transparent,
|
||||||
|
highlightColor: Colors.transparent,
|
||||||
|
onTap: () async {
|
||||||
|
final pickedDate = await showDatePicker(
|
||||||
|
context: context,
|
||||||
|
initialDate: getCurrentTimestamp,
|
||||||
|
firstDate: DateTime(1990),
|
||||||
lastDate: DateTime.now(),
|
lastDate: DateTime.now(),
|
||||||
timePicker: false,
|
builder: (context, child) {
|
||||||
validator: (value) {
|
return wrapInMaterialDatePickerTheme(
|
||||||
if (value == null || value.isEmpty) {
|
context,
|
||||||
return 'Por favor, selecione uma data';
|
child!,
|
||||||
}
|
headerBackgroundColor:
|
||||||
return null;
|
FlutterFlowTheme.of(context)
|
||||||
|
.primary,
|
||||||
|
headerForegroundColor:
|
||||||
|
FlutterFlowTheme.of(context).info,
|
||||||
|
headerTextStyle: FlutterFlowTheme.of(
|
||||||
|
context)
|
||||||
|
.headlineLarge
|
||||||
|
.override(
|
||||||
|
fontFamily:
|
||||||
|
FlutterFlowTheme.of(context)
|
||||||
|
.headlineLargeFamily,
|
||||||
|
fontSize: 32.0,
|
||||||
|
letterSpacing: 0.0,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
useGoogleFonts: GoogleFonts
|
||||||
|
.asMap()
|
||||||
|
.containsKey(FlutterFlowTheme
|
||||||
|
.of(context)
|
||||||
|
.headlineLargeFamily),
|
||||||
|
),
|
||||||
|
pickerBackgroundColor:
|
||||||
|
FlutterFlowTheme.of(context)
|
||||||
|
.primaryBackground,
|
||||||
|
pickerForegroundColor:
|
||||||
|
FlutterFlowTheme.of(context)
|
||||||
|
.primaryText,
|
||||||
|
selectedDateTimeBackgroundColor:
|
||||||
|
FlutterFlowTheme.of(context)
|
||||||
|
.primary,
|
||||||
|
selectedDateTimeForegroundColor:
|
||||||
|
FlutterFlowTheme.of(context).info,
|
||||||
|
actionButtonForegroundColor:
|
||||||
|
FlutterFlowTheme.of(context)
|
||||||
|
.primaryText,
|
||||||
|
iconSize: 24.0,
|
||||||
|
);
|
||||||
},
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
if (pickedDate != null) {
|
||||||
|
setState(() {
|
||||||
|
log('Chamou o setState da datinha');
|
||||||
|
|
||||||
|
_model.selectedDate = DateTime(
|
||||||
|
pickedDate.year,
|
||||||
|
pickedDate.month,
|
||||||
|
pickedDate.day,
|
||||||
|
);
|
||||||
|
|
||||||
|
log(_model.selectedDate.toString());
|
||||||
|
_model.textControllerData =
|
||||||
|
TextEditingController(
|
||||||
|
text: dateTimeFormat(
|
||||||
|
'dd/MM/yyyy',
|
||||||
|
_model.selectedDate,
|
||||||
|
locale: FFLocalizations.of(context)
|
||||||
|
.languageCode,
|
||||||
|
));
|
||||||
|
log(_model.textControllerData.text);
|
||||||
|
_model.textControllerData?.selection =
|
||||||
|
TextSelection.collapsed(
|
||||||
|
offset: _model
|
||||||
|
.textControllerData!.text.length,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
child: Container(
|
||||||
|
width: double.infinity,
|
||||||
|
height: 80.0,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
borderRadius: BorderRadius.circular(10.0),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Align(
|
Align(
|
||||||
|
@ -231,7 +467,13 @@ Widget formAddPets(BuildContext context, PetsPageModel _model,
|
||||||
padding: const EdgeInsets.fromLTRB(0, 0, 0, 15),
|
padding: const EdgeInsets.fromLTRB(0, 0, 0, 15),
|
||||||
child: CustomSelect(
|
child: CustomSelect(
|
||||||
options: const ['MAC', 'FEM'],
|
options: const ['MAC', 'FEM'],
|
||||||
controller: _model.dropDownValueController1,
|
controller: _model.dropDownValueController1 ??=
|
||||||
|
FormFieldController<String>(
|
||||||
|
_model.dropDownValue1 ??= ''),
|
||||||
|
changed: (val) => safeSetState(() {
|
||||||
|
_model.dropDownValue1 = val;
|
||||||
|
}),
|
||||||
|
dropDownValue: _model.dropDownValue1,
|
||||||
optionsLabel: [
|
optionsLabel: [
|
||||||
FFLocalizations.of(context)
|
FFLocalizations.of(context)
|
||||||
.getVariableText(ptText: 'Macho', enText: 'Male'),
|
.getVariableText(ptText: 'Macho', enText: 'Male'),
|
||||||
|
@ -246,7 +488,12 @@ Widget formAddPets(BuildContext context, PetsPageModel _model,
|
||||||
padding: const EdgeInsets.fromLTRB(0, 0, 0, 15),
|
padding: const EdgeInsets.fromLTRB(0, 0, 0, 15),
|
||||||
child: CustomSelect(
|
child: CustomSelect(
|
||||||
options: const ['MIN', 'PEQ', 'MED', 'GRA', 'GIG'],
|
options: const ['MIN', 'PEQ', 'MED', 'GRA', 'GIG'],
|
||||||
controller: _model.dropDownValueController1,
|
controller: _model.dropDownValueController2 ??=
|
||||||
|
FormFieldController<String>(
|
||||||
|
_model.dropDownValue2 ??= ''),
|
||||||
|
changed: (val) => safeSetState(() {
|
||||||
|
_model.dropDownValue2 = val;
|
||||||
|
}),
|
||||||
optionsLabel: [
|
optionsLabel: [
|
||||||
FFLocalizations.of(context)
|
FFLocalizations.of(context)
|
||||||
.getVariableText(ptText: 'Mini', enText: 'Mini'),
|
.getVariableText(ptText: 'Mini', enText: 'Mini'),
|
||||||
|
@ -289,6 +536,7 @@ Widget formAddPets(BuildContext context, PetsPageModel _model,
|
||||||
),
|
),
|
||||||
CustomInputUtil(
|
CustomInputUtil(
|
||||||
controller: _model.textControllerObservation,
|
controller: _model.textControllerObservation,
|
||||||
|
focusNode: _model.textFieldFocusObservation,
|
||||||
labelText: FFLocalizations.of(context).getVariableText(
|
labelText: FFLocalizations.of(context).getVariableText(
|
||||||
ptText: 'Escreva as suas observações aqui...',
|
ptText: 'Escreva as suas observações aqui...',
|
||||||
enText: 'Write your observations here...'),
|
enText: 'Write your observations here...'),
|
||||||
|
@ -299,9 +547,13 @@ Widget formAddPets(BuildContext context, PetsPageModel _model,
|
||||||
haveMaxLength: true,
|
haveMaxLength: true,
|
||||||
maxLength: 80,
|
maxLength: 80,
|
||||||
),
|
),
|
||||||
ElevatedButton(
|
Padding(
|
||||||
onPressed: _isFormValid(context) ? () {} : () {},
|
padding: const EdgeInsets.fromLTRB(70, 20, 70, 30),
|
||||||
child: Text('Cadastrar')),
|
child: SubmitButtonUtil(
|
||||||
|
labelText: FFLocalizations.of(context).getVariableText(
|
||||||
|
ptText: 'Cadastrar', enText: 'Register'),
|
||||||
|
onPressed: () {}),
|
||||||
|
),
|
||||||
])),
|
])),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|
Loading…
Reference in New Issue