ajustes para salvar acessos liberados
This commit is contained in:
@@ -20,7 +20,7 @@ class MyApp extends StatelessWidget {
|
|||||||
title: 'CONTROLE DE ACESSO',
|
title: 'CONTROLE DE ACESSO',
|
||||||
routes: {
|
routes: {
|
||||||
'/': (_)=> LoginScreen(),
|
'/': (_)=> LoginScreen(),
|
||||||
'/home':(context)=> HomeScreen(cidade: ModalRoute.of(context)!.settings.arguments as String),
|
'/home':(context)=> HomeScreen(dados: ModalRoute.of(context)!.settings.arguments as List),
|
||||||
'/cadastro':(context)=>ResponsibleRegisterScreen(ModalRoute.of(context)!.settings.arguments as AlunoModel),
|
'/cadastro':(context)=>ResponsibleRegisterScreen(ModalRoute.of(context)!.settings.arguments as AlunoModel),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|||||||
9
lib/models/login_model.dart
Normal file
9
lib/models/login_model.dart
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
class LoginModel{
|
||||||
|
String login;
|
||||||
|
bool check;
|
||||||
|
|
||||||
|
LoginModel({
|
||||||
|
required this.login,
|
||||||
|
required this.check,
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -4,14 +4,15 @@ import 'package:educa_controle_acesso/widgets/input_text.dart';
|
|||||||
import 'package:educa_controle_acesso/widgets/text_custom.dart';
|
import 'package:educa_controle_acesso/widgets/text_custom.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import '../models/aluno_model.dart';
|
import '../models/aluno_model.dart';
|
||||||
|
import '../models/login_model.dart';
|
||||||
import '../widgets/buttom_custom.dart';
|
import '../widgets/buttom_custom.dart';
|
||||||
import '../widgets/dados_alunos_container.dart';
|
import '../widgets/dados_alunos_container.dart';
|
||||||
import 'package:http/http.dart' as http;
|
import 'package:http/http.dart' as http;
|
||||||
import '../widgets/snackBars.dart';
|
import '../widgets/snackBars.dart';
|
||||||
|
|
||||||
class HomeScreen extends StatefulWidget {
|
class HomeScreen extends StatefulWidget {
|
||||||
String cidade;
|
List dados;
|
||||||
HomeScreen({required this.cidade});
|
HomeScreen({required this.dados,});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<HomeScreen> createState() => _HomeScreenState();
|
State<HomeScreen> createState() => _HomeScreenState();
|
||||||
@@ -21,6 +22,7 @@ class _HomeScreenState extends State<HomeScreen> {
|
|||||||
|
|
||||||
var inputPesquisa = TextEditingController();
|
var inputPesquisa = TextEditingController();
|
||||||
List<AlunoModel> alunos = [];
|
List<AlunoModel> alunos = [];
|
||||||
|
List<LoginModel> logins = [];
|
||||||
List resultadoPesquisa = [];
|
List resultadoPesquisa = [];
|
||||||
bool filtroEstudante = false;
|
bool filtroEstudante = false;
|
||||||
bool filtroData = false;
|
bool filtroData = false;
|
||||||
@@ -29,13 +31,14 @@ class _HomeScreenState extends State<HomeScreen> {
|
|||||||
bool filtroTurma = false;
|
bool filtroTurma = false;
|
||||||
bool filtroEscola = false;
|
bool filtroEscola = false;
|
||||||
bool buscandoDados = false;
|
bool buscandoDados = false;
|
||||||
|
bool showEscola = false;
|
||||||
|
|
||||||
carregarAlunos()async{
|
carregarAlunos()async{
|
||||||
resultadoPesquisa.clear();
|
resultadoPesquisa.clear();
|
||||||
alunos.clear();
|
alunos.clear();
|
||||||
String q = inputPesquisa.text.replaceAll(' ', '%20').toUpperCase();
|
String q = inputPesquisa.text.replaceAll(' ', '%20').toUpperCase();
|
||||||
// print(q);
|
// print(q);
|
||||||
final url = 'http://192.168.18.2:8000/aluno?NOME=$q&CIDADE=${widget.cidade}';
|
final url = 'http://192.168.18.2:8000/aluno?NOME=$q&CIDADE=${widget.dados[0]}';
|
||||||
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);
|
||||||
@@ -67,7 +70,7 @@ class _HomeScreenState extends State<HomeScreen> {
|
|||||||
serie: list[i]['DESC_SERIE'],
|
serie: list[i]['DESC_SERIE'],
|
||||||
turma: list[i]['TURMA'],
|
turma: list[i]['TURMA'],
|
||||||
dados: list[i],
|
dados: list[i],
|
||||||
cidade: widget.cidade
|
cidade: widget.dados[0]
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
resultadoPesquisa.add(alunos[i]);
|
resultadoPesquisa.add(alunos[i]);
|
||||||
@@ -86,34 +89,75 @@ class _HomeScreenState extends State<HomeScreen> {
|
|||||||
// pesquisarAluno();
|
// pesquisarAluno();
|
||||||
// }
|
// }
|
||||||
|
|
||||||
pesquisarAluno()async{
|
// pesquisarAluno()async{
|
||||||
resultadoPesquisa =[];
|
// resultadoPesquisa =[];
|
||||||
if(inputPesquisa.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(inputPesquisa.text.toUpperCase()) ||
|
||||||
|
// data.contains(inputPesquisa.text.toUpperCase()) ||
|
||||||
|
// ra.contains(inputPesquisa.text.toUpperCase())
|
||||||
|
// ){
|
||||||
|
// if(resultadoPesquisa.length<10){
|
||||||
|
// resultadoPesquisa.add(alunos[i]);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }else{
|
||||||
|
// if(alunos.length<10){
|
||||||
|
// for(int i = 0;i<alunos.length;i++){
|
||||||
|
// resultadoPesquisa.add(alunos[i]);
|
||||||
|
// }
|
||||||
|
// }else{
|
||||||
|
// for(int i = 0;i<10;i++){
|
||||||
|
// resultadoPesquisa.add(alunos[i]);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// setState(() {});
|
||||||
|
// }
|
||||||
|
|
||||||
if(nome.contains(inputPesquisa.text.toUpperCase()) ||
|
getAcessos()async{
|
||||||
data.contains(inputPesquisa.text.toUpperCase()) ||
|
logins.clear();
|
||||||
ra.contains(inputPesquisa.text.toUpperCase())
|
setState(() {
|
||||||
){
|
buscandoDados = true;
|
||||||
if(resultadoPesquisa.length<10){
|
});
|
||||||
resultadoPesquisa.add(alunos[i]);
|
final url = 'http://192.168.18.2:8000/acesso?LOGIN=${inputPesquisa.text}&CIDADE=${widget.dados[0]}';
|
||||||
|
print(url);
|
||||||
|
final response = await http.get(Uri.parse(url));
|
||||||
|
var map = json.decode(response.body);
|
||||||
|
print(map);
|
||||||
|
List list = map;
|
||||||
|
for(int i=0;list.length>i;i++){
|
||||||
|
logins.add(LoginModel(login: list[i]['NO_USERNAME'],check: false));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setState(() {
|
||||||
|
buscandoDados = false;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inserirAcessos(int index)async{
|
||||||
|
final url = 'http://192.168.18.2:8000/inserir_acesso';
|
||||||
|
final response = await http.post(
|
||||||
|
Uri.parse(url),
|
||||||
|
body:{
|
||||||
|
'DATA' : DateTime.now().toString(),
|
||||||
|
'CONDICAO': logins[index].check?"1":"2",
|
||||||
|
'CADASTRADO_POR': widget.dados[1].toString().toUpperCase(),
|
||||||
|
'ID_USUARIO' : logins[index].login,
|
||||||
|
'CIDADE': widget.dados[0],
|
||||||
|
'NOVO' : 'NAO'
|
||||||
}
|
}
|
||||||
}else{
|
);
|
||||||
if(alunos.length<10){
|
print(response.body);
|
||||||
for(int i = 0;i<alunos.length;i++){
|
if(response.body == 'cadastrado com sucesso' || response.body == 'editado com sucesso'){
|
||||||
resultadoPesquisa.add(alunos[i]);
|
showSnackBar(context, '${response.body}!', Colors.green);
|
||||||
}
|
|
||||||
}else{
|
|
||||||
for(int i = 0;i<10;i++){
|
|
||||||
resultadoPesquisa.add(alunos[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
buscandoDados = false;
|
||||||
setState(() {});
|
setState(() {});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -123,7 +167,7 @@ class _HomeScreenState extends State<HomeScreen> {
|
|||||||
double width = MediaQuery.of(context).size.width;
|
double width = MediaQuery.of(context).size.width;
|
||||||
double height = MediaQuery.of(context).size.height;
|
double height = MediaQuery.of(context).size.height;
|
||||||
|
|
||||||
return widget.cidade==null || widget.cidade == ''?Container():Scaffold(
|
return widget.dados[0]==null || widget.dados[0] == ''?Container():Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: Row(
|
title: Row(
|
||||||
children: [
|
children: [
|
||||||
@@ -132,7 +176,18 @@ class _HomeScreenState extends State<HomeScreen> {
|
|||||||
),
|
),
|
||||||
TextCustom(text: '- PESQUISAR ALUNO',color: Colors.white,),
|
TextCustom(text: '- PESQUISAR ALUNO',color: Colors.white,),
|
||||||
Spacer(),
|
Spacer(),
|
||||||
TextCustom(text: widget.cidade,color: Colors.white,)
|
widget.dados[1].toString().toUpperCase()=='ADMIN'?ButtonCustom(
|
||||||
|
onPressed: ()=>setState(()=>showEscola?showEscola=false:showEscola=true),
|
||||||
|
text: showEscola?'Acesso Pais':'Acesso Escola',
|
||||||
|
size: 15,
|
||||||
|
widthCustom: 0.1,
|
||||||
|
heightCustom: 0.05,
|
||||||
|
colorButton: PaletteColors.primaryColor,
|
||||||
|
colorText: PaletteColors.white,
|
||||||
|
colorBorder: PaletteColors.white
|
||||||
|
):Container(),
|
||||||
|
SizedBox(width: width * 0.02),
|
||||||
|
TextCustom(text: widget.dados[0]==null?'':widget.dados[0],color: Colors.white,)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
backgroundColor: PaletteColors.grey,
|
backgroundColor: PaletteColors.grey,
|
||||||
@@ -148,7 +203,82 @@ class _HomeScreenState extends State<HomeScreen> {
|
|||||||
),
|
),
|
||||||
):Padding(
|
):Padding(
|
||||||
padding: const EdgeInsets.all(8.0),
|
padding: const EdgeInsets.all(8.0),
|
||||||
child: ListView(
|
child: showEscola?ListView(
|
||||||
|
children: [
|
||||||
|
SizedBox(height: height*0.05),
|
||||||
|
Padding(
|
||||||
|
padding: EdgeInsets.symmetric(horizontal: width>900?width*0.1:width*0.05),
|
||||||
|
child: Row(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
InputText(
|
||||||
|
hint: 'Pesquisar por login do usuário'.toUpperCase(),
|
||||||
|
controller: inputPesquisa,
|
||||||
|
width: width*0.25,
|
||||||
|
inputFormatters: [],
|
||||||
|
fontSize: 14,
|
||||||
|
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;
|
||||||
|
});
|
||||||
|
getAcessos();
|
||||||
|
}else{
|
||||||
|
showSnackBar(context, 'Digite alguma informação para pesquisar', Colors.red);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
ButtonCustom(
|
||||||
|
widthCustom: 0.05,
|
||||||
|
heightCustom: 0.063,
|
||||||
|
text: "LIMPAR",
|
||||||
|
size: 10.0,
|
||||||
|
colorText: PaletteColors.white,
|
||||||
|
colorButton: PaletteColors.primaryColor,
|
||||||
|
colorBorder: PaletteColors.primaryColor,
|
||||||
|
onPressed: ()=>setState((){
|
||||||
|
inputPesquisa.clear();
|
||||||
|
resultadoPesquisa.clear();
|
||||||
|
alunos.clear();
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
)
|
||||||
|
),
|
||||||
|
Container(
|
||||||
|
padding: EdgeInsets.symmetric(horizontal: width>900?width*0.1:width*0.05),
|
||||||
|
height: height*0.2,
|
||||||
|
child: ListView.builder(
|
||||||
|
itemCount: logins.length,
|
||||||
|
itemBuilder: (context,index){
|
||||||
|
return Row(
|
||||||
|
children: [
|
||||||
|
Checkbox(
|
||||||
|
value: logins[index].check,
|
||||||
|
onChanged: (v){
|
||||||
|
buscandoDados = true;
|
||||||
|
setState(()=>logins[index].check=v!);
|
||||||
|
inserirAcessos(index);
|
||||||
|
}
|
||||||
|
),
|
||||||
|
TextCustom(text: logins[index].login),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
):ListView(
|
||||||
children: [
|
children: [
|
||||||
SizedBox(height: height*0.05),
|
SizedBox(height: height*0.05),
|
||||||
Padding(
|
Padding(
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ class _LoginScreenState extends State<LoginScreen> {
|
|||||||
//ibueno
|
//ibueno
|
||||||
final inputLogin = TextEditingController(text: 'admin');
|
final inputLogin = TextEditingController(text: 'admin');
|
||||||
final inputSenha = TextEditingController(text: 'las1594@@');
|
final inputSenha = TextEditingController(text: 'las1594@@');
|
||||||
final inputCodigo = TextEditingController(text: 'e001');
|
final inputCodigo = TextEditingController(text: 'e003');
|
||||||
bool loading = false;
|
bool loading = false;
|
||||||
List listCodigo = [];
|
List listCodigo = [];
|
||||||
|
|
||||||
@@ -76,14 +76,16 @@ class _LoginScreenState extends State<LoginScreen> {
|
|||||||
if(map['NO_USERNAME']==map['SENHA']){
|
if(map['NO_USERNAME']==map['SENHA']){
|
||||||
if(map['NO_USERNAME']==inputLogin.text.toUpperCase() && map['SENHA']==inputSenha.text.toUpperCase()){
|
if(map['NO_USERNAME']==inputLogin.text.toUpperCase() && map['SENHA']==inputSenha.text.toUpperCase()){
|
||||||
showSnackBar(context, 'Acesso validado', Colors.green);
|
showSnackBar(context, 'Acesso validado', Colors.green);
|
||||||
Navigator.pushNamed(context, '/home',arguments: cidade);
|
List dados = [cidade,inputLogin.text];
|
||||||
|
Navigator.pushNamed(context, '/home',arguments: dados);
|
||||||
}else{
|
}else{
|
||||||
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{
|
||||||
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.pushNamed(context, '/home',arguments: cidade);
|
List dados = [cidade,inputLogin.text];
|
||||||
|
Navigator.pushNamed(context, '/home',arguments: dados);
|
||||||
}else{
|
}else{
|
||||||
showSnackBar(context, 'Login não cadastrado e/ou senha incorreta', Colors.red);
|
showSnackBar(context, 'Login não cadastrado e/ou senha incorreta', Colors.red);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user