526 lines
27 KiB
Dart
526 lines
27 KiB
Dart
import 'dart:developer';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter/services.dart';
|
|
|
|
import 'package:google_fonts/google_fonts.dart';
|
|
|
|
import 'package:hub/components/atomic_components/shared_components_atoms/appbar.dart';
|
|
import 'package:hub/components/atomic_components/shared_components_atoms/custom_datepicker.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/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/flutter_flow/flutter_flow_theme.dart';
|
|
import 'package:hub/flutter_flow/flutter_flow_util.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/nav/nav.dart';
|
|
import 'package:hub/flutter_flow/upload_data.dart';
|
|
|
|
import 'package:hub/pages/pets_page/pets_page_model.dart';
|
|
import 'package:sqflite/sqflite.dart';
|
|
|
|
class PetsPageWidget extends StatefulWidget {
|
|
PetsPageWidget({super.key});
|
|
|
|
@override
|
|
State<PetsPageWidget> createState() => _PetsPageWidgetState();
|
|
}
|
|
|
|
class _PetsPageWidgetState extends State<PetsPageWidget> with SingleTickerProviderStateMixin {
|
|
late PetsPageModel _model;
|
|
final _formKey = GlobalKey<FormState>();
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
_model = PetsPageModel();
|
|
_model.tabBarController = TabController(length: 2, vsync: this);
|
|
|
|
_model.textControllerName ??= TextEditingController();
|
|
_model.textFieldFocusName ??= FocusNode();
|
|
|
|
_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
|
|
void dispose() {
|
|
super.dispose();
|
|
_model.dispose();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
appBar: appBarPets(context),
|
|
backgroundColor: FlutterFlowTheme.of(context).primaryBackground,
|
|
body: tabViewPets(context));
|
|
}
|
|
|
|
PreferredSizeWidget appBarPets(BuildContext context) {
|
|
return AppBarUtil(title: 'Pets', onBackButtonPressed: () => context.pop());
|
|
}
|
|
|
|
Widget tabViewPets(BuildContext context) {
|
|
return TabViewUtil(
|
|
context: context,
|
|
model: _model,
|
|
labelTab1: 'Cadastrar',
|
|
labelTab2: 'Consultar',
|
|
controller: _model.tabBarController,
|
|
widget1: formAddPets(context),
|
|
widget2: const Center(child: Text('Consultar')),
|
|
);
|
|
}
|
|
|
|
Widget formAddPets(BuildContext context) {
|
|
return SingleChildScrollView(
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.max,
|
|
children: [
|
|
Align(
|
|
alignment: const AlignmentDirectional(-1.0, 0.0),
|
|
child: Padding(
|
|
padding: const EdgeInsetsDirectional.fromSTEB(24.0, 20, 0.0, 15),
|
|
child: Text(
|
|
FFLocalizations.of(context).getVariableText(
|
|
ptText: 'Preencha o formulário com os dados do seu Pet',
|
|
enText: 'Fill out the form with your Pet\'s data',
|
|
),
|
|
textAlign: TextAlign.start,
|
|
style: FlutterFlowTheme.of(context).bodyMedium.override(
|
|
fontFamily: FlutterFlowTheme.of(context).bodyMediumFamily,
|
|
letterSpacing: 0.0,
|
|
useGoogleFonts: GoogleFonts.asMap().containsKey(
|
|
FlutterFlowTheme.of(context).bodyMediumFamily),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
Form(
|
|
key: _formKey,
|
|
autovalidateMode: AutovalidateMode.onUserInteraction,
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.max,
|
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
|
children: [
|
|
Padding(
|
|
padding: const EdgeInsets.fromLTRB(0, 10, 0, 20),
|
|
child: MediaUploadButtonUtil(
|
|
uploadedFile: _model.uploadedLocalFile,
|
|
isUploading: _model.isDataUploading,
|
|
labelText: FFLocalizations.of(context).getVariableText(
|
|
ptText: 'Clique para adicionar a foto de seu Pet',
|
|
enText: 'Click to add your Pet\'s photo'),
|
|
),
|
|
),
|
|
CustomInputUtil(
|
|
controller: _model.textControllerName,
|
|
validator:
|
|
_model.textControllerNameValidator.asValidator(context),
|
|
focusNode: _model.textFieldFocusName,
|
|
labelText: FFLocalizations.of(context)
|
|
.getVariableText(ptText: 'Nome', enText: 'Name'),
|
|
hintText: FFLocalizations.of(context)
|
|
.getVariableText(ptText: 'Nome', enText: 'Name'),
|
|
suffixIcon: Icons.person,
|
|
haveMaxLength: true,
|
|
maxLength: 80,
|
|
),
|
|
Padding(
|
|
padding: const EdgeInsets.fromLTRB(0, 0, 0, 15),
|
|
child: CustomInputUtil(
|
|
controller: _model.textControllerSpecies,
|
|
focusNode: _model.textFieldFocusSpecies,
|
|
labelText: FFLocalizations.of(context).getVariableText(
|
|
ptText: 'Espécie', enText: 'Species'),
|
|
hintText: FFLocalizations.of(context).getVariableText(
|
|
ptText: 'Espécie', enText: 'Species'),
|
|
suffixIcon: Icons.pest_control,
|
|
haveMaxLength: false,
|
|
),
|
|
),
|
|
Padding(
|
|
padding: const EdgeInsets.fromLTRB(0, 0, 0, 15),
|
|
child: CustomInputUtil(
|
|
controller: _model.textControllerRace,
|
|
focusNode: _model.textFieldFocusRace,
|
|
labelText: FFLocalizations.of(context)
|
|
.getVariableText(ptText: 'Raça', enText: 'Race'),
|
|
hintText: FFLocalizations.of(context)
|
|
.getVariableText(ptText: 'Raça', enText: 'Race'),
|
|
suffixIcon: Icons.pets,
|
|
haveMaxLength: false,
|
|
),
|
|
),
|
|
Padding(
|
|
padding: const EdgeInsets.fromLTRB(0, 0, 0, 15),
|
|
child: CustomInputUtil(
|
|
controller: _model.textControllerColor,
|
|
focusNode: _model.textFieldFocusColor,
|
|
labelText: FFLocalizations.of(context)
|
|
.getVariableText(ptText: 'Cor', enText: 'Color'),
|
|
hintText: FFLocalizations.of(context)
|
|
.getVariableText(ptText: 'Cor', enText: 'Color'),
|
|
suffixIcon: Icons.invert_colors,
|
|
haveMaxLength: false,
|
|
),
|
|
),
|
|
Padding(
|
|
padding: const EdgeInsets.fromLTRB(0, 0, 0, 15),
|
|
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,
|
|
focusNode: _model.textFieldFocusData,
|
|
readOnly: true,
|
|
autovalidateMode:
|
|
AutovalidateMode.onUserInteraction,
|
|
autofocus: false,
|
|
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(),
|
|
builder: (context, child) {
|
|
return wrapInMaterialDatePickerTheme(
|
|
context,
|
|
child!,
|
|
headerBackgroundColor:
|
|
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(
|
|
alignment: const AlignmentDirectional(-1.0, 0.0),
|
|
child: Padding(
|
|
padding: const EdgeInsetsDirectional.fromSTEB(
|
|
24.0, 0, 0.0, 15),
|
|
child: Text(
|
|
FFLocalizations.of(context).getVariableText(
|
|
ptText: 'Selecione as opções disponíveis',
|
|
enText: 'Select the available options',
|
|
),
|
|
textAlign: TextAlign.start,
|
|
style: FlutterFlowTheme.of(context).bodySmall.override(
|
|
fontFamily:
|
|
FlutterFlowTheme.of(context).bodySmallFamily,
|
|
letterSpacing: 0.0,
|
|
fontWeight: FontWeight.w600,
|
|
useGoogleFonts: GoogleFonts.asMap().containsKey(
|
|
FlutterFlowTheme.of(context)
|
|
.bodyMediumFamily),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
Padding(
|
|
padding: const EdgeInsets.fromLTRB(0, 0, 0, 15),
|
|
child: CustomSelect(
|
|
options: const ['MAC', 'FEM'],
|
|
controller: _model.dropDownValueController1 ??=
|
|
FormFieldController<String>(
|
|
_model.dropDownValue1 ??= ''),
|
|
changed: (val) => safeSetState(() {
|
|
_model.dropDownValue1 = val;
|
|
}),
|
|
dropDownValue: _model.dropDownValue1,
|
|
optionsLabel: [
|
|
FFLocalizations.of(context)
|
|
.getVariableText(ptText: 'Macho', enText: 'Male'),
|
|
FFLocalizations.of(context).getVariableText(
|
|
ptText: 'Fêmea', enText: 'Female')
|
|
],
|
|
hintText: FFLocalizations.of(context).getVariableText(
|
|
ptText: 'Selecione o gênero do Pet',
|
|
enText: 'Select the gender of the Pet')),
|
|
),
|
|
Padding(
|
|
padding: const EdgeInsets.fromLTRB(0, 0, 0, 15),
|
|
child: CustomSelect(
|
|
options: const ['MIN', 'PEQ', 'MED', 'GRA', 'GIG'],
|
|
controller: _model.dropDownValueController2 ??=
|
|
FormFieldController<String>(
|
|
_model.dropDownValue2 ??= ''),
|
|
changed: (val) => safeSetState(() {
|
|
_model.dropDownValue2 = val;
|
|
}),
|
|
optionsLabel: [
|
|
FFLocalizations.of(context)
|
|
.getVariableText(ptText: 'Mini', enText: 'Mini'),
|
|
FFLocalizations.of(context).getVariableText(
|
|
ptText: 'Pequeno', enText: 'Small'),
|
|
FFLocalizations.of(context).getVariableText(
|
|
ptText: 'Médio', enText: 'Medium'),
|
|
FFLocalizations.of(context)
|
|
.getVariableText(ptText: 'Grande', enText: 'Big'),
|
|
FFLocalizations.of(context).getVariableText(
|
|
ptText: 'Gigante', enText: 'Giant'),
|
|
],
|
|
hintText: FFLocalizations.of(context).getVariableText(
|
|
ptText: 'Selecione o porte do Pet',
|
|
enText: 'Select the size of the Pet')),
|
|
),
|
|
Align(
|
|
alignment: const AlignmentDirectional(-1.0, 0.0),
|
|
child: Padding(
|
|
padding: const EdgeInsetsDirectional.fromSTEB(
|
|
24.0, 0, 0.0, 15),
|
|
child: Text(
|
|
FFLocalizations.of(context).getVariableText(
|
|
ptText: 'Você tem alguma observação sobre o seu Pet?',
|
|
enText:
|
|
'Do you have any observations about your Pet?',
|
|
),
|
|
textAlign: TextAlign.start,
|
|
style: FlutterFlowTheme.of(context).bodySmall.override(
|
|
fontFamily:
|
|
FlutterFlowTheme.of(context).bodySmallFamily,
|
|
letterSpacing: 0.0,
|
|
fontWeight: FontWeight.w600,
|
|
useGoogleFonts: GoogleFonts.asMap().containsKey(
|
|
FlutterFlowTheme.of(context)
|
|
.bodyMediumFamily),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
CustomInputUtil(
|
|
controller: _model.textControllerObservation,
|
|
focusNode: _model.textFieldFocusObservation,
|
|
labelText: FFLocalizations.of(context).getVariableText(
|
|
ptText: 'Escreva as suas observações aqui...',
|
|
enText: 'Write your observations here...'),
|
|
hintText: FFLocalizations.of(context).getVariableText(
|
|
ptText: 'Escreva as suas observações aqui...',
|
|
enText: 'Write your observations here...'),
|
|
suffixIcon: Icons.text_fields,
|
|
haveMaxLength: true,
|
|
maxLength: 80,
|
|
),
|
|
Padding(
|
|
padding: const EdgeInsets.fromLTRB(70, 20, 70, 30),
|
|
child: SubmitButtonUtil(
|
|
labelText: FFLocalizations.of(context).getVariableText(
|
|
ptText: 'Cadastrar', enText: 'Register'),
|
|
onPressed: () {}),
|
|
),
|
|
])),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
|