ajustes da pesquisa e conexão com a api
This commit is contained in:
@@ -20,7 +20,7 @@ class HomeScreen extends StatefulWidget {
|
|||||||
|
|
||||||
class _HomeScreenState extends State<HomeScreen> {
|
class _HomeScreenState extends State<HomeScreen> {
|
||||||
|
|
||||||
var controllerPesquisa = TextEditingController();
|
var inputPesquisa = TextEditingController();
|
||||||
List<AlunoModel> alunos = [];
|
List<AlunoModel> alunos = [];
|
||||||
List resultadoPesquisa = [];
|
List resultadoPesquisa = [];
|
||||||
bool filtroEstudante = false;
|
bool filtroEstudante = false;
|
||||||
@@ -29,11 +29,15 @@ class _HomeScreenState extends State<HomeScreen> {
|
|||||||
bool filtroSerie = false;
|
bool filtroSerie = false;
|
||||||
bool filtroTurma = false;
|
bool filtroTurma = false;
|
||||||
bool filtroEscola = false;
|
bool filtroEscola = false;
|
||||||
bool buscandoDados = true;
|
bool buscandoDados = false;
|
||||||
|
|
||||||
carregarAlunos()async{
|
carregarAlunos()async{
|
||||||
final url = 'http://localhost:8000/aluno?NR_LOGRADOURO=715';
|
resultadoPesquisa.clear();
|
||||||
print(url);
|
alunos.clear();
|
||||||
|
String q = inputPesquisa.text.replaceAll(' ', '%20').toUpperCase();
|
||||||
|
// print(q);
|
||||||
|
final url = 'http://localhost:8000/aluno?NOME=$q';
|
||||||
|
// print(url);
|
||||||
final response = await http.get(Uri.parse(url));
|
final response = await http.get(Uri.parse(url));
|
||||||
var map = json.decode(response.body);
|
var map = json.decode(response.body);
|
||||||
if(map==null){
|
if(map==null){
|
||||||
@@ -44,40 +48,45 @@ class _HomeScreenState extends State<HomeScreen> {
|
|||||||
}else{
|
}else{
|
||||||
List list = map;
|
List list = map;
|
||||||
print(list);
|
print(list);
|
||||||
for(int i =0; list.length>i;i++){
|
if(list.length != 0){
|
||||||
String data = list[i]['DT_NASCIMENTO']??'';
|
for(int i =0; list.length>i;i++){
|
||||||
String dia = '00';
|
String data = list[i]['DT_NASCIMENTO']??'';
|
||||||
String mes = '00';
|
String dia = '00';
|
||||||
String ano = '0000';
|
String mes = '00';
|
||||||
if(data!=''){
|
String ano = '0000';
|
||||||
dia = data.substring(6,8);
|
if(data!=''){
|
||||||
mes = data.substring(4,6);
|
dia = data.substring(6,8);
|
||||||
ano = data.substring(0,4);
|
mes = data.substring(4,6);
|
||||||
|
ano = data.substring(0,4);
|
||||||
|
}
|
||||||
|
alunos.add(AlunoModel(nome: list[i]['NO_ALUNO']??'', data_nasc: '${dia}/${mes}/${ano}', ra: list[i]['NR_RA']??'', escola: 'escola', serie: 'serie', turma: 'turma',dados: list[i]));
|
||||||
|
resultadoPesquisa.add(alunos[i]);
|
||||||
}
|
}
|
||||||
alunos.add(AlunoModel(nome: list[i]['NO_ALUNO']??'', data_nasc: '${dia}/${mes}/${ano}', ra: list[i]['NR_RA']??'', escola: 'escola', serie: 'serie', turma: 'turma',dados: list[i]));
|
}else{
|
||||||
|
showSnackBar(context, 'Aluno(a) não localizado', Colors.red);
|
||||||
}
|
}
|
||||||
setState(() {
|
setState(() {
|
||||||
buscandoDados = false;
|
buscandoDados = false;
|
||||||
});
|
});
|
||||||
pesquisarAluno();
|
// pesquisarAluno();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pesquisa(){
|
// pesquisa(){
|
||||||
pesquisarAluno();
|
// pesquisarAluno();
|
||||||
}
|
// }
|
||||||
|
|
||||||
pesquisarAluno()async{
|
pesquisarAluno()async{
|
||||||
resultadoPesquisa =[];
|
resultadoPesquisa =[];
|
||||||
if(controllerPesquisa.text.isNotEmpty){
|
if(inputPesquisa.text.isNotEmpty){
|
||||||
for (int i =0;alunos.length>i;i++) {
|
for (int i =0;alunos.length>i;i++) {
|
||||||
String nome = alunos[i].nome.toUpperCase();
|
String nome = alunos[i].nome.toUpperCase();
|
||||||
String data = alunos[i].data_nasc.toUpperCase();
|
String data = alunos[i].data_nasc.toUpperCase();
|
||||||
String ra = alunos[i].ra.toUpperCase();
|
String ra = alunos[i].ra.toUpperCase();
|
||||||
|
|
||||||
if(nome.contains(controllerPesquisa.text.toUpperCase()) ||
|
if(nome.contains(inputPesquisa.text.toUpperCase()) ||
|
||||||
data.contains(controllerPesquisa.text.toUpperCase()) ||
|
data.contains(inputPesquisa.text.toUpperCase()) ||
|
||||||
ra.contains(controllerPesquisa.text.toUpperCase())
|
ra.contains(inputPesquisa.text.toUpperCase())
|
||||||
){
|
){
|
||||||
if(resultadoPesquisa.length<10){
|
if(resultadoPesquisa.length<10){
|
||||||
resultadoPesquisa.add(alunos[i]);
|
resultadoPesquisa.add(alunos[i]);
|
||||||
@@ -101,8 +110,7 @@ class _HomeScreenState extends State<HomeScreen> {
|
|||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
carregarAlunos();
|
// inputPesquisa.addListener(pesquisa);
|
||||||
controllerPesquisa.addListener(pesquisa);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -143,13 +151,32 @@ class _HomeScreenState extends State<HomeScreen> {
|
|||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
InputText(
|
InputText(
|
||||||
hint: 'Pesquisar por estudante, RA ou data de nascimento'.toUpperCase(),
|
hint: 'Pesquisar por nome do aluno(a)'.toUpperCase(),
|
||||||
controller: controllerPesquisa,
|
controller: inputPesquisa,
|
||||||
width: width*0.25,
|
width: width*0.25,
|
||||||
inputFormatters: [],
|
inputFormatters: [],
|
||||||
fontSize: 12,
|
fontSize: 12,
|
||||||
colorBackground: Colors.white,
|
colorBackground: Colors.white,
|
||||||
),
|
),
|
||||||
|
ButtonCustom(
|
||||||
|
widthCustom: 0.05,
|
||||||
|
heightCustom: 0.063,
|
||||||
|
text: "PESQUISAR",
|
||||||
|
size: 10.0,
|
||||||
|
colorText: PaletteColors.white,
|
||||||
|
colorButton: PaletteColors.green,
|
||||||
|
colorBorder: PaletteColors.green,
|
||||||
|
onPressed: (){
|
||||||
|
if(inputPesquisa.text.isNotEmpty){
|
||||||
|
setState(() {
|
||||||
|
buscandoDados = true;
|
||||||
|
});
|
||||||
|
carregarAlunos();
|
||||||
|
}else{
|
||||||
|
showSnackBar(context, 'Digite alguma informação para pesquisar', Colors.red);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
ButtonCustom(
|
ButtonCustom(
|
||||||
widthCustom: 0.05,
|
widthCustom: 0.05,
|
||||||
heightCustom: 0.063,
|
heightCustom: 0.063,
|
||||||
@@ -158,7 +185,11 @@ class _HomeScreenState extends State<HomeScreen> {
|
|||||||
colorText: PaletteColors.white,
|
colorText: PaletteColors.white,
|
||||||
colorButton: PaletteColors.primaryColor,
|
colorButton: PaletteColors.primaryColor,
|
||||||
colorBorder: PaletteColors.primaryColor,
|
colorBorder: PaletteColors.primaryColor,
|
||||||
onPressed: ()=>setState(()=>controllerPesquisa.clear()),
|
onPressed: ()=>setState((){
|
||||||
|
inputPesquisa.clear();
|
||||||
|
resultadoPesquisa.clear();
|
||||||
|
alunos.clear();
|
||||||
|
}),
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -20,8 +20,10 @@ class _LoginScreenState extends State<LoginScreen> {
|
|||||||
//MMATOS LOGIN IGUAL A SENHA
|
//MMATOS LOGIN IGUAL A SENHA
|
||||||
//AMENEZES LOGIN DIFERENTE DA SENHA
|
//AMENEZES LOGIN DIFERENTE DA SENHA
|
||||||
//SENHAS CRIPTOGRAFADAS PORQUE FORMA ALTERADAS, SENHAS NOVAS USUÁRIO E SENHA SÃO IGUAIS
|
//SENHAS CRIPTOGRAFADAS PORQUE FORMA ALTERADAS, SENHAS NOVAS USUÁRIO E SENHA SÃO IGUAIS
|
||||||
final inputLogin = TextEditingController(text: 'mmatos');
|
// final inputLogin = TextEditingController(text: 'mmatos');
|
||||||
final inputSenha = TextEditingController(text: 'mmatos');
|
final inputLogin = TextEditingController(text: 'admin');
|
||||||
|
final inputSenha = TextEditingController(text: 'rkm12345');
|
||||||
|
// final inputSenha = TextEditingController(text: 'mmatos');
|
||||||
bool loading = false;
|
bool loading = false;
|
||||||
|
|
||||||
verificacao(){
|
verificacao(){
|
||||||
@@ -41,10 +43,10 @@ class _LoginScreenState extends State<LoginScreen> {
|
|||||||
|
|
||||||
conectAPI()async{
|
conectAPI()async{
|
||||||
final url = 'http://localhost:8000/login?NO_USERNAME=${inputLogin.text.toUpperCase()}';
|
final url = 'http://localhost:8000/login?NO_USERNAME=${inputLogin.text.toUpperCase()}';
|
||||||
print(url);
|
// print(url);
|
||||||
final response = await http.get(Uri.parse(url));
|
final response = await http.get(Uri.parse(url));
|
||||||
var map = json.decode(response.body);
|
var map = json.decode(response.body);
|
||||||
print(map);
|
// print(map);
|
||||||
if(map==false){
|
if(map==false){
|
||||||
showSnackBar(context, 'Login não cadastrado e/ou senha incorreta', Colors.red);
|
showSnackBar(context, 'Login não cadastrado e/ou senha incorreta', Colors.red);
|
||||||
}else{
|
}else{
|
||||||
@@ -59,7 +61,7 @@ class _LoginScreenState extends State<LoginScreen> {
|
|||||||
showSnackBar(context, 'Login não cadastrado e/ou senha incorreta', Colors.red);
|
showSnackBar(context, 'Login não cadastrado e/ou senha incorreta', Colors.red);
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
print(MainControllers().encrypt(inputSenha.text,map['SENHA']));
|
// print(MainControllers().encrypt(inputSenha.text,map['SENHA']));
|
||||||
if(MainControllers().encrypt(inputSenha.text,map['SENHA']) == map['SENHA']){
|
if(MainControllers().encrypt(inputSenha.text,map['SENHA']) == map['SENHA']){
|
||||||
showSnackBar(context, 'Acesso validado', Colors.green);
|
showSnackBar(context, 'Acesso validado', Colors.green);
|
||||||
Navigator.push(
|
Navigator.push(
|
||||||
@@ -77,6 +79,20 @@ class _LoginScreenState extends State<LoginScreen> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
paisBanco()async{
|
||||||
|
final url = 'http://localhost:8000/pais';
|
||||||
|
// print(url);
|
||||||
|
final response = await http.get(Uri.parse(url));
|
||||||
|
var map = json.decode(response.body);
|
||||||
|
print(map);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
paisBanco();
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
double height = MediaQuery.of(context).size.height;
|
double height = MediaQuery.of(context).size.height;
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import 'dart:convert';
|
||||||
|
|
||||||
import 'package:brasil_fields/brasil_fields.dart';
|
import 'package:brasil_fields/brasil_fields.dart';
|
||||||
import 'package:educa_controle_acesso/models/aluno_model.dart';
|
import 'package:educa_controle_acesso/models/aluno_model.dart';
|
||||||
import 'package:educa_controle_acesso/models/responsavel_model.dart';
|
import 'package:educa_controle_acesso/models/responsavel_model.dart';
|
||||||
@@ -12,6 +14,7 @@ import '../widgets/caixa_texto_container.dart';
|
|||||||
import '../widgets/input_text.dart';
|
import '../widgets/input_text.dart';
|
||||||
import '../widgets/snackBars.dart';
|
import '../widgets/snackBars.dart';
|
||||||
import '../widgets/text_custom.dart';
|
import '../widgets/text_custom.dart';
|
||||||
|
import 'package:http/http.dart' as http;
|
||||||
|
|
||||||
class ResponsibleRegisterScreen extends StatefulWidget {
|
class ResponsibleRegisterScreen extends StatefulWidget {
|
||||||
AlunoModel alunoModel;
|
AlunoModel alunoModel;
|
||||||
@@ -94,6 +97,55 @@ class _ResponsibleRegisterScreenState extends State<ResponsibleRegisterScreen> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
carregaPais(){
|
||||||
|
if(widget.alunoModel.dados['NO_PAI']!=''){
|
||||||
|
responsaveis.add(
|
||||||
|
ResponsavelModel(
|
||||||
|
nomeAluno: widget.alunoModel.nome.toUpperCase(),
|
||||||
|
raAluno: widget.alunoModel.ra.toUpperCase(),
|
||||||
|
escola: widget.alunoModel.escola.toUpperCase(),
|
||||||
|
serie: widget.alunoModel.serie.toUpperCase(),
|
||||||
|
turma: widget.alunoModel.turma.toUpperCase(),
|
||||||
|
nomeResponsavel: widget.alunoModel.dados['NO_PAI'],
|
||||||
|
parentesco: 'PAI',
|
||||||
|
cpf: '',
|
||||||
|
senha: '',
|
||||||
|
dataCadastro: DateFormat('dd/MM/yyyy HH:mm').format(DateTime.now())
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if(widget.alunoModel.dados['NO_MAE']!=''){
|
||||||
|
responsaveis.add(
|
||||||
|
ResponsavelModel(
|
||||||
|
nomeAluno: widget.alunoModel.nome.toUpperCase(),
|
||||||
|
raAluno: widget.alunoModel.ra.toUpperCase(),
|
||||||
|
escola: widget.alunoModel.escola.toUpperCase(),
|
||||||
|
serie: widget.alunoModel.serie.toUpperCase(),
|
||||||
|
turma: widget.alunoModel.turma.toUpperCase(),
|
||||||
|
nomeResponsavel: widget.alunoModel.dados['NO_MAE'],
|
||||||
|
parentesco: 'MAE',
|
||||||
|
cpf: '',
|
||||||
|
senha: '',
|
||||||
|
dataCadastro: DateFormat('dd/MM/yyyy HH:mm').format(DateTime.now())
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
paisBanco()async{
|
||||||
|
final url = 'http://localhost:8000/pais';
|
||||||
|
// print(url);
|
||||||
|
final response = await http.get(Uri.parse(url));
|
||||||
|
var map = json.decode(response.body);
|
||||||
|
print(map);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
carregaPais();
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user