ajustes para consumir a api das respectivas bases
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import 'dart:convert';
|
||||
import 'package:educa_controle_acesso/utils/cidades_db.dart';
|
||||
import 'package:educa_controle_acesso/widgets/input_text.dart';
|
||||
import 'package:educa_controle_acesso/widgets/text_custom.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -20,17 +21,33 @@ class _LoginScreenState extends State<LoginScreen> {
|
||||
//las1594@@
|
||||
//SENHAS CRIPTOGRAFADAS PORQUE FORMA ALTERADAS, SENHAS NOVAS USUÁRIO E SENHA SÃO IGUAIS
|
||||
//ibueno
|
||||
final inputLogin = TextEditingController();
|
||||
final inputSenha = TextEditingController();
|
||||
final inputLogin = TextEditingController(text: 'admin');
|
||||
final inputSenha = TextEditingController(text: 'las1594@@');
|
||||
final inputCodigo = TextEditingController(text: 'e001');
|
||||
bool loading = false;
|
||||
List listCodigo = [];
|
||||
|
||||
carregarLista(){
|
||||
for(int i=0;Cidades().listCidades.length>i;i++){
|
||||
listCodigo.add(Cidades().listCidades[i].codigo);
|
||||
}
|
||||
}
|
||||
|
||||
verificacao(){
|
||||
if(inputLogin.text.isNotEmpty){
|
||||
if(inputSenha.text.isNotEmpty){
|
||||
setState(() {
|
||||
loading = true;
|
||||
});
|
||||
conectAPI();
|
||||
if(inputCodigo.text.isNotEmpty){
|
||||
if(listCodigo.contains(inputCodigo.text.toUpperCase())){
|
||||
setState(() {
|
||||
loading = true;
|
||||
});
|
||||
conectAPI();
|
||||
}else{
|
||||
showSnackBar(context, 'Código inválido', Colors.red);
|
||||
}
|
||||
}else{
|
||||
showSnackBar(context, 'Preencha o código de acesso', Colors.red);
|
||||
}
|
||||
}else{
|
||||
showSnackBar(context, 'Preencha sua senha', Colors.red);
|
||||
}
|
||||
@@ -40,7 +57,15 @@ class _LoginScreenState extends State<LoginScreen> {
|
||||
}
|
||||
|
||||
conectAPI()async{
|
||||
final url = 'http://192.168.18.2:8000/logincontrole?NO_USERNAME=${inputLogin.text.toUpperCase()}';
|
||||
|
||||
String cidade = '';
|
||||
for(int i =0; Cidades().listCidades.length>i;i++){
|
||||
if(Cidades().listCidades[i].codigo == inputCodigo.text.toUpperCase()){
|
||||
cidade = Cidades().listCidades[i].cidadeQuery.toUpperCase();
|
||||
}
|
||||
}
|
||||
|
||||
final url = 'http://192.168.18.2:8000/logincontrole?NO_USERNAME=${inputLogin.text.toUpperCase()}&CIDADE=$cidade';
|
||||
print(url);
|
||||
final response = await http.get(Uri.parse(url));
|
||||
var map = json.decode(response.body);
|
||||
@@ -51,14 +76,14 @@ class _LoginScreenState extends State<LoginScreen> {
|
||||
if(map['NO_USERNAME']==map['SENHA']){
|
||||
if(map['NO_USERNAME']==inputLogin.text.toUpperCase() && map['SENHA']==inputSenha.text.toUpperCase()){
|
||||
showSnackBar(context, 'Acesso validado', Colors.green);
|
||||
Navigator.pushNamed(context, '/home',arguments: 'ok');
|
||||
Navigator.pushNamed(context, '/home',arguments: cidade);
|
||||
}else{
|
||||
showSnackBar(context, 'Login não cadastrado e/ou senha incorreta', Colors.red);
|
||||
}
|
||||
}else{
|
||||
if(MainControllers().encrypt(inputSenha.text,map['SENHA']) == map['SENHA']){
|
||||
showSnackBar(context, 'Acesso validado', Colors.green);
|
||||
Navigator.pushNamed(context, '/home',arguments: 'ok');
|
||||
Navigator.pushNamed(context, '/home',arguments: cidade);
|
||||
}else{
|
||||
showSnackBar(context, 'Login não cadastrado e/ou senha incorreta', Colors.red);
|
||||
}
|
||||
@@ -69,6 +94,12 @@ class _LoginScreenState extends State<LoginScreen> {
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
carregarLista();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
double height = MediaQuery.of(context).size.height;
|
||||
@@ -106,6 +137,17 @@ class _LoginScreenState extends State<LoginScreen> {
|
||||
),
|
||||
),
|
||||
SizedBox(height: height * 0.02),
|
||||
loading?Container():Container(
|
||||
width: width>900? width * 0.18:width*0.5,
|
||||
child: InputText(
|
||||
inputFormatters: [],
|
||||
controller: inputCodigo,
|
||||
title: 'CÓDIGO',
|
||||
width: width * 0.18,
|
||||
colorBorder: PaletteColors.white,
|
||||
),
|
||||
),
|
||||
SizedBox(height: height * 0.02),
|
||||
loading?Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
|
||||
Reference in New Issue
Block a user