feito o cadastro do cidadão
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rkm/models/args_load_init_model.dart';
|
||||
import 'package:rkm/service/api/url_api_const.dart';
|
||||
import 'package:rkm/utils/color_palette.dart';
|
||||
import 'package:rkm/utils/const_variable.dart';
|
||||
@@ -7,9 +6,9 @@ import 'package:rkm/widgets/button_default.dart';
|
||||
import 'package:rkm/widgets/dropdown_button_city.dart';
|
||||
import 'package:rkm/widgets/input_text.dart';
|
||||
import 'package:rkm/widgets/text_default.dart';
|
||||
import '../../models/city_load_model.dart';
|
||||
import '../../service/api/api_data_load.dart';
|
||||
import '../../service/api/encrypt_password.dart';
|
||||
import '../../service/db/db_sqlite_load.dart';
|
||||
import '../../service/shared_preferences/shared_preferences_service.dart';
|
||||
import '../load_init_screen.dart';
|
||||
class LoginLoadScreen extends StatefulWidget {
|
||||
@@ -28,13 +27,17 @@ class _LoginLoadScreenState extends State<LoginLoadScreen> {
|
||||
String? selectCity;
|
||||
bool validatorDropDown= false;
|
||||
int contLogo = 0;
|
||||
String mode = 'desenvolvimento';
|
||||
String urlAPI = UrlApiConst.ApiUrlDesenvolvimento;
|
||||
String mode = 'homologacao';
|
||||
String urlAPI = UrlApiConst.ApiUrlHomologacao;
|
||||
bool loading = false;
|
||||
String nameCityApi = '';
|
||||
String nameCityFront = '';
|
||||
String codState = '';
|
||||
int codCity = 0;
|
||||
int codCityIbge = 0;
|
||||
|
||||
final PrefService _prefService = PrefService();
|
||||
checkLogin()async{
|
||||
CityLoadModel? model;
|
||||
ArgsLoadInitModel? args;
|
||||
if(inputUser.text.isNotEmpty && inputPassword.text.isNotEmpty && inputUser.text.length>3 && inputPassword.text.length>3){
|
||||
if(selectCity!=null){
|
||||
_prefService.createCacheModel(inputUser.text,inputPassword.text,selectCity!,mode);
|
||||
@@ -43,30 +46,34 @@ class _LoginLoadScreenState extends State<LoginLoadScreen> {
|
||||
loading = true;
|
||||
for(int i=0;ConstVariable().itensCity.length > i;i++){
|
||||
if(ConstVariable().itensCity[i].nameCityFront == selectCity!){
|
||||
model = ConstVariable().itensCity[i];
|
||||
nameCityApi = ConstVariable().itensCity[i].nameCityApi;
|
||||
nameCityFront = ConstVariable().itensCity[i].nameCityFront;
|
||||
codCityIbge = ConstVariable().itensCity[i].codCityIbge;
|
||||
codCity = ConstVariable().itensCity[i].codCity;
|
||||
codState = ConstVariable().itensCity[i].codState;
|
||||
}
|
||||
}
|
||||
});
|
||||
if(model!=null){
|
||||
args = ArgsLoadInitModel(
|
||||
mode: mode,
|
||||
model:model!,
|
||||
user: inputUser.text,
|
||||
password: inputPassword.text,
|
||||
urlAPI: urlAPI
|
||||
);
|
||||
}
|
||||
if(args!=null){
|
||||
await ApiDataLoad().apiConect(args!).then((response) async {
|
||||
if(inputUser.text == inputPassword.text || response['bloqueio']==1){
|
||||
await ApiDataLoad().apiConect(urlAPI,mode,nameCityApi,inputUser.text).then((response) async {
|
||||
print("erre : "+response.toString());
|
||||
if(response == 'Erro' || response.toString() == 'Error: -902 - I/O error during "open" operation for file "/bases/conectasus/extrema/SISTEMA.FDB" Error while trying to open file No such file or directory'){
|
||||
setState(() {
|
||||
error = 'Usuário bloqueado/senha incorreta';
|
||||
loading = false;
|
||||
error = 'Erro na conexão!Verifique sua internet\n ou a cidade que está selecionada!';
|
||||
});
|
||||
}else if(inputUser.text == inputPassword.text || response['bloqueio']==1){
|
||||
setState(() {
|
||||
loading = false;
|
||||
error = 'Usuário bloqueado/usuário e/ou senha incorreta';
|
||||
});
|
||||
}else if(response['status']==0) {
|
||||
setState(() {
|
||||
loading = false;
|
||||
error = 'Usuário não encontrado';
|
||||
});
|
||||
}else if(response['status']==1) {
|
||||
print('aqui 1');
|
||||
print(response);
|
||||
setState((){
|
||||
error = '';
|
||||
});
|
||||
@@ -76,14 +83,37 @@ class _LoginLoadScreenState extends State<LoginLoadScreen> {
|
||||
setState(() {
|
||||
loading = false;
|
||||
});
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) => LoadInitScreen(args: args!)),
|
||||
);
|
||||
await DbSqliteLoad().deleteLoad().then((_)async {
|
||||
DbSqliteLoad().saveArgs(
|
||||
mode,
|
||||
inputUser.text,
|
||||
inputPassword.text,
|
||||
urlAPI,
|
||||
codCity,
|
||||
nameCityApi,
|
||||
nameCityFront,
|
||||
codState,
|
||||
codCityIbge).then((value) {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => LoadInitScreen()),
|
||||
);
|
||||
});
|
||||
});
|
||||
}else{
|
||||
setState(() {
|
||||
loading = false;
|
||||
error = 'Usuário bloqueado/senha incorreta';
|
||||
});
|
||||
}
|
||||
}else{
|
||||
setState(() {
|
||||
loading = false;
|
||||
error = 'Falha de conexão com API';
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}else{
|
||||
setState(() {
|
||||
error = 'Selecione sua cidade';
|
||||
@@ -158,7 +188,6 @@ class _LoginLoadScreenState extends State<LoginLoadScreen> {
|
||||
InputText(
|
||||
hint: 'Usuário',
|
||||
label: inputUser.text.isNotEmpty?'':'Usuário',
|
||||
error: 'Campo obrigatório',
|
||||
controller: inputUser,
|
||||
width: width*0.6,
|
||||
colorBorder: Colors.white,
|
||||
@@ -167,7 +196,6 @@ class _LoginLoadScreenState extends State<LoginLoadScreen> {
|
||||
InputText(
|
||||
hint: 'Senha',
|
||||
label: inputPassword.text.isNotEmpty?'':'Senha',
|
||||
error: 'Campo obrigatório',
|
||||
obscure: true,
|
||||
controller: inputPassword,
|
||||
width: width*0.6,
|
||||
@@ -195,7 +223,10 @@ class _LoginLoadScreenState extends State<LoginLoadScreen> {
|
||||
width: width*0.6,
|
||||
),
|
||||
SizedBox(height: 10),
|
||||
TextDefault(text: error,color: ColorPalette.red),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 20.0),
|
||||
child: TextDefault(text: error,color: ColorPalette.red,maxLines: 3),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user