import 'package:flutter/material.dart'; import 'package:intl/intl.dart'; import 'package:rkm/config/color_palette.dart'; import 'package:rkm/config/const_variable.dart'; import 'package:rkm/widgets/alert_dialog_default.dart'; import 'package:rkm/widgets/button_default.dart'; import 'package:rkm/widgets/title_containers.dart'; import 'package:sqflite/sqflite.dart'; import '../../controllers/main_controllers.dart'; import '../../service/db/db_querys.dart'; import '../../service/db/db_sqlite_load.dart'; import '../../service/db/db_sqlite_sync.dart'; import '../../widgets/appbar_default.dart'; import '../../widgets/dropdown_with_subtitle.dart'; import '../../widgets/error_default.dart'; import '../../widgets/input_search_text.dart'; import '../../widgets/input_with_subtitle.dart'; import '../../widgets/onbackbutton.dart'; import '../../widgets/subtitle_appbar_citizen.dart'; import '../../widgets/switch_with_subtitle.dart'; import '../../widgets/text_default.dart'; class RegisterCitizenScreen extends StatefulWidget { String select; RegisterCitizenScreen({required this.select}); @override State createState() => _RegisterCitizenScreenState(); } class _RegisterCitizenScreenState extends State { var nameController = TextEditingController(); var nameSocialController = TextEditingController(); var spouseController = TextEditingController(); var cityBirthController = TextEditingController(); var cityController = TextEditingController(); var searchCityBirthController = TextEditingController(); var searchCityController = TextEditingController(); var nameMotherController = TextEditingController(); var nameFatherController = TextEditingController(); var codIBGEController = TextEditingController(); var unitController = TextEditingController(); var medicalRecordController = TextEditingController(); var medicalRecordProvController = TextEditingController(); var classificationProvController = TextEditingController(); var numberFamilyController = TextEditingController(); var cepController = TextEditingController(); var numberController = TextEditingController(); var complementController = TextEditingController(); var referencePointController = TextEditingController(); var foneDDDController = TextEditingController(); var foneController = TextEditingController(); var mobileDDDController = TextEditingController(); var mobileController = TextEditingController(); var messageDDDController = TextEditingController(); var messageController = TextEditingController(); var emailController = TextEditingController(); var observationController = TextEditingController(); var CPFController = TextEditingController(); var CNSController = TextEditingController(); var voterController = TextEditingController(); var RGController = TextEditingController(); var RGComplementController = TextEditingController(); var RGOrganController = TextEditingController(); var RGDateController = TextEditingController(text: 'RG - Data de Emissão'); var numberCertificateController = TextEditingController(); var nameCertificateController = TextEditingController(); var bookCertificateController = TextEditingController(); var sheetCertificateController = TextEditingController(); var termCertificateController = TextEditingController(); var dateCertificateController = TextEditingController(text: 'Data de Emissão da Certidão'); var CTPSController = TextEditingController(); var numberCTPSController = TextEditingController(); var PISController = TextEditingController(); var NISController = TextEditingController(); var incomeController = TextEditingController(); var professionalController = TextEditingController(); var dateDeathController = TextEditingController(text: 'Data Óbito'); String checkCNS = ''; String checkCPF = ''; String? selectTypeCertificate; String? selectCTPSUF; String? selectRGUF; String? selectTypeStreet; String? selectStreet; String? selectSubdivision; String? selectZone; String? selectVillage; String? selectCountry; String? selectClassification; String? selectGender; String? selectMaritalStatus; String? selectBreed; String? selectScooling; String? selectDeficiency; String? selectNaturality; bool enableSpouse = false; bool enableMother = false; bool enableFather = false; bool enableCityCard = false; bool enableBlocked = false; bool checkBoxNumber = false; String date = 'Data de Nascimento'; String dateDB = ''; List cityDB = []; List ibgeDB = []; List streetDB = []; List subdivisionDB = []; List villageDB = []; List typeStreetDB = []; List showResultSearchCity = []; List showResultSearchIbge = []; List listVillageDB =[]; String idBairro=''; String idTipo=''; bool showCheckError = false; bool showTab = false; String errorTopo = 'Existem campos obrigatórios não preenchidos.'; escolherprazoInicio(BuildContext context,String type) async { var pickDate = await showDatePicker( context: context, initialDate: DateTime.now(), firstDate: DateTime(1900), lastDate: DateTime(2024)); if (pickDate != null) { setState(() { if(type == 'birth'){ dateDB = '${pickDate.year}-${pickDate.month<10?'0':''}${pickDate.month}-${pickDate.day<10?'0':''}${pickDate.day}'; date = formatData(year: pickDate.year, month: pickDate.month, day: pickDate.day); } if(type == 'rg'){ RGDateController.text = formatData(year: pickDate.year, month: pickDate.month, day: pickDate.day); } if(type == 'cert'){ dateCertificateController.text = formatData(year: pickDate.year, month: pickDate.month, day: pickDate.day); } if(type == 'death'){ dateDeathController.text = formatData(year: pickDate.year, month: pickDate.month, day: pickDate.day); } }); } } String formatData({int? year, int? month, int? day}) { DateTime data = DateTime(year!, month!, day!); String formattedDate = DateFormat('dd/MM/yyyy').format(data); return formattedDate; } getUnit()async{ Database db = await DbSqliteLoad().intialDB(); var queryControl = "SELECT * FROM CONTROLE_INTERNO"; List listControl = await db.rawQuery(queryControl); setState(() { unitController.text = listControl[0]['NOME_UNIDADE']; }); } changedCity()async{ Database db = await DbSqliteLoad().intialDB(); var queryCity = "SELECT * FROM ARGS"; List listCity = await db.rawQuery(queryCity); // print(listCity); setState(() { cityController.text = '${listCity[0]['NAME_CITY_FRONT']} - ${listCity[0]['COD_STATE']}'.toUpperCase(); codIBGEController.text = listCity[0]['COD_IBGE'].toString(); }); } loadVillgeDB()async{ Database db = await DbSqliteLoad().intialDB(); var query = "SELECT * FROM BAIRROS ORDER BY NO_BAIRRO"; listVillageDB = await db.rawQuery(query); for(int i=0; listVillageDB.length > i;i++){ villageDB.add('${listVillageDB[i]['NO_BAIRRO']}'); } setState(() {}); } loadTypeStreetDB()async{ Database db = await DbSqliteLoad().intialDB(); var query = "SELECT * FROM LOGRADOUROS_TIPOS ORDER BY NO_LOGR_TIPO"; List list = await db.rawQuery(query); for(int i=0; list.length > i;i++){ typeStreetDB.add('${list[i]['NO_LOGR_TIPO']}'); } setState(() {}); } loadStreetDB()async{ streetDB=[]; Database db = await DbSqliteLoad().intialDB(); // var query = "SELECT * FROM EQUIPES JOIN PROFISSIONAIS_EQUIPE ON PROFISSIONAIS_EQUIPE.ID_EQUIPE = EQUIPES.ID_EQUIPE WHERE ID_UNIDADE = $idUnidade AND ID_PROFISSIONAL = $idUsuario"; // {ID_LOGR_ENDERECO: 14, ID_LOGR_TIPO: 27, DESC_LOGR_ENDERECO: NICOLAU MAROTTI, ID_BAIRRO: 135}, var query = "SELECT * FROM LOGRADOUROS_ENDERECOS WHERE ID_BAIRRO = $idBairro AND ID_LOGR_TIPO = $idTipo ORDER BY DESC_LOGR_ENDERECO"; List list = await db.rawQuery(query); for(int i=0; list.length > i;i++){ streetDB.add('${list[i]['DESC_LOGR_ENDERECO']}'); } // print(streetDB); setState(() {}); } loadSubdivisionsDB()async{ Database db = await DbSqliteLoad().intialDB(); List list = await db.rawQuery("SELECT * FROM LOGRADOUROS_LOTEAMENTOS ORDER BY DESC_LOGR_LOTEAMENTO"); for(int i=0; list.length > i;i++){ subdivisionDB.add('${list[i]['DESC_LOGR_LOTEAMENTO']}'); } // print(list); setState(() {}); } _searchCity(){ searchCity('city'); } _searchCityBirth(){ searchCity('birth'); } getCity()async{ Database db = await DbSqliteLoad().intialDB(); var query = "SELECT * FROM MUNICIPIOS ORDER BY NO_MUNICIPIO"; List list = await db.rawQuery(query); // print("SELECT * FROM UNIDADES"); // print(await db.rawQuery("SELECT * FROM UNIDADES")); for(int i=0; list.length > i;i++){ cityDB.add('${list[i]['NO_MUNICIPIO']} - ${list[i]['UF_ESTADO']}'); ibgeDB.add('${list[i]['CODIGO_IBGE']}'); } searchCity('init'); return 'complete'; } searchCity(String search)async{ if(search=='city'?searchCityController.text.isNotEmpty:searchCityBirthController.text.isNotEmpty){ showResultSearchCity =[]; showResultSearchIbge =[]; for (int i =0;cityDB.length>i;i++) { String CIDADE = '${cityDB[i]}'; if(CIDADE.contains(search=='city'?searchCityController.text.toUpperCase():searchCityBirthController.text.toUpperCase())){ if(showResultSearchCity.length<10){ showResultSearchCity.add(cityDB[i]); showResultSearchIbge.add(ibgeDB[i]); } } } setState(() { // print(showResultSearchCity); }); }else{ setState(() { for(int i = 0;i<10;i++){ showResultSearchCity.add(cityDB[i]); showResultSearchIbge.add(ibgeDB[i]); } }); } } checkSave(){ bool checkMother = false; bool checkFather = false; bool checkClassification = false; if(!enableMother && nameMotherController.text.isEmpty){ checkMother = true; print('colocar nome mãe'); } if(!enableFather && nameFatherController.text.isEmpty){ checkFather = true; print('colocar nome pai'); } if((selectClassification!='OUTRO MUNICIPIO' && selectCountry == 'BRASIL' && selectStreet == null) || (selectStreet!=null && (cepController.text.isEmpty || cepController.text.length!=8)) || (selectStreet!=null && numberController.text.isEmpty) || (selectTypeStreet == null && selectClassification!='OUTRO MUNICIPIO') || (selectVillage == null && (selectCountry == 'BRASIL' && selectClassification!='OUTRO MUNICIPIO')) || (cityController.text.isEmpty && selectCountry!='OUTRO') || selectCountry == null ){ checkClassification = true; print('erro no end'); } //ok if(nameController.text.isEmpty || selectGender==null || selectNaturality==null || selectBreed==null || selectDeficiency==null || selectClassification==null || selectCountry==null || date == 'Data de Nascimento'|| cityBirthController.text.isEmpty || messageDDDController.text.isEmpty || messageController.text.isEmpty || checkMother || checkFather || checkClassification|| (selectMaritalStatus == 'CASADO(A)' && spouseController.text.isEmpty) ){ print('erro'); setState(() { showCheckError = true; }); }else{ print('passou'); saveCitizen(); } } saveCitizen()async{ Map row = { 'CD_USUARIO_SUS' : '0', 'NOME_CIDADAO' : nameController.text, 'NOME_SOCIAL' : nameSocialController.text, 'SEXO' : selectGender, 'DT_NASCIMENTO' : dateDB, 'ID_ESTADO_CIVIL' : '', 'ID_ESTADO_CIVIL' : '', 'NOME_CONJUGE' : spouseController.text, 'NACIONALIDADE' : selectNaturality, 'ID_MUNICIPIO_NASC' : '', 'NO_MUNICIPIO_NASC' : cityBirthController.text, 'ESTADO_UF_NASC' : '', 'ID_ETNIA' : '', 'ID_ESCOLARIDADE' : '', 'ID_DEFICIENCIA' : '', 'NOME_MAE' : nameMotherController.text, 'DESCONHECE_MAE' : '${!enableMother}', 'NOME_PAI' : nameFatherController.text, 'DESCONHECE_PAI' : '${!enableFather}', 'ID_UNIDADE' : '', 'NUM_PRONTUARIO' : medicalRecordController.text, 'NUM_PRONTUARIO_PROV' : medicalRecordProvController.text, 'CLASSIFICACAO' : selectClassification, 'CLASSIFICACAO_SUB' : '', 'NUM_FAMILIA' : numberFamilyController.text, 'ID_PAIS_RESID' : '', 'ID_MUNICIPIO_RESID' : '', 'NO_MUNICIPIO_RESID' : cityController.text, 'ESTADO_UF_RESID' : '', 'CODIGO_IBGE_RESID' : codIBGEController.text, 'NO_BAIRRO_LOGR' : selectVillage, 'ID_LOGR_TIPO' : idTipo, 'NOME_LOGR' : selectStreet, 'CEP_LOGR' : cepController.text, 'NUMERO_LOGR' : numberController.text, 'LOTEAMENTO_LOGR' : selectSubdivision, 'COMPL_LOGR' : complementController.text, 'PONTO_REFERENCIA' : referencePointController.text, 'ZONA_LOGR' : selectZone, 'DDD_TELEFONE' : foneDDDController.text, 'NUM_TELEFONE' : foneController.text, 'DDD_RECADO' : messageDDDController.text, 'NUM_RECADO' : messageController.text, 'EMAIL' : emailController.text, 'OBSERVACOES' : observationController.text, 'CPF' : CPFController.text, 'CNS' : checkCNS == 'ok'&& CNSController.text.isNotEmpty?CNSController.text:'999999999999999', 'TITULO_ELEITOR' : voterController.text, 'RG_NUMERO' : RGController.text, 'RG_COMPLEMENTO' : RGComplementController.text, 'RG_UF' : selectRGUF, 'RG_ORGAO' : RGOrganController.text, 'RG_DATA_EMISSAO' : RGDateController.text, 'TIPO_CERTIDAO' : selectTypeCertificate, 'NUM_CERTIDAO' : numberCertificateController.text, 'CARTORIO_CERTIDAO' : nameCertificateController.text, 'LIVRO_CERTIDAO' : bookCertificateController.text, 'FOLHA_CERTIDAO' : sheetCertificateController.text, 'TERMO_CERTIDAO' : termCertificateController.text, 'DT_EMISSAO_CERTIDAO' : dateCertificateController.text, 'NUM_CTPS' : CTPSController.text, 'NUM_SERIE_CTPS' : numberCTPSController.text, 'ESTADO_UF_CTPS' : selectCTPSUF, 'NUM_PIS_PASEP' : PISController.text, 'FL_RETIROU_CARTAO' : enableCityCard, 'NUM_NIS' : NISController.text, 'NUM_PROT_CROSS' : '', 'RENDA_MENSAL' : incomeController.text, 'PROFISSAO' : professionalController.text, 'DT_OBITO' : dateDeathController.text, 'DECLARACAO_OBITO' : '', 'BLOQUEIO' : enableBlocked, 'ORIGEM' : '', 'DT_HORA_CADASTRO' : DateTime.now().toString(), 'ID_USUARIO_CADASTRO' : '', 'ID_DOMICILIO' : '', 'ATENDIMENTOS' : '', 'SINCRONIZADO' : '', }; await DbSqliteSync().insertCidadaos(row,'update').then((value){ if(checkCNS != 'ok' || CNSController.text.isEmpty){ AlertDialogDefault().alert( context, 'Aviso', 'CNS Inválido!', 'OK' ); setState(() { errorTopo = 'O usuário foi cadastrado sem um CNS válido!'; }); }else{ setState(() { showCheckError = false; }); } AlertDialogDefault().alert( context, 'Aviso', 'Cidadão cadastrado com sucesso!', 'OK' ); setState(() { showTab = true; }); // print(value); }); } @override void initState() { super.initState(); searchCityBirthController.addListener(_searchCityBirth); searchCityController.addListener(_searchCity); getCity(); getUnit(); loadVillgeDB(); loadTypeStreetDB(); loadSubdivisionsDB(); setState(() { cityBirthController.text = widget.select; }); } @override Widget build(BuildContext context) { double height = MediaQuery.of(context).size.height; double width = MediaQuery.of(context).size.width; return WillPopScope( onWillPop: ()=> OnBackButton().onBackButton(context), child: Scaffold( appBar: AppBarDefault().appbar(context, 'RKM AB - Cadastro Cidadão'), body: Container( height: double.infinity, width: double.infinity, decoration: ConstVariable().backgroundGradient, child: ListView( children: [ SubtitleAppbarCitizen(title: 1,edit: showTab), showCheckError?Card( margin: EdgeInsets.all(10), child: Container( padding: EdgeInsets.all(10), child: Row( children: [ Icon(Icons.warning,color: Colors.red,), TextDefault(text: errorTopo,color: ColorPalette.red,fontSize: 15,) ], ), ), color: ColorPalette.white, ):Container(), Card( margin: EdgeInsets.all(10), child: Padding( padding: const EdgeInsets.all(8.0), child: Column( children: [ ButtonDefault( onPressed: ()=>checkSave(), title: 'Salvar', borderColor: ColorPalette.appBar, background: ColorPalette.appBar, textColor: ColorPalette.white, width: double.infinity, ), ButtonDefault( onPressed: ()=>Navigator.pop(context), title: 'Cancelar', borderColor: ColorPalette.blackButton, background: ColorPalette.blackButton, textColor: ColorPalette.white, width: double.infinity, ) ], ), ), ), Card( margin: EdgeInsets.all(10), child: Column( children: [ TitleContainers(title: 'Indentificação'), Row( children: [ Container( height: height*0.5, width: width*0.2, child: Icon(Icons.person,size: 80,), ), Column( mainAxisAlignment: MainAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: [ InputWithSubtitle( controller: nameController, subtitle: 'Nome', errorInput: nameController.text.isNotEmpty?'':'Campo Obrigatório', labelInput: 'Nome', widthInput: width*0.7, widthSubtitle: width*0.7, hintInput: 'Escreva aqui', onChanged: (v)=>setState((){}), ), InputWithSubtitle( controller: nameSocialController, subtitle: 'Nome Social', errorInput: 'Campo Obrigatório', labelInput: 'Nome Social', widthInput: width*0.7, widthSubtitle: width*0.7, hintInput: 'Escreva aqui', mandatory: false, onChanged: (v)=>setState((){}), ), DropdownWithSubtitle( list: ConstVariable().listGender, subtitle: 'Sexo', hintDropdown: 'Sexo', select: selectGender, widthSubtitle: width*0.6, widthDropdown: width*0.69, widthContainerDropdown: width*0.6, onChanged: (value){ setState(() { selectGender = value!; }); }, ), selectGender==null?ErrorDefault():Container(), Container( width: width*0.75, child: Row( children: [ // Padding( // padding: const EdgeInsets.symmetric(horizontal: 5.0,vertical: 15), // child: TextDefault( // text: 'Data de Nascimento', // color: ColorPalette.black54, // fontWeigth: FontWeight.bold, // fontSize: 18, // ), // ), // Spacer(), GestureDetector( onTap: ()=>escolherprazoInicio(context,'birth'), child: Container( alignment: Alignment.centerLeft, height: 58, margin: EdgeInsets.symmetric(horizontal: 15,vertical: 5), padding: EdgeInsets.symmetric(horizontal: 8,vertical: 10), decoration: BoxDecoration( border: Border.all(color: ColorPalette.black54), borderRadius: BorderRadius.all( Radius.circular(5.0) ), ), width: width*0.7, child: TextDefault( text: date, color: ColorPalette.black54, fontSize: 18, ), ), ) ], ), ), date == 'Data de Nascimento'?ErrorDefault():Container(), DropdownWithSubtitle( list: ConstVariable().listMaritalStatus, subtitle: 'Estado Civil', hintDropdown: 'Estado Civil', select: selectMaritalStatus, widthSubtitle: width*0.6, widthDropdown: width*0.69, widthContainerDropdown: width*0.6, onChanged: (value){ setState(() { selectMaritalStatus = value!; if(selectMaritalStatus=='CASADO(A)'){ enableSpouse = true; }else{ enableSpouse = false; } }); }, ), InputWithSubtitle( controller: spouseController, subtitle: 'Cônjuge', errorInput: enableSpouse?'Campo Obrigatório':'', labelInput: 'Cônjuge', widthInput: width*0.7, widthSubtitle: width*0.2, hintInput: 'Escreva aqui', enable: enableSpouse, onChanged: (v)=>setState((){}), ), DropdownWithSubtitle( list: ConstVariable().listNationality, subtitle: 'Naturalidade', hintDropdown: 'Naturalidade', select: selectNaturality, widthSubtitle: width*0.6, widthDropdown: width*0.69, widthContainerDropdown: width*0.6, onChanged: (value){ setState(() { selectNaturality = value!; if(selectNaturality!='BRASILEIRO'){ cityBirthController.text = 'MUNICIPIO IGNORADO - SP'; }else{ cityBirthController.text = ''; } }); }, ), selectNaturality==null?ErrorDefault():Container(), GestureDetector( onTap: cityBirthController.text == 'MUNICIPIO IGNORADO - SP'?null:(){ searchCityController.text = ''; searchCityBirthController.text = ''; searchCity('birth'); showDialog( context: context, builder: (context){ return AlertDialog( scrollable: true, content: StatefulBuilder( builder: (context, setState) { //aqui return Column( children: [ InputSearchText( onChanged: (v){ setState((){ searchCity('birth'); }); }, controller: searchCityBirthController, width: width*0.8, hint: 'Buscar...', color: ColorPalette.titleContainer, border: false, ), Container( padding: EdgeInsets.symmetric(vertical: 10), width: width*0.8, child: Container( width: width*0.8, height: height*0.6, padding: EdgeInsets.symmetric(horizontal: 10), child: ListView.separated( separatorBuilder:(context,index)=> Divider(color: ColorPalette.black54,height: 5,), itemCount: showResultSearchCity.length, itemBuilder: (context,index){ return Container( width: width*0.8, color: ColorPalette.white, child: ListTile( onTap: (){ setState(() { cityBirthController.text = showResultSearchCity[index]; Navigator.pop(context); }); }, title: TextDefault( color: ColorPalette.black54, text: showResultSearchCity[index], fontSize: 16, maxLines: 2, ), ), ); } ), ), ), ], ); }), ); }, ); }, child: InputWithSubtitle( controller: cityBirthController, subtitle: 'Município de Nascimento', errorInput: cityBirthController.text.isNotEmpty?'':'Campo Obrigatório', labelInput: 'Município de Nascimento', widthInput: width*0.7, widthSubtitle: width*0.2, hintInput: 'Escreva aqui', enable: false, onChanged: (v)=>setState((){}), ), ), DropdownWithSubtitle( list: ConstVariable().listBreed, subtitle: 'Raça/Cor', hintDropdown: 'Raça/Cor', select: selectBreed, widthSubtitle: width*0.6, widthDropdown: width*0.69, widthContainerDropdown: width*0.6, onChanged: (value){ setState(() { selectBreed = value!; }); }, ), selectBreed==null?ErrorDefault():Container(), DropdownWithSubtitle( list: ConstVariable().listScooling, subtitle: 'Escolaridade', hintDropdown: 'Escolaridade', select: selectScooling, widthSubtitle: width*0.6, widthDropdown: width*0.69, widthContainerDropdown: width*0.6, onChanged: (value){ setState(() { selectScooling = value!; }); }, ), DropdownWithSubtitle( list: ConstVariable().listDeficiency, subtitle: 'Deficiência', hintDropdown: 'Deficiência', select: selectDeficiency, widthSubtitle: width*0.6, widthDropdown: width*0.69, widthContainerDropdown: width*0.6, onChanged: (value){ setState(() { selectDeficiency = value!; }); }, ), selectDeficiency==null?ErrorDefault():Container(), InputWithSubtitle( controller: nameMotherController, subtitle: 'Nome da Mãe', errorInput: enableMother?'':'Campo Obrigatório', labelInput: 'Nome da Mãe', widthInput: width*0.7, widthSubtitle: width*0.2, hintInput: 'Escreva aqui', enable: !enableMother, onChanged: (v)=>setState((){}), ), SwitchWithSubtitle( width: width*0.65, title: 'Desconhece Mãe', value: enableMother, onChanged: (value){ setState(() { enableMother = value; if(enableMother){ nameMotherController.text = ''; } }); }, ), InputWithSubtitle( controller: nameFatherController, subtitle: 'Nome do Pai', errorInput: enableFather?'':'Campo Obrigatório', labelInput: 'Nome do Pai', widthInput: width*0.7, widthSubtitle: width*0.2, hintInput: 'Escreva aqui', enable: !enableFather, onChanged: (v)=>setState((){}), ), SwitchWithSubtitle( width: width*0.65, title: 'Desconhece Pai', value: enableFather, onChanged: (value){ setState(() { enableFather = value; if(enableFather){ nameFatherController.text = ''; } }); }, ), ], ) ], ) ], ), ), Card( margin: EdgeInsets.all(10), child: Column( children: [ TitleContainers(title: 'Identificação da Saúde'), Row( children: [ Container( height: height*0.4, width: width*0.2, child: Icon(Icons.medical_services_rounded,size: 80,), ), Column( mainAxisAlignment: MainAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: [ InputWithSubtitle( controller: unitController, subtitle: 'Unidade', errorInput: 'Campo Obrigatório', labelInput: 'Unidade', widthInput: width*0.7, widthSubtitle: width*0.7, hintInput: 'Escreva aqui', enable: false, onChanged: (v)=>setState((){}), ), InputWithSubtitle( controller: medicalRecordController, subtitle: 'Prontuário', errorInput: 'Campo Obrigatório', labelInput: 'Prontuário', widthInput: width*0.7, widthSubtitle: width*0.7, hintInput: 'Escreva aqui', enable: false, onChanged: (v)=>setState((){}), ), InputWithSubtitle( controller: medicalRecordProvController, subtitle: 'Prontuário Provisório', errorInput: 'Campo Obrigatório', labelInput: 'Prontuário Provisório', widthInput: width*0.7, widthSubtitle: width*0.7, hintInput: 'Escreva aqui', enable: false, onChanged: (v)=>setState((){}), ), DropdownWithSubtitle( subtitle: 'Classificação', select: selectClassification, widthSubtitle: width*0.6, widthDropdown: width*0.69, widthContainerDropdown: width*0.6, hintDropdown: 'Classificação', onChanged: (value){ setState(() { selectClassification = value; if(selectClassification=='OUTRO MUNICIPIO'){ cityController.clear(); codIBGEController.clear(); cepController.clear(); numberController.clear(); selectCountry = null; selectVillage = null; selectStreet = null; selectTypeStreet = null; AlertDialogDefault().alert( context, 'Aviso', 'As informações dos campos Bairro, Tipo Logradouro, Nome Logradouro, CEP,' 'Número, Loteamento e Complemento deverão ser inseridos no campo Observações!', 'OK' ); }else{ changedCity(); selectCountry = 'BRASIL'; } }); }, list: [ 'MUNICIPE', 'PROVISORIO', 'OUTRO MUNICIPIO', ] ), selectClassification==null?ErrorDefault():Container(), InputWithSubtitle( controller: numberFamilyController, subtitle: 'Número da Família', errorInput: '', labelInput: 'Número da Família', widthInput: width*0.7, widthSubtitle: width*0.7, mandatory: false, hintInput: 'Escreva aqui', onChanged: (v)=>setState((){}), ), ], ), ] ), ], ), ), Card( margin: EdgeInsets.all(10), child: Column( children: [ TitleContainers(title: 'Endereço'), Row( children: [ Container( height: height*0.4, width: width*0.2, child: Icon(Icons.map_outlined,size: 80,), ), Column( mainAxisAlignment: MainAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: [ DropdownWithSubtitle( subtitle: 'Pais de Residência', select: selectCountry, widthSubtitle: width*0.6, widthDropdown: width*0.69, widthContainerDropdown: width*0.6, hintDropdown: 'Pais de Residência', onChanged:selectClassification!='OUTRO MUNICIPIO'?null:(value){ setState(() { selectCountry = value; if(selectCountry=='OUTRO'){ cityController.text= 'MUNICIPIO IGNORADO - SP'; codIBGEController.text = '000000'; numberController.clear(); selectVillage = null; selectStreet = null; idBairro = ''; idTipo = ''; cepController.text = ''; AlertDialogDefault().alert( context, 'Aviso', 'As informações dos campos Bairro, Tipo Logradouro, Nome Logradouro, CEP,' 'Número, Loteamento e Complemento deverão ser inseridos no campo Observações!', 'OK' ); }else{ cityController.text = ''; codIBGEController.text = ''; } }); }, list: [ 'BRASIL', 'OUTRO', ] ), selectCountry==null?ErrorDefault():Container(), GestureDetector( onTap: selectClassification!='OUTRO MUNICIPIO'|| cityController.text == 'MUNICIPIO IGNORADO - SP'?null: (){ searchCityController.text = ''; searchCityBirthController.text = ''; searchCity('city'); showDialog( context: context, builder: (context){ return AlertDialog( scrollable: true, content: StatefulBuilder( builder: (context, setState) { return Column( children: [ InputSearchText( onChanged: (v){ setState((){ searchCity('city'); }); }, controller: searchCityController, width: width*0.8, hint: 'Buscar...', color: ColorPalette.titleContainer, border: false, ), Container( padding: EdgeInsets.symmetric(vertical: 10), width: width*0.8, child: Container( width: width*0.8, height: height*0.6, padding: EdgeInsets.symmetric(horizontal: 10), child: ListView.separated( separatorBuilder:(context,index)=> Divider(color: ColorPalette.black54,height: 5,), itemCount: showResultSearchCity.length, itemBuilder: (context,index){ return Container( width: width*0.8, color: ColorPalette.white, child: ListTile( onTap: (){ setState(() { cityController.text = showResultSearchCity[index]; codIBGEController.text = showResultSearchIbge[index]; // print("IBGE ${showResultSearchIbge[index]}"); Navigator.pop(context); }); }, title: TextDefault( color: ColorPalette.black54, text: showResultSearchCity[index], fontSize: 16, maxLines: 2, ), ), ); } ), ), ), ], ); }), ); }, ); }, child: InputWithSubtitle( controller: cityController, subtitle: 'Município de Residência', errorInput: 'Campo Obrigatório', labelInput: 'Município de Residência', widthInput: width*0.7, widthSubtitle: width*0.2, hintInput: 'Escreva aqui', enable: false, onChanged: (v)=>setState((){}), ), ), InputWithSubtitle( controller: codIBGEController, subtitle: 'Cód. IBGE', errorInput: '', labelInput: 'Cód. IBGE', widthInput: width*0.7, widthSubtitle: width*0.2, hintInput: 'Escreva aqui', enable: false, onChanged: (v)=>setState((){}), ), DropdownWithSubtitle( subtitle: 'Bairro', select: selectVillage, widthSubtitle: width*0.6, widthDropdown: width*0.69, widthContainerDropdown: width*0.6, hintDropdown: 'Bairro', onChanged:selectClassification=='OUTRO MUNICIPIO'?null: (value)async{ setState(() { selectVillage = value; selectTypeStreet = null; selectStreet = null; idBairro = ''; idTipo = ''; }); idBairro = await DBQuerys().buscaBairro(selectVillage); }, //aqui list: villageDB ), selectClassification!='OUTRO MUNICIPIO' && selectVillage == null?ErrorDefault():Container(), DropdownWithSubtitle( subtitle: 'Tipo de Logradouro', select: selectTypeStreet, widthSubtitle: width*0.6, widthDropdown: width*0.69, widthContainerDropdown: width*0.6, hintDropdown: 'Tipo de Logradouro', onChanged:selectClassification=='OUTRO MUNICIPIO' || selectVillage == null?null: (value)async{ setState(() { selectTypeStreet = value; selectStreet = null; }); idTipo = await DBQuerys().buscaTipoLogradouro(selectTypeStreet); if(idBairro!='' && idTipo!=''){ loadStreetDB(); } }, list: typeStreetDB ), selectTypeStreet!='OUTRO MUNICIPIO' && selectTypeStreet == null && selectCountry == null?ErrorDefault():Container(), DropdownWithSubtitle( subtitle: 'Nome do Logradouro', select: selectStreet, widthSubtitle: width*0.6, widthDropdown: width*0.69, widthContainerDropdown: width*0.6, hintDropdown: 'Nome do Logradouro', onChanged:selectClassification=='OUTRO MUNICIPIO' || selectVillage == null?null: (value){ setState(() { selectStreet = value; }); }, list: streetDB ), InputWithSubtitle( typeInput: 'cep', controller: cepController, subtitle: 'CEP(só números)', errorInput: selectClassification!='OUTRO MUNICIPIO'&& cepController.text.isEmpty?'Campo Obrigatório':cepController.text.length!=8?'CEP incorreto':'', labelInput: 'CEP(só números)', widthInput: width*0.7, widthSubtitle: width*0.2, hintInput: 'Escreva aqui', enable: selectClassification!='OUTRO MUNICIPIO'?true:false, onChanged: (v)=>setState((){}), ), Container( width: width*0.7, child: Row( children: [ InputWithSubtitle( controller: numberController, subtitle: 'Número', errorInput: 'Campo Obrigatório', labelInput: 'Número', widthInput: width*0.4, widthSubtitle: width*0.2, widthError: 0.4, hintInput: 'Escreva aqui', enable: selectClassification!='OUTRO MUNICIPIO' && !checkBoxNumber?true:false, onChanged: (v)=>setState((){}), ), Checkbox( value: checkBoxNumber, onChanged: (value){ setState(() { checkBoxNumber = value!; if(checkBoxNumber){ numberController.text = '0'; }else{ numberController.clear(); } }); } ), Spacer(), Padding( padding: const EdgeInsets.symmetric(horizontal: 10.0), child: TextDefault(text: 'SEM NÚMERO',fontSize: 15,), ) ], ), ), DropdownWithSubtitle( subtitle: 'Loteamento/Subdistrito', select: selectSubdivision, widthSubtitle: width*0.6, widthDropdown: width*0.69, widthContainerDropdown: width*0.6, hintDropdown: 'Loteamento/Subdistrito', onChanged: (value){ setState(() { selectSubdivision = value; }); }, list: subdivisionDB ), InputWithSubtitle( controller: complementController, subtitle: 'Complemento', errorInput: 'Campo Obrigatório', labelInput: 'Complemento', widthInput: width*0.7, widthSubtitle: width*0.2, hintInput: 'Escreva aqui', mandatory: false, onChanged: (v)=>setState((){}), ), InputWithSubtitle( controller: referencePointController, subtitle: 'Ponto de Referência', errorInput: 'Campo Obrigatório', labelInput: 'Ponto de Referência', widthInput: width*0.7, widthSubtitle: width*0.2, hintInput: 'Escreva aqui', mandatory: false, onChanged: (v)=>setState((){}), ), DropdownWithSubtitle( subtitle: 'Zona', select: selectZone, widthSubtitle: width*0.6, widthDropdown: width*0.69, widthContainerDropdown: width*0.6, hintDropdown: 'Zona', onChanged: (value){ setState(() { selectZone = value; }); }, list: ['URBANA','RURAL'] ), ], ), ] ), ], ), ), Card( margin: EdgeInsets.all(10), child: Column( children: [ TitleContainers(title: 'Contato'), Row( children: [ Container( height: height*0.4, width: width*0.2, child: Icon(Icons.medical_services_rounded,size: 80,), ), Padding( padding: const EdgeInsets.symmetric(horizontal: 10.0), child: Column( mainAxisAlignment: MainAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: [ InputWithSubtitle( controller: foneDDDController, subtitle: 'Telefone - DDD', errorInput: 'Campo Obrigatório', labelInput: 'Telefone - DDD', widthInput: width*0.7, widthSubtitle: width*0.7, hintInput: 'Escreva aqui', mandatory: false, onChanged: (v)=>setState((){}), ), InputWithSubtitle( controller: foneController, subtitle: 'Telefone (Só Números)', errorInput: 'Campo Obrigatório', labelInput: 'Telefone(Só Números)', widthInput: width*0.7, widthSubtitle: width*0.7, hintInput: 'Escreva aqui', mandatory: false, onChanged: (v)=>setState((){}), ), InputWithSubtitle( controller: mobileDDDController, subtitle: 'Celular - DDD', errorInput: 'Campo Obrigatório', labelInput: 'Celular - DDD', widthInput: width*0.7, widthSubtitle: width*0.7, hintInput: 'Escreva aqui', mandatory: false, onChanged: (v)=>setState((){}), ), InputWithSubtitle( controller: mobileController, subtitle: 'Celular (Só Números)', errorInput: 'Campo Obrigatório', labelInput: 'Celular (Só Números)', widthInput: width*0.7, widthSubtitle: width*0.7, hintInput: 'Escreva aqui', mandatory: false, onChanged: (v)=>setState((){}), ), InputWithSubtitle( controller: messageDDDController, subtitle: 'Recado - DDD', errorInput: 'Campo Obrigatório', labelInput: 'Recado - DDD', widthInput: width*0.7, widthSubtitle: width*0.7, hintInput: 'Escreva aqui', onChanged: (v)=>setState((){}), ), InputWithSubtitle( controller: messageController, subtitle: 'Recado (Só Números)', errorInput: 'Campo Obrigatório', labelInput: 'Recado (Só Números)', widthInput: width*0.7, widthSubtitle: width*0.7, hintInput: 'Escreva aqui', onChanged: (v)=>setState((){}), ), InputWithSubtitle( controller: emailController, subtitle: 'E-mail', errorInput: 'Campo Obrigatório', labelInput: 'E-mail', widthInput: width*0.7, widthSubtitle: width*0.7, hintInput: 'Escreva aqui', mandatory: false, onChanged: (v)=>setState((){}), ), ], ), ), ] ), ], ), ), Card( margin: EdgeInsets.all(10), child: Column( children: [ TitleContainers(title: 'Observações'), Row( children: [ Container( height: height*0.2, width: width*0.2, child: Icon(Icons.sell,size: 80,), ), Padding( padding: const EdgeInsets.symmetric(horizontal: 10.0), child: Column( mainAxisAlignment: MainAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: [ InputWithSubtitle( controller: observationController, subtitle: 'Observação', errorInput: 'Campo Obrigatório', labelInput: 'Observação', widthInput: width*0.7, widthSubtitle: width*0.7, hintInput: 'Escreva aqui', textInputType: TextInputType.multiline, maxLines: 5, mandatory: false, onChanged: (v)=>setState((){}), ), ], ), ), ] ), ], ), ), Card( margin: EdgeInsets.all(10), child: Column( children: [ TitleContainers(title: 'Documentos'), Row( children: [ Container( height: height*0.4, width: width*0.2, child: Icon(Icons.description_outlined,size: 80,), ), Column( mainAxisAlignment: MainAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: [ InputWithSubtitle( controller: CPFController, subtitle: 'CPF (Só Números)', errorInput: 'Campo Obrigatório', labelInput: 'CPF (Só Números)', widthInput: width*0.7, widthSubtitle: width*0.7, hintInput: 'Escreva aqui', mandatory: false, onChanged: (v)async{ if(CPFController.text.isNotEmpty){ checkCPF = await MainControllers().validaCPF(v); }else{ checkCPF = 'ok'; } setState((){}); } ), checkCPF!='ok' && checkCPF!='' ?Container( width: width*0.7,child: TextDefault(text: checkCPF,fontSize: 15,color: ColorPalette.red,) ):Container(), InputWithSubtitle( controller: CNSController, subtitle: 'CNS', errorInput: 'Campo Obrigatório', labelInput: 'CNS', widthInput: width*0.7, widthSubtitle: width*0.7, hintInput: 'Escreva aqui', mandatory: false, onChanged: (v)async{ if(CNSController.text.isNotEmpty){ checkCNS = await MainControllers().validaCNS(v); }else{ checkCNS = 'ok'; } setState((){}); } ), checkCNS!='ok' && checkCNS!='' ?Container( width: width*0.7,child: TextDefault(text: checkCNS,fontSize: 15,color: ColorPalette.red,) ):Container(), InputWithSubtitle( controller: voterController, subtitle: 'Título de Eleitor', errorInput: 'Campo Obrigatório', labelInput: 'Título de Eleitor', widthInput: width*0.7, widthSubtitle: width*0.7, hintInput: 'Escreva aqui', mandatory: false, onChanged: (v)=>setState((){}), ), InputWithSubtitle( controller: RGController, subtitle: 'RG', errorInput: 'Campo Obrigatório', labelInput: 'RG', widthInput: width*0.7, widthSubtitle: width*0.7, hintInput: 'Escreva aqui', mandatory: false, onChanged: (v)=>setState((){}), ), InputWithSubtitle( controller: RGComplementController, subtitle: 'RG - Complemento', errorInput: 'Campo Obrigatório', labelInput: 'RG - Complemento', widthInput: width*0.7, widthSubtitle: width*0.7, hintInput: 'Escreva aqui', mandatory: false, onChanged: (v)=>setState((){}), ), DropdownWithSubtitle( subtitle: 'RG - UF', select: selectRGUF, widthSubtitle: width*0.6, widthDropdown: width*0.69, widthContainerDropdown: width*0.6, hintDropdown: 'RG - UF', onChanged: (value){ setState(() { selectRGUF = value; }); }, list: ConstVariable().RGUF ), InputWithSubtitle( controller: RGOrganController, subtitle: 'RG - Órgão', errorInput: 'Campo Obrigatório', labelInput: 'RG - Órgão', widthInput: width*0.7, widthSubtitle: width*0.7, hintInput: 'Escreva aqui', mandatory: false, onChanged: (v)=>setState((){}), ), GestureDetector( onTap: ()=>escolherprazoInicio(context,'rg'), child: Container( alignment: Alignment.centerLeft, height: 58, margin: EdgeInsets.symmetric(horizontal: 15,vertical: 5), padding: EdgeInsets.symmetric(horizontal: 8,vertical: 10), decoration: BoxDecoration( border: Border.all(color: ColorPalette.black54), borderRadius: BorderRadius.all( Radius.circular(5.0) ), ), width: width*0.7, child: TextDefault( text: RGDateController.text, color: ColorPalette.black54, fontSize: 18, ), ), ), DropdownWithSubtitle( subtitle: 'Tipo de certidão', select: selectTypeCertificate, widthSubtitle: width*0.6, widthDropdown: width*0.69, widthContainerDropdown: width*0.6, hintDropdown: 'Tipo de certidão', onChanged: (value){ setState(() { selectTypeCertificate = value; }); }, list: [ 'NASCIMENTO', 'CASAMENTO', 'DIVÓRCIO', 'ADMINISTRATIVA - ÍNDIO', 'NASCIMENTO - N', 'CASAMENTO - N', 'DIVÓRCIO - N', 'ADMINISTRATIVA - ÍNDIO - N', ] ), InputWithSubtitle( controller: numberCertificateController, subtitle: 'Número da Certidão', errorInput: 'Campo Obrigatório', labelInput: 'Número da Certidão', widthInput: width*0.7, widthSubtitle: width*0.7, hintInput: 'Escreva aqui', mandatory: false, onChanged: (v)=>setState((){}), ), InputWithSubtitle( controller: nameCertificateController, subtitle: 'Nome do Cartório da Certidão', errorInput: 'Campo Obrigatório', labelInput: 'Nome do Cartório da Certidão', widthInput: width*0.7, widthSubtitle: width*0.7, hintInput: 'Escreva aqui', mandatory: false, onChanged: (v)=>setState((){}), ), InputWithSubtitle( controller: bookCertificateController, subtitle: 'Livro da Certidão', errorInput: 'Campo Obrigatório', labelInput: 'Livro da Certidão', widthInput: width*0.7, widthSubtitle: width*0.7, hintInput: 'Escreva aqui', mandatory: false, onChanged: (v)=>setState((){}), ), InputWithSubtitle( controller: sheetCertificateController, subtitle: 'Folha da Certidão', errorInput: 'Campo Obrigatório', labelInput: 'Folha da Certidão', widthInput: width*0.7, widthSubtitle: width*0.7, hintInput: 'Escreva aqui', mandatory: false, onChanged: (v)=>setState((){}), ), InputWithSubtitle( controller: termCertificateController, subtitle: 'Termo da Certidão', errorInput: 'Campo Obrigatório', labelInput: 'Termo da Certidão', widthInput: width*0.7, widthSubtitle: width*0.7, hintInput: 'Escreva aqui', mandatory: false, onChanged: (v)=>setState((){}), ), GestureDetector( onTap: ()=>escolherprazoInicio(context,'cert'), child: Container( alignment: Alignment.centerLeft, height: 58, margin: EdgeInsets.symmetric(horizontal: 15,vertical: 5), padding: EdgeInsets.symmetric(horizontal: 8,vertical: 10), decoration: BoxDecoration( border: Border.all(color: ColorPalette.black54), borderRadius: BorderRadius.all( Radius.circular(5.0) ), ), width: width*0.7, child: TextDefault( text: dateCertificateController.text, color: ColorPalette.black54, fontSize: 18, ), ), ), InputWithSubtitle( controller: CTPSController, subtitle: 'CTPS', errorInput: 'Campo Obrigatório', labelInput: 'CTPS', widthInput: width*0.7, widthSubtitle: width*0.7, hintInput: 'Escreva aqui', mandatory: false, onChanged: (v)=>setState((){}), ), InputWithSubtitle( controller: numberCTPSController, subtitle: 'Número de Série CTPS', errorInput: 'Campo Obrigatório', labelInput: 'Número de Série CTPS', widthInput: width*0.7, widthSubtitle: width*0.7, hintInput: 'Escreva aqui', mandatory: false, onChanged: (v)=>setState((){}), ), DropdownWithSubtitle( subtitle: 'CTPS - UF', select: selectCTPSUF, widthSubtitle: width*0.6, widthDropdown: width*0.69, widthContainerDropdown: width*0.6, hintDropdown: 'CTPS - UF', onChanged: (value){ setState(() { selectCTPSUF = value; }); }, list: ConstVariable().RGUF ), InputWithSubtitle( controller: PISController, subtitle: 'PIS/PASEP', errorInput: 'Campo Obrigatório', labelInput: 'PIS/PASEP', widthInput: width*0.7, widthSubtitle: width*0.7, hintInput: 'Escreva aqui', mandatory: false, onChanged: (v)=>setState((){}), ), Container( width: width*0.65, child: Row( children: [ TextDefault(text: 'Retirou cartão municipal da cidade?',fontSize: 15,color: Colors.black54), Spacer(), Switch(value: enableCityCard, onChanged: (value)=>setState(()=>enableCityCard=value!) ) ], ), ), InputWithSubtitle( controller: NISController, subtitle: 'Identificação da saúde - NIS', errorInput: 'Campo Obrigatório', labelInput: 'Identificação da saúde - NIS', widthInput: width*0.7, widthSubtitle: width*0.7, hintInput: 'Escreva aqui', mandatory: false, onChanged: (v)=>setState((){}), ), ], ), ] ), ], ), ), Card( margin: EdgeInsets.all(10), child: Column( children: [ TitleContainers(title: 'Outros'), Row( children: [ Container( height: height*0.3, width: width*0.2, child: Icon(Icons.tag,size: 80,), ), Column( mainAxisAlignment: MainAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: [ InputWithSubtitle( controller: incomeController, subtitle: 'Renda Mensal', errorInput: 'Campo Obrigatório', labelInput: 'Renda Mensal', widthInput: width*0.7, widthSubtitle: width*0.7, hintInput: 'Escreva aqui', mandatory: false, onChanged: (v)=>setState((){}), ), InputWithSubtitle( controller: professionalController, subtitle: 'Profissão', errorInput: 'Campo Obrigatório', labelInput: 'Profissão', widthInput: width*0.7, widthSubtitle: width*0.7, hintInput: 'Escreva aqui', mandatory: false, onChanged: (v)=>setState((){}), ), GestureDetector( onTap: ()=>escolherprazoInicio(context,'death'), child: Container( alignment: Alignment.centerLeft, height: 58, margin: EdgeInsets.symmetric(horizontal: 15,vertical: 5), padding: EdgeInsets.symmetric(horizontal: 8,vertical: 10), decoration: BoxDecoration( border: Border.all(color: ColorPalette.black54), borderRadius: BorderRadius.all( Radius.circular(5.0) ), ), width: width*0.7, child: TextDefault( text: dateDeathController.text, color: ColorPalette.black54, fontSize: 18, ), ), ), Container( width: width*0.65, child: Row( children: [ TextDefault(text: 'Bloqueado',fontSize: 15,color: ColorPalette.black54), Spacer(), Switch(value: enableBlocked, onChanged: (value)=>setState(()=>enableBlocked=value!)), ], ), ) ], ), ] ), ], ), ), ] ) ), ), ); } }