ajustes em diversos pontos do app para receber o username, e ajustar para exibir apenas as telas que realmente será utilizado no app.
This commit is contained in:
@@ -30,7 +30,6 @@ class _LoginSavedScreenState extends State<LoginSavedScreen> {
|
||||
String? now;
|
||||
bool validatorDropDown= false;
|
||||
int contLogo = 0;
|
||||
bool loading = false;
|
||||
String urlAPI='';
|
||||
String mode = '';
|
||||
String nameCityApi = '';
|
||||
@@ -38,6 +37,8 @@ class _LoginSavedScreenState extends State<LoginSavedScreen> {
|
||||
int codCity = 0;
|
||||
int codCityIbge = 0;
|
||||
String codState = '';
|
||||
String passwordDB = '';
|
||||
String userDB = '';
|
||||
|
||||
recupDB()async{
|
||||
await DbSqliteLoad().intialDB().then((db)async{
|
||||
@@ -46,8 +47,8 @@ class _LoginSavedScreenState extends State<LoginSavedScreen> {
|
||||
mode = list[0]['MODE'];
|
||||
nameCityApi = list[0]['NAME_CITY_API'];
|
||||
nameCityFront = list[0]['NAME_CITY_FRONT'];
|
||||
inputUser.text = list[0]['USER'];
|
||||
inputPassword.text = list[0]['PASSWORD'];
|
||||
userDB = list[0]['USER'];
|
||||
passwordDB = list[0]['PASSWORD'];
|
||||
codCity = list[0]['COD_CITY'];
|
||||
codState = list[0]['COD_STATE'];
|
||||
codCityIbge = list[0]['COD_IBGE'];
|
||||
@@ -57,43 +58,17 @@ class _LoginSavedScreenState extends State<LoginSavedScreen> {
|
||||
|
||||
checkLogin()async{
|
||||
if(inputUser.text.isNotEmpty && inputPassword.text.isNotEmpty && inputUser.text.length>3 && inputPassword.text.length>3){
|
||||
setState(() {
|
||||
error = '';
|
||||
loading = true;
|
||||
});
|
||||
await ApiDataLoad().apiConect(urlAPI,mode,nameCityApi,inputUser.text).then((response) async {
|
||||
if(inputUser.text == inputPassword.text || response['bloqueio']==1){
|
||||
setState(() {
|
||||
error = 'Usuário bloqueado/senha incorreta';
|
||||
});
|
||||
}else if(response['status']==0) {
|
||||
setState(() {
|
||||
error = 'Usuário não encontrado';
|
||||
});
|
||||
}else if(response['status']==1) {
|
||||
setState((){
|
||||
error = '';
|
||||
});
|
||||
//verificar se a criptografia identificou se a senha está correta
|
||||
if(MainControllers().encrypt(inputPassword.text,response['userPass']) == response['userPass']){
|
||||
// print(EncryptPassword().encrypt(inputPassword.text,response['userPass']));
|
||||
DbSqliteLoad().updateArgs(mode, inputUser.text, inputPassword.text).then((value){
|
||||
setState(() {
|
||||
loading = false;
|
||||
});
|
||||
int mes = DateTime.now().month;
|
||||
if(widget.listControl[0]['COMPETENCIA'].toString()=='${DateTime.now().year}${mes<10?'0${mes}':'$mes'}'){
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) => HomeScreen()),
|
||||
);
|
||||
}else{
|
||||
Navigator.pushNamed(context, '/import_sigtap');
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
if(inputUser.text == userDB && inputPassword.text == passwordDB){
|
||||
setState(() {
|
||||
error = '';
|
||||
});
|
||||
Navigator.push(context,MaterialPageRoute(builder: (context) => HomeScreen(username: inputUser.text,)));
|
||||
}else{
|
||||
setState(() {
|
||||
error = 'Usuário/senha inválido(s)';
|
||||
});
|
||||
}
|
||||
|
||||
}else{
|
||||
setState(() {
|
||||
error = 'Usuário/senha inválido(s)';
|
||||
@@ -146,16 +121,7 @@ class _LoginSavedScreenState extends State<LoginSavedScreen> {
|
||||
mode == 'homologacao'?Image.asset('assets/images/homologacao.png',width: width*0.4):Container(),
|
||||
mode == 'desenvolvimento'?Image.asset('assets/images/desenvolvimento.png',width: width*0.4):Container(),
|
||||
SizedBox(height: 10),
|
||||
loading?Center(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Image.asset('assets/images/loading.gif'),
|
||||
SizedBox(height: 10),
|
||||
TextDefault(text: 'Carregando dados...',color: ColorPalette.black54,fontSize: 20,fontWeigth: FontWeight.bold,)
|
||||
],
|
||||
),
|
||||
):Form(
|
||||
Form(
|
||||
autovalidateMode: AutovalidateMode.onUserInteraction,
|
||||
child: Container(
|
||||
width: width*0.6,
|
||||
@@ -183,7 +149,7 @@ class _LoginSavedScreenState extends State<LoginSavedScreen> {
|
||||
),
|
||||
),
|
||||
),
|
||||
loading?Container():ButtonDefault(
|
||||
ButtonDefault(
|
||||
onPressed: ()=>checkLogin(),
|
||||
title: 'Entrar',
|
||||
width: width*0.6,
|
||||
|
||||
Reference in New Issue
Block a user