ajustado os dados do calendário;
do login com o cpf
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:line_icons/line_icons.dart';
|
||||
import 'package:rkm_educa_prof_app/componentes/text_custom.dart';
|
||||
import 'package:rkm_educa_prof_app/telas/tela_calendario.dart';
|
||||
import '../servicos/shared_preferences/shared.dart';
|
||||
import '../telas/tela_login.dart';
|
||||
import '../utils/dimensoes.dart';
|
||||
@@ -8,10 +9,10 @@ import 'item_drawer.dart';
|
||||
|
||||
class DrawerCustom extends StatelessWidget {
|
||||
|
||||
String usuario;
|
||||
List dados;
|
||||
|
||||
DrawerCustom({
|
||||
required this.usuario
|
||||
required this.dados
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -35,7 +36,7 @@ class DrawerCustom extends StatelessWidget {
|
||||
// ),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 8.0,horizontal: 40),
|
||||
child: TextCustom(text: usuario.split(" ").first,fontWeight: FontWeight.bold,size: 16.0,textAlign: TextAlign.start),
|
||||
child: TextCustom(text: dados[1].split(" ").first,fontWeight: FontWeight.bold,size: 16.0,textAlign: TextAlign.start),
|
||||
),
|
||||
Container(
|
||||
height: Dimensoes.height*0.5,
|
||||
@@ -70,8 +71,8 @@ class DrawerCustom extends StatelessWidget {
|
||||
ItemDrawer(
|
||||
icone: LineIcons.calendar,
|
||||
texto: 'CALENDÁRIO ESCOLAR',
|
||||
onPressed: (){},
|
||||
// onPressed: ()=>Navigator.push(context, MaterialPageRoute(builder: (context)=>TelaChamada(alunos: alunos,indiceAluno: indiceFilhos))),
|
||||
// onPressed: (){},
|
||||
onPressed: ()=>Navigator.push(context, MaterialPageRoute(builder: (context)=>TelaCalendario(dados: dados,))),
|
||||
),
|
||||
Container(height: 1,color: Colors.grey,margin: EdgeInsets.symmetric(horizontal: 20),),
|
||||
],
|
||||
|
||||
@@ -2,10 +2,10 @@ import 'package:flutter/material.dart';
|
||||
import '../componentes/drawer_custom.dart';
|
||||
|
||||
class TelaHome extends StatefulWidget {
|
||||
List list;
|
||||
List dados;
|
||||
|
||||
TelaHome({
|
||||
required this.list
|
||||
required this.dados
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -21,7 +21,7 @@ class _TelaHomeState extends State<TelaHome> {
|
||||
backgroundColor: Colors.white,
|
||||
iconTheme: IconThemeData(color: Colors.black),
|
||||
),
|
||||
drawer: DrawerCustom(usuario: widget.list[1]),
|
||||
drawer: DrawerCustom(dados: widget.dados,),
|
||||
body: Center(
|
||||
child: Text('home'),
|
||||
),
|
||||
|
||||
@@ -2,14 +2,13 @@ import 'dart:convert';
|
||||
import 'package:brasil_fields/brasil_fields.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:package_info/package_info.dart';
|
||||
import 'package:rkm_educa_prof_app/telas/tela_home.dart';
|
||||
import '../componentes/buttom_custom.dart';
|
||||
import '../componentes/dropdown_button_city.dart';
|
||||
import '../componentes/input_text.dart';
|
||||
import '../componentes/snackBars.dart';
|
||||
import '../controllers/main_controllers.dart';
|
||||
import '../servicos/shared_preferences/shared.dart';
|
||||
import '../utils/cidades_db.dart';
|
||||
import '../utils/cores.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import '../componentes/text_custom.dart';
|
||||
@@ -35,31 +34,16 @@ class _TelaLoginState extends State<TelaLogin> {
|
||||
var map;
|
||||
int contLogo = 0;
|
||||
String urlAPI = 'https://homol-controle-educa-api.rkmsistemas.com.br';
|
||||
List listCidades = [];
|
||||
String? selectCity;
|
||||
final PrefService _prefService = PrefService();
|
||||
String _version = 'Carregando...';
|
||||
|
||||
verificacao(){
|
||||
String cidade = '';
|
||||
if(inputLogin.text.isNotEmpty){
|
||||
if(inputSenha.text.isNotEmpty){
|
||||
if(selectCity!=null){
|
||||
for(int i =0; listCidades.length > i; i ++){
|
||||
if(selectCity == Cidades().listCidades[i].cidadeFront){
|
||||
cidade = Cidades().listCidades[i].cidadeQuery;
|
||||
}
|
||||
}
|
||||
setState(() {
|
||||
carregando = true;
|
||||
});
|
||||
if(inputLogin.text.toUpperCase() == 'ADMIN'){
|
||||
conectAPI(cidade);
|
||||
}else{
|
||||
getAcessosMariaDB(cidade);
|
||||
}
|
||||
}else{
|
||||
showSnackBar(context, 'Selecione sua cidade', Colors.red);
|
||||
}
|
||||
setState(() {
|
||||
carregando = true;
|
||||
});
|
||||
getAcessosMariaDB();
|
||||
}else{
|
||||
showSnackBar(context, 'Preencha sua senha', Colors.red);
|
||||
}
|
||||
@@ -68,9 +52,9 @@ class _TelaLoginState extends State<TelaLogin> {
|
||||
}
|
||||
}
|
||||
|
||||
conectAPI(String cidade)async{
|
||||
conectAPI(String cidade, String usuario)async{
|
||||
|
||||
final url = '$urlAPI/logincontrole?NO_USERNAME=${inputLogin.text.toUpperCase()}&CIDADE=${cidade.toUpperCase()}';
|
||||
final url = '$urlAPI/logincontrole?NO_USERNAME=${usuario}&CIDADE=${cidade.toUpperCase()}';
|
||||
print(url);
|
||||
final response = await http.get(Uri.parse(url));
|
||||
var map = json.decode(response.body);
|
||||
@@ -79,63 +63,70 @@ class _TelaLoginState extends State<TelaLogin> {
|
||||
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()){
|
||||
if(map['NO_USERNAME']==usuario && map['SENHA']==inputSenha.text.toUpperCase()){
|
||||
showSnackBar(context, 'Acesso validado', Colors.green);
|
||||
List dados = [cidade.toUpperCase(),map['NO_USUARIO_SISTEMA']??'',urlAPI,map['NO_FANTASIA']??'',map['CD_UNIDADE']??0];
|
||||
Navigator.pushReplacement(context, MaterialPageRoute(builder: (context) => TelaHome(list: dados) ));
|
||||
Navigator.pushReplacement(context, MaterialPageRoute(builder: (context) => TelaHome(dados: dados) ));
|
||||
}else{
|
||||
setState(() {
|
||||
carregando = false;
|
||||
});
|
||||
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);
|
||||
showSnackBar(context, 'Acesso validado', Colors.green);
|
||||
List dados = [cidade.toUpperCase(),map['NO_USUARIO_SISTEMA']??'',urlAPI,map['NO_FANTASIA']??'',map['CD_UNIDADE']??0];
|
||||
List dados = [cidade.toUpperCase(),map['NO_USUARIO_SISTEMA']??'',urlAPI,map['NO_FANTASIA']??'',map['CD_UNIDADE']??0,inputLogin.text];
|
||||
_prefService.createCacheLogin(inputLogin.text, inputSenha.text,cidade).then((value) =>
|
||||
Navigator.pushReplacement(context, MaterialPageRoute(builder: (context) => TelaHome(list: dados) )));
|
||||
Navigator.pushReplacement(context, MaterialPageRoute(builder: (context) => TelaHome(dados: dados) )));
|
||||
}else{
|
||||
setState(() {
|
||||
carregando = false;
|
||||
});
|
||||
showSnackBar(context, 'Login não cadastrado e/ou senha incorreta e/ou Código incorreto', Colors.red);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
carregarLista(){
|
||||
for(int i=0;Cidades().listCidades.length>i;i++){
|
||||
listCidades.add(Cidades().listCidades[i].cidadeQuery);
|
||||
}
|
||||
}
|
||||
|
||||
getAcessosMariaDB(String cidade)async{
|
||||
final url = '$urlAPI/acesso_maria?LOGIN=${inputLogin.text.toUpperCase()}&CIDADE=${cidade.toUpperCase()}';
|
||||
getAcessosMariaDB()async{
|
||||
final url = '$urlAPI/loginprof?CPF=${inputLogin.text}';
|
||||
print(url);
|
||||
final response = await http.get(Uri.parse(url));
|
||||
var map = json.decode(response.body);
|
||||
print(map);
|
||||
List list = map;
|
||||
if(list.length != 0 ){
|
||||
for(int i=0;list.length>i;i++){
|
||||
if(list[i]['ID_USUARIO']==inputLogin.text.toUpperCase() &&list[i]['CONDICAO']=='1'){
|
||||
conectAPI(cidade);
|
||||
await http.get(Uri.parse(url)).then((response) async{
|
||||
var map = await json.decode(response.body);
|
||||
print(map);
|
||||
if(map != false){
|
||||
if(map['CPF']==inputLogin.text && map['CONDICAO']=='1'){
|
||||
print('api foi');
|
||||
conectAPI(map['CIDADE'],map['ID_USUARIO']);
|
||||
}else{
|
||||
setState(() {
|
||||
carregando = false;
|
||||
});
|
||||
showSnackBar(context, 'Login seu acesso não está liberado!', Colors.red);
|
||||
}
|
||||
}else{
|
||||
setState(() {
|
||||
carregando = false;
|
||||
});
|
||||
showSnackBar(context, 'Login não cadastrado e/ou senha incorreta e/ou Código incorreto', Colors.red);
|
||||
}
|
||||
}else{
|
||||
setState(() {
|
||||
carregando = false;
|
||||
});
|
||||
showSnackBar(context, 'Login não cadastrado e/ou senha incorreta e/ou Código incorreto', Colors.red);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> _getAppVersion() async {
|
||||
PackageInfo packageInfo = await PackageInfo.fromPlatform();
|
||||
String version = packageInfo.version;
|
||||
setState(() {
|
||||
_version = version;
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
carregarLista();
|
||||
_getAppVersion();
|
||||
_prefService.readCacheLogin().then((login){
|
||||
if(login!=null){
|
||||
setState(() {
|
||||
@@ -143,8 +134,8 @@ class _TelaLoginState extends State<TelaLogin> {
|
||||
});
|
||||
print(login);
|
||||
inputLogin.text = login[0];
|
||||
inputSenha.text = login[1];
|
||||
conectAPI(login[2]);
|
||||
inputSenha.text = login[5];
|
||||
conectAPI(login[2],login[1]);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -183,7 +174,7 @@ class _TelaLoginState extends State<TelaLogin> {
|
||||
// print(urlAPI);
|
||||
}),
|
||||
child: Container(
|
||||
child: Image.asset("assets/images/logoEduca.png",width:Dimensoes.width * 0.4,height: Dimensoes.height * 0.12)
|
||||
child: Image.asset("assets/images/rkmprof.png",width:Dimensoes.width * 0.35,height: Dimensoes.height * 0.10)
|
||||
),
|
||||
),
|
||||
urlAPI==Fixos.LINK_API_LOCAL?Container(
|
||||
@@ -195,10 +186,13 @@ class _TelaLoginState extends State<TelaLogin> {
|
||||
carregando?Container():Container(
|
||||
width: Dimensoes.width>900? Dimensoes.width * 0.18:Dimensoes.width*0.7,
|
||||
child: InputText(
|
||||
inputFormatters: [],
|
||||
inputFormatters: [
|
||||
FilteringTextInputFormatter.digitsOnly,
|
||||
CpfInputFormatter(),
|
||||
],
|
||||
textInputType: TextInputType.text,
|
||||
controller: inputLogin,
|
||||
title: 'Login',
|
||||
title: 'CPF',
|
||||
width: Dimensoes.width>900? Dimensoes.width * 0.18:Dimensoes.width*0.7,
|
||||
colorBorder: PaletaCores.branco,
|
||||
),
|
||||
@@ -215,17 +209,6 @@ class _TelaLoginState extends State<TelaLogin> {
|
||||
),
|
||||
),
|
||||
SizedBox(height: Dimensoes.height * 0.02),
|
||||
carregando?Container():DropDownButtonCity(
|
||||
error: 'Campo obrigatório',
|
||||
validator: true,
|
||||
select: selectCity,
|
||||
onChanged: (value){
|
||||
setState(() {
|
||||
selectCity = value!;
|
||||
print(selectCity);
|
||||
});
|
||||
},
|
||||
),
|
||||
SizedBox(height: Dimensoes.height * 0.02),
|
||||
carregando?Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
@@ -244,6 +227,10 @@ class _TelaLoginState extends State<TelaLogin> {
|
||||
colorBorder: PaletaCores.corPrimaria,
|
||||
onPressed: ()=>verificacao(),
|
||||
),
|
||||
carregando?Container():Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 20.0),
|
||||
child: Center(child: Text('Versão: $_version')),
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
|
||||
@@ -33,7 +33,7 @@ class _TelaSplashState extends State<TelaSplash> {
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Container(
|
||||
child: Image.asset("assets/images/logoEduca.png",width:Dimensoes.width * 0.4,height: Dimensoes.height * 0.15)
|
||||
child: Image.asset("assets/images/rkmprof.png",width:Dimensoes.width * 0.4,height: Dimensoes.height * 0.15)
|
||||
),
|
||||
CircularProgressIndicator(color: PaletaCores.cinzaClaro,)
|
||||
],
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
name: rkm_educa_prof_app
|
||||
description: A new Flutter project.
|
||||
publish_to: 'none'
|
||||
version: 1.0.0+1
|
||||
version: 1.0.1+2
|
||||
|
||||
environment:
|
||||
sdk: '>=3.1.4 <4.0.0'
|
||||
@@ -16,6 +16,8 @@ dependencies:
|
||||
http:
|
||||
brasil_fields:
|
||||
line_icons:
|
||||
flutter_calendar_carousel: ^2.4.2
|
||||
package_info: ^2.0.2
|
||||
|
||||
flutter_localizations:
|
||||
sdk: flutter
|
||||
|
||||
Reference in New Issue
Block a user