From 632cdbfeeff56d94394805ba91b27022c4b5d76d Mon Sep 17 00:00:00 2001 From: Reginaldo Date: Thu, 13 Apr 2023 22:54:17 -0300 Subject: [PATCH] =?UTF-8?q?feito=20o=20cadastro=20do=20cidad=C3=A3o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- android/app/src/main/AndroidManifest.xml | 2 + lib/controllers/format_txt.dart | 9 + lib/controllers/main_controllers.dart | 144 ++ lib/models/args_load_init_model.dart | 17 - lib/screens/home_screen.dart | 27 +- lib/screens/load_init_screen.dart | 55 +- lib/screens/login/login_load_screen.dart | 87 +- lib/screens/login/login_saved_screen.dart | 76 +- lib/screens/login/sync_login_screen.dart | 74 +- .../main_register_citizen_screen.dart | 87 - .../register_citizen_screen.dart | 1765 +++++++++++------ .../register_home_screen.dart | 26 +- .../register_individual_screen.dart | 20 + .../select_service/service_home_screen.dart | 2 + .../service_individual_screen.dart | 8 + lib/screens/splash_screen.dart | 53 +- lib/screens/sync_init_screen.dart | 66 +- lib/service/api/api_data_load.dart | 72 +- lib/service/api/api_data_sync.dart | 42 +- lib/service/db/db_querys.dart | 36 + lib/service/db/db_sqlite_load.dart | 34 +- lib/service/db/db_sqlite_sync.dart | 206 +- .../shared_preferences_service.dart | 12 +- lib/utils/const_variable.dart | 4 + lib/utils/routes.dart | 2 +- lib/widgets/alert_dialog_search_stateful.dart | 120 ++ lib/widgets/appbar_default.dart | 7 +- lib/widgets/error_default.dart | 33 + lib/widgets/input_search_text.dart | 7 +- lib/widgets/input_text.dart | 14 +- lib/widgets/input_with_subtitle.dart | 12 +- lib/widgets/subtitle_appbar_citizen.dart | 57 + pubspec.lock | 7 + pubspec.yaml | 1 + 34 files changed, 2076 insertions(+), 1108 deletions(-) create mode 100644 lib/controllers/format_txt.dart create mode 100644 lib/controllers/main_controllers.dart delete mode 100644 lib/models/args_load_init_model.dart delete mode 100644 lib/screens/registers_citizen/main_register_citizen_screen.dart rename lib/screens/{ => registers_citizen}/register_home_screen.dart (96%) create mode 100644 lib/service/db/db_querys.dart create mode 100644 lib/widgets/alert_dialog_search_stateful.dart create mode 100644 lib/widgets/error_default.dart create mode 100644 lib/widgets/subtitle_appbar_citizen.dart diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 5e1c587..1a22d5b 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -1,6 +1,8 @@ + diff --git a/lib/controllers/format_txt.dart b/lib/controllers/format_txt.dart new file mode 100644 index 0000000..fb21e90 --- /dev/null +++ b/lib/controllers/format_txt.dart @@ -0,0 +1,9 @@ +import 'package:flutter/services.dart'; + +class FormatText extends TextInputFormatter{ + @override + TextEditingValue formatEditUpdate( + TextEditingValue txtOdl,TextEditingValue txtNew){ + return txtNew.copyWith(text: txtNew.text.toUpperCase()); + } +} \ No newline at end of file diff --git a/lib/controllers/main_controllers.dart b/lib/controllers/main_controllers.dart new file mode 100644 index 0000000..28afa0b --- /dev/null +++ b/lib/controllers/main_controllers.dart @@ -0,0 +1,144 @@ +import 'package:get/get.dart'; +import 'package:rkm/service/db/db_querys.dart'; + +class MainControllers{ + validaCNS(String cns)async{ + //valido provisório 783107557570002 + //cns valido def 187455333020009 + String response = 'CNS inválido'; + String type = cns.substring(0,1); + if(type == '7'|| type =='8' || type == '9'){ + response = await validaCNSProv(cns); + }else{ + response = validaCNSDef(cns); + } + return response; + } + validaCNSProv(String vlrCNS)async{ + int resto; + int soma; + if(vlrCNS.length == 15){ + // print('pis'); + // print(vlrCNS); + soma = ((int.parse(vlrCNS.substring( 0, 1))) * 15) + + ((int.parse(vlrCNS.substring( 1, 2))) * 14) + + ((int.parse(vlrCNS.substring( 2, 3))) * 13) + + ((int.parse(vlrCNS.substring( 3, 4))) * 12) + + ((int.parse(vlrCNS.substring( 4, 5))) * 11) + + ((int.parse(vlrCNS.substring( 5, 6))) * 10) + + ((int.parse(vlrCNS.substring( 6, 7))) * 9) + + ((int.parse(vlrCNS.substring( 7, 8))) * 8) + + ((int.parse(vlrCNS.substring( 8, 9))) * 7) + + ((int.parse(vlrCNS.substring( 9,10))) * 6) + + ((int.parse(vlrCNS.substring(10,11))) * 5) + + ((int.parse(vlrCNS.substring(11,12))) * 4) + + ((int.parse(vlrCNS.substring(12,13))) * 3) + + ((int.parse(vlrCNS.substring(13,14))) * 2) + + ((int.parse(vlrCNS.substring(14,15))) * 1); + + resto = soma % 11; + // print('soma'); + // print(soma); + // print('resto'); + // print(resto); + if (resto == 0) + { + // CNS provisório válido + List result = await DBQuerys().duplicidadeCNS(vlrCNS); + if(result.length==0){ + return 'ok'; + }else{ + return 'CNS duplicado'; + } + } + else + { + // CNS provisório inválido + return 'CNS provisório inválido'; + } + }else{ + if(vlrCNS.length< 15){ + return 'CNS inválido! Faltando números'; + }else{ + return 'CNS inválido! Sobrando números'; + } + } + } + validaCNSDef(String vlrCNS){ + int soma = 0; + int resto = 0; + int dv = 0; + String pis = ''; + String resultado = ''; + + if(vlrCNS.length == 15){ + pis = vlrCNS.substring(0,11); + soma = (int.parse(pis.substring(0,1)) * 15) + + ((int.parse(pis.substring(1,2))) * 14) + + ((int.parse(pis.substring(2,3))) * 13) + + ((int.parse(pis.substring(3,4))) * 12) + + ((int.parse(pis.substring(4,5))) * 11) + + ((int.parse(pis.substring(5,6))) * 10) + + ((int.parse(pis.substring(6,7))) * 9) + + ((int.parse(pis.substring(7,8))) * 8) + + ((int.parse(pis.substring(8,9))) * 7) + + ((int.parse(pis.substring(9,10))) * 6) + + ((int.parse(pis.substring(10,11))) * 5); + resto = soma % 11; + dv = 11 - resto; + if (dv == 11) { + dv = 0; + } + if (dv == 10) { + soma = (((int.parse(pis.substring(0,1))) * 15) + + ((int.parse(pis.substring(1,2))) * 14) + + ((int.parse(pis.substring(2,3))) * 13) + + ((int.parse(pis.substring(3,4))) * 12) + + ((int.parse(pis.substring(4,5))) * 11) + + ((int.parse(pis.substring(5,6))) * 10) + + ((int.parse(pis.substring(6,7))) * 9) + + ((int.parse(pis.substring(7,8))) * 8) + + ((int.parse(pis.substring(8,9))) * 7) + + ((int.parse(pis.substring(9,10))) * 6) + + ((int.parse(pis.substring(10,11))) * 5) + 2); + resto = soma % 11; + dv = 11 - resto; + resultado = pis + "001" + dv.toString(); + } else { + resultado = pis + "000" + dv.toString(); + } + if (vlrCNS != resultado) { + // CNS inválido + return 'CNS definitivo inválido'; + } else { + // CNS válido + String result = DBQuerys().duplicidadeCNS(vlrCNS); + if(result==''){ + return 'ok'; + }else{ + return 'CNS duplicado"'; + } + } + }else{ + if(vlrCNS.length< 15){ + return 'CNS inválido! Faltando números'; + }else{ + return 'CNS inválido! Sobrando números'; + } + } + } + validaCPF(String cpf)async{ + // 60352523620 CPF VÁLIDO + if(GetUtils.isCpf(cpf)){ + List result = await DBQuerys().duplicidadeCPF(cpf); + print(cpf); + if(result.length==0){ + return 'ok'; + }else{ + return 'CPF duplicado'; + } + }else{ + return 'CPF inválido'; + } + } +} \ No newline at end of file diff --git a/lib/models/args_load_init_model.dart b/lib/models/args_load_init_model.dart deleted file mode 100644 index 6c49c14..0000000 --- a/lib/models/args_load_init_model.dart +++ /dev/null @@ -1,17 +0,0 @@ -import 'city_load_model.dart'; - -class ArgsLoadInitModel{ - String mode; - CityLoadModel model; - String user; - String password; - String urlAPI; - - ArgsLoadInitModel({ - required this.mode, - required this.model, - required this.user, - required this.password, - required this.urlAPI, - }); -} \ No newline at end of file diff --git a/lib/screens/home_screen.dart b/lib/screens/home_screen.dart index bd61f1d..9a3da61 100644 --- a/lib/screens/home_screen.dart +++ b/lib/screens/home_screen.dart @@ -1,12 +1,12 @@ import 'package:flutter/material.dart'; import 'package:line_icons/line_icons.dart'; +import 'package:rkm/screens/registers_citizen/register_citizen_screen.dart'; import 'package:rkm/utils/const_variable.dart'; import 'package:rkm/widgets/icon_button_default.dart'; import 'package:rkm/widgets/input_search_text.dart'; import '../service/db/db_sqlite_load.dart'; import '../widgets/appbar_default.dart'; import '../widgets/item_citizen.dart'; -import 'registers_citizen/main_register_citizen_screen.dart'; class HomeScreen extends StatefulWidget { const HomeScreen({Key? key}) : super(key: key); @@ -24,6 +24,7 @@ class _HomeScreenState extends State { loadCitizen()async{ await DbSqliteLoad().intialDB().then((db)async { dataCitizen = await db.query('CIDADAOS ORDER BY NOME_CIDADAO'); + // print(await db.rawQuery("SELECT * FROM CIDADAOS WHERE NOME_PAI='REGINALDO OLIVEIRA'")); }); searchCitizen(); return 'complete'; @@ -34,24 +35,25 @@ class _HomeScreenState extends State { showResults =[]; for (int i =0;dataCitizen.length>i;i++) { String NOME_CIDADAO = '${dataCitizen[i]['NOME_CIDADAO']}'; - String CNS = '${dataCitizen[i]['CNS']}'; - String NUM_PRONTUARIO = '${dataCitizen[i]['NUM_PRONTUARIO']}'; + String CNS = '${dataCitizen[i]['CNS']}'==''?'999999':'${dataCitizen[i]['CNS']}'; + String NUM_PRONTUARIO = '${dataCitizen[i]['NUM_PRONTUARIO']}'==''?'null':'${dataCitizen[i]['NUM_PRONTUARIO']}'; List splitted = '${dataCitizen[i]['DT_NASCIMENTO']}'.split('-'); - String DT_NASCIMENTO = '${splitted[2]}/${splitted[1]}/${splitted[0]}'; + String DT_NASCIMENTO = '00/00/0000'; + if( splitted.length==3){ + DT_NASCIMENTO = '${splitted[2]}/${splitted[1]}/${splitted[0]}'; + } if( NOME_CIDADAO.contains(inputSearch.text.toUpperCase()) || NUM_PRONTUARIO.contains(inputSearch.text.toUpperCase()) || DT_NASCIMENTO.contains(inputSearch.text.toUpperCase()) || CNS.contains(inputSearch.text.toUpperCase()) ){ - print('ok $i'); if(showResults.length<10){ showResults.add(dataCitizen[i]); } } } setState(() { - print(showResults); }); }else{ setState(() { @@ -71,6 +73,7 @@ class _HomeScreenState extends State { super.initState(); loadCitizen(); inputSearch.addListener(_searchInit); + } @override void dispose() { @@ -103,7 +106,7 @@ class _HomeScreenState extends State { icon: Icons.person_add, onPressed: ()=> Navigator.push( context, - MaterialPageRoute(builder: (context) => MainRegisterCitizenScreen(screens: 1,)), + MaterialPageRoute(builder: (context) => RegisterCitizenScreen(select: '')), ) ), IconButtonDefault( @@ -124,16 +127,20 @@ class _HomeScreenState extends State { itemBuilder: (context,index){ List splitted = '${showResults[index]['DT_NASCIMENTO']}'.split('-'); + String date='00/00/0000'; + if(splitted.length==3){ + date = '${splitted[2]}/${splitted[1]}/${splitted[0]}'; + } return ItemCitizen( - date: '${splitted[2]}/${splitted[1]}/${splitted[0]}', + date: date, name: '${showResults[index]['NOME_CIDADAO']}', mother:'${showResults[index]['NOME_MAE']}', - numberCNS: '${showResults[index]['CNS']}'=='null'?'999999999999999':'${showResults[index]['CNS']}', + numberCNS: '${showResults[index]['CNS']}'=='null'||'${showResults[index]['CNS']}'==''?'999999999999999':'${showResults[index]['CNS']}', numberMedicalRecord: '${showResults[index]['NUM_PRONTUARIO']}', onTap: ()=> Navigator.push( context, - MaterialPageRoute(builder: (context) => MainRegisterCitizenScreen(screens: 3,)), + MaterialPageRoute(builder: (context) => RegisterCitizenScreen(select: '')), ), ); } diff --git a/lib/screens/load_init_screen.dart b/lib/screens/load_init_screen.dart index c47cf3c..503b382 100644 --- a/lib/screens/load_init_screen.dart +++ b/lib/screens/load_init_screen.dart @@ -4,17 +4,11 @@ import 'package:rkm/utils/color_palette.dart'; import 'package:rkm/widgets/alert_dialog_default.dart'; import 'package:rkm/widgets/button_default.dart'; import 'package:rkm/widgets/text_default.dart'; -import '../models/args_load_init_model.dart'; import '../service/api/api_data_load.dart'; import '../service/db/db_sqlite_load.dart'; import '../service/shared_preferences/shared_preferences_service.dart'; class LoadInitScreen extends StatefulWidget { - ArgsLoadInitModel args; - - LoadInitScreen({ - required this.args, -}); @override State createState() => _LoadInitScreenState(); @@ -26,81 +20,97 @@ class _LoadInitScreenState extends State { String messageSteps = 'Aguarde ...'; bool finish = false; String idUsuario = ''; - + String mode = ''; + String urlAPI = ''; + bool loading = false; + String nameCityApi = ''; + String user = ''; @override void initState() { super.initState(); - initLoading(); + recupDB(); + } + + recupDB()async{ + await DbSqliteLoad().intialDB().then((db)async{ + List list = await db.query('ARGS'); + urlAPI = list[0]['URLAPI']; + mode = list[0]['MODE']; + nameCityApi = list[0]['NAME_CITY_API']; + user = list[0]['USER']; + if(urlAPI!=''){ + initLoading(); + } + }); } initLoading()async{ - await DbSqliteLoad().deleteLoad().then((_)async{ - await ApiDataLoad().loadPerm(widget.args).then((response)async{ + await ApiDataLoad().loadPerm(urlAPI,mode,nameCityApi,user).then((response)async{ if(response['status'] == 0){ AlertDialogDefault().alert(context, 'Erro', 'Permissão negada', 'Voltar'); } else if(response['status'] == 1 && response['load_perm'] == "S") { idUsuario = response['idUsuario'].toString(); print('idUsuario $idUsuario'); _prefService.createCacheidUsuario(idUsuario).then((value)async{ - await ApiDataLoad().loadUnidades(widget.args).then((value)async{ + await ApiDataLoad().loadUnidades(urlAPI,mode,nameCityApi,user).then((value)async{ if(value.length !=0){ setState(() { messageSteps = "Etapa 1 de 7 - Gravando as Unidades no Aplicativo"; }); await DbSqliteLoad().saveUnidadesDB(value).then((value)async{ - await ApiDataLoad().loadProcedimentos(widget.args).then((value)async{ + await ApiDataLoad().loadProcedimentos(urlAPI,mode,nameCityApi,user).then((value)async{ setState(() { messageSteps = "Etapa 2 de 7 - Gravando os Procedimentos no Aplicativo"; }); await DbSqliteLoad().saveProceduresDB(value).then((value)async{ print('finalizou save Procedures'); - await ApiDataLoad().loadProcedimentosRegistros(widget.args).then((value)async{ + await ApiDataLoad().loadProcedimentosRegistros(urlAPI,mode,nameCityApi,user).then((value)async{ await DbSqliteLoad().saveProceduresRegisterDB(value).then((value)async{ print('finalizou saveProceduresRegisterDB'); - await ApiDataLoad().loadCID(widget.args).then((value)async{ + await ApiDataLoad().loadCID(urlAPI,mode,nameCityApi,user).then((value)async{ print('loadCID'); setState(() { messageSteps = "Etapa 3 de 7 - Gravando os CIDs no Aplicativo"; }); await DbSqliteLoad().saveCID(value).then((value)async{ print('finalizou saveCID'); - await ApiDataLoad().loadProcedimentosCID(widget.args).then((value)async{ + await ApiDataLoad().loadProcedimentosCID(urlAPI,mode,nameCityApi,user).then((value)async{ print('loadProcedimentosCID'); await DbSqliteLoad().saveProceduresCID(value).then((value)async{ print('finalizou saveProceduresCID'); - await ApiDataLoad().loadCBO(widget.args).then((value)async{ + await ApiDataLoad().loadCBO(urlAPI,mode,nameCityApi,user).then((value)async{ print('loadCBO'); setState(() { messageSteps = "Etapa 4 de 7 - Gravando os CBOs no Aplicativo"; }); await DbSqliteLoad().saveCBO(value).then((value)async{ print('finalizou saveCBO'); - await ApiDataLoad().loadProcedimentosCBO(widget.args).then((value)async{ + await ApiDataLoad().loadProcedimentosCBO(urlAPI,mode,nameCityApi,user).then((value)async{ print('loadProcedimentosCBO'); await DbSqliteLoad().saveProceduresCBO(value).then((value)async{ print('finalizou saveProceduresCBO'); - await ApiDataLoad().loadCIAP(widget.args).then((value)async{ + await ApiDataLoad().loadCIAP(urlAPI,mode,nameCityApi,user).then((value)async{ print('loadCIAP'); setState(() { messageSteps = "Etapa 5 de 7 - Gravando os CIAPs no Aplicativo"; }); await DbSqliteLoad().saveCIAP(value).then((value)async{ print('finalizou saveCIAP'); - await ApiDataLoad().loadMunicipios(widget.args).then((value)async{ + await ApiDataLoad().loadMunicipios(urlAPI,mode,nameCityApi,user).then((value)async{ print('loadMunicipios'); setState(() { messageSteps = "Etapa 6 de 7 - Gravando os Municípios no Aplicativo"; }); await DbSqliteLoad().saveCity(value).then((value)async{ print('finalizou saveCity'); - await ApiDataLoad().loadEquipes(widget.args).then((value)async{ + await ApiDataLoad().loadEquipes(urlAPI,mode,nameCityApi,user).then((value)async{ print('loadEquipes'); setState(() { messageSteps = "Etapa 7 de 7 - Gravando as Equipes no Aplicativo"; }); await DbSqliteLoad().saveTeam(value).then((value)async{ print('finalizou saveTeam'); - await ApiDataLoad().loadEquipeComponentes(widget.args).then((value)async{ + await ApiDataLoad().loadEquipeComponentes(urlAPI,mode,nameCityApi,user).then((value)async{ print('loadEquipeComponentes'); await DbSqliteLoad().saveTeamComponents(value).then((value)async{ print('finalizou saveTeamComponents'); @@ -135,7 +145,6 @@ class _LoadInitScreenState extends State { }); } }); - }); } @override @@ -157,7 +166,7 @@ class _LoadInitScreenState extends State { onPressed: (){ Navigator.pushReplacement( context, - MaterialPageRoute(builder: (context) => SyncLoginScreen(args: widget.args)), + MaterialPageRoute(builder: (context) => SyncLoginScreen()), ); }, title: 'Continuar', diff --git a/lib/screens/login/login_load_screen.dart b/lib/screens/login/login_load_screen.dart index 3a4a469..814329c 100644 --- a/lib/screens/login/login_load_screen.dart +++ b/lib/screens/login/login_load_screen.dart @@ -1,5 +1,4 @@ import 'package:flutter/material.dart'; -import 'package:rkm/models/args_load_init_model.dart'; import 'package:rkm/service/api/url_api_const.dart'; import 'package:rkm/utils/color_palette.dart'; import 'package:rkm/utils/const_variable.dart'; @@ -7,9 +6,9 @@ import 'package:rkm/widgets/button_default.dart'; import 'package:rkm/widgets/dropdown_button_city.dart'; import 'package:rkm/widgets/input_text.dart'; import 'package:rkm/widgets/text_default.dart'; -import '../../models/city_load_model.dart'; import '../../service/api/api_data_load.dart'; import '../../service/api/encrypt_password.dart'; +import '../../service/db/db_sqlite_load.dart'; import '../../service/shared_preferences/shared_preferences_service.dart'; import '../load_init_screen.dart'; class LoginLoadScreen extends StatefulWidget { @@ -28,13 +27,17 @@ class _LoginLoadScreenState extends State { String? selectCity; bool validatorDropDown= false; int contLogo = 0; - String mode = 'desenvolvimento'; - String urlAPI = UrlApiConst.ApiUrlDesenvolvimento; + String mode = 'homologacao'; + String urlAPI = UrlApiConst.ApiUrlHomologacao; bool loading = false; + String nameCityApi = ''; + String nameCityFront = ''; + String codState = ''; + int codCity = 0; + int codCityIbge = 0; + final PrefService _prefService = PrefService(); checkLogin()async{ - CityLoadModel? model; - ArgsLoadInitModel? args; if(inputUser.text.isNotEmpty && inputPassword.text.isNotEmpty && inputUser.text.length>3 && inputPassword.text.length>3){ if(selectCity!=null){ _prefService.createCacheModel(inputUser.text,inputPassword.text,selectCity!,mode); @@ -43,30 +46,34 @@ class _LoginLoadScreenState extends State { loading = true; for(int i=0;ConstVariable().itensCity.length > i;i++){ if(ConstVariable().itensCity[i].nameCityFront == selectCity!){ - model = ConstVariable().itensCity[i]; + nameCityApi = ConstVariable().itensCity[i].nameCityApi; + nameCityFront = ConstVariable().itensCity[i].nameCityFront; + codCityIbge = ConstVariable().itensCity[i].codCityIbge; + codCity = ConstVariable().itensCity[i].codCity; + codState = ConstVariable().itensCity[i].codState; } } }); - if(model!=null){ - args = ArgsLoadInitModel( - mode: mode, - model:model!, - user: inputUser.text, - password: inputPassword.text, - urlAPI: urlAPI - ); - } - if(args!=null){ - await ApiDataLoad().apiConect(args!).then((response) async { - if(inputUser.text == inputPassword.text || response['bloqueio']==1){ + await ApiDataLoad().apiConect(urlAPI,mode,nameCityApi,inputUser.text).then((response) async { + print("erre : "+response.toString()); + if(response == 'Erro' || response.toString() == 'Error: -902 - I/O error during "open" operation for file "/bases/conectasus/extrema/SISTEMA.FDB" Error while trying to open file No such file or directory'){ setState(() { - error = 'Usuário bloqueado/senha incorreta'; + loading = false; + error = 'Erro na conexão!Verifique sua internet\n ou a cidade que está selecionada!'; + }); + }else if(inputUser.text == inputPassword.text || response['bloqueio']==1){ + setState(() { + loading = false; + error = 'Usuário bloqueado/usuário e/ou senha incorreta'; }); }else if(response['status']==0) { setState(() { + loading = false; error = 'Usuário não encontrado'; }); }else if(response['status']==1) { + print('aqui 1'); + print(response); setState((){ error = ''; }); @@ -76,14 +83,37 @@ class _LoginLoadScreenState extends State { setState(() { loading = false; }); - Navigator.push( - context, - MaterialPageRoute(builder: (context) => LoadInitScreen(args: args!)), - ); + await DbSqliteLoad().deleteLoad().then((_)async { + DbSqliteLoad().saveArgs( + mode, + inputUser.text, + inputPassword.text, + urlAPI, + codCity, + nameCityApi, + nameCityFront, + codState, + codCityIbge).then((value) { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => LoadInitScreen()), + ); + }); + }); + }else{ + setState(() { + loading = false; + error = 'Usuário bloqueado/senha incorreta'; + }); } + }else{ + setState(() { + loading = false; + error = 'Falha de conexão com API'; + }); } }); - } }else{ setState(() { error = 'Selecione sua cidade'; @@ -158,7 +188,6 @@ class _LoginLoadScreenState extends State { InputText( hint: 'Usuário', label: inputUser.text.isNotEmpty?'':'Usuário', - error: 'Campo obrigatório', controller: inputUser, width: width*0.6, colorBorder: Colors.white, @@ -167,7 +196,6 @@ class _LoginLoadScreenState extends State { InputText( hint: 'Senha', label: inputPassword.text.isNotEmpty?'':'Senha', - error: 'Campo obrigatório', obscure: true, controller: inputPassword, width: width*0.6, @@ -195,7 +223,10 @@ class _LoginLoadScreenState extends State { width: width*0.6, ), SizedBox(height: 10), - TextDefault(text: error,color: ColorPalette.red), + Padding( + padding: const EdgeInsets.symmetric(horizontal: 20.0), + child: TextDefault(text: error,color: ColorPalette.red,maxLines: 3), + ), ], ), ), diff --git a/lib/screens/login/login_saved_screen.dart b/lib/screens/login/login_saved_screen.dart index 8de0068..a9ddecc 100644 --- a/lib/screens/login/login_saved_screen.dart +++ b/lib/screens/login/login_saved_screen.dart @@ -1,29 +1,20 @@ -import 'dart:convert'; import 'package:flutter/material.dart'; import 'package:intl/intl.dart'; -import 'package:rkm/models/args_load_init_model.dart'; import 'package:rkm/screens/home_screen.dart'; import 'package:rkm/screens/login/sync_login_screen.dart'; -import 'package:rkm/service/api/url_api_const.dart'; -import 'package:rkm/service/db/db_sqlite_load.dart'; import 'package:rkm/utils/color_palette.dart'; import 'package:rkm/utils/const_variable.dart'; import 'package:rkm/widgets/button_default.dart'; -import 'package:rkm/widgets/dropdown_button_city.dart'; import 'package:rkm/widgets/input_text.dart'; import 'package:rkm/widgets/text_default.dart'; -import 'package:sqflite/sqflite.dart'; -import '../../models/city_load_model.dart'; import '../../service/api/api_data_load.dart'; import '../../service/api/encrypt_password.dart'; -import '../load_init_screen.dart'; +import '../../service/db/db_sqlite_load.dart'; class LoginSavedScreen extends StatefulWidget { List listControl; - ArgsLoadInitModel args; LoginSavedScreen({ required this.listControl, - required this.args }); @override @@ -39,23 +30,37 @@ class _LoginSavedScreenState extends State { bool validatorDropDown= false; int contLogo = 0; bool loading = false; + String urlAPI=''; + String mode = ''; + String nameCityApi = ''; + String nameCityFront = ''; + int codCity = 0; + int codCityIbge = 0; + String codState = ''; + + recupDB()async{ + await DbSqliteLoad().intialDB().then((db)async{ + List list = await db.query('ARGS'); + urlAPI = list[0]['URLAPI']; + mode = list[0]['MODE']; + nameCityApi = list[0]['NAME_CITY_API']; + nameCityFront = list[0]['NAME_CITY_FRONT']; + inputUser.text = list[0]['USER']; + inputPassword.text = list[0]['PASSWORD']; + codCity = list[0]['COD_CITY']; + codState = list[0]['COD_STATE']; + codCityIbge = list[0]['COD_IBGE']; + }); + setState(() {}); + } checkLogin()async{ - ArgsLoadInitModel? args; if(inputUser.text.isNotEmpty && inputPassword.text.isNotEmpty && inputUser.text.length>3 && inputPassword.text.length>3){ setState(() { error = ''; loading = true; }); - args = ArgsLoadInitModel( - mode: widget.args.mode, - model:widget.args.model, - user: inputUser.text, - password: inputPassword.text, - urlAPI: widget.args.urlAPI - ); - if(args!=null){ - await ApiDataLoad().apiConect(args!).then((response) async { + await ApiDataLoad().apiConect(urlAPI,mode,nameCityApi,inputUser.text).then((response) async { if(inputUser.text == inputPassword.text || response['bloqueio']==1){ setState(() { error = 'Usuário bloqueado/senha incorreta'; @@ -71,17 +76,18 @@ class _LoginSavedScreenState extends State { //verificar se a criptografia identificou se a senha está correta if(EncryptPassword().encrypt(inputPassword.text,response['userPass']) == response['userPass']){ // print(EncryptPassword().encrypt(inputPassword.text,response['userPass'])); - setState(() { - loading = false; + DbSqliteLoad().updateArgs(mode, inputUser.text, inputPassword.text).then((value){ + setState(() { + loading = false; + }); + Navigator.push( + context, + MaterialPageRoute(builder: (context) => HomeScreen()), + ); }); - Navigator.push( - context, - MaterialPageRoute(builder: (context) => HomeScreen()), - ); } } }); - } }else{ setState(() { error = 'Usuário/senha inválido(s)'; @@ -89,6 +95,12 @@ class _LoginSavedScreenState extends State { } } + @override + void initState() { + super.initState(); + recupDB(); + } + @override Widget build(BuildContext context) { @@ -108,7 +120,7 @@ class _LoginSavedScreenState extends State { onPressed: (){ Navigator.push( context, - MaterialPageRoute(builder: (context) => SyncLoginScreen(args: widget.args)), + MaterialPageRoute(builder: (context) => SyncLoginScreen()), ); } ) @@ -125,8 +137,8 @@ class _LoginSavedScreenState extends State { mainAxisAlignment: MainAxisAlignment.start, children: [ Image.asset('assets/images/logo.PNG',width: width*0.4), - widget.args.mode == 'homologacao'?Image.asset('assets/images/homologacao.png',width: width*0.4):Container(), - widget.args.mode == 'desenvolvimento'?Image.asset('assets/images/desenvolvimento.png',width: width*0.4):Container(), + mode == 'homologacao'?Image.asset('assets/images/homologacao.png',width: width*0.4):Container(), + mode == 'desenvolvimento'?Image.asset('assets/images/desenvolvimento.png',width: width*0.4):Container(), SizedBox(height: 10), loading?Center( child: Column( @@ -147,7 +159,6 @@ class _LoginSavedScreenState extends State { InputText( hint: 'Usuário', label: inputUser.text.isNotEmpty?'':'Usuário', - error: 'Campo obrigatório', controller: inputUser, width: width*0.6, colorBorder: Colors.white, @@ -156,7 +167,6 @@ class _LoginSavedScreenState extends State { InputText( hint: 'Senha', label: inputPassword.text.isNotEmpty?'':'Senha', - error: 'Campo obrigatório', obscure: true, controller: inputPassword, width: width*0.6, @@ -210,7 +220,7 @@ class _LoginSavedScreenState extends State { padding: EdgeInsets.symmetric(vertical: 5), width: width*0.6, child: TextDefault( - text: 'Área: '+widget.listControl[0]['AREA'].toString(), + text: 'Área: '+widget.listControl[0]['AREA'].toString()+' - Microárea: '+widget.listControl[0]['MICROAREA'].toString(), fontWeigth: FontWeight.bold, color: Colors.black, textAlign: TextAlign.center, diff --git a/lib/screens/login/sync_login_screen.dart b/lib/screens/login/sync_login_screen.dart index 340d633..1a964bd 100644 --- a/lib/screens/login/sync_login_screen.dart +++ b/lib/screens/login/sync_login_screen.dart @@ -1,28 +1,17 @@ import 'package:flutter/material.dart'; -import 'package:intl/intl.dart'; -import 'package:rkm/models/args_load_init_model.dart'; import 'package:rkm/screens/sync_init_screen.dart'; -import 'package:rkm/service/api/url_api_const.dart'; import 'package:rkm/utils/color_palette.dart'; import 'package:rkm/utils/const_variable.dart'; import 'package:rkm/widgets/button_default.dart'; -import 'package:rkm/widgets/dropdown_button_city.dart'; import 'package:rkm/widgets/dropdown_button_default.dart'; import 'package:rkm/widgets/input_text.dart'; import 'package:rkm/widgets/text_default.dart'; import 'package:sqflite/sqflite.dart'; -import '../../models/city_load_model.dart'; import '../../service/api/api_data_load.dart'; import '../../service/api/encrypt_password.dart'; import '../../service/db/db_sqlite_load.dart'; import '../../service/shared_preferences/shared_preferences_service.dart'; -import '../load_init_screen.dart'; class SyncLoginScreen extends StatefulWidget { - ArgsLoadInitModel args; - - SyncLoginScreen({ - required this.args -}); @override State createState() => _SyncLoginScreenState(); @@ -39,17 +28,30 @@ class _SyncLoginScreenState extends State { bool validatorDropDown= false; bool citizenOutArea = false; int contLogo = 0; - String mode = 'desenvolvimento'; - String urlAPI = UrlApiConst.ApiUrlDesenvolvimento; + String mode = ''; + String urlAPI = ''; + String nameCityApi = ''; bool loading = false; List listUnit=[]; List searchUnitCodList=[]; List listTeam = []; String idUnidade =''; - String idUsuario =''; + String idUsuario ='1'; final PrefService _prefService = PrefService(); + recupDB()async{ + await DbSqliteLoad().intialDB().then((db)async{ + List list = await db.query('ARGS'); + urlAPI = list[0]['URLAPI']; + mode = list[0]['MODE']; + nameCityApi = list[0]['NAME_CITY_API']; + inputUser.text = list[0]['USER']; + inputPassword.text = list[0]['PASSWORD']; + }); + setState(() {}); + } + checkLogin()async{ if(inputUser.text.isNotEmpty && inputPassword.text.isNotEmpty && inputUser.text.length>3 && inputPassword.text.length>3){ if(selectUnit!=null){ @@ -58,7 +60,7 @@ class _SyncLoginScreenState extends State { loading = true; }); - await ApiDataLoad().apiConect(widget.args!).then((response) async { + await ApiDataLoad().apiConect(urlAPI,mode,nameCityApi,inputUser.text).then((response) async { if(inputUser.text == inputPassword.text || response['bloqueio']==1){ setState(() { error = 'Usuário bloqueado/senha incorreta'; @@ -75,18 +77,13 @@ class _SyncLoginScreenState extends State { setState(() { loading = false; }); - ArgsLoadInitModel?args = ArgsLoadInitModel( - mode: mode, - model:widget.args.model, - user: inputUser.text, - password: inputPassword.text, - urlAPI: urlAPI - ); _prefService.createCacheSync(selectTeam!, citizenOutArea).then((value){ - Navigator.push( - context, - MaterialPageRoute(builder: (context) => SyncInitScreen(args: args)), - ); + DbSqliteLoad().updateArgs(mode, inputUser.text, inputPassword.text).then((value) { + Navigator.push( + context, + MaterialPageRoute(builder: (context) => SyncInitScreen()), + ); + }); }); } } @@ -106,13 +103,9 @@ class _SyncLoginScreenState extends State { @override void initState() { super.initState(); - setState(() { - mode = widget.args.mode; - inputUser.text = widget.args.user; - inputPassword.text = widget.args.password; - }); + recupDB(); getUnit(); - getUser(); + // getUser(); } getUser(){ _prefService.readCacheIdUsuario('idUsuario').then((value){ @@ -136,24 +129,28 @@ class _SyncLoginScreenState extends State { } getTeam()async{ + Database db = await DbSqliteLoad().intialDB(); for(int i=0; listUnit.length > i;i++){ if(listUnit[i] == selectUnit){ idUnidade = searchUnitCodList[i].toString(); - _prefService.createCacheidUnidade(idUnidade); + _prefService.createCacheUnidade(idUnidade,selectUnit!); } } if(idUnidade!=''){ - Database db = await DbSqliteLoad().intialDB(); + print('idUnidade'); + print(idUnidade); + print('idUsuario'); + print(idUsuario); var query = "SELECT * FROM EQUIPES JOIN PROFISSIONAIS_EQUIPE ON PROFISSIONAIS_EQUIPE.ID_EQUIPE = EQUIPES.ID_EQUIPE WHERE ID_UNIDADE = $idUnidade AND ID_PROFISSIONAL = $idUsuario"; List list = await db.rawQuery(query); listTeam.clear(); for(int i=0; list.length > i;i++){ listTeam.add('INE: ${list[i]['INE']} / Área: ${list[i]['AREA']} - Microárea : ${list[i]['MICROAREA']}'); } - // print('getEquipes'); - // print(listTeam); setState(() {}); } + print('listTeam'); + print(listTeam); } @override @@ -200,7 +197,6 @@ class _SyncLoginScreenState extends State { InputText( hint: 'Usuário', label: inputUser.text.isNotEmpty?'':'Usuário', - error: 'Campo obrigatório', controller: inputUser, width: width*0.6, colorBorder: Colors.white, @@ -209,7 +205,6 @@ class _SyncLoginScreenState extends State { InputText( hint: 'Senha', label: inputPassword.text.isNotEmpty?'':'Senha', - error: 'Campo obrigatório', obscure: true, controller: inputPassword, width: width*0.6, @@ -266,7 +261,8 @@ class _SyncLoginScreenState extends State { padding: EdgeInsets.symmetric(vertical: 5), width: width*0.6, child: TextDefault( - text: 'Cidade Sincronizada: ${widget.args.model.nameCityFront!=''?widget.args.model.nameCityFront:''}', + text: '', + // text: 'Cidade Sincronizada: ${widget.args!.model.nameCityFront!=''?widget.args!.model.nameCityFront:''}', fontWeigth: FontWeight.bold, fontSize: 18, color: Colors.black, diff --git a/lib/screens/registers_citizen/main_register_citizen_screen.dart b/lib/screens/registers_citizen/main_register_citizen_screen.dart deleted file mode 100644 index 5baeaeb..0000000 --- a/lib/screens/registers_citizen/main_register_citizen_screen.dart +++ /dev/null @@ -1,87 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:rkm/screens/registers_citizen/register_citizen_screen.dart'; -import 'package:rkm/screens/register_home_screen.dart'; -import 'package:rkm/screens/registers_citizen/register_individual_screen.dart'; -import 'package:rkm/utils/color_palette.dart'; -import 'package:rkm/widgets/text_default.dart'; -import '../../widgets/alert_dialog_settings.dart'; -import '../../widgets/icon_button_default.dart'; - -class MainRegisterCitizenScreen extends StatefulWidget { - int screens; - MainRegisterCitizenScreen({ - required this.screens -}); - - @override - State createState() => _MainRegisterCitizenScreenState(); -} - -class _MainRegisterCitizenScreenState extends State { - - int index = 1; - - TabBar get _tabBar => TabBar( - labelColor: index==1?ColorPalette.gray:ColorPalette.blackButton, - unselectedLabelColor: ColorPalette.gray, - indicatorColor: ColorPalette.white, - tabs: [ - Tab(text: 'Cadastro Cidadão',icon: Icon(Icons.person),iconMargin: EdgeInsets.zero,height: 50,), - Tab(text: 'Cadastro Individual',icon: Icon(Icons.article),iconMargin: EdgeInsets.zero,height: 40,), - Tab(text: 'Cadastro Domiciliar',icon: Icon(Icons.home),iconMargin: EdgeInsets.zero,height: 40,) - ], - ); - - updateIndex(){ - setState(() { - index = widget.screens; - }); - } - - @override - void initState() { - super.initState(); - updateIndex(); - } - - @override - Widget build(BuildContext context) =>DefaultTabController( - length: index, - child: Scaffold( - appBar: AppBar( - title: TextDefault(text: 'RKM AB - Cadastro Cidadão',color: ColorPalette.white,), - centerTitle: true, - actions: [ - IconButtonDefault( - icon: Icons.settings, - color: ColorPalette.white, - onPressed: ()=>AlertDialogSettings().alert(context) - ), - IconButtonDefault( - icon: Icons.logout, - color: ColorPalette.white, - onPressed: ()=>Navigator.pushNamedAndRemoveUntil(context, '/login',(Route route) => false)), - ], - bottom: PreferredSize( - preferredSize: _tabBar.preferredSize, - child: Material( - color: ColorPalette.white, //<-- SEE HERE - child: _tabBar, - ), - ), - ), - body:index==1 ? - TabBarView( - children: [ - RegisterCitizenScreen(), - ], - ):TabBarView( - children: [ - RegisterCitizenScreen(), - RegisterIndividualScreen(), - RegisterHomeScreen(), - ], - ), - ) - ); -} diff --git a/lib/screens/registers_citizen/register_citizen_screen.dart b/lib/screens/registers_citizen/register_citizen_screen.dart index 6900717..9aa9143 100644 --- a/lib/screens/registers_citizen/register_citizen_screen.dart +++ b/lib/screens/registers_citizen/register_citizen_screen.dart @@ -5,13 +5,25 @@ import 'package:rkm/utils/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/alert_dialog_search_stateful.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 { - const RegisterCitizenScreen({Key? key}) : super(key: key); + String select; + + RegisterCitizenScreen({required this.select}); @override State createState() => _RegisterCitizenScreenState(); @@ -29,7 +41,7 @@ class _RegisterCitizenScreenState extends State { var nameMotherController = TextEditingController(); var nameFatherController = TextEditingController(); var codIBGEController = TextEditingController(); - var unitController = TextEditingController(text: 'USF PINHAL - EMILIA STEPHANI SIMIONATO'); + var unitController = TextEditingController(); var medicalRecordController = TextEditingController(); var medicalRecordProvController = TextEditingController(); var classificationProvController = TextEditingController(); @@ -52,21 +64,22 @@ class _RegisterCitizenScreenState extends State { var RGController = TextEditingController(); var RGComplementController = TextEditingController(); var RGOrganController = TextEditingController(); - var RGDateController = 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(); + 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(); - + var dateDeathController = TextEditingController(text: 'Data Óbito'); + String checkCNS = ''; + String checkCPF = ''; String? selectTypeCertificate; String? selectCTPSUF; String? selectRGUF; @@ -90,16 +103,39 @@ class _RegisterCitizenScreenState extends State { bool enableBlocked = false; bool checkBoxNumber = false; String date = 'Data de Nascimento'; + 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; - escolherprazoInicio(BuildContext context) async { + escolherprazoInicio(BuildContext context,String type) async { var pickDate = await showDatePicker( context: context, initialDate: DateTime.now(), - firstDate: DateTime(2022), - lastDate: DateTime(2025)); + firstDate: DateTime(1900), + lastDate: DateTime(2024)); if (pickDate != null) { setState(() { - date = formatData(year: pickDate.year, month: pickDate.month, day: pickDate.day); + if(type == 'birth'){ + 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); + } }); } } @@ -110,21 +146,262 @@ class _RegisterCitizenScreenState extends State { 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(){ + if(nameController.text.isEmpty){ + setState(() { + showCheckError = true; + }); + }else{ + showCheckError = false; + saveCitizen(); + } + } + + saveCitizen()async{ + Map row = { + 'CD_USUARIO_SUS' : '0', + 'NOME_CIDADAO' : nameController.text, + 'NOME_SOCIAL' : nameSocialController.text, + 'SEXO' : selectGender, + 'DT_NASCIMENTO' : date, + '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' : CNSController.text, + '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){ + print('sucesso'); + 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 heigth = MediaQuery.of(context).size.height; + 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: true), + showCheckError?Card( + margin: EdgeInsets.all(10), + child: Container( + padding: EdgeInsets.all(10), + child: Row( + children: [ + Icon(Icons.warning,color: Colors.red,), + TextDefault(text: 'Existem campos obrigatórios não preenchidos.',color: ColorPalette.red,fontSize: 15,) + ], + ), + ), + color: ColorPalette.white, + ):Container(), Card( margin: EdgeInsets.all(10), child: Padding( @@ -132,7 +409,7 @@ class _RegisterCitizenScreenState extends State { child: Column( children: [ ButtonDefault( - onPressed: (){}, + onPressed: ()=>checkSave(), title: 'Salvar', borderColor: ColorPalette.appBar, background: ColorPalette.appBar, @@ -159,7 +436,7 @@ class _RegisterCitizenScreenState extends State { Row( children: [ Container( - height: heigth*0.5, + height: height*0.5, width: width*0.2, child: Icon(Icons.person,size: 80,), ), @@ -170,11 +447,12 @@ class _RegisterCitizenScreenState extends State { InputWithSubtitle( controller: nameController, subtitle: 'Nome', - errorInput: 'Campo Obrigatório', + 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, @@ -184,14 +462,15 @@ class _RegisterCitizenScreenState extends State { widthInput: width*0.7, widthSubtitle: width*0.7, hintInput: 'Escreva aqui', + onChanged: (v)=>setState((){}), ), DropdownWithSubtitle( list: ConstVariable().listGender, - widthSubtitle: width*0.7, subtitle: 'Sexo', hintDropdown: 'Sexo', select: selectGender, - widthDropdown: width*0.7, + widthSubtitle: width*0.6, + widthDropdown: width*0.69, widthContainerDropdown: width*0.6, onChanged: (value){ setState(() { @@ -199,6 +478,7 @@ class _RegisterCitizenScreenState extends State { }); }, ), + selectGender==null?ErrorDefault():Container(), Container( width: width*0.75, child: Row( @@ -214,15 +494,16 @@ class _RegisterCitizenScreenState extends State { // ), // Spacer(), GestureDetector( - onTap: ()=>escolherprazoInicio(context), + onTap: ()=>escolherprazoInicio(context,'birth'), child: Container( - height: 50, - margin: EdgeInsets.symmetric(horizontal: 10), + 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) // <--- border radius here + Radius.circular(5.0) ), ), width: width*0.7, @@ -236,14 +517,15 @@ class _RegisterCitizenScreenState extends State { ], ), ), + date == 'Data de Nascimento'?ErrorDefault():Container(), DropdownWithSubtitle( list: ConstVariable().listMaritalStatus, - widthSubtitle: width*0.2, subtitle: 'Estado Civil', - hintDropdown: 'Selecione', + hintDropdown: 'Estado Civil', select: selectMaritalStatus, - widthDropdown: width*0.7, - widthContainerDropdown: width*0.4, + widthSubtitle: width*0.6, + widthDropdown: width*0.69, + widthContainerDropdown: width*0.6, onChanged: (value){ setState(() { selectMaritalStatus = value!; @@ -258,21 +540,22 @@ class _RegisterCitizenScreenState extends State { InputWithSubtitle( controller: spouseController, subtitle: 'Cônjuge', - errorInput: 'Campo Obrigatório', + 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, - widthSubtitle: width*0.2, subtitle: 'Naturalidade', - hintDropdown: 'Selecione', + hintDropdown: 'Naturalidade', select: selectNaturality, - widthDropdown: width*0.7, - widthContainerDropdown: width*0.4, + widthSubtitle: width*0.6, + widthDropdown: width*0.69, + widthContainerDropdown: width*0.6, onChanged: (value){ setState(() { selectNaturality = value!; @@ -284,67 +567,109 @@ class _RegisterCitizenScreenState extends State { }); }, ), + selectNaturality==null?ErrorDefault():Container(), GestureDetector( - onTap: ()=>cityBirthController.text == 'MUNICIPIO IGNORADO - SP'?null:AlertDialogDefault().alert_with_search( - context, searchCityBirthController, - ListView.separated( - separatorBuilder:(context,index)=> Divider(color: ColorPalette.black54,height: 5,), - itemCount: ConstVariable().itensCity.length, - itemBuilder: (context,index){ - return Container( - width: width*0.8, - color: ColorPalette.white, - child: ListTile( - onTap: (){ - setState(() { - cityBirthController.text = ConstVariable().itensCity[index].nameCityFront; - Navigator.pop(context); - }); - }, - title: TextDefault( - color: ColorPalette.black54, - text: ConstVariable().itensCity[index].nameCityFront, - fontSize: 16, - maxLines: 2, - ), - ), - ); - } - ), - ), + 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: 'Campo Obrigatório', + 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, - widthSubtitle: width*0.2, subtitle: 'Raça/Cor', hintDropdown: 'Raça/Cor', select: selectBreed, - widthDropdown: width*0.7, - widthContainerDropdown: width*0.4, + 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, - widthSubtitle: width*0.2, subtitle: 'Escolaridade', hintDropdown: 'Escolaridade', select: selectScooling, - widthDropdown: width*0.7, - widthContainerDropdown: width*0.4, + widthSubtitle: width*0.6, + widthDropdown: width*0.69, + widthContainerDropdown: width*0.6, onChanged: (value){ setState(() { selectScooling = value!; @@ -353,30 +678,32 @@ class _RegisterCitizenScreenState extends State { ), DropdownWithSubtitle( list: ConstVariable().listDeficiency, - widthSubtitle: width*0.2, subtitle: 'Deficiência', hintDropdown: 'Deficiência', select: selectDeficiency, - widthDropdown: width*0.7, - widthContainerDropdown: width*0.4, + 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: 'Campo Obrigatório', + 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.7, + width: width*0.65, title: 'Desconhece Mãe', value: enableMother, onChanged: (value){ @@ -391,15 +718,16 @@ class _RegisterCitizenScreenState extends State { InputWithSubtitle( controller: nameFatherController, subtitle: 'Nome do Pai', - errorInput: 'Campo Obrigatório', + 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.7, + width: width*0.65, title: 'Desconhece Pai', value: enableFather, onChanged: (value){ @@ -426,84 +754,100 @@ class _RegisterCitizenScreenState extends State { Row( children: [ Container( - height: heigth*0.4, + 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: unitController, - subtitle: 'Unidade', - errorInput: 'Campo Obrigatório', - labelInput: 'Unidade', - widthInput: width*0.7, - widthSubtitle: width*0.7, - hintInput: 'Escreva aqui', - enable: false, - ), - 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, - ), - 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, - ), - DropdownWithSubtitle( - subtitle: 'Classificação', - select: selectClassification, - widthDropdown: width*0.672, - widthContainerDropdown: width*0.5, - widthSubtitle: width*0.3, - hintDropdown: 'Número da Família', - onChanged: (value){ - setState(() { - selectClassification = value; - if(selectClassification=='OUTRO MUNICIPIO'){ - 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' - ); - } - }); - }, - list: [ - 'MUNICIPE', - 'PROVISORIO', - 'OUTRO MUNICIPIO', - ] - ), - InputWithSubtitle( - controller: numberFamilyController, - subtitle: 'Número da Família', - errorInput: 'Campo Obrigatório', - labelInput: 'Número da Família', - widthInput: width*0.7, - widthSubtitle: width*0.7, - hintInput: 'Escreva aqui', - ), - ], - ), + 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((){}), + ), + ], ), ] ), @@ -518,227 +862,298 @@ class _RegisterCitizenScreenState extends State { Row( children: [ Container( - height: heigth*0.4, + height: height*0.4, width: width*0.2, child: Icon(Icons.map_outlined,size: 80,), ), - Padding( - padding: const EdgeInsets.symmetric(horizontal: 10.0), - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - mainAxisSize: MainAxisSize.min, - children: [ - DropdownWithSubtitle( - subtitle: 'Pais de Residência', - select: selectCountry, - widthDropdown: width*0.672, - widthContainerDropdown: width*0.5, - widthSubtitle: width*0.3, - hintDropdown: 'Pais de Residência', - onChanged: (value){ - setState(() { - selectCountry = value; - if(selectCountry=='OUTRO'){ - cityController.text= 'MUNICIPIO IGNORADO - SP'; - codIBGEController.text = '000000'; - 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 = ''; - } - }); + 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, + ), + ), + ); + } + ), + ), + ), + ], + ); + }), + ); }, - list: [ - 'BRASIL', - 'OUTRO', - ] + ); + }, + 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((){}), ), - GestureDetector( - onTap: ()=>cityController.text == 'MUNICIPIO IGNORADO - SP'?null:AlertDialogDefault().alert_with_search( - context, searchCityController, - ListView.separated( - separatorBuilder:(context,index)=> Divider(color: ColorPalette.black54,height: 5,), - itemCount: ConstVariable().itensCity.length, - itemBuilder: (context,index){ - return Container( - width: width*0.8, - color: ColorPalette.white, - child: ListTile( - onTap: (){ - setState(() { - cityController.text = ConstVariable().itensCity[index].nameCityFront; - codIBGEController.text = ConstVariable().itensCity[index].codCityIbge.toString(); - Navigator.pop(context); - }); - }, - title: TextDefault( - color: ColorPalette.black54, - text: ConstVariable().itensCity[index].nameCityFront, - fontSize: 16, - maxLines: 2, - ), - ), - ); - } + ), + 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?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( + controller: cepController, + subtitle: 'CEP(só números)', + errorInput: 'Campo Obrigatório', + 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'?true:false, + onChanged: (v)=>setState((){}), ), - ), - 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, - ), + 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,), + ) + ], ), - InputWithSubtitle( - controller: codIBGEController, - subtitle: 'Cód. IBGE', - errorInput: 'Campo Obrigatório', - labelInput: 'Cód. IBGE', - widthInput: width*0.7, - widthSubtitle: width*0.2, - hintInput: 'Escreva aqui', - enable: false, - ), - DropdownWithSubtitle( - subtitle: 'Bairro', - select: selectVillage, - widthDropdown: width*0.672, - widthContainerDropdown: width*0.5, - widthSubtitle: width*0.3, - hintDropdown: 'Bairro', - onChanged: (value){ - setState(() { - selectVillage = value; - }); - }, - list: [] - ), - DropdownWithSubtitle( - subtitle: 'Tipo de Logradouro', - select: selectTypeStreet, - widthDropdown: width*0.672, - widthContainerDropdown: width*0.5, - widthSubtitle: width*0.3, - hintDropdown: 'Tipo de Logradouro', - onChanged: (value){ - setState(() { - selectTypeStreet = value; - }); - }, - list: [] - ), - DropdownWithSubtitle( - subtitle: 'Nome do Logradouro', - select: selectStreet, - widthDropdown: width*0.672, - widthContainerDropdown: width*0.5, - widthSubtitle: width*0.3, - hintDropdown: 'Nome do Logradouro', - onChanged: (value){ - setState(() { - selectStreet = value; - }); - }, - list: [] - ), - InputWithSubtitle( - controller: cepController, - subtitle: 'CEP(só números)', - errorInput: 'Campo Obrigatório', - labelInput: 'CEP(só números)', - widthInput: width*0.7, - widthSubtitle: width*0.2, - hintInput: 'Escreva aqui', - enable: false, - ), - 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, - hintInput: 'Escreva aqui', - enable: false, - ), - Checkbox( - value: checkBoxNumber, - onChanged: (value){ - setState(() { - checkBoxNumber = value!; - }); - } - ), - Spacer(), - Padding( - padding: const EdgeInsets.symmetric(horizontal: 10.0), - child: TextDefault(text: 'SEM NÚMERO',fontSize: 15,), - ) - ], - ), - ), - DropdownWithSubtitle( - subtitle: 'Loteamento/Subdistrito', - select: selectSubdivision, - widthDropdown: width*0.672, - widthContainerDropdown: width*0.5, - widthSubtitle: width*0.3, - hintDropdown: 'Loteamento/Subdistrito', - onChanged: (value){ - setState(() { - selectSubdivision = value; - }); - }, - list: [] - ), - InputWithSubtitle( - controller: complementController, - subtitle: 'Complemento', - errorInput: 'Campo Obrigatório', - labelInput: 'Complemento', - widthInput: width*0.7, - widthSubtitle: width*0.2, - hintInput: 'Escreva aqui', - ), - 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', - ), - DropdownWithSubtitle( - subtitle: 'Zona', - select: selectZone, - widthDropdown: width*0.672, - widthContainerDropdown: width*0.5, - widthSubtitle: width*0.3, - hintDropdown: 'Zona', - onChanged: (value){ - setState(() { - selectZone = value; - }); - }, - list: ['URBANA','RURAL'] - ), - ], - ), + ), + 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'] + ), + ], ), ] ), @@ -753,7 +1168,7 @@ class _RegisterCitizenScreenState extends State { Row( children: [ Container( - height: heigth*0.4, + height: height*0.4, width: width*0.2, child: Icon(Icons.medical_services_rounded,size: 80,), ), @@ -771,6 +1186,8 @@ class _RegisterCitizenScreenState extends State { widthInput: width*0.7, widthSubtitle: width*0.7, hintInput: 'Escreva aqui', + mandatory: false, + onChanged: (v)=>setState((){}), ), InputWithSubtitle( controller: foneController, @@ -780,6 +1197,8 @@ class _RegisterCitizenScreenState extends State { widthInput: width*0.7, widthSubtitle: width*0.7, hintInput: 'Escreva aqui', + mandatory: false, + onChanged: (v)=>setState((){}), ), InputWithSubtitle( controller: mobileDDDController, @@ -789,6 +1208,8 @@ class _RegisterCitizenScreenState extends State { widthInput: width*0.7, widthSubtitle: width*0.7, hintInput: 'Escreva aqui', + mandatory: false, + onChanged: (v)=>setState((){}), ), InputWithSubtitle( controller: mobileController, @@ -798,6 +1219,8 @@ class _RegisterCitizenScreenState extends State { widthInput: width*0.7, widthSubtitle: width*0.7, hintInput: 'Escreva aqui', + mandatory: false, + onChanged: (v)=>setState((){}), ), InputWithSubtitle( controller: messageDDDController, @@ -807,6 +1230,7 @@ class _RegisterCitizenScreenState extends State { widthInput: width*0.7, widthSubtitle: width*0.7, hintInput: 'Escreva aqui', + onChanged: (v)=>setState((){}), ), InputWithSubtitle( controller: messageController, @@ -816,6 +1240,7 @@ class _RegisterCitizenScreenState extends State { widthInput: width*0.7, widthSubtitle: width*0.7, hintInput: 'Escreva aqui', + onChanged: (v)=>setState((){}), ), InputWithSubtitle( controller: emailController, @@ -825,6 +1250,8 @@ class _RegisterCitizenScreenState extends State { widthInput: width*0.7, widthSubtitle: width*0.7, hintInput: 'Escreva aqui', + mandatory: false, + onChanged: (v)=>setState((){}), ), ], ), @@ -842,7 +1269,7 @@ class _RegisterCitizenScreenState extends State { Row( children: [ Container( - height: heigth*0.2, + height: height*0.2, width: width*0.2, child: Icon(Icons.sell,size: 80,), ), @@ -862,6 +1289,8 @@ class _RegisterCitizenScreenState extends State { hintInput: 'Escreva aqui', textInputType: TextInputType.multiline, maxLines: 5, + mandatory: false, + onChanged: (v)=>setState((){}), ), ], ), @@ -879,233 +1308,304 @@ class _RegisterCitizenScreenState extends State { Row( children: [ Container( - height: heigth*0.4, + height: height*0.4, width: width*0.2, child: Icon(Icons.description_outlined,size: 80,), ), - Padding( - padding: const EdgeInsets.symmetric(horizontal: 10.0), - child: 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', - ), - InputWithSubtitle( - controller: CNSController, - subtitle: 'CNS', - errorInput: 'Campo Obrigatório', - labelInput: 'CNS', - widthInput: width*0.7, - widthSubtitle: width*0.7, - hintInput: 'Escreva aqui', - ), - 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', - ), - InputWithSubtitle( - controller: RGController, - subtitle: 'RG', - errorInput: 'Campo Obrigatório', - labelInput: 'RG', - widthInput: width*0.7, - widthSubtitle: width*0.7, - hintInput: 'Escreva aqui', - ), - InputWithSubtitle( - controller: RGComplementController, - subtitle: 'RG - Complemento', - errorInput: 'Campo Obrigatório', - labelInput: 'RG - Complemento', - widthInput: width*0.7, - widthSubtitle: width*0.7, - hintInput: 'Escreva aqui', - ), - DropdownWithSubtitle( - subtitle: 'RG - UF', - select: selectRGUF, - widthDropdown: width*0.672, - widthContainerDropdown: width*0.5, - widthSubtitle: width*0.3, - hintDropdown: 'RG - UF', - onChanged: (value){ - setState(() { - selectRGUF = value; - }); - }, - list: [] - ), - 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', - ), - InputWithSubtitle( - controller: RGDateController, - subtitle: 'RG - Data de Emissão', - errorInput: 'Campo Obrigatório', - labelInput: 'RG - Data de Emissão', - widthInput: width*0.7, - widthSubtitle: width*0.7, - hintInput: 'Escreva aqui', - ), - DropdownWithSubtitle( - subtitle: 'Tipo de certidão', - select: selectTypeCertificate, - widthDropdown: width*0.672, - widthContainerDropdown: width*0.5, - widthSubtitle: width*0.3, - 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', - ), - 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', - ), - 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', - ), - 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', - ), - 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', - ), - InputWithSubtitle( - controller: dateCertificateController, - subtitle: 'Data de Emissão da Certidão', - errorInput: 'Campo Obrigatório', - labelInput: 'Data de Emissão da Certidão', - widthInput: width*0.7, - widthSubtitle: width*0.7, - hintInput: 'Escreva aqui', - ), - InputWithSubtitle( - controller: CTPSController, - subtitle: 'CTPS', - errorInput: 'Campo Obrigatório', - labelInput: 'CTPS', - widthInput: width*0.7, - widthSubtitle: width*0.7, - hintInput: 'Escreva aqui', - ), - 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', - ), - DropdownWithSubtitle( - subtitle: 'CTPS - UF', - select: selectCTPSUF, - widthDropdown: width*0.672, - widthContainerDropdown: width*0.5, - widthSubtitle: width*0.3, - hintDropdown: 'CTPS - UF', - onChanged: (value){ - setState(() { - selectCTPSUF = value; - }); - }, - list: [] - ), - InputWithSubtitle( - controller: PISController, - subtitle: 'PIS/PASEP', - errorInput: 'Campo Obrigatório', - labelInput: 'PIS/PASEP', - widthInput: width*0.7, - widthSubtitle: width*0.7, - hintInput: 'Escreva aqui', - ), - Container( + 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: Row( - children: [ - TextDefault(text: 'Retirou cartão municipal da cidade?'), - Spacer(), - Switch(value: enableCityCard, onChanged: (value)=>setState(()=>enableCityCard=value!) - ) - ], + child: TextDefault( + text: RGDateController.text, + color: ColorPalette.black54, + fontSize: 18, ), ), - 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', + ), + 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((){}), + ), + ], ), ] ), @@ -1120,55 +1620,68 @@ class _RegisterCitizenScreenState extends State { Row( children: [ Container( - height: heigth*0.3, + height: height*0.3, width: width*0.2, child: Icon(Icons.tag,size: 80,), ), - Padding( - padding: const EdgeInsets.symmetric(horizontal: 10.0), - child: 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', - ), - InputWithSubtitle( - controller: professionalController, - subtitle: 'Profissão', - errorInput: 'Campo Obrigatório', - labelInput: 'Profissão', - widthInput: width*0.7, - widthSubtitle: width*0.7, - hintInput: 'Escreva aqui', - ), - InputWithSubtitle( - controller: dateDeathController, - subtitle: 'Data Óbito', - errorInput: 'Campo Obrigatório', - labelInput: 'Data Óbito', - widthInput: width*0.7, - widthSubtitle: width*0.7, - hintInput: 'Escreva aqui', - ), - Container( - width: width*0.7, - child: Row( - children: [ - TextDefault(text: 'Bloqueado'), - Spacer(), - Switch(value: enableBlocked, onChanged: (value)=>setState(()=>enableBlocked=value!)), - ], + 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!)), + ], + ), + ) + ], ), ] ), diff --git a/lib/screens/register_home_screen.dart b/lib/screens/registers_citizen/register_home_screen.dart similarity index 96% rename from lib/screens/register_home_screen.dart rename to lib/screens/registers_citizen/register_home_screen.dart index 1585c91..b06bad8 100644 --- a/lib/screens/register_home_screen.dart +++ b/lib/screens/registers_citizen/register_home_screen.dart @@ -5,11 +5,13 @@ import 'package:rkm/utils/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 '../widgets/dropdown_with_subtitle.dart'; -import '../widgets/input_with_subtitle.dart'; -import '../widgets/onbackbutton.dart'; -import '../widgets/switch_with_subtitle.dart'; -import '../widgets/text_default.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'; +import '../../widgets/text_default.dart'; class RegisterHomeScreen extends StatefulWidget { const RegisterHomeScreen({Key? key}) : super(key: key); @@ -162,12 +164,14 @@ class _RegisterHomeScreenState extends State { return WillPopScope( onWillPop: ()=> 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), Card( margin: EdgeInsets.all(10), child: Padding( @@ -295,7 +299,8 @@ class _RegisterHomeScreenState extends State { labelInput: 'Moradores', widthSubtitle: width*0.4, widthInput: width*0.7, - controller: controllerResidents + controller: controllerResidents, + onChanged: (v)=>setState((){}), ), InputWithSubtitle( subtitle: 'Cômodos', @@ -304,7 +309,8 @@ class _RegisterHomeScreenState extends State { labelInput: 'Cômodos', widthSubtitle: width*0.4, widthInput: width*0.7, - controller: controllerComfortable + controller: controllerComfortable, + onChanged: (v)=>setState((){}), ), DropdownWithSubtitle( list:[], @@ -419,7 +425,8 @@ class _RegisterHomeScreenState extends State { labelInput: 'Quantidade', widthSubtitle: width*0.4, widthInput: width*0.7, - controller: controllerAmount + controller: controllerAmount, + onChanged: (v)=>setState((){}), ), ], ) @@ -454,6 +461,7 @@ class _RegisterHomeScreenState extends State { widthInput: width*0.7, widthSubtitle: width*0.7, hintInput: 'Escreva aqui', + onChanged: (v)=>setState((){}), ), InputWithSubtitle( controller: unitProfessionalController, @@ -463,6 +471,7 @@ class _RegisterHomeScreenState extends State { widthInput: width*0.7, widthSubtitle: width*0.7, hintInput: 'Escreva aqui', + onChanged: (v)=>setState((){}), ), DropdownWithSubtitle( subtitle: 'CBO', @@ -501,6 +510,7 @@ class _RegisterHomeScreenState extends State { widthSubtitle: width*0.7, hintInput: 'Escreva aqui', enable: false, + onChanged: (v)=>setState((){}), ), ], ), diff --git a/lib/screens/registers_citizen/register_individual_screen.dart b/lib/screens/registers_citizen/register_individual_screen.dart index 885838f..1d292d9 100644 --- a/lib/screens/registers_citizen/register_individual_screen.dart +++ b/lib/screens/registers_citizen/register_individual_screen.dart @@ -6,10 +6,12 @@ import 'package:rkm/utils/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 '../../widgets/appbar_default.dart'; import '../../widgets/check_box_two_subtitle.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'; import '../../widgets/text_default.dart'; class RegisterIndividualScreen extends StatefulWidget { @@ -145,12 +147,14 @@ class _RegisterIndividualScreenState extends State { return WillPopScope( onWillPop: ()=> OnBackButton().onBackButton(context), child: Scaffold( + appBar: AppBarDefault().appbar(context, 'RKM AB - Cadastro Individual'), body: Container( height: double.infinity, width: double.infinity, decoration: ConstVariable().backgroundGradient, child: ListView( children: [ + SubtitleAppbarCitizen(title: 2,edit: true), Card( margin: EdgeInsets.all(10), child: Padding( @@ -255,6 +259,7 @@ class _RegisterIndividualScreenState extends State { widthSubtitle: width*0.2, hintInput: 'Escreva aqui', enable: enableSpouse, + onChanged: (v)=>setState((){}), ), DropdownWithSubtitle( list: [], @@ -279,6 +284,7 @@ class _RegisterIndividualScreenState extends State { widthSubtitle: width*0.2, hintInput: 'Escreva aqui', enable: enableSpouse, + onChanged: (v)=>setState((){}), ), InputWithSubtitle( controller: enterBrazilController, @@ -289,6 +295,7 @@ class _RegisterIndividualScreenState extends State { widthSubtitle: width*0.2, hintInput: 'Escreva aqui', enable: enableSpouse, + onChanged: (v)=>setState((){}), ), InputWithSubtitle( controller: dateNaturalnessController, @@ -299,6 +306,7 @@ class _RegisterIndividualScreenState extends State { widthSubtitle: width*0.2, hintInput: 'Escreva aqui', enable: enableSpouse, + onChanged: (v)=>setState((){}), ), InputWithSubtitle( controller: porterNaturalnessController, @@ -309,6 +317,7 @@ class _RegisterIndividualScreenState extends State { widthSubtitle: width*0.2, hintInput: 'Escreva aqui', enable: enableSpouse, + onChanged: (v)=>setState((){}), ), DropdownWithSubtitle( list:['SUPERIOR, APERFEIÇAOMENTO,ESPECIAL'], @@ -440,6 +449,7 @@ class _RegisterIndividualScreenState extends State { widthSubtitle: width*0.2, hintInput: 'Escreva aqui', enable: enableSpouse, + onChanged: (v)=>setState((){}), ), DropdownWithSubtitle( list: ['NÃO DESEJA INFORMAR'], @@ -560,6 +570,7 @@ class _RegisterIndividualScreenState extends State { widthSubtitle: width*0.2, hintInput: 'Escreva aqui', enable: enableSpouse, + onChanged: (v)=>setState((){}), ), SwitchWithSubtitle( width: width*0.7, @@ -621,6 +632,7 @@ class _RegisterIndividualScreenState extends State { widthSubtitle: width*0.7, hintInput: 'Escreva aqui', enable: false, + onChanged: (v)=>setState((){}), ), DropdownWithSubtitle( list: [], @@ -789,6 +801,7 @@ class _RegisterIndividualScreenState extends State { widthSubtitle: width*0.7, hintInput: 'Escreva aqui', enable: false, + onChanged: (v)=>setState((){}), ), DropdownWithSubtitle( subtitle: 'Doença Cardíaca', @@ -899,6 +912,7 @@ class _RegisterIndividualScreenState extends State { widthSubtitle: width*0.7, hintInput: 'Escreva aqui', enable: false, + onChanged: (v)=>setState((){}), ), InputWithSubtitle( controller: otherCondicionsController, @@ -909,6 +923,7 @@ class _RegisterIndividualScreenState extends State { widthSubtitle: width*0.7, hintInput: 'Escreva aqui', enable: false, + onChanged: (v)=>setState((){}), ), ], ), @@ -974,6 +989,7 @@ class _RegisterIndividualScreenState extends State { widthSubtitle: width*0.7, hintInput: 'Escreva aqui', enable: false, + onChanged: (v)=>setState((){}), ), SwitchWithSubtitle( width: width*0.7, @@ -1023,6 +1039,7 @@ class _RegisterIndividualScreenState extends State { widthSubtitle: width*0.7, hintInput: 'Escreva aqui', enable: false, + onChanged: (v)=>setState((){}), ), DropdownWithSubtitle( subtitle: 'Alimentação Diária', @@ -1132,6 +1149,7 @@ class _RegisterIndividualScreenState extends State { widthInput: width*0.7, widthSubtitle: width*0.7, hintInput: 'Escreva aqui', + onChanged: (v)=>setState((){}), ), InputWithSubtitle( controller: unitProfessionalController, @@ -1141,6 +1159,7 @@ class _RegisterIndividualScreenState extends State { widthInput: width*0.7, widthSubtitle: width*0.7, hintInput: 'Escreva aqui', + onChanged: (v)=>setState((){}), ), DropdownWithSubtitle( subtitle: 'CBO', @@ -1179,6 +1198,7 @@ class _RegisterIndividualScreenState extends State { widthSubtitle: width*0.7, hintInput: 'Escreva aqui', enable: false, + onChanged: (v)=>setState((){}), ), ], ), diff --git a/lib/screens/select_service/service_home_screen.dart b/lib/screens/select_service/service_home_screen.dart index a7fb311..7abcf3d 100644 --- a/lib/screens/select_service/service_home_screen.dart +++ b/lib/screens/select_service/service_home_screen.dart @@ -101,6 +101,7 @@ class _ServiceHomeScreenState extends State { widthSubtitle: width*0.7, hintInput: 'Escreva aqui', enable: false, + onChanged: (v)=>setState((){}), ), InputWithSubtitle( controller: unitController, @@ -111,6 +112,7 @@ class _ServiceHomeScreenState extends State { widthSubtitle: width*0.7, hintInput: 'Escreva aqui', enable: false, + onChanged: (v)=>setState((){}), ), DropdownWithSubtitle( list: [], diff --git a/lib/screens/select_service/service_individual_screen.dart b/lib/screens/select_service/service_individual_screen.dart index 8e87425..134ac73 100644 --- a/lib/screens/select_service/service_individual_screen.dart +++ b/lib/screens/select_service/service_individual_screen.dart @@ -214,6 +214,7 @@ class _ServiceIndividualScreenState extends State { widthInput: width*0.7, controller: weigthController, colorBorder: ColorPalette.white, + onChanged: (v)=>setState((){}), ), InputWithSubtitle( subtitle: 'Altura (em metros - 0,00)', @@ -224,6 +225,7 @@ class _ServiceIndividualScreenState extends State { widthInput: width*0.7, controller: heightController, colorBorder: ColorPalette.white, + onChanged: (v)=>setState((){}), ), InputWithSubtitle( subtitle: 'Perímetro cefálico (em centímetros - 000,00)', @@ -234,6 +236,7 @@ class _ServiceIndividualScreenState extends State { widthInput: width*0.7, controller: cephalicPerimeterController, colorBorder: ColorPalette.white, + onChanged: (v)=>setState((){}), ), SwitchWithSubtitle( width: width*0.7, @@ -285,6 +288,7 @@ class _ServiceIndividualScreenState extends State { controller: userResponsibleRegisterController, colorBorder: ColorPalette.white, enable: false, + onChanged: (v)=>setState((){}), ), InputWithSubtitle( subtitle: 'Unidade do Profissional', @@ -296,6 +300,7 @@ class _ServiceIndividualScreenState extends State { controller: userUnitController, colorBorder: ColorPalette.white, enable: false, + onChanged: (v)=>setState((){}), ), DropdownWithSubtitle( list: [], @@ -356,6 +361,7 @@ class _ServiceIndividualScreenState extends State { controller: dumController, colorBorder: ColorPalette.white, enable: false, + onChanged: (v)=>setState((){}), ), SwitchWithSubtitle( onChanged: (value){}, @@ -373,6 +379,7 @@ class _ServiceIndividualScreenState extends State { controller: oldPregnancyController, colorBorder: ColorPalette.white, enable: false, + onChanged: (v)=>setState((){}), ), InputWithSubtitle( subtitle: 'Partos', @@ -384,6 +391,7 @@ class _ServiceIndividualScreenState extends State { controller: childBirthsController, colorBorder: ColorPalette.white, enable: false, + onChanged: (v)=>setState((){}), ), ], ) diff --git a/lib/screens/splash_screen.dart b/lib/screens/splash_screen.dart index e7296a9..abc987e 100644 --- a/lib/screens/splash_screen.dart +++ b/lib/screens/splash_screen.dart @@ -1,7 +1,5 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; -import 'package:rkm/models/args_load_init_model.dart'; -import 'package:rkm/models/city_load_model.dart'; import 'package:rkm/screens/login/sync_login_screen.dart'; import 'package:rkm/service/api/url_api_const.dart'; import 'package:rkm/utils/const_variable.dart'; @@ -18,20 +16,19 @@ class SplashScreen extends StatefulWidget { class _SplashScreenState extends State { - CityLoadModel? model; @override void initState() { super.initState(); - DbSqliteLoad().intialDB(); - final PrefService _prefService = PrefService(); - _prefService.readCacheModel('user', 'password', 'city', 'mode').then((list){ - for(int i=0;ConstVariable().itensCity.length > i;i++){ - if(ConstVariable().itensCity[i].nameCityFront == list[2]!){ - model = ConstVariable().itensCity[i]; + DbSqliteLoad().intialDB().then((value){ + final PrefService _prefService = PrefService(); + _prefService.readCacheModel('user', 'password', 'city', 'mode').then((list){ + if(list[0] == null){ + Navigator.pushReplacementNamed(context, '/login_load'); + }else{ + timer(list); } - } - timer(list); + }); }); } @@ -42,39 +39,25 @@ class _SplashScreenState extends State { if(dataControl.length != 0){ var query = "SELECT * FROM CONTROLE_INTERNO"; dataControl = await db.rawQuery(query); - // print(dataCitizen); + String? url; + if(list[3]=='desenvolvimento'){ + url = UrlApiConst.ApiUrlDesenvolvimento; + }else if(list[3]=='homologacao'){ + url = UrlApiConst.ApiUrlHomologacao; + }else{ + url = UrlApiConst.ApiUrlOnline; + } if(dataCitizen.length != 0){ - String? url; - if(list[3]=='desenvolvimento'){ - url = UrlApiConst.ApiUrlDesenvolvimento; - }else if(list[3]=='online'){ - url = UrlApiConst.ApiUrlOnline; - }else if(list[3]=='homologacao'){ - url = UrlApiConst.ApiUrlHomologacao; - } - ArgsLoadInitModel args = ArgsLoadInitModel(mode: list[3], model: model!, user: list[0], password: list[1], urlAPI: url!); - Navigator.push( context, - MaterialPageRoute(builder: (context) => LoginSavedScreen(listControl: dataControl,args: args,)), + MaterialPageRoute(builder: (context) => LoginSavedScreen(listControl: dataControl,)), ); }else{ - String? url; - if(list[3]=='desenvolvimento'){ - url = UrlApiConst.ApiUrlDesenvolvimento; - }else if(list[3]=='online'){ - url = UrlApiConst.ApiUrlOnline; - }else if(list[3]=='homologacao'){ - url = UrlApiConst.ApiUrlHomologacao; - } - if(url!=null && model!=null){ - ArgsLoadInitModel args = ArgsLoadInitModel(mode: list[3], model: model!, user: list[0], password: list[1], urlAPI: url!); Navigator.push( context, - MaterialPageRoute(builder: (context) => SyncLoginScreen(args: args)), + MaterialPageRoute(builder: (context) => SyncLoginScreen()), ); } - } }else{ Navigator.pushReplacementNamed(context, '/login_load'); } diff --git a/lib/screens/sync_init_screen.dart b/lib/screens/sync_init_screen.dart index dbea72f..35ba53f 100644 --- a/lib/screens/sync_init_screen.dart +++ b/lib/screens/sync_init_screen.dart @@ -6,17 +6,10 @@ import 'package:rkm/utils/color_palette.dart'; import 'package:rkm/widgets/alert_dialog_default.dart'; import 'package:rkm/widgets/button_default.dart'; import 'package:rkm/widgets/text_default.dart'; -import '../models/args_load_init_model.dart'; -import '../service/api/api_data_load.dart'; import '../service/db/db_sqlite_load.dart'; import '../service/shared_preferences/shared_preferences_service.dart'; class SyncInitScreen extends StatefulWidget { - ArgsLoadInitModel args; - - SyncInitScreen({ - required this.args, -}); @override State createState() => _SyncInitScreenState(); @@ -29,24 +22,51 @@ class _SyncInitScreenState extends State { bool finish = false; String idUsuario = ''; String idUnidade = ''; + String nomeUnidade = ''; String area = ''; String microarea = ''; bool foraArea = false; + String urlAPI=''; + String mode = ''; + String nameCityApi = ''; + String nameCityFront = ''; + String user = ''; + int codCity = 0; + int codCityIbge = 0; + String codState = ''; @override void initState() { super.initState(); - dataUser(); + recupDB(); + } + + recupDB()async{ + await DbSqliteLoad().intialDB().then((db)async{ + List list = await db.query('ARGS'); + urlAPI = list[0]['URLAPI']; + mode = list[0]['MODE']; + nameCityApi = list[0]['NAME_CITY_API']; + nameCityFront = list[0]['NAME_CITY_FRONT']; + user = list[0]['USER']; + codCity = list[0]['COD_CITY']; + codState = list[0]['COD_STATE']; + codCityIbge = list[0]['COD_IBGE']; + if(urlAPI!=''){ + dataUser(); + } + }); } dataUser()async{ - _prefService.readCacheIdUnidade('idUnidade').then((id)async{ + _prefService.readCacheUnidade('idUnidade').then((listUnidade)async{ _prefService.readCacheSync('area', false).then((list){ foraArea = list[1]; List splited = list[0].split(': '); area = splited[2].toString().substring(0,1); microarea = splited[3]; - idUnidade = id; + idUnidade = listUnidade[0]; + nomeUnidade = listUnidade[1]; initSync(); }); }); @@ -54,75 +74,75 @@ class _SyncInitScreenState extends State { initSync()async{ await DbSqliteSync().deleteSync().then((_)async{ - await ApiDataSync().syncPerm(widget.args).then((response)async{ + await ApiDataSync().syncPerm(urlAPI,mode,nameCityApi,user).then((response)async{ if(response['status'] == 0 || response['sync_perm'] != "S"){ AlertDialogDefault().alert(context, 'Erro', 'Usuário sem permissão para Sincronização de Unidade!', 'Voltar'); }else{ setState(()=> messageSteps = "Etapa 1 de 10 - Importando informações do CONECTASUS"); - await ApiDataSync().syncBairros(widget.args).then((value)async{ + await ApiDataSync().syncBairros(urlAPI,mode,nameCityApi,user).then((value)async{ if(value.length == 0){ setState(()=> messageSteps = "ERRO: Erro para carregar os Bairros - Por favor, tente novamente!"); }else{ setState(()=> messageSteps = "Etapa 2 de 10 - Gravando os Bairros no Aplicativo"); } await DbSqliteSync().insertBairros(value).then((value)async{ - await ApiDataSync().syncTiposLogradouros(widget.args).then((value)async{ + await ApiDataSync().syncTiposLogradouros(urlAPI,mode,nameCityApi,user).then((value)async{ if(value.length == 0){ setState(()=> messageSteps = "ERRO: Erro para carregar os Tipos de Logradouros - Por favor, tente novamente!"); }else{ setState(()=> messageSteps = "Etapa 3 de 10 - Gravando os Tipos de Logradouros no Aplicativo"); } await DbSqliteSync().insertTiposLogradouros(value).then((value)async{ - await ApiDataSync().syncLogradouros(widget.args).then((value)async{ + await ApiDataSync().syncLogradouros(urlAPI,mode,nameCityApi,user).then((value)async{ if(value.length == 0){ setState(()=> messageSteps = "ERRO: Erro para carregar os Logradouros - Por favor, tente novamente!"); }else{ setState(()=> messageSteps = "Etapa 4 de 10 - Gravando os Logradouros no Aplicativo"); } await DbSqliteSync().insertLogradouros(value).then((value)async{ - await ApiDataSync().syncLoteamentos(widget.args).then((value)async{ + await ApiDataSync().syncLoteamentos(urlAPI,mode,nameCityApi,user).then((value)async{ if(value.length == 0){ setState(()=> messageSteps = "ERRO: Erro para carregar os Loteamentos - Por favor, tente novamente!"); }else{ setState(()=> messageSteps = "Etapa 5 de 10 - Gravando os Loteamentos no Aplicativo"); } await DbSqliteSync().insertLoteamentos(value).then((value)async{ - await ApiDataSync().syncProfissionais(widget.args,idUnidade).then((value)async{ + await ApiDataSync().syncProfissionais(urlAPI,mode,nameCityApi,user,idUnidade).then((value)async{ if(value.length == 0){ setState(()=> messageSteps = "ERRO: Erro para carregar os Profissionais - Por favor, tente novamente!"); }else{ setState(()=> messageSteps = "Etapa 6 de 10 - Gravando os Profissionais no Aplicativo"); } await DbSqliteSync().insertProfissionais(value).then((value)async{ - await ApiDataSync().syncProfissionaisCBOs(widget.args,idUnidade).then((value)async{ + await ApiDataSync().syncProfissionaisCBOs(urlAPI,mode,nameCityApi,user,idUnidade).then((value)async{ if(value.length == 0){ setState(()=> messageSteps = "ERRO: Erro para carregar os CBOs dos Profissionais - Por favor, tente novamente!"); }else{ setState(()=> messageSteps = "Etapa 7 de 10 - Gravando os CBO´s dos Profissionais no Aplicativo"); } await DbSqliteSync().insertProfissionaisCBOs(value).then((value)async{ - await ApiDataSync().syncCidadaos(widget.args,idUnidade,area,microarea,foraArea).then((value)async{ + await ApiDataSync().syncCidadaos(urlAPI,mode,nameCityApi,user,idUnidade,area,microarea,foraArea).then((value)async{ if(value.length == 0){ setState(()=> messageSteps = "ERRO: Erro para carregar os Cadastros dos Cidadãos - Por favor, tente novamente!"); }else{ setState(()=> messageSteps = "Etapa 8 de 10 - Gravando os Cidadãos no Aplicativo"); } - await DbSqliteSync().insertCidadaos(value).then((value)async{ - await ApiDataSync().syncCadastrosDomiciliares(widget.args,idUnidade,area,microarea,foraArea).then((value)async{ + await DbSqliteSync().insertCidadaos(value,'sync').then((value)async{ + await ApiDataSync().syncCadastrosDomiciliares(urlAPI,mode,nameCityApi,user,idUnidade,area,microarea,foraArea).then((value)async{ if(value.length == 0){ setState(()=> messageSteps = "ERRO: Erro para carregar os Cadastros Domiciliares - Por favor, tente novamente!"); }else{ setState(()=> messageSteps = "Etapa 9 de 10 - Gravando os Cadastros Domiciliares no Aplicativo"); } await DbSqliteSync().insertCadastrosDomiciliares(value).then((value)async{ - await ApiDataSync().syncCadastrosIndividuais(widget.args,idUnidade,area,microarea,foraArea).then((value)async{ + await ApiDataSync().syncCadastrosIndividuais(urlAPI,mode,nameCityApi,user,idUnidade,area,microarea,foraArea).then((value)async{ if(value.length == 0){ setState(()=> messageSteps = "ERRO: Erro para carregar os Cadastros Individuais - Por favor, tente novamente!"); }else{ setState(()=> messageSteps = "Etapa 10 de 10 - Gravando os Cadastros Individuais no Aplicativo"); } await DbSqliteSync().insertCadastrosIndividuais(value).then((value)async{ - await DbSqliteSync().saveSync(widget.args,idUnidade,area,microarea).then((value)async{ + await DbSqliteSync().saveSync(codCity,codState,urlAPI,mode,nameCityApi,nameCityFront,codCityIbge,user,idUnidade,nomeUnidade,area,microarea).then((value)async{ Navigator.pushNamed(context, '/home'); }); }); @@ -167,7 +187,7 @@ class _SyncInitScreenState extends State { onPressed: (){ Navigator.pushReplacement( context, - MaterialPageRoute(builder: (context) => SyncLoginScreen(args: widget.args)), + MaterialPageRoute(builder: (context) => SyncLoginScreen()), ); }, title: 'Continuar', diff --git a/lib/service/api/api_data_load.dart b/lib/service/api/api_data_load.dart index 8ef8859..ecb9779 100644 --- a/lib/service/api/api_data_load.dart +++ b/lib/service/api/api_data_load.dart @@ -1,106 +1,114 @@ import 'dart:convert'; import 'package:http/http.dart' as http; -import '../../models/args_load_init_model.dart'; class ApiDataLoad{ - Future apiConect(ArgsLoadInitModel args)async{ - //http://192.168.0.42:8010/api/atb/desenvolvimento/cabreuva/load/pass/admin - final url = '${args.urlAPI}${args.mode}/${args.model.nameCityApi}/pass/${args.user}'; + Future apiConect(urlAPI,mode,nameCityApi,user)async{ + //http://192.168.0.42:8010/api/atb/desenvolvimento/corumbatai/pass/admin + //https://app0.rkmsistemas.com.br/api/atb/homologacao/cabreuva/pass/admin + final url = '${urlAPI}${mode}/${nameCityApi}/pass/${user}'; + print(url); final response = await http.get(Uri.parse(url)); - final map = json.decode(response.body); - return map; + var map; + print(response.statusCode); + if(response.statusCode == 200){ + return map = json.decode(response.body); + }else{ + return map = 'Erro'; + } } - Future loadPerm(ArgsLoadInitModel args)async{ + Future loadPerm(urlAPI,mode,nameCityApi,user)async{ + //https://app0.rkmsistemas.com.br/api/atb/homologacao/cabreuva/load/perm/admin //http://192.168.0.42:8010/api/atb/desenvolvimento/corumbatai/load/perm/admin - final url = '${args.urlAPI}${args.mode}/${args.model.nameCityApi}/load/perm/${args.user}'; + final url = '${urlAPI}${mode}/${nameCityApi}/load/perm/${user}'; // final url = 'http://192.168.0.42:8010/api/atb/desenvolvimento/corumbatai/load/perm/admin'; final response = await http.get(Uri.parse(url)); final map = json.decode(response.body); return map; } - Future loadUnidades(ArgsLoadInitModel args)async{ + Future loadUnidades(urlAPI,mode,nameCityApi,user)async{ + //https://app0.rkmsistemas.com.br/api/atb/homologacao/cabreuva/admin/load/unidades // http://192.168.0.42:8010/api/atb/desenvolvimento/corumbatai/admin/load/unidades - final url = '${args.urlAPI}${args.mode}/${args.model.nameCityApi}/${args.user}/load/unidades'; + final url = '${urlAPI}${mode}/${nameCityApi}/${user}/load/unidades'; final response = await http.get(Uri.parse(url)); final map = json.decode(response.body); return map; } - Future loadProcedimentos(ArgsLoadInitModel args)async{ + Future loadProcedimentos(urlAPI,mode,nameCityApi,user)async{ // http://192.168.0.42:8010/api/atb/desenvolvimento/corumbatai/admin/load/procedimentos - final url = '${args.urlAPI}${args.mode}/${args.model.nameCityApi}/${args.user}/load/procedimentos'; + final url = '${urlAPI}${mode}/${nameCityApi}/${user}/load/procedimentos'; final response = await http.get(Uri.parse(url)); final map = json.decode(response.body); return map; } - Future loadProcedimentosRegistros(ArgsLoadInitModel args)async{ + Future loadProcedimentosRegistros(urlAPI,mode,nameCityApi,user)async{ // http://192.168.0.42:8010/api/atb/desenvolvimento/corumbatai/admin/load/procedimentosRegistros - final url = '${args.urlAPI}${args.mode}/${args.model.nameCityApi}/${args.user}/load/procedimentosRegistros'; + final url = '${urlAPI}${mode}/${nameCityApi}/${user}/load/procedimentosRegistros'; final response = await http.get(Uri.parse(url)); final map = json.decode(response.body); return map; } - Future loadCID(ArgsLoadInitModel args)async{ + Future loadCID(urlAPI,mode,nameCityApi,user)async{ // http://192.168.0.42:8010/api/atb/desenvolvimento/corumbatai/admin/load/cid - final url = '${args.urlAPI}${args.mode}/${args.model.nameCityApi}/${args.user}/load/cid'; + final url = '${urlAPI}${mode}/${nameCityApi}/${user}/load/cid'; final response = await http.get(Uri.parse(url)); final map = json.decode(response.body); return map; } - Future loadProcedimentosCID(ArgsLoadInitModel args)async{ + Future loadProcedimentosCID(urlAPI,mode,nameCityApi,user)async{ // http://192.168.0.42:8010/api/atb/desenvolvimento/corumbatai/admin/load/procedimentosCID - final url = '${args.urlAPI}${args.mode}/${args.model.nameCityApi}/${args.user}/load/procedimentosCID'; + final url = '${urlAPI}${mode}/${nameCityApi}/${user}/load/procedimentosCID'; final response = await http.get(Uri.parse(url)); final map = json.decode(response.body); return map; } - Future loadCBO(ArgsLoadInitModel args)async{ + Future loadCBO(urlAPI,mode,nameCityApi,user)async{ // http://192.168.0.42:8010/api/atb/desenvolvimento/corumbatai/admin/load/cbo - final url = '${args.urlAPI}${args.mode}/${args.model.nameCityApi}/${args.user}/load/cbo'; + final url = '${urlAPI}${mode}/${nameCityApi}/${user}/load/cbo'; final response = await http.get(Uri.parse(url)); final map = json.decode(response.body); return map; } - Future loadProcedimentosCBO(ArgsLoadInitModel args)async{ + Future loadProcedimentosCBO(urlAPI,mode,nameCityApi,user)async{ // http://192.168.0.42:8010/api/atb/desenvolvimento/corumbatai/admin/load/procedimentosCBO - final url = '${args.urlAPI}${args.mode}/${args.model.nameCityApi}/${args.user}/load/procedimentosCBO'; + final url = '${urlAPI}${mode}/${nameCityApi}/${user}/load/procedimentosCBO'; final response = await http.get(Uri.parse(url)); final map = json.decode(response.body); return map; } - Future loadCIAP(ArgsLoadInitModel args)async{ + Future loadCIAP(urlAPI,mode,nameCityApi,user)async{ // http://192.168.0.42:8010/api/atb/desenvolvimento/corumbatai/admin/load/ciap - final url = '${args.urlAPI}${args.mode}/${args.model.nameCityApi}/${args.user}/load/ciap'; + final url = '${urlAPI}${mode}/${nameCityApi}/${user}/load/ciap'; final response = await http.get(Uri.parse(url)); final map = json.decode(response.body); return map; } - Future loadMunicipios(ArgsLoadInitModel args)async{ + Future loadMunicipios(urlAPI,mode,nameCityApi,user)async{ // http://192.168.0.42:8010/api/atb/desenvolvimento/corumbatai/admin/load/municipios - final url = '${args.urlAPI}${args.mode}/${args.model.nameCityApi}/${args.user}/load/municipios'; + final url = '${urlAPI}${mode}/${nameCityApi}/${user}/load/municipios'; final response = await http.get(Uri.parse(url)); final map = json.decode(response.body); return map; } - Future loadEquipes(ArgsLoadInitModel args)async{ + Future loadEquipes(urlAPI,mode,nameCityApi,user)async{ // http://192.168.0.42:8010/api/atb/desenvolvimento/corumbatai/admin/load/equipes // https://app0.rkmsistemas.com.br/api/atb/homologacao/cabreuva/admin/load/equipes - final url = '${args.urlAPI}${args.mode}/${args.model.nameCityApi}/${args.user}/load/equipes'; + final url = '${urlAPI}${mode}/${nameCityApi}/${user}/load/equipes'; final response = await http.get(Uri.parse(url)); final map = json.decode(response.body); return map; } - Future loadEquipeComponentes(ArgsLoadInitModel args)async{ + Future loadEquipeComponentes(urlAPI,mode,nameCityApi,user)async{ // http://192.168.0.42:8010/api/atb/desenvolvimento/corumbatai/admin/load/equipeComponentes - final url = '${args.urlAPI}${args.mode}/${args.model.nameCityApi}/${args.user}/load/equipeComponentes'; + final url = '${urlAPI}${mode}/${nameCityApi}/${user}/load/equipeComponentes'; final response = await http.get(Uri.parse(url)); final map = json.decode(response.body); return map; } - Future loadCompetencia(ArgsLoadInitModel args)async{ + Future loadCompetencia(urlAPI,mode,nameCityApi,user)async{ // http://192.168.0.42:8010/api/atb/desenvolvimento/corumbatai/admin/load/competencia 'criar uma lista dentro do DB não usar essa api para competencia'; 'competencia sera dinamica com 4 meses para tras exemplo 042023/032023/022023/01/2023'; - final url = '${args.urlAPI}${args.mode}/${args.model.nameCityApi}/${args.user}/load/competencia'; + final url = '${urlAPI}${mode}/${nameCityApi}/${user}/load/competencia'; final response = await http.get(Uri.parse(url)); final map = json.decode(response.body); return map; diff --git a/lib/service/api/api_data_sync.dart b/lib/service/api/api_data_sync.dart index 41c17bb..13f8781 100644 --- a/lib/service/api/api_data_sync.dart +++ b/lib/service/api/api_data_sync.dart @@ -1,77 +1,75 @@ import 'dart:convert'; import 'package:http/http.dart' as http; -import '../../models/args_load_init_model.dart'; -import '../shared_preferences/shared_preferences_service.dart'; class ApiDataSync{ - Future syncPerm(ArgsLoadInitModel args)async{ + Future syncPerm(urlAPI,mode,nameCityApi,user)async{ //http://192.168.0.42:8010/api/atb/desenvolvimento/corumbatai/sync/perm/admin - final url = '${args.urlAPI}${args.mode}/${args.model.nameCityApi}/sync/perm/${args.user}'; + final url = '${urlAPI}${mode}/${nameCityApi}/sync/perm/${user}'; // final url = 'http://192.168.0.42:8010/api/atb/desenvolvimento/corumbatai/load/perm/admin'; final response = await http.get(Uri.parse(url)); final map = json.decode(response.body); // print(map); return map; } - Future syncBairros(ArgsLoadInitModel args)async{ + Future syncBairros(urlAPI,mode,nameCityApi,user)async{ // http://192.168.0.42:8010/api/atb/desenvolvimento/corumbatai/admin/sync/bairros - final url = '${args.urlAPI}${args.mode}/${args.model.nameCityApi}/${args.user}/sync/bairros'; + final url = '${urlAPI}${mode}/${nameCityApi}/${user}/sync/bairros'; final response = await http.get(Uri.parse(url)); final map = json.decode(response.body); return map; } - Future syncTiposLogradouros(ArgsLoadInitModel args)async{ + Future syncTiposLogradouros(urlAPI,mode,nameCityApi,user)async{ // http://192.168.0.42:8010/api/atb/desenvolvimento/corumbatai/admin/sync/tiposLogradouros - final url = '${args.urlAPI}${args.mode}/${args.model.nameCityApi}/${args.user}/sync/tiposLogradouros'; + final url = '${urlAPI}${mode}/${nameCityApi}/${user}/sync/tiposLogradouros'; final response = await http.get(Uri.parse(url)); final map = json.decode(response.body); return map; } - Future syncLogradouros(ArgsLoadInitModel args)async{ + Future syncLogradouros(urlAPI,mode,nameCityApi,user)async{ // http://192.168.0.42:8010/api/atb/desenvolvimento/corumbatai/admin/sync/logradouros - final url = '${args.urlAPI}${args.mode}/${args.model.nameCityApi}/${args.user}/sync/logradouros'; + final url = '${urlAPI}${mode}/${nameCityApi}/${user}/sync/logradouros'; final response = await http.get(Uri.parse(url)); final map = json.decode(response.body); return map; } - Future syncLoteamentos(ArgsLoadInitModel args)async{ + Future syncLoteamentos(urlAPI,mode,nameCityApi,user)async{ // http://192.168.0.42:8010/api/atb/desenvolvimento/corumbatai/admin/sync/loteamentos - final url = '${args.urlAPI}${args.mode}/${args.model.nameCityApi}/${args.user}/sync/loteamentos'; + final url = '${urlAPI}${mode}/${nameCityApi}/${user}/sync/loteamentos'; final response = await http.get(Uri.parse(url)); final map = json.decode(response.body); return map; } - Future syncProfissionais(ArgsLoadInitModel args,String idUnidade)async{ + Future syncProfissionais(urlAPI,mode,nameCityApi,user,idUnidade)async{ // http://192.168.0.42:8010/api/atb/desenvolvimento/corumbatai/admin/sync/3/profissionais - final url = '${args.urlAPI}${args.mode}/${args.model.nameCityApi}/${args.user}/sync/${idUnidade}/profissionais'; + final url = '${urlAPI}${mode}/${nameCityApi}/${user}/sync/${idUnidade}/profissionais'; final response = await http.get(Uri.parse(url)); final map = json.decode(response.body); return map; } - Future syncProfissionaisCBOs(ArgsLoadInitModel args,String idUnidade)async{ + Future syncProfissionaisCBOs(urlAPI,mode,nameCityApi,user,idUnidade)async{ // http://192.168.0.42:8010/api/atb/desenvolvimento/corumbatai/admin/sync/3/profissionaisCBOs - final url = '${args.urlAPI}${args.mode}/${args.model.nameCityApi}/${args.user}/sync/${idUnidade}/profissionaisCBOs'; + final url = '${urlAPI}${mode}/${nameCityApi}/${user}/sync/${idUnidade}/profissionaisCBOs'; final response = await http.get(Uri.parse(url)); final map = json.decode(response.body); return map; } - Future syncCidadaos(ArgsLoadInitModel args,String idUnidade,String area, String microarea, bool foraArea)async{ + Future syncCidadaos(urlAPI,mode,nameCityApi,user,idUnidade,area,microarea,foraArea)async{ // http://192.168.0.42:8010/api/atb/desenvolvimento/corumbatai/admin/sync/3/cidadaos/1/1/true - final url = '${args.urlAPI}${args.mode}/${args.model.nameCityApi}/${args.user}/sync/${idUnidade}/cidadaos/$area/$microarea/$foraArea'; + final url = '${urlAPI}${mode}/${nameCityApi}/${user}/sync/${idUnidade}/cidadaos/$area/$microarea/$foraArea'; final response = await http.get(Uri.parse(url)); final map = json.decode(response.body); return map; } - Future syncCadastrosDomiciliares(ArgsLoadInitModel args,String idUnidade,String area, String microarea, bool foraArea)async{ + Future syncCadastrosDomiciliares(urlAPI,mode,nameCityApi,user,idUnidade,area,microarea,foraArea)async{ // http://192.168.0.42:8010/api/atb/desenvolvimento/corumbatai/admin/sync/3/cadastrosDomiciliares/1/1/true - final url = '${args.urlAPI}${args.mode}/${args.model.nameCityApi}/${args.user}/sync/${idUnidade}/cadastrosDomiciliares/$area/$microarea/$foraArea'; + final url = '${urlAPI}${mode}/${nameCityApi}/${user}/sync/${idUnidade}/cadastrosDomiciliares/$area/$microarea/$foraArea'; final response = await http.get(Uri.parse(url)); final map = json.decode(response.body); return map; } - Future syncCadastrosIndividuais(ArgsLoadInitModel args,String idUnidade,String area, String microarea, bool foraArea)async{ + Future syncCadastrosIndividuais(urlAPI,mode,nameCityApi,user,idUnidade,area,microarea,foraArea)async{ // http://192.168.0.42:8010/api/atb/desenvolvimento/corumbatai/admin/sync/3/cadastrosIndividuais/1/1/true - final url = '${args.urlAPI}${args.mode}/${args.model.nameCityApi}/${args.user}/sync/${idUnidade}/cadastrosIndividuais/$area/$microarea/$foraArea'; + final url = '${urlAPI}${mode}/${nameCityApi}/${user}/sync/${idUnidade}/cadastrosIndividuais/$area/$microarea/$foraArea'; final response = await http.get(Uri.parse(url)); final map = json.decode(response.body); return map; diff --git a/lib/service/db/db_querys.dart b/lib/service/db/db_querys.dart new file mode 100644 index 0000000..2507af4 --- /dev/null +++ b/lib/service/db/db_querys.dart @@ -0,0 +1,36 @@ +import 'package:rkm/service/db/db_sqlite_load.dart'; +import 'package:sqflite/sqflite.dart'; + +class DBQuerys{ + duplicidadeCNS(String CNS)async{ + // 707806656421614 JÁ EXISTE + // String teste = '707806656421614'; + Database db = await DbSqliteLoad().intialDB(); + // print(await db.rawQuery('SELECT * FROM CIDADAOS WHERE CNS=$teste')); + List list = await db.rawQuery('SELECT * FROM CIDADAOS WHERE CNS = $CNS'); + return list; + } + duplicidadeCPF(numCPF)async{ + // 11992420475 já existe + String teste = '11992420475'; + Database db = await DbSqliteLoad().intialDB(); + // print(await db.rawQuery('SELECT CPF FROM CIDADAOS')); + List list = await db.rawQuery("SELECT * FROM CIDADAOS WHERE CPF = $numCPF"); + // List list = await db.rawQuery("SELECT * FROM CIDADAOS WHERE CPF = $teste"); + return list; + } + buscaBairro(nomeBairro)async{ + Database db = await DbSqliteLoad().intialDB(); + List list = await db.rawQuery("SELECT * FROM BAIRROS WHERE NO_BAIRRO = '$nomeBairro'"); + // print(await db.rawQuery('SELECT NO_BAIRRO FROM BAIRROS')); + // print(list[0]['ID_BAIRRO']); + return list[0]['ID_BAIRRO'].toString(); + } + buscaTipoLogradouro(tipo)async{ + Database db = await DbSqliteLoad().intialDB(); + List list = await db.rawQuery("SELECT * FROM LOGRADOUROS_TIPOS WHERE NO_LOGR_TIPO = '$tipo'"); + // print(await db.rawQuery('SELECT NO_BAIRRO FROM BAIRROS')); + print(list[0]['ID_LOGR_TIPO']); + return list[0]['ID_LOGR_TIPO'].toString(); + } +} \ No newline at end of file diff --git a/lib/service/db/db_sqlite_load.dart b/lib/service/db/db_sqlite_load.dart index 0c832cd..711cc25 100644 --- a/lib/service/db/db_sqlite_load.dart +++ b/lib/service/db/db_sqlite_load.dart @@ -1,4 +1,3 @@ -import 'package:rkm/models/args_load_init_model.dart'; import 'package:sqflite/sqflite.dart'; import 'package:path/path.dart'; @@ -61,6 +60,7 @@ class DbSqliteLoad{ db.execute('CREATE TABLE IF NOT EXISTS VISITAS_DOMICILIARES (ID_VISITA_DOMICILIAR INTEGER PRIMARY KEY AUTOINCREMENT, ID_CIDADAO INTEGER, CD_USUARIO_SUS TEXT, DT_ATENDIMENTO TEXT, TURNO INTEGER, TIPO_IMOVEL INTEGER, VISITA_ACOMPANHADA INTEGER, DESFECHO INTEGER, PESO TEXT, ALTURA TEXT, ID_PROFISSIONAL INTEGER, CBO_PROFISSIONAL TEXT, INE_PROFISSIONAL TEXT, CNES_UNIDADE TEXT, ID_UNIDADE INTEGER, ID_EQUIPE INTEGER, COMPLEMENTO TEXT, SINCRONIZADO TEXT);'); db.execute('CREATE TABLE IF NOT EXISTS VISITAS_DOMICILIARES_COMPL (ID_VISITA_DOMICILIAR INTEGER, ID_VISITA_DOM_TIPO INTEGER, ID_VISITA_COMPLEMENTO INTEGER);'); db.execute('CREATE TABLE IF NOT EXISTS VISITAS_DOMICILIARES_PROC (ID_VISITA_DOMICILIAR INTEGER, COD_PROC_SIGTAP TEXT);'); + db.execute('CREATE TABLE IF NOT EXISTS ARGS (ID_USER INTEGER, MODE TEXT, USER TEXT, PASSWORD TEXT, URLAPI TEXT, COD_CITY INTEGER, NAME_CITY_API TEXT, NAME_CITY_FRONT TEXT, COD_STATE TEXT, COD_IBGE INTEGER);'); } ); return db; @@ -105,12 +105,42 @@ class DbSqliteLoad{ 'DELETE FROM VISITAS_DOMICILIARES;', 'DELETE FROM VISITAS_DOMICILIARES_COMPL;', 'DELETE FROM VISITAS_DOMICILIARES_PROC;', + 'DELETE FROM ARGS;', ]; Database db = await intialDB(); for(int i=0;querys.length>i;i++){ db.execute(querys[i]); } } + + Future saveArgs(mode,user,password,urlAPI,codCity,nameCityApi,nameCityFront,codState,codCityIbge)async{ + Database db = await intialDB(); + Map row = { + 'ID_USER' : 1, + 'MODE' : mode, + 'USER' : user, + 'PASSWORD' : password, + 'URLAPI' : urlAPI, + 'COD_CITY' : codCity, + 'NAME_CITY_API' : nameCityApi, + 'NAME_CITY_FRONT': nameCityFront, + 'COD_STATE' : codState, + 'COD_IBGE' : codCityIbge, + }; + int id = await db.insert('ARGS', row); + return db; + } + + Future updateArgs(mode,user,password)async{ + Database db = await intialDB(); + var query = "UPDATE ARGS SET USER = '$user' WHERE ID_USER = 1;"; + var query1 = "UPDATE ARGS SET PASSWORD = '$password' WHERE ID_USER = 1;"; + await db.execute(query); + await db.execute(query1); + // print(await db.query('ARGS')); + return db; + } + Future saveUnidadesDB(var value)async{ Database db = await intialDB(); for(int i=0;value.length > i;i++){ @@ -289,7 +319,7 @@ class DbSqliteLoad{ int id = await db.insert('PROFISSIONAIS_EQUIPE', row); // print('id increment $id PROCEDIMENTOS_SIGTAP_REGISTRO'); } - print(await db.query('PROFISSIONAIS_EQUIPE')); + // print(await db.query('PROFISSIONAIS_EQUIPE')); return db; } } \ No newline at end of file diff --git a/lib/service/db/db_sqlite_sync.dart b/lib/service/db/db_sqlite_sync.dart index 4c448a5..58d2725 100644 --- a/lib/service/db/db_sqlite_sync.dart +++ b/lib/service/db/db_sqlite_sync.dart @@ -1,13 +1,11 @@ import 'package:rkm/service/db/db_sqlite_load.dart'; import 'package:sqflite/sqflite.dart'; -import '../../models/args_load_init_model.dart'; - class DbSqliteSync{ Future deleteSync()async{ var querys = [ - "UPDATE CONTROLE_INTERNO SET SYNC_UNIDADE = NULL, UNIDADE_SYNC = NULL, NOME_UNIDADE = NULL WHERE rowid = 1;", + "DELETE FROM CONTROLE_INTERNO", "DELETE FROM BAIRROS;", "DELETE FROM LOGRADOUROS_TIPOS;", "DELETE FROM LOGRADOUROS_ENDERECOS;", @@ -62,13 +60,13 @@ class DbSqliteSync{ for(int i=0;value.length > i;i++){ Map row = { 'ID_LOGR_ENDERECO' : value[i]['idLogradouro'], - 'ID_LOGR_TIPO' : value[i]['descLogradouro'], - 'DESC_LOGR_ENDERECO' : value[i]['idTipoLogradouro'], + 'ID_LOGR_TIPO' : value[i]['idTipoLogradouro'], + 'DESC_LOGR_ENDERECO' : value[i]['descLogradouro'], 'ID_BAIRRO' : value[i]['idBairro'], }; int id = await db.insert('LOGRADOUROS_ENDERECOS', row); // print('id increment $id PROCEDIMENTOS_SIGTAP_REGISTRO'); - // print(await db.query('LOGRADOUROS_ENDERECOS')); + print(await db.query('LOGRADOUROS_ENDERECOS')); } return db; } @@ -121,7 +119,7 @@ class DbSqliteSync{ } return db; } - Future insertCidadaos(var value)async{ + Future insertCidadaos(var value,String type)async{ Database db = await DbSqliteLoad().intialDB(); // CIDADAOS (ID_CIDADAO,CD_USUARIO_SUS,NOME_CIDADAO,NOME_SOCIAL,SEXO,DT_NASCIMENTO,ID_ESTADO_CIVIL,NOME_CONJUGE,NACIONALIDADE,ID_MUNICIPIO_NASC,NO_MUNICIPIO_NASC,ESTADO_UF_NASC // ID_ETNIA,ID_ESCOLARIDADE,ID_DEFICIENCIA,NOME_MAE,DESCONHECE_MAE,NOME_PAI,DESCONHECE_PAI,ID_UNIDADE,NUM_PRONTUARIO,NUM_PRONTUARIO_PROV,CLASSIFICACAO,CLASSIFICACAO_SUB, @@ -141,92 +139,97 @@ class DbSqliteSync{ '"nrLivroCertidao":null,"nrFolhaCertidao":null,"noTermoCertidao":"","dtEmissaoCertidao":null,"nrCtps":null,"nrSerieCtps":null,"cdSiglaUfCtps":"--","nrPispasep":"",' '"cartaoMunicipalRetirado":"N","nrNis":"","rendaMensal":null,"profissao":"","dtObito":null,"bloqueio":"0","origem":"S","cdDomicilio":1838,"atendimentos":0,' '"idUsuarioCadastro":null'; - for(int i=0;value.length > i;i++){ - Map row = { - 'ID_CIDADAO' : value[i]['idCidadao'], - 'CD_USUARIO_SUS' : value[i]['cdUsuarioSus'], - 'NOME_CIDADAO' : value[i]['noUsuario'], - 'NOME_SOCIAL' : value[i]['nomeSocial'], - 'SEXO' : value[i]['inSexo'], - 'DT_NASCIMENTO' : value[i]['dtNascimento'], - 'ID_ESTADO_CIVIL' : value[i]['inSituacaoConjugal'], - 'ID_ESTADO_CIVIL' : value[i]['inSituacaoConjugal'], - 'NOME_CONJUGE' : value[i]['noConjugue'], - 'NACIONALIDADE' : value[i]['nacionalidade'], - 'ID_MUNICIPIO_NASC' : value[i]['cdMunicipioNasc'], - 'NO_MUNICIPIO_NASC' : value[i]['noMunicipioNasc'], - 'ESTADO_UF_NASC' : value[i]['cdEstado'], - 'ID_ETNIA' : value[i]['cdEtnia'], - 'ID_ESCOLARIDADE' : value[i]['cdUsuarioEscolaridade'], - 'ID_DEFICIENCIA' : value[i]['nrDeficiencia'], - 'NOME_MAE' : value[i]['noMae'], - 'DESCONHECE_MAE' : value[i]['desconheceMae'], - 'NOME_PAI' : value[i]['noPai'], - 'DESCONHECE_PAI' : value[i]['desconhecePai'], - 'DESCONHECE_PAI' : value[i]['desconhecePai'], - 'ID_UNIDADE' : value[i]['nrUnidade'], - 'NUM_PRONTUARIO' : value[i]['nrProntuario'], - 'NUM_PRONTUARIO_PROV' : value[i]['nrProntuarioProvisorio'], - 'CLASSIFICACAO' : value[i]['classificacao'], - 'CLASSIFICACAO_SUB' : '', - 'NUM_FAMILIA' : value[i]['nrFamilia'], - 'ID_PAIS_RESID' : value[i]['idPaisResid'], - 'ID_MUNICIPIO_RESID' : value[i]['cdMunicipioResid'], - 'NO_MUNICIPIO_RESID' : value[i]['noMunicipioResid'], - 'ESTADO_UF_RESID' : value[i]['cdEstadoResid'], - 'CODIGO_IBGE_RESID' : value[i]['muniCdCodIbgeResid'], - 'NO_BAIRRO_LOGR' : value[i]['noBairro'], - 'ID_LOGR_TIPO' : value[i]['idTipoLogradouro'], - 'NOME_LOGR' : value[i]['noLogradouro'], - 'CEP_LOGR' : value[i]['cdCep'], - 'NUMERO_LOGR' : value[i]['nrLogradouro'], - 'LOTEAMENTO_LOGR' : value[i]['loteamento'], - 'COMPL_LOGR' : value[i]['noComplLogradouro'], - 'PONTO_REFERENCIA' : value[i]['pontoReferencia'], - 'ZONA_LOGR' : value[i]['zona'], - 'DDD_TELEFONE' : value[i]['nrDddTelefone'], - 'NUM_TELEFONE' : value[i]['nrCelular'], - 'DDD_RECADO' : value[i]['nrDddRecado'], - 'NUM_RECADO' : value[i]['nrRecado'], - 'EMAIL' : value[i]['email'], - 'OBSERVACOES' : value[i]['observacao'], - 'CPF' : value[i]['nrCpf'], - 'CNS' : value[i]['nrCns'], - 'TITULO_ELEITOR' : value[i]['tituloEleitor'], - 'RG_NUMERO' : value[i]['nrIdentidade'], - 'RG_COMPLEMENTO' : value[i]['noComplIdentidade'], - 'RG_UF' : value[i]['cdSiglaUfIdentidade'], - 'RG_ORGAO' : value[i]['cdOrgaoEmissorIdentidade'], - 'RG_DATA_EMISSAO' : value[i]['dtEmissaoIdentidade'], - 'TIPO_CERTIDAO' : value[i]['cdTipoCertidao'], - 'NUM_CERTIDAO' : value[i]['nrCertidaoNova'], - 'CARTORIO_CERTIDAO' : value[i]['noCartorioCertidao'], - 'LIVRO_CERTIDAO' : value[i]['nrLivroCertidao'], - 'FOLHA_CERTIDAO' : value[i]['nrFolhaCertidao'], - 'TERMO_CERTIDAO' : value[i]['noTermoCertidao'], - 'DT_EMISSAO_CERTIDAO' : value[i]['dtEmissaoCertidao'], - 'NUM_CTPS' : value[i]['nrCtps'], - 'NUM_SERIE_CTPS' : value[i]['nrSerieCtps'], - 'ESTADO_UF_CTPS' : value[i]['cdSiglaUfCtps'], - 'NUM_PIS_PASEP' : value[i]['nrPispasep'], - 'FL_RETIROU_CARTAO' : value[i]['cartaoMunicipalRetirado'], - 'NUM_NIS' : value[i]['nrNis'], - 'NUM_PROT_CROSS' : '', - 'RENDA_MENSAL' : value[i]['rendaMensal'], - 'PROFISSAO' : value[i]['profissao'], - 'DT_OBITO' : value[i]['dtObito'], - 'DECLARACAO_OBITO' : '', - 'BLOQUEIO' : value[i]['bloqueio'], - 'ORIGEM' : value[i]['origem'], - 'DT_HORA_CADASTRO' : value[i]['profissao'], - 'ID_USUARIO_CADASTRO' : value[i]['idUsuarioCadastro'], - 'ID_DOMICILIO' : value[i]['cdDomicilio'], - 'ATENDIMENTOS' : value[i]['atendimentos'], - 'SINCRONIZADO' : '', - }; - int id = await db.insert('CIDADAOS', row); - // print('id increment $id PROCEDIMENTOS_SIGTAP_REGISTRO'); - // print(await db.query('CIDADAOS')); + + if(type=='sync'){ + for(int i=0;value.length > i;i++){ + Map row = { + 'ID_CIDADAO' : value[i]['idCidadao'], + 'CD_USUARIO_SUS' : value[i]['cdUsuarioSus'], + 'NOME_CIDADAO' : value[i]['noUsuario'], + 'NOME_SOCIAL' : value[i]['nomeSocial'], + 'SEXO' : value[i]['inSexo'], + 'DT_NASCIMENTO' : value[i]['dtNascimento'], + 'ID_ESTADO_CIVIL' : value[i]['inSituacaoConjugal'], + 'ID_ESTADO_CIVIL' : value[i]['inSituacaoConjugal'], + 'NOME_CONJUGE' : value[i]['noConjugue'], + 'NACIONALIDADE' : value[i]['nacionalidade'], + 'ID_MUNICIPIO_NASC' : value[i]['cdMunicipioNasc'], + 'NO_MUNICIPIO_NASC' : value[i]['noMunicipioNasc'], + 'ESTADO_UF_NASC' : value[i]['cdEstado'], + 'ID_ETNIA' : value[i]['cdEtnia'], + 'ID_ESCOLARIDADE' : value[i]['cdUsuarioEscolaridade'], + 'ID_DEFICIENCIA' : value[i]['nrDeficiencia'], + 'NOME_MAE' : value[i]['noMae'], + 'DESCONHECE_MAE' : value[i]['desconheceMae'], + 'NOME_PAI' : value[i]['noPai'], + 'DESCONHECE_PAI' : value[i]['desconhecePai'], + 'ID_UNIDADE' : value[i]['nrUnidade'], + 'NUM_PRONTUARIO' : value[i]['nrProntuario'], + 'NUM_PRONTUARIO_PROV' : value[i]['nrProntuarioProvisorio'], + 'CLASSIFICACAO' : value[i]['classificacao'], + 'CLASSIFICACAO_SUB' : '', + 'NUM_FAMILIA' : value[i]['nrFamilia'], + 'ID_PAIS_RESID' : value[i]['idPaisResid'], + 'ID_MUNICIPIO_RESID' : value[i]['cdMunicipioResid'], + 'NO_MUNICIPIO_RESID' : value[i]['noMunicipioResid'], + 'ESTADO_UF_RESID' : value[i]['cdEstadoResid'], + 'CODIGO_IBGE_RESID' : value[i]['muniCdCodIbgeResid'], + 'NO_BAIRRO_LOGR' : value[i]['noBairro'], + 'ID_LOGR_TIPO' : value[i]['idTipoLogradouro'], + 'NOME_LOGR' : value[i]['noLogradouro'], + 'CEP_LOGR' : value[i]['cdCep'], + 'NUMERO_LOGR' : value[i]['nrLogradouro'], + 'LOTEAMENTO_LOGR' : value[i]['loteamento'], + 'COMPL_LOGR' : value[i]['noComplLogradouro'], + 'PONTO_REFERENCIA' : value[i]['pontoReferencia'], + 'ZONA_LOGR' : value[i]['zona'], + 'DDD_TELEFONE' : value[i]['nrDddTelefone'], + 'NUM_TELEFONE' : value[i]['nrCelular'], + 'DDD_RECADO' : value[i]['nrDddRecado'], + 'NUM_RECADO' : value[i]['nrRecado'], + 'EMAIL' : value[i]['email'], + 'OBSERVACOES' : value[i]['observacao'], + 'CPF' : value[i]['nrCpf'], + 'CNS' : value[i]['nrCns'], + 'TITULO_ELEITOR' : value[i]['tituloEleitor'], + 'RG_NUMERO' : value[i]['nrIdentidade'], + 'RG_COMPLEMENTO' : value[i]['noComplIdentidade'], + 'RG_UF' : value[i]['cdSiglaUfIdentidade'], + 'RG_ORGAO' : value[i]['cdOrgaoEmissorIdentidade'], + 'RG_DATA_EMISSAO' : value[i]['dtEmissaoIdentidade'], + 'TIPO_CERTIDAO' : value[i]['cdTipoCertidao'], + 'NUM_CERTIDAO' : value[i]['nrCertidaoNova'], + 'CARTORIO_CERTIDAO' : value[i]['noCartorioCertidao'], + 'LIVRO_CERTIDAO' : value[i]['nrLivroCertidao'], + 'FOLHA_CERTIDAO' : value[i]['nrFolhaCertidao'], + 'TERMO_CERTIDAO' : value[i]['noTermoCertidao'], + 'DT_EMISSAO_CERTIDAO' : value[i]['dtEmissaoCertidao'], + 'NUM_CTPS' : value[i]['nrCtps'], + 'NUM_SERIE_CTPS' : value[i]['nrSerieCtps'], + 'ESTADO_UF_CTPS' : value[i]['cdSiglaUfCtps'], + 'NUM_PIS_PASEP' : value[i]['nrPispasep'], + 'FL_RETIROU_CARTAO' : value[i]['cartaoMunicipalRetirado'], + 'NUM_NIS' : value[i]['nrNis'], + 'NUM_PROT_CROSS' : '', + 'RENDA_MENSAL' : value[i]['rendaMensal'], + 'PROFISSAO' : value[i]['profissao'], + 'DT_OBITO' : value[i]['dtObito'], + 'DECLARACAO_OBITO' : '', + 'BLOQUEIO' : value[i]['bloqueio'], + 'ORIGEM' : value[i]['origem'], + 'DT_HORA_CADASTRO' : value[i]['profissao'], + 'ID_USUARIO_CADASTRO' : value[i]['idUsuarioCadastro'], + 'ID_DOMICILIO' : value[i]['cdDomicilio'], + 'ATENDIMENTOS' : value[i]['atendimentos'], + 'SINCRONIZADO' : '', + }; + int id = await db.insert('CIDADAOS', row); + // print('id increment $id PROCEDIMENTOS_SIGTAP_REGISTRO'); + // print(await db.query('CIDADAOS')); + } + }else{ + int id = await db.insert('CIDADAOS', value); + print('novo id $id'); } return db; } @@ -414,7 +417,7 @@ class DbSqliteSync{ } return db; } - Future saveSync(ArgsLoadInitModel args,idUnidade,area,microarea)async{ + Future saveSync(codCity,codState,urlAPI,mode,nameCityApi,nameCityFront,codCityIbge,user,idUnidade,nomeUnidade,area,microarea)async{ Database db = await DbSqliteLoad().intialDB(); //refatorar cidade_load e nome_cidade 'parameters = [{"carga_inicial": 1, "cidade_load": cidade, "nome_cidade": vm.nomeCidade[cidade], "cidade_id": cidadeID, "estado": estado, "ibge": ibge, "ambiente": ambiente, "competencia": competencia.replace(/\D/g, '')}]'; @@ -422,21 +425,20 @@ class DbSqliteSync{ Map row = { 'CARGA_INICIAL' : 1, - 'CIDADE_LOAD' : args.model.nameCityApi, - 'NOME_CIDADE' : args.model.nameCityFront, - 'ID_MUNICIPIO' : args.model.codCity, - 'UF_ESTADO' : args.model.codState, - 'CODIGO_IBGE' : args.model.codCityIbge, - 'AMBIENTE' : args.mode, + 'CIDADE_LOAD' : nameCityApi, + 'NOME_CIDADE' : nameCityFront, + 'ID_MUNICIPIO' : codCity, + 'UF_ESTADO' : codState, + 'CODIGO_IBGE' : codCityIbge, + 'AMBIENTE' : mode, 'SYNC_UNIDADE' : idUnidade, - 'NOME_UNIDADE' : args.model.nameCityFront, + 'NOME_UNIDADE' : nomeUnidade, 'AREA' : area, 'MICROAREA' : microarea, 'ULTIMA_SINCRONIZACAO' : DateTime.now().toString(), 'COMPETENCIA' : '${DateTime.now().year}${DateTime.now().month<10?'0':''}${DateTime.now().month-1}', }; int id = await db.insert('CONTROLE_INTERNO', row); - print(await db.query('CONTROLE_INTERNO')); return db; } } \ No newline at end of file diff --git a/lib/service/shared_preferences/shared_preferences_service.dart b/lib/service/shared_preferences/shared_preferences_service.dart index 9b47fe5..4c28142 100644 --- a/lib/service/shared_preferences/shared_preferences_service.dart +++ b/lib/service/shared_preferences/shared_preferences_service.dart @@ -7,10 +7,11 @@ class PrefService{ SharedPreferences _preferences = await SharedPreferences.getInstance(); _preferences.setString('idUsuario', idUsuario); } - Future createCacheidUnidade(String idUnidade)async{ + Future createCacheUnidade(String idUnidade, String nomeUnidade)async{ SharedPreferences _preferences = await SharedPreferences.getInstance(); _preferences.setString('idUnidade', idUnidade); + _preferences.setString('nomeUnidade', nomeUnidade); } Future createCacheSync(String area,bool foraArea)async{ @@ -33,10 +34,15 @@ class PrefService{ var idUsuario = _preferences.getString('idUsuario'); return idUsuario; } - Future readCacheIdUnidade(String idUnidade) async{ + Future readCacheUnidade(String idUnidade) async{ SharedPreferences _preferences = await SharedPreferences.getInstance(); var idUnidade = _preferences.getString('idUnidade'); - return idUnidade; + var nomeUnidade = _preferences.getString('nomeUnidade'); + List list =[ + idUnidade, + nomeUnidade, + ]; + return list; } Future readCacheModel(String user,String password,String city,String mode) async{ SharedPreferences _preferences = await SharedPreferences.getInstance(); diff --git a/lib/utils/const_variable.dart b/lib/utils/const_variable.dart index 11ccc6e..86012f1 100644 --- a/lib/utils/const_variable.dart +++ b/lib/utils/const_variable.dart @@ -8,6 +8,10 @@ class ConstVariable{ EdgeInsetsGeometry paddingWidth = EdgeInsets.symmetric(horizontal: 10); double fontSizeInput = 15; double fontSizeTitleAppBar = 20; + List RGUF = ['AC','AI','AL','AM','AN','AP','AS','BA','BY','CA','CB','CE','CH','CN','CO','DC','DF','ES','GD','GO','GU', + 'HU','IL','LA','LE','LI','LO','LT','MA','MG','MO','MS','MT','NB','NE','NW','NT','NY','OH','OU','PA','PB', + 'PE','PI','PO','PR','QH','RJ','RM','RN','RO','RR','RN','RO','RR','RS','SC','SE','SF','SJ','SP','TA','TO', + 'VC','XX','ZU']; List itensProceduresStart = [ 'ATENDIMENTO INDIVIDUAL', 'VISTA DOMICILIAR' diff --git a/lib/utils/routes.dart b/lib/utils/routes.dart index 74bf88a..33850a8 100644 --- a/lib/utils/routes.dart +++ b/lib/utils/routes.dart @@ -21,7 +21,7 @@ import '../screens/sinc_data_screen.dart'; var routes = { '/home': (context) => HomeScreen(), '/login_load': (context) => LoginLoadScreen(), - '/register_citizen': (context) => RegisterCitizenScreen(), + '/register_citizen': (context) => RegisterCitizenScreen(select: '',), '/attendance_list': (context) => AttendanceListScreen(), '/about': (context) => AboutScreen(), '/main_procedures': (context) => MainProceduresScreen(), diff --git a/lib/widgets/alert_dialog_search_stateful.dart b/lib/widgets/alert_dialog_search_stateful.dart new file mode 100644 index 0000000..90f4790 --- /dev/null +++ b/lib/widgets/alert_dialog_search_stateful.dart @@ -0,0 +1,120 @@ +import 'package:flutter/material.dart'; +import 'package:rkm/widgets/text_default.dart'; +import 'package:sqflite/sqflite.dart'; +import '../screens/registers_citizen/register_citizen_screen.dart'; +import '../service/db/db_sqlite_load.dart'; +import '../utils/color_palette.dart'; +import 'input_search_text.dart'; + +class AlertDialogSearchStateful extends StatefulWidget { + + @override + State createState() => _AlertDialogSearchStatefulState(); +} + +class _AlertDialogSearchStatefulState extends State { + + List cityDB = []; + List showResultSearchCity = []; + var controller = TextEditingController(); + + _searchCityBirth(){ + searchCity(); + } + 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']}'); + } + searchCity(); + return 'complete'; + } + + searchCity()async{ + if(controller.text.isNotEmpty){ + showResultSearchCity =[]; + for (int i =0;cityDB.length>i;i++) { + String CIDADE = '${cityDB[i]}'; + + if(CIDADE.contains(controller.text.toUpperCase())){ + if(showResultSearchCity.length<10){ + showResultSearchCity.add(cityDB[i]); + } + } + } + setState(() { + print(showResultSearchCity); + }); + }else{ + setState(() { + for(int i = 0;i<10;i++){ + showResultSearchCity.add(cityDB[i]); + } + }); + } + } + + @override + void initState() { + super.initState(); + getCity(); + controller.addListener(_searchCityBirth); + } + + @override + Widget build(BuildContext context) { + + double width = MediaQuery.of(context).size.width; + double height = MediaQuery.of(context).size.height; + + return AlertDialog( + title: InputSearchText( + controller: controller, + width: width*0.3, + hint: 'Buscar...', + color: ColorPalette.titleContainer, + border: false, + ), + content: Container( + padding: EdgeInsets.symmetric(vertical: 10), + width: width*0.8, + child: Container( + width: width*0.8, + height: height*0.8, + 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(() { + controller.text = showResultSearchCity[index]; + Navigator.push( + context, + MaterialPageRoute(builder: (context) => RegisterCitizenScreen(select: controller.text,)), + ); + }); + }, + title: TextDefault( + color: ColorPalette.black54, + text: showResultSearchCity[index], + fontSize: 16, + maxLines: 2, + ), + ), + ); + } + ), + ), + ), + ); + } +} diff --git a/lib/widgets/appbar_default.dart b/lib/widgets/appbar_default.dart index 8d8ce33..a6e7d5f 100644 --- a/lib/widgets/appbar_default.dart +++ b/lib/widgets/appbar_default.dart @@ -1,14 +1,13 @@ import 'package:flutter/material.dart'; -import 'package:rkm/models/args_load_init_model.dart'; import 'package:rkm/widgets/alert_dialog_settings.dart'; -import '../screens/login/sync_login_screen.dart'; +import '../screens/login/login_saved_screen.dart'; import '../utils/color_palette.dart'; import 'icon_button_default.dart'; class AppBarDefault{ @override - PreferredSize appbar(BuildContext context,String title,{ArgsLoadInitModel? args}) { + PreferredSize appbar(BuildContext context,String title) { return PreferredSize( preferredSize: Size.fromHeight(50), child: AppBar( @@ -26,7 +25,7 @@ class AppBarDefault{ onPressed: (){ Navigator.push( context, - MaterialPageRoute(builder: (context) => SyncLoginScreen(args: args!)), + MaterialPageRoute(builder: (context) => LoginSavedScreen(listControl: [])), ); }), ], diff --git a/lib/widgets/error_default.dart b/lib/widgets/error_default.dart new file mode 100644 index 0000000..5ad3aa4 --- /dev/null +++ b/lib/widgets/error_default.dart @@ -0,0 +1,33 @@ +import 'package:flutter/material.dart'; +import 'package:rkm/widgets/text_default.dart'; + +class ErrorDefault extends StatelessWidget { + double widthDefault; + String error; + + ErrorDefault({ + this.widthDefault = 0.7, + this.error = 'Esse campo é obrigatório!' + }); + @override + Widget build(BuildContext context) { + + double height = MediaQuery.of(context).size.height; + double width = MediaQuery.of(context).size.width; + + return Container( + height: 20, + width: width*widthDefault, + child: Column( + children: [ + Divider(color: Colors.red,height: 2,thickness:2), + Container( + height: 15, + width: width*widthDefault, + child: TextDefault(text:error,color: Colors.red,fontSize: 12), + ), + ], + ), + ); + } +} diff --git a/lib/widgets/input_search_text.dart b/lib/widgets/input_search_text.dart index 92fc686..6621321 100644 --- a/lib/widgets/input_search_text.dart +++ b/lib/widgets/input_search_text.dart @@ -9,6 +9,7 @@ class InputSearchText extends StatelessWidget { double width; Color color; bool border; + var onChanged; InputSearchText({ required this.controller, @@ -17,6 +18,7 @@ class InputSearchText extends StatelessWidget { this.hint = '', this.color = ColorPalette.white, this.border = true, + this.onChanged = null }); @override @@ -26,9 +28,10 @@ class InputSearchText extends StatelessWidget { margin: ConstVariable().marginHightInput, width: width, child: TextFormField( + onChanged: onChanged, controller: this.controller, style: TextStyle( - color: ColorPalette.gray, + color: Colors.black, fontSize: this.fontSize, ), decoration: InputDecoration( @@ -37,7 +40,7 @@ class InputSearchText extends StatelessWidget { border: border?OutlineInputBorder():null, hintText: this.hint, hintStyle: TextStyle( - color: ColorPalette.gray, + color: Colors.black, fontSize: this.fontSize, ) ) diff --git a/lib/widgets/input_text.dart b/lib/widgets/input_text.dart index bfccace..3478a9a 100644 --- a/lib/widgets/input_text.dart +++ b/lib/widgets/input_text.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:rkm/utils/color_palette.dart'; +import '../controllers/format_txt.dart'; import '../utils/const_variable.dart'; class InputText extends StatelessWidget { @@ -9,7 +10,6 @@ class InputText extends StatelessWidget { String hint; double width; String label; - String error; bool enable; TextInputType textInputType; int maxLines; @@ -23,7 +23,6 @@ class InputText extends StatelessWidget { this.fontSize = 15.0, this.hint = '', this.label = '', - this.error = '', this.enable = true, this.textInputType = TextInputType.text, this.maxLines = 1, @@ -35,18 +34,15 @@ class InputText extends StatelessWidget { Widget build(BuildContext context) { return Container( color: ColorPalette.white, - margin: ConstVariable().marginHightInput, + margin: EdgeInsets.only(top: 5), width: width, child: TextFormField( keyboardType: textInputType, maxLines: maxLines, onChanged: onChanged, - validator: (value) { - if (value!=null && value!.length==0) { - return error; - } - return null; - }, + inputFormatters: [ + FormatText() + ], obscureText: this.obscure, controller: this.controller, style: TextStyle( diff --git a/lib/widgets/input_with_subtitle.dart b/lib/widgets/input_with_subtitle.dart index df09044..8de37d0 100644 --- a/lib/widgets/input_with_subtitle.dart +++ b/lib/widgets/input_with_subtitle.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:rkm/widgets/text_default.dart'; import '../utils/color_palette.dart'; +import 'error_default.dart'; import 'input_text.dart'; class InputWithSubtitle extends StatelessWidget { @@ -10,8 +11,11 @@ class InputWithSubtitle extends StatelessWidget { String labelInput; double widthSubtitle; double widthInput; + double widthError; var controller; + var onChanged; bool enable; + bool mandatory; TextInputType textInputType; int maxLines; Color colorBorder; @@ -25,9 +29,12 @@ class InputWithSubtitle extends StatelessWidget { required this.widthInput, required this.controller, this.enable = true, + this.mandatory = true, this.textInputType = TextInputType.text, this.maxLines = 1, - this.colorBorder = ColorPalette.black54 + this.colorBorder = ColorPalette.black54, + required this.onChanged, + this.widthError = 0.7 }); @override @@ -49,13 +56,14 @@ class InputWithSubtitle extends StatelessWidget { controller: controller, width: widthInput, hint: hintInput, - error: errorInput, label: labelInput, enable: enable, textInputType: textInputType, maxLines:maxLines, colorBorder: colorBorder, + onChanged: onChanged, ), + controller.text=='' &&(enable&&mandatory)?ErrorDefault(widthDefault: widthError,):Container(), Divider(color: ColorPalette.black54,height: 5,endIndent: 10,) ], ); diff --git a/lib/widgets/subtitle_appbar_citizen.dart b/lib/widgets/subtitle_appbar_citizen.dart new file mode 100644 index 0000000..8230a44 --- /dev/null +++ b/lib/widgets/subtitle_appbar_citizen.dart @@ -0,0 +1,57 @@ +import 'package:flutter/material.dart'; +import 'package:rkm/widgets/text_default.dart'; +import '../screens/registers_citizen/register_citizen_screen.dart'; +import '../screens/registers_citizen/register_home_screen.dart'; +import '../screens/registers_citizen/register_individual_screen.dart'; +import '../utils/color_palette.dart'; + +class SubtitleAppbarCitizen extends StatelessWidget { + int title; + bool edit; + + SubtitleAppbarCitizen({ + required this.title, + this.edit = false + }); + + @override + Widget build(BuildContext context) { + + double heigth = MediaQuery.of(context).size.height; + double width = MediaQuery.of(context).size.width; + + return Container( + color: ColorPalette.white, + width: width, + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + TextButton.icon( + onPressed:edit? ()=> Navigator.push( + context, + MaterialPageRoute(builder: (context) => RegisterCitizenScreen(select: '',)), + ):null, + icon: Icon(Icons.person,color: title==1?Colors.black:ColorPalette.gray,), + label: TextDefault(text: 'Cadastro Cidadão',fontSize: 14,color: title==1?Colors.black:ColorPalette.gray,) + ), + TextButton.icon( + onPressed:edit? ()=> Navigator.push( + context, + MaterialPageRoute(builder: (context) => RegisterIndividualScreen()), + ):null, + icon: Icon(Icons.assignment_outlined,color: title==2?Colors.black:ColorPalette.gray,), + label: TextDefault(text: 'Cadastro Individual',fontSize: 14,color: title==2?Colors.black:ColorPalette.gray,) + ), + TextButton.icon( + onPressed:edit? ()=> Navigator.push( + context, + MaterialPageRoute(builder: (context) => RegisterHomeScreen()), + ):null, + icon: Icon(Icons.home,color: title==3?Colors.black:ColorPalette.gray,), + label: TextDefault(text: 'Cadastro Domiciliar',fontSize: 14,color: title==3?Colors.black:ColorPalette.gray,) + ), + ], + ), + ); + } +} diff --git a/pubspec.lock b/pubspec.lock index b5bb256..2a78a36 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -128,6 +128,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.0.6" + get: + dependency: "direct main" + description: + name: get + url: "https://pub.dartlang.org" + source: hosted + version: "4.6.5" http: dependency: "direct main" description: diff --git a/pubspec.yaml b/pubspec.yaml index b7dc655..ec5e3d7 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -19,6 +19,7 @@ dependencies: gainer_crypto: ^0.0.6 sqflite: ^2.0.0+3 shared_preferences: ^2.0.15 + get: dev_dependencies: flutter_test: