criada as telas tela_avisos.dart, tela_detalhes_avisos.dart e tela_contatos.dart
This commit is contained in:
134
lib/telas/tela_login.dart
Normal file
134
lib/telas/tela_login.dart
Normal file
@@ -0,0 +1,134 @@
|
||||
import 'dart:convert';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rkm_educa_app/telas/tela_seleciona_filho.dart';
|
||||
import 'package:rkm_educa_app/utils/dimensoes.dart';
|
||||
import '../controllers/main_controllers.dart';
|
||||
import '../utils/cores.dart';
|
||||
import '../componentes/buttom_custom.dart';
|
||||
import '../componentes/input_text.dart';
|
||||
import '../componentes/snackBars.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import '../componentes/text_custom.dart';
|
||||
|
||||
class TelaLogin extends StatefulWidget {
|
||||
const TelaLogin({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<TelaLogin> createState() => _TelaLoginState();
|
||||
}
|
||||
|
||||
class _TelaLoginState extends State<TelaLogin> {
|
||||
|
||||
final inputLogin = TextEditingController(text: 'mmatos');
|
||||
final inputSenha = TextEditingController(text: 'mmatos');
|
||||
bool loading = false;
|
||||
|
||||
verificacao(){
|
||||
if(inputLogin.text.isNotEmpty){
|
||||
if(inputSenha.text.isNotEmpty){
|
||||
setState(() {
|
||||
loading = true;
|
||||
});
|
||||
conectAPI();
|
||||
}else{
|
||||
showSnackBar(context, 'Preencha sua senha', Colors.red);
|
||||
}
|
||||
}else{
|
||||
showSnackBar(context, 'Preencha seu Login', Colors.red);
|
||||
}
|
||||
}
|
||||
|
||||
conectAPI()async{
|
||||
final url = 'http://192.168.18.2/projeto/api_educa/index.php/?NO_USERNAME=${inputLogin.text.toUpperCase()}';
|
||||
print(url);
|
||||
final response = await http.get(Uri.parse(url));
|
||||
var map = json.decode(response.body);
|
||||
print(map);
|
||||
if(map==false){
|
||||
showSnackBar(context, 'Login não cadastrado e/ou senha incorreta', 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);
|
||||
Navigator.pushReplacement(context,MaterialPageRoute(builder: (context) => TelaSelecionaFilho()));
|
||||
}else{
|
||||
showSnackBar(context, 'Login não cadastrado e/ou senha incorreta', Colors.red);
|
||||
}
|
||||
}else{
|
||||
print(MainControllers().encrypt(inputSenha.text,map['SENHA']));
|
||||
if(MainControllers().encrypt(inputSenha.text,map['SENHA']) == map['SENHA']){
|
||||
showSnackBar(context, 'Acesso validado', Colors.green);
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) => TelaSelecionaFilho()),
|
||||
);
|
||||
}else{
|
||||
showSnackBar(context, 'Login não cadastrado e/ou senha incorreta', Colors.red);
|
||||
}
|
||||
// MainControllers().encrypt(inputSenha.text,map['SENHA']) == map['SENHA']
|
||||
}
|
||||
}
|
||||
setState(() {
|
||||
loading = false;
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
Dimensoes().init(context);
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: PaletaCores.branco,
|
||||
body: Center(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Container(
|
||||
child: Image.asset("assets/images/logoEduca.png",width:Dimensoes.width * 0.4,height: Dimensoes.height * 0.12)
|
||||
),
|
||||
loading?Container():Container(
|
||||
width: Dimensoes.width>900? Dimensoes.width * 0.18:Dimensoes.width*0.7,
|
||||
child: InputText(
|
||||
inputFormatters: [],
|
||||
controller: inputLogin,
|
||||
title: 'Login',
|
||||
width: Dimensoes.width>900? Dimensoes.width * 0.18:Dimensoes.width*0.7,
|
||||
colorBorder: PaletaCores.branco,
|
||||
),
|
||||
),
|
||||
loading?Container():Container(
|
||||
width: Dimensoes.width>900? Dimensoes.width * 0.18:Dimensoes.width*0.7,
|
||||
child: InputText(
|
||||
inputFormatters: [],
|
||||
controller: inputSenha,
|
||||
title: 'Senha',
|
||||
obscure: true,
|
||||
width: Dimensoes.width>900? Dimensoes.width * 0.18:Dimensoes.width*0.7,
|
||||
colorBorder: PaletaCores.branco,
|
||||
),
|
||||
),
|
||||
SizedBox(height: Dimensoes.height * 0.02),
|
||||
loading?Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
CircularProgressIndicator(),
|
||||
SizedBox(width: 20,),
|
||||
TextCustom(text: 'VALIDANDO ACESSO...')
|
||||
],
|
||||
):ButtonCustom(
|
||||
widthCustom: 0.7,
|
||||
heightCustom: 0.07,
|
||||
text: "Entrar",
|
||||
size: 14.0,
|
||||
colorText: PaletaCores.branco,
|
||||
colorButton: PaletaCores.corPrimaria,
|
||||
colorBorder: PaletaCores.corPrimaria,
|
||||
onPressed: ()=>verificacao(),
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user