From 21bbd9bdbfca7bcfacd7c97bab5910461943a924 Mon Sep 17 00:00:00 2001 From: Reginaldo Date: Tue, 15 Aug 2023 16:49:42 -0300 Subject: [PATCH] ajustes na pesquisa dos usuarios e ajustes no app bar --- lib/screens/home_screen.dart | 19 ++++++++++++++----- lib/screens/login_screen.dart | 10 +++++++--- lib/screens/responsible_register_screen.dart | 10 ++++++++-- 3 files changed, 29 insertions(+), 10 deletions(-) diff --git a/lib/screens/home_screen.dart b/lib/screens/home_screen.dart index 47a635e..9449d0f 100644 --- a/lib/screens/home_screen.dart +++ b/lib/screens/home_screen.dart @@ -95,7 +95,8 @@ class _HomeScreenState extends State { setState(() { buscandoDados = true; }); - final url = '${widget.dados[2]}/acesso_maria?LOGIN=${inputPesquisa.text.toUpperCase()}&CIDADE=${widget.dados[0]}'; + String usuario = inputPesquisa.text.replaceAll(' ', '%20').toUpperCase(); + final url = '${widget.dados[2]}/pesquisa_acesso?NOME=$usuario&CIDADE=${widget.dados[0]}'; print(url); final response = await http.get(Uri.parse(url)); var map = json.decode(response.body); @@ -119,6 +120,7 @@ class _HomeScreenState extends State { buscandoDados = false; }); }else{ + print('aqui'); getAcessosBasePrincipal(); } } @@ -128,7 +130,8 @@ class _HomeScreenState extends State { setState(() { buscandoDados = true; }); - final url = '${widget.dados[2]}/acesso_base?LOGIN=${inputPesquisa.text.toUpperCase()}&CIDADE=${widget.dados[0]}'; + String usuario = inputPesquisa.text.replaceAll(' ', '%20').toUpperCase(); + final url = '${widget.dados[2]}/acesso_base?NOME=$usuario&CIDADE=${widget.dados[0]}'; print(url); final response = await http.get(Uri.parse(url)); var map = json.decode(response.body); @@ -184,7 +187,7 @@ class _HomeScreenState extends State { ), TextCustom(text: showEscola?'- PESQUISAR USUÁRIOS':'- PESQUISAR ESTUDANTES',color: Colors.white,), Spacer(), - widget.dados[1].toString().toUpperCase()=='ADMIN'?ButtonCustom( + widget.dados[1].toString().toUpperCase()=='ADMINISTRADOR'?ButtonCustom( onPressed: (){ inputPesquisa.clear(); setState(()=>showEscola?showEscola=false:showEscola=true); @@ -197,8 +200,14 @@ class _HomeScreenState extends State { colorBorder: PaletteColors.white ):Container(), SizedBox(width: width * 0.02), - TextCustom(text: widget.dados[0]==null?'':widget.dados[0],color: Colors.white,), - TextCustom(text:widget.dados[1]==null?'':' - '+widget.dados[1].toString().toUpperCase(),color: Colors.white,), + Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + TextCustom(text: widget.dados[0]==null?'':widget.dados[0],color: Colors.white,), + TextCustom(text:widget.dados[1]==null?'':widget.dados[1].toString().toUpperCase(),color: Colors.white,), + ], + ), ], ), backgroundColor: PaletteColors.grey, diff --git a/lib/screens/login_screen.dart b/lib/screens/login_screen.dart index e2ebcad..c40fe03 100644 --- a/lib/screens/login_screen.dart +++ b/lib/screens/login_screen.dart @@ -94,26 +94,30 @@ class _LoginScreenState extends State { conectAPI()async{ + print('aqui'); + final url = '$urlAPI/logincontrole?NO_USERNAME=${inputLogin.text.toUpperCase()}&CIDADE=${widget.cidade.toUpperCase()}'; print(url); final response = await http.get(Uri.parse(url)); var map = json.decode(response.body); - // print(map); + print(map); if(map==false){ showSnackBar(context, 'Login não cadastrado e/ou senha incorreta e/ou Código incorreto', Colors.red); }else{ if(map['NO_USERNAME']==map['SENHA']){ if(map['NO_USERNAME']==inputLogin.text.toUpperCase() && map['SENHA']==inputSenha.text.toUpperCase()){ showSnackBar(context, 'Acesso validado', Colors.green); - List dados = [widget.cidade.toUpperCase(),inputLogin.text,urlAPI,map['NO_FANTASIA']??'']; + List dados = [widget.cidade.toUpperCase(),map['NO_USUARIO_SISTEMA']??'',urlAPI,map['NO_FANTASIA']??'']; Navigator.pushNamed(context, '/home',arguments: dados); }else{ showSnackBar(context, 'Login não cadastrado e/ou senha incorreta e/ou Código incorreto', Colors.red); } }else{ if(MainControllers().encrypt(inputSenha.text,map['SENHA']) == map['SENHA']){ + print(map); + print(map['NO_USUARIO_SISTEMA']); showSnackBar(context, 'Acesso validado', Colors.green); - List dados = [widget.cidade.toUpperCase(),inputLogin.text,urlAPI,map['NO_FANTASIA']??'']; + List dados = [widget.cidade.toUpperCase(),map['NO_USUARIO_SISTEMA']??'',urlAPI,map['NO_FANTASIA']??'']; Navigator.pushNamed(context, '/home',arguments: dados); }else{ showSnackBar(context, 'Login não cadastrado e/ou senha incorreta e/ou Código incorreto', Colors.red); diff --git a/lib/screens/responsible_register_screen.dart b/lib/screens/responsible_register_screen.dart index 7059b96..e797761 100644 --- a/lib/screens/responsible_register_screen.dart +++ b/lib/screens/responsible_register_screen.dart @@ -256,8 +256,14 @@ class _ResponsibleRegisterScreenState extends State { ), TextCustom(text: '- Cadastrar Responsável',color: Colors.white,), Spacer(), - TextCustom(text: widget.alunoModel.cidade,color: Colors.white,), - TextCustom(text:' - '+ widget.alunoModel.login.toUpperCase(),color: Colors.white,), + Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + TextCustom(text: widget.alunoModel.cidade,color: Colors.white,), + TextCustom(text:widget.alunoModel.login.toUpperCase(),color: Colors.white,), + ], + ), ], ), backgroundColor: PaletteColors.grey,