criada a conexão com a api na api_get_pass.dart na tela tela login_screen.dart e feito a encrypt_password.dart
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
import 'dart:convert';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:rkm/service/url_api_const.dart';
|
||||
import 'package:rkm/utils/color_palette.dart';
|
||||
import 'package:rkm/utils/const_variable.dart';
|
||||
import 'package:rkm/widgets/button_default.dart';
|
||||
@@ -7,6 +9,8 @@ import 'package:rkm/widgets/dropdown_button_city.dart';
|
||||
import 'package:rkm/widgets/input_text.dart';
|
||||
import 'package:rkm/widgets/text_default.dart';
|
||||
|
||||
import '../service/api_get_pass.dart';
|
||||
import '../service/encrypt_password.dart';
|
||||
class LoginScreen extends StatefulWidget {
|
||||
const LoginScreen({Key? key}) : super(key: key);
|
||||
|
||||
@@ -22,24 +26,45 @@ class _LoginScreenState extends State<LoginScreen> {
|
||||
String? now;
|
||||
String? selectCity;
|
||||
bool validatorDropDown= false;
|
||||
int contLogo = 0;
|
||||
String mode = 'online';
|
||||
String url = UrlApiConst.ApiUrlOnline;
|
||||
|
||||
checkLogin(){
|
||||
// if(inputUser.text.isNotEmpty && inputPassword.text.isNotEmpty && inputUser.text == 'teste' && inputPassword.text == '123'){
|
||||
// if(selectCity!=null){
|
||||
checkLogin()async{
|
||||
if(inputUser.text.isNotEmpty && inputPassword.text.isNotEmpty && inputUser.text.length>3 && inputPassword.text.length>3){
|
||||
if(selectCity!=null){
|
||||
setState(() {
|
||||
error = '';
|
||||
});
|
||||
Navigator.pushNamed(context, '/home');
|
||||
// }else{
|
||||
// setState(() {
|
||||
// error = 'Selecione sua cidade';
|
||||
// });
|
||||
// }
|
||||
// }else{
|
||||
// setState(() {
|
||||
// error = 'Usuário/senha inválido(s)';
|
||||
// });
|
||||
// }
|
||||
await ApiGetPass().apiConect(selectCity,mode,inputUser.text,url).then((response){
|
||||
print(response);
|
||||
print(inputUser.text);
|
||||
print(inputPassword.text);
|
||||
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 = '';
|
||||
print(EncryptPassword().encrypt(inputPassword.text,response['userPass']));
|
||||
});
|
||||
}
|
||||
});
|
||||
}else{
|
||||
setState(() {
|
||||
error = 'Selecione sua cidade';
|
||||
});
|
||||
}
|
||||
}else{
|
||||
setState(() {
|
||||
error = 'Usuário/senha inválido(s)';
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -61,15 +86,15 @@ class _LoginScreenState extends State<LoginScreen> {
|
||||
centerTitle: true,
|
||||
title: TextDefault(text: 'RKM AB - Carga Inicial',fontSize: ConstVariable().fontSizeTitleAppBar,color: ColorPalette.white),
|
||||
),
|
||||
bottomSheet: Container(
|
||||
color: ColorPalette.secundary,
|
||||
padding: EdgeInsets.all(8.0),
|
||||
child: TextDefault(
|
||||
text: 'Última sincronização $now',
|
||||
fontSize: 15,
|
||||
color: ColorPalette.gray,
|
||||
),
|
||||
),
|
||||
// bottomSheet: Container(
|
||||
// color: ColorPalette.secundary,
|
||||
// padding: EdgeInsets.all(8.0),
|
||||
// child: TextDefault(
|
||||
// text: 'Última sincronização $now',
|
||||
// fontSize: 15,
|
||||
// color: ColorPalette.gray,
|
||||
// ),
|
||||
// ),
|
||||
body: SingleChildScrollView(
|
||||
child: Container(
|
||||
padding: EdgeInsets.only(top: height*0.2),
|
||||
@@ -80,7 +105,27 @@ class _LoginScreenState extends State<LoginScreen> {
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Image.asset('assets/images/logo.PNG',width: width*0.4),
|
||||
GestureDetector(
|
||||
onTap: ()=>setState((){
|
||||
contLogo++;
|
||||
if(contLogo>=5 && contLogo<=10){
|
||||
mode = 'homologacao';
|
||||
url = UrlApiConst.ApiUrlHomologacao;
|
||||
}
|
||||
if(contLogo>10){
|
||||
mode = 'desenvolvimento';
|
||||
url = UrlApiConst.ApiUrlDesenvolvimento;
|
||||
if(contLogo==15){
|
||||
contLogo=0;
|
||||
mode = 'online';
|
||||
url = UrlApiConst.ApiUrlOnline;
|
||||
}
|
||||
}
|
||||
}),
|
||||
child: Image.asset('assets/images/logo.PNG',width: width*0.4)
|
||||
),
|
||||
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),
|
||||
Form(
|
||||
autovalidateMode: AutovalidateMode.onUserInteraction,
|
||||
@@ -91,18 +136,22 @@ class _LoginScreenState extends State<LoginScreen> {
|
||||
children: [
|
||||
InputText(
|
||||
hint: 'Usuário',
|
||||
label: 'Usuário',
|
||||
label: inputUser.text.isNotEmpty?'':'Usuário',
|
||||
error: 'Campo obrigatório',
|
||||
controller: inputUser,
|
||||
width: width*0.6
|
||||
width: width*0.6,
|
||||
colorBorder: Colors.white,
|
||||
onChanged: (v)=>setState((){}),
|
||||
),
|
||||
InputText(
|
||||
hint: 'Senha',
|
||||
label: 'Senha',
|
||||
error: 'Campo obrigatório',
|
||||
obscure: true,
|
||||
controller: inputPassword,
|
||||
width: width*0.6
|
||||
hint: 'Senha',
|
||||
label: inputPassword.text.isNotEmpty?'':'Senha',
|
||||
error: 'Campo obrigatório',
|
||||
obscure: true,
|
||||
controller: inputPassword,
|
||||
width: width*0.6,
|
||||
colorBorder: Colors.white,
|
||||
onChanged: (v)=>setState((){}),
|
||||
),
|
||||
DropDownButtonCity(
|
||||
error: 'Campo obrigatório',
|
||||
|
||||
Reference in New Issue
Block a user