563 lines
28 KiB
Dart
563 lines
28 KiB
Dart
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/service/db/db_querys.dart';
|
|
import 'package:rkm/widgets/button_default.dart';
|
|
import 'package:rkm/widgets/title_containers.dart';
|
|
import '../../service/shared_preferences/shared_preferences_service.dart';
|
|
import '../../widgets/appbar_default.dart';
|
|
import '../../widgets/dropdown_with_subtitle.dart';
|
|
import '../../widgets/input_with_subtitle.dart';
|
|
import '../../widgets/onbackbutton.dart';
|
|
import '../../widgets/subtitle_appbar_citizen.dart';
|
|
import '../../widgets/switch_with_subtitle.dart';
|
|
class RegisterHomeScreen extends StatefulWidget {
|
|
List listData;
|
|
RegisterHomeScreen({required this.listData});
|
|
|
|
@override
|
|
State<RegisterHomeScreen> createState() => _RegisterHomeScreenState();
|
|
}
|
|
|
|
class _RegisterHomeScreenState extends State<RegisterHomeScreen> {
|
|
|
|
var responsibleRegisterController = TextEditingController();
|
|
var unitProfessionalController = TextEditingController();
|
|
var dataRegisterController = TextEditingController(text: '06/12/2022');
|
|
var controllerComfortable = TextEditingController();
|
|
var controllerResidents = TextEditingController();
|
|
var controllerAmount = TextEditingController();
|
|
|
|
String? selectCBO;
|
|
String? selectAcessHome;
|
|
String? selectMaterialWall;
|
|
String? selectWater;
|
|
String? selectTreatmentWater;
|
|
String? selectDestinyTrash;
|
|
String? selectFormSanitaryDrainage;
|
|
String? selectRural;
|
|
|
|
bool enableAnimals = false;
|
|
bool enableCats = false;
|
|
bool enableDogs = false;
|
|
bool enableBirds = false;
|
|
bool enableOther = false;
|
|
bool enableAccompaniedCompany = false;
|
|
bool enableEnergy = false;
|
|
bool statusRegister = true;
|
|
bool renponsibleFamily = true;
|
|
bool frequencySchool = false;
|
|
bool enableFather = false;
|
|
bool enableCityCard = false;
|
|
bool enableBlocked = false;
|
|
bool checkBoxNumber = false;
|
|
String date = 'Data de Nascimento';
|
|
bool FORA_AREA = false;
|
|
|
|
List<String> listTypeHome = [];
|
|
List<String> listINE = [];
|
|
List<String> listSituationHome = [];
|
|
List<String> listTypeLocation = [];
|
|
List<String> listTypeResidence = [];
|
|
|
|
String idUsuario = '';
|
|
String idUnidade = '';
|
|
String nomeUnidade = '';
|
|
String INE_DB='';
|
|
String? INE;
|
|
String? TIPO_IMOVEL;
|
|
String? SITUACAO_MORADIA;
|
|
String? TIPO_LOCALIDADE;
|
|
String? TIPO_DOMICILIO;
|
|
|
|
int ID_AREA_DOMICILIO=0;
|
|
int ID_MICROAREA_DOMICILIO=0;
|
|
int TIPO_IMOVEL_COD = 0;
|
|
int SITUACAO_MORADIA_COD = 0;
|
|
int TIPO_LOCALIDADE_COD = 0;
|
|
int TIPO_DOMICILIO_COD = 0;
|
|
|
|
escolherprazoInicio(BuildContext context) async {
|
|
var pickDate = await showDatePicker(
|
|
context: context,
|
|
initialDate: DateTime.now(),
|
|
firstDate: DateTime(2022),
|
|
lastDate: DateTime(2025));
|
|
if (pickDate != null) {
|
|
setState(() {
|
|
date = 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;
|
|
}
|
|
|
|
getUser(){
|
|
final PrefService _prefService = PrefService();
|
|
_prefService.readCacheIdUsuario('idUsuario').then((value){
|
|
if(value != null){
|
|
idUsuario = value;
|
|
}
|
|
});
|
|
_prefService.readCacheUnidade('idUnidade').then((value){
|
|
if(value!=null){
|
|
idUnidade = value[0];
|
|
nomeUnidade = value[1];
|
|
}
|
|
loadLists();
|
|
});
|
|
}
|
|
|
|
loadLists(){
|
|
for(int i = 0; ConstVariable().listTypeHome.length > i; i++){
|
|
listTypeHome.add(ConstVariable().listTypeHome[i].title);
|
|
}
|
|
for(int i = 0; ConstVariable().listSituationHome.length > i; i++){
|
|
listSituationHome.add(ConstVariable().listSituationHome[i].title);
|
|
}
|
|
for(int i = 0; ConstVariable().listTypeLocation.length > i; i++){
|
|
listTypeLocation.add(ConstVariable().listTypeLocation[i].title);
|
|
}
|
|
for(int i = 0; ConstVariable().listTypeResidence.length > i; i++){
|
|
listTypeResidence.add(ConstVariable().listTypeResidence[i].title);
|
|
}
|
|
loadRegisterHome();
|
|
}
|
|
|
|
loadRegisterHome()async{
|
|
int ID_DOMICILIO = widget.listData[0]['ID_DOMICILIO'];
|
|
DBQuerys().buscaCadDomiciliar(ID_DOMICILIO).then((dataHome)async{
|
|
TIPO_IMOVEL_COD = dataHome[0]['TIPO_IMOVEL']??0;
|
|
for (int i = 0; ConstVariable().listTypeHome.length > i; i++) {
|
|
if (ConstVariable().listTypeHome[i].cod == TIPO_IMOVEL_COD) {
|
|
TIPO_IMOVEL = ConstVariable().listTypeHome[i].title;
|
|
}
|
|
}
|
|
List list = await DBQuerys().buscaDadosProfissional(idUnidade,idUsuario);
|
|
ID_AREA_DOMICILIO = list[0]['AREA'];
|
|
ID_MICROAREA_DOMICILIO = list[0]['MICROAREA'];
|
|
INE_DB = list[0]['INE'];
|
|
INE = 'INE: $INE_DB / Área: $ID_AREA_DOMICILIO - Microárea : $ID_MICROAREA_DOMICILIO';
|
|
listINE.add(INE!);
|
|
FORA_AREA = dataHome[0]['FORA_AREA']==1?true:false;
|
|
SITUACAO_MORADIA_COD = dataHome[0]['SITUACAO_MORADIA']??0;
|
|
for (int i = 0; ConstVariable().listSituationHome.length > i; i++) {
|
|
if (ConstVariable().listSituationHome[i].cod == SITUACAO_MORADIA_COD) {
|
|
SITUACAO_MORADIA = ConstVariable().listSituationHome[i].title;
|
|
}
|
|
}
|
|
TIPO_LOCALIDADE_COD = dataHome[0]['TIPO_LOCALIDADE']??0;
|
|
for (int i = 0; ConstVariable().listTypeLocation.length > i; i++) {
|
|
if (ConstVariable().listTypeLocation[i].cod == TIPO_LOCALIDADE_COD) {
|
|
TIPO_LOCALIDADE = ConstVariable().listTypeLocation[i].title;
|
|
}
|
|
}
|
|
TIPO_DOMICILIO_COD = dataHome[0]['TIPO_DOMICILIO']??0;
|
|
for (int i = 0; ConstVariable().listTypeResidence.length > i; i++) {
|
|
if (ConstVariable().listTypeResidence[i].cod == TIPO_DOMICILIO_COD) {
|
|
TIPO_DOMICILIO = ConstVariable().listTypeResidence[i].title;
|
|
}
|
|
}
|
|
print(TIPO_DOMICILIO_COD);
|
|
print(TIPO_DOMICILIO);
|
|
////[{"cdDomicilio":16,"cdTipoImovel":1,"cdAreaDomicilio":null,"cdMicroareaDomicilio":null,"foraArea":1,"cdSituacao":2,
|
|
// cdTipoLocalidade":1,"cdTipoDomicilio":1,"nrMoradores":6,"nrComodo":7,"situacaoProducaoRural":0,"tipoAcesso":1,
|
|
// "materialParedesExternas":1,"dispEnergiaEletrica":1,"cdTipoAbastecimento":1,"cdTratamentoAgua":4,"cdDestinoLixo":1,
|
|
// "cdEscoamento":1,"animais":0,"animaisGato":0,"animaisCachorro":0,"animaisPassaro":0,"animaisOutros":0,"animaisQtde":null,
|
|
// "respCadastro":68,"cnesUnidade":"9372253","cboRespCadastro":"515105","ine":"0001485628","dtCadastro":"2021-11-10",
|
|
// "cdEquipe":5,"noInstPermanencia":null,"outrosProfissionaisInst":null,"noResponsavelInst":null,"cnsResponsavelInst":null,
|
|
// "gargoResponsavelInst":null,"telefoneResponsavelInst":null},
|
|
setState(() {});
|
|
});
|
|
}
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
getUser();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
|
|
double heigth = MediaQuery.of(context).size.height;
|
|
double width = MediaQuery.of(context).size.width;
|
|
|
|
return WillPopScope(
|
|
onWillPop: ()async => await OnBackButton().onBackButton(context),
|
|
child: Scaffold(
|
|
appBar: AppBarDefault().appbar(context, 'RKM AB - Cadastro Domiciliar'),
|
|
body: Container(
|
|
height: double.infinity,
|
|
width: double.infinity,
|
|
decoration: ConstVariable().backgroundGradient,
|
|
child: ListView(
|
|
children: [
|
|
SubtitleAppbarCitizen(title: 3,edit: true,listData: widget.listData),
|
|
Card(
|
|
margin: EdgeInsets.all(10),
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(8.0),
|
|
child: Column(
|
|
children: [
|
|
ButtonDefault(
|
|
onPressed: (){},
|
|
title: 'Alterar',
|
|
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: 'Condições de Moradia'),
|
|
Row(
|
|
children: [
|
|
Container(
|
|
height: heigth*0.5,
|
|
width: width*0.2,
|
|
child: Icon(Icons.home,size: 80,),
|
|
),
|
|
Column(
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
DropdownWithSubtitle(
|
|
list:listTypeHome,
|
|
widthSubtitle: width*0.7,
|
|
subtitle: 'Tipo de Imóvel',
|
|
hintDropdown: 'Tipo de Imóvel',
|
|
select: TIPO_IMOVEL,
|
|
widthDropdown: width*0.7,
|
|
widthContainerDropdown: width*0.6,
|
|
onChanged: (value){
|
|
setState(()=>TIPO_IMOVEL = value!);
|
|
for (int i = 0; ConstVariable().listTypeHome.length > i; i++) {
|
|
if (ConstVariable().listTypeHome[i].title == TIPO_IMOVEL) {
|
|
TIPO_IMOVEL_COD = ConstVariable().listTypeHome[i].cod;
|
|
}
|
|
}
|
|
},
|
|
),
|
|
DropdownWithSubtitle(
|
|
list:listINE,
|
|
widthSubtitle: width*0.7,
|
|
subtitle: 'INE - Área / Microárea do Domicílio',
|
|
hintDropdown: 'INE - Área / Microárea do Domicílio',
|
|
select: INE,
|
|
widthDropdown: width*0.7,
|
|
widthContainerDropdown: width*0.6,
|
|
onChanged: (value)=>setState(()=>INE = value!),
|
|
),
|
|
SwitchWithSubtitle(
|
|
width: width*0.7,
|
|
title: 'Fora de área',
|
|
value: FORA_AREA,
|
|
onChanged: (value)=>setState(()=>FORA_AREA=value),
|
|
),
|
|
DropdownWithSubtitle(
|
|
list:listSituationHome,
|
|
widthSubtitle: width*0.7,
|
|
subtitle: 'Situação',
|
|
hintDropdown: 'Situação',
|
|
select: SITUACAO_MORADIA,
|
|
widthDropdown: width*0.7,
|
|
widthContainerDropdown: width*0.6,
|
|
onChanged: (value){
|
|
setState(()=>SITUACAO_MORADIA = value!);
|
|
for (int i = 0; ConstVariable().listSituationHome.length > i; i++) {
|
|
if (ConstVariable().listSituationHome[i].title == TIPO_IMOVEL) {
|
|
SITUACAO_MORADIA_COD = ConstVariable().listSituationHome[i].cod;
|
|
}
|
|
}
|
|
},
|
|
),
|
|
DropdownWithSubtitle(
|
|
list:listTypeLocation,
|
|
widthSubtitle: width*0.7,
|
|
subtitle: 'Localização',
|
|
hintDropdown: 'Localização',
|
|
select: TIPO_LOCALIDADE,
|
|
widthDropdown: width*0.7,
|
|
widthContainerDropdown: width*0.6,
|
|
onChanged: (value){
|
|
setState(()=>TIPO_LOCALIDADE = value!);
|
|
for (int i = 0; ConstVariable().listTypeLocation.length > i; i++) {
|
|
if (ConstVariable().listTypeLocation[i].title == TIPO_LOCALIDADE) {
|
|
TIPO_LOCALIDADE_COD = ConstVariable().listTypeLocation[i].cod;
|
|
}
|
|
}
|
|
},
|
|
),
|
|
DropdownWithSubtitle(
|
|
list:listTypeResidence,
|
|
widthSubtitle: width*0.7,
|
|
subtitle: 'Tipo de Domicílio',
|
|
hintDropdown: 'Tipo de Domicílio',
|
|
select: TIPO_DOMICILIO,
|
|
widthDropdown: width*0.7,
|
|
widthContainerDropdown: width*0.6,
|
|
onChanged: (value){
|
|
setState(()=>TIPO_DOMICILIO = value!);
|
|
for (int i = 0; ConstVariable().listTypeResidence.length > i; i++) {
|
|
if (ConstVariable().listTypeResidence[i].title == TIPO_DOMICILIO) {
|
|
TIPO_DOMICILIO_COD = ConstVariable().listTypeResidence[i].cod;
|
|
}
|
|
}
|
|
},
|
|
),
|
|
InputWithSubtitle(
|
|
subtitle: 'Moradores',
|
|
hintInput: 'Moradores',
|
|
errorInput: 'Campo obrigatório',
|
|
labelInput: 'Moradores',
|
|
widthSubtitle: width*0.4,
|
|
widthInput: width*0.7,
|
|
controller: controllerResidents,
|
|
onChanged: (v)=>setState((){}),
|
|
),
|
|
InputWithSubtitle(
|
|
subtitle: 'Cômodos',
|
|
hintInput: 'Cômodos',
|
|
errorInput: 'Campo obrigatório',
|
|
labelInput: 'Cômodos',
|
|
widthSubtitle: width*0.4,
|
|
widthInput: width*0.7,
|
|
controller: controllerComfortable,
|
|
onChanged: (v)=>setState((){}),
|
|
),
|
|
DropdownWithSubtitle(
|
|
list:[],
|
|
widthSubtitle: width*0.7,
|
|
subtitle: 'Situação Rural',
|
|
hintDropdown: 'Situação Rural',
|
|
select: selectRural,
|
|
widthDropdown: width*0.7,
|
|
widthContainerDropdown: width*0.6,
|
|
onChanged: (value)=>setState(()=>selectRural = value!)
|
|
),
|
|
DropdownWithSubtitle(
|
|
list:['ASFALTO'],
|
|
widthSubtitle: width*0.7,
|
|
subtitle: 'Tipo de Acesso ao Domicílio',
|
|
hintDropdown: 'Tipo de Acesso ao Domicílio',
|
|
select: selectAcessHome,
|
|
widthDropdown: width*0.7,
|
|
widthContainerDropdown: width*0.6,
|
|
onChanged: (value)=>setState(()=>selectAcessHome = value!)
|
|
),
|
|
DropdownWithSubtitle(
|
|
list:['ALVENARIA COM REVESTIMENTO'],
|
|
widthSubtitle: width*0.7,
|
|
subtitle: 'Material Predominante - Parede',
|
|
hintDropdown: 'Material Predominante - Parede',
|
|
select: selectMaterialWall,
|
|
widthDropdown: width*0.7,
|
|
widthContainerDropdown: width*0.6,
|
|
onChanged: (value)=>setState(()=>selectMaterialWall = value!)
|
|
),
|
|
SwitchWithSubtitle(
|
|
width: width*0.7,
|
|
title: 'Disponibilidade de Energia Elétroca',
|
|
value: enableEnergy,
|
|
onChanged: (value)=>setState(()=>enableEnergy = value),
|
|
),
|
|
DropdownWithSubtitle(
|
|
list:['REDE ENCANADA ATÉ O DOMICÍLIO'],
|
|
widthSubtitle: width*0.7,
|
|
subtitle: 'Abastecimento de Água',
|
|
hintDropdown: 'Abastecimento de Água',
|
|
select: selectWater,
|
|
widthDropdown: width*0.7,
|
|
widthContainerDropdown: width*0.6,
|
|
onChanged: (value)=>setState(()=>selectWater = value!)
|
|
),
|
|
DropdownWithSubtitle(
|
|
list:['FILTRAÇÃO'],
|
|
widthSubtitle: width*0.7,
|
|
subtitle: 'Tratamento de Água',
|
|
hintDropdown: 'Tratamento de Água',
|
|
select: selectTreatmentWater,
|
|
widthDropdown: width*0.7,
|
|
widthContainerDropdown: width*0.6,
|
|
onChanged: (value)=>setState(()=>selectTreatmentWater = value!)
|
|
),
|
|
DropdownWithSubtitle(
|
|
list:['COLETADO'],
|
|
widthSubtitle: width*0.7,
|
|
subtitle: 'Destino de Lixo',
|
|
hintDropdown: 'Destino de Lixo',
|
|
select: selectDestinyTrash,
|
|
widthDropdown: width*0.7,
|
|
widthContainerDropdown: width*0.6,
|
|
onChanged: (value)=>setState(()=>selectDestinyTrash = value!)
|
|
),
|
|
DropdownWithSubtitle(
|
|
list:['REDE COLETORA DE ESGOTO OU PLUVIAL'],
|
|
widthSubtitle: width*0.7,
|
|
subtitle: 'Forma de Escoamento Sanitário',
|
|
hintDropdown: 'Forma de Escoamento Sanitário',
|
|
select: selectFormSanitaryDrainage,
|
|
widthDropdown: width*0.7,
|
|
widthContainerDropdown: width*0.6,
|
|
onChanged: (value)=>setState(()=>selectFormSanitaryDrainage = value!)
|
|
),
|
|
SwitchWithSubtitle(
|
|
width: width*0.7,
|
|
title: 'Animais',
|
|
value: enableAnimals,
|
|
onChanged: (value)=>setState(()=>enableAnimals = value!),
|
|
),
|
|
SwitchWithSubtitle(
|
|
width: width*0.7,
|
|
title: 'Quais - Gato',
|
|
value: enableCats,
|
|
onChanged: (value)=>setState(()=>enableCats = value!),
|
|
),
|
|
SwitchWithSubtitle(
|
|
width: width*0.7,
|
|
title: 'Quais - Cachorro',
|
|
value: enableDogs,
|
|
onChanged: (value)=>setState(()=>enableDogs = value!),
|
|
),
|
|
SwitchWithSubtitle(
|
|
width: width*0.7,
|
|
title: 'Quais - Pássaro',
|
|
value: enableBirds,
|
|
onChanged: (value)=>setState(()=>enableBirds = value!),
|
|
),
|
|
SwitchWithSubtitle(
|
|
width: width*0.7,
|
|
title: 'Quais - Outros',
|
|
value: enableOther,
|
|
onChanged: (value)=>setState(()=>enableOther = value!),
|
|
),
|
|
InputWithSubtitle(
|
|
subtitle: 'Quantidade',
|
|
hintInput: 'Quantidade',
|
|
errorInput: 'Campo obrigatório',
|
|
labelInput: 'Quantidade',
|
|
widthSubtitle: width*0.4,
|
|
widthInput: width*0.7,
|
|
controller: controllerAmount,
|
|
onChanged: (v)=>setState((){}),
|
|
),
|
|
],
|
|
)
|
|
],
|
|
)
|
|
],
|
|
),
|
|
),
|
|
Card(
|
|
margin: EdgeInsets.all(10),
|
|
child: Column(
|
|
children: [
|
|
TitleContainers(title: 'Outros'),
|
|
Row(
|
|
children: [
|
|
Container(
|
|
height: heigth*0.4,
|
|
width: width*0.2,
|
|
child: Icon(Icons.business_center,size: 80,),
|
|
),
|
|
Padding(
|
|
padding: const EdgeInsets.symmetric(horizontal: 0.0),
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
InputWithSubtitle(
|
|
controller: responsibleRegisterController,
|
|
subtitle: 'Usuário responsável Pelo Cadastro',
|
|
errorInput: 'Campo Obrigatório',
|
|
labelInput: 'Usuário responsável Pelo Cadastro',
|
|
widthInput: width*0.7,
|
|
widthSubtitle: width*0.7,
|
|
hintInput: 'Escreva aqui',
|
|
onChanged: (v)=>setState((){}),
|
|
),
|
|
InputWithSubtitle(
|
|
controller: unitProfessionalController,
|
|
subtitle: 'Unidade do Profissional',
|
|
errorInput: 'Campo Obrigatório',
|
|
labelInput: 'Unidade do Profissional',
|
|
widthInput: width*0.7,
|
|
widthSubtitle: width*0.7,
|
|
hintInput: 'Escreva aqui',
|
|
onChanged: (v)=>setState((){}),
|
|
),
|
|
DropdownWithSubtitle(
|
|
subtitle: 'CBO',
|
|
select: selectCBO,
|
|
widthDropdown: width*0.673,
|
|
widthContainerDropdown: width*0.5,
|
|
widthSubtitle: width*0.3,
|
|
hintDropdown: 'CBO',
|
|
onChanged: (value){
|
|
setState(() {
|
|
selectCBO = value;
|
|
});
|
|
},
|
|
list: []
|
|
),
|
|
DropdownWithSubtitle(
|
|
subtitle: 'Código da Equipe',
|
|
select: selectCBO,
|
|
widthDropdown: width*0.672,
|
|
widthContainerDropdown: width*0.5,
|
|
widthSubtitle: width*0.3,
|
|
hintDropdown: 'Código da Equipe',
|
|
onChanged: (value){
|
|
setState(() {
|
|
selectCBO = value;
|
|
});
|
|
},
|
|
list: ['INE - 0001558536 / Área 4 - Microárea: - ']
|
|
),
|
|
InputWithSubtitle(
|
|
controller: dataRegisterController,
|
|
subtitle: 'Data do Cadastro',
|
|
errorInput: 'Campo Obrigatório',
|
|
labelInput: 'Data do Cadastro',
|
|
widthInput: width*0.7,
|
|
widthSubtitle: width*0.7,
|
|
hintInput: 'Escreva aqui',
|
|
enabled: false,
|
|
onChanged: (v)=>setState((){}),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
]
|
|
),
|
|
],
|
|
),
|
|
),
|
|
]
|
|
)
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|