inserida a possibilidade de resetar a senha e bloquear o responsável

This commit is contained in:
Reginaldo
2023-06-30 16:41:54 -03:00
parent a04cdfa77c
commit 615680c947
5 changed files with 180 additions and 76 deletions

View File

@@ -186,7 +186,7 @@ class _HomeScreenState extends State<HomeScreen> {
setState(()=>showEscola?showEscola=false:showEscola=true);
},
text: showEscola?'Cadastrar Pais':'Cadastrar Usuários',
size: 15,
fontSize: 15,
widthCustom: 0.1,
heightCustom: 0.05,
colorButton: PaletteColors.primaryColor,
@@ -231,7 +231,7 @@ class _HomeScreenState extends State<HomeScreen> {
widthCustom: 0.05,
heightCustom: 0.063,
text: "PESQUISAR",
size: 10.0,
fontSize: 10.0,
colorText: PaletteColors.white,
colorButton: PaletteColors.green,
colorBorder: PaletteColors.green,
@@ -251,7 +251,7 @@ class _HomeScreenState extends State<HomeScreen> {
widthCustom: 0.05,
heightCustom: 0.063,
text: "LIMPAR",
size: 10.0,
fontSize: 10.0,
colorText: PaletteColors.white,
colorButton: PaletteColors.primaryColor,
colorBorder: PaletteColors.primaryColor,
@@ -347,7 +347,7 @@ class _HomeScreenState extends State<HomeScreen> {
widthCustom: 0.05,
heightCustom: 0.063,
text: "PESQUISAR",
size: 10.0,
fontSize: 10.0,
colorText: PaletteColors.white,
colorButton: PaletteColors.green,
colorBorder: PaletteColors.green,
@@ -366,7 +366,7 @@ class _HomeScreenState extends State<HomeScreen> {
widthCustom: 0.05,
heightCustom: 0.063,
text: "LIMPAR",
size: 10.0,
fontSize: 10.0,
colorText: PaletteColors.white,
colorButton: PaletteColors.primaryColor,
colorBorder: PaletteColors.primaryColor,

View File

@@ -197,7 +197,7 @@ class _LoginScreenState extends State<LoginScreen> {
widthCustom: 0.1,
heightCustom: 0.07,
text: "ENTRAR",
size: 14.0,
fontSize: 14.0,
colorText: PaletteColors.white,
colorButton: PaletteColors.primaryColor,
colorBorder: PaletteColors.primaryColor,

View File

@@ -33,59 +33,74 @@ class _ResponsibleRegisterScreenState extends State<ResponsibleRegisterScreen> {
var inputNome = TextEditingController();
var inputParentesco = TextEditingController();
var inputCpf = TextEditingController();
var inputSenha = TextEditingController();
// var inputSenha = TextEditingController();
var inputData = TextEditingController();
bool carregando = true;
inserirDB()async{
bloquearResponsavel(int index)async{
final url = 'http://192.168.18.2:8000/inserirpais';
final response = await http.post(
Uri.parse(url),
body:{
'CD_ALUNO' : widget.alunoModel.dados['CD_ALUNO'],
'ALUNO': widget.alunoModel.dados['NO_ALUNO'],
'CPF': inputCpf.text,
'NOME' : inputNome.text,
'SENHA' : inputSenha.text,
'PARENTESCO' : inputParentesco.text,
'DATA_CADASTRO' : DateFormat('dd/MM/yyyy HH:mm').format(DateTime.now()),
'CONDICAO' : editando?'EDITADO':'NOVO',
'CIDADE' : widget.alunoModel.cidade
}
Uri.parse(url),
body:{
'CD_ALUNO' : widget.alunoModel.dados['CD_ALUNO'],
'ALUNO': widget.alunoModel.dados['NO_ALUNO'],
'CPF': responsaveis[index].CPF,
'NOME' : responsaveis[index].NOME,
'SENHA' : responsaveis[index].SENHA,
'PARENTESCO' : responsaveis[index].PARENTESCO,
'DATA_CADASTRO' : DateFormat('dd/MM/yyyy HH:mm').format(DateTime.now()),
'CONDICAO' : 'BLOQUEADO',
'CIDADE' : widget.alunoModel.cidade
}
);
if(response.body == 'cadastrado com sucesso' || response.body == 'editado com sucesso'){
editando?
showSnackBar(context, 'Responsável alterado!', Colors.green):
showSnackBar(context, 'Responsável adicionado!', Colors.green);
inputNome.clear();
inputParentesco.clear();
inputCpf.clear();
showRegister = false;
editando = false;
indice = null;
inputData.clear();
paisBanco();
setState((){});
}else{
carregando = false;
setState((){});
showSnackBar(context, 'Erro ao fazer o registro, verifique os dados do usuário', Colors.red);
}
}
inserirDB(int index)async{
final url = 'http://192.168.18.2:8000/inserirpais';
final response = await http.post(
Uri.parse(url),
body:{
'CD_ALUNO' : widget.alunoModel.dados['CD_ALUNO'],
'ALUNO': widget.alunoModel.dados['NO_ALUNO'],
'CPF': responsaveis[index].CPF,
'NOME' : responsaveis[index].NOME,
'SENHA' : editando?responsaveis[index].SENHA: responsaveis[index].CPF.replaceAll('-','').replaceAll('.', ''),
'PARENTESCO' : responsaveis[index].PARENTESCO,
'DATA_CADASTRO' : DateFormat('dd/MM/yyyy HH:mm').format(DateTime.now()),
'CONDICAO' : editando?'EDITADO':'NOVO',
'CIDADE' : widget.alunoModel.cidade
}
);
print(response.body);
if(response.body == 'cadastrado com sucesso' || response.body == 'editado com sucesso'){
editando?
showSnackBar(context, 'Responsável alterado!', Colors.green):
showSnackBar(context, 'Responsável adicionado!', Colors.green);
if(editando && indice!=null){
responsaveis[indice!] = ResponsavelModel(
CD_ALUNO: widget.alunoModel.dados['CD_ALUNO'],
NOME: inputNome.text,
PARENTESCO: inputParentesco.text,
CPF: inputCpf.text,
SENHA: inputSenha.text,
DATA_CADASTRO: DateFormat('dd/MM/yyyy HH:mm').format(DateTime.now()),
CONDICAO: ''
);
}else{
responsaveis.add(
ResponsavelModel(
CD_ALUNO: widget.alunoModel.dados['CD_ALUNO'],
NOME: inputNome.text.toUpperCase(),
PARENTESCO: inputParentesco.text.toUpperCase(),
CPF: inputCpf.text,
SENHA: inputSenha.text.toUpperCase(),
DATA_CADASTRO: DateFormat('dd/MM/yyyy HH:mm').format(DateTime.now()),
CONDICAO: ''
)
);
}
inputNome.clear();
inputParentesco.clear();
inputCpf.clear();
inputSenha.clear();
showRegister = false;
editando = false;
indice = null;
@@ -104,14 +119,10 @@ class _ResponsibleRegisterScreenState extends State<ResponsibleRegisterScreen> {
if(inputNome.text.isNotEmpty && inputNome.text.contains(' ')){
if(inputParentesco.text.isNotEmpty){
if(inputCpf.text.isNotEmpty && GetUtils.isCpf(inputCpf.text)){
if(inputSenha.text.isNotEmpty && inputSenha.text.length > 5){
setState(() {
carregando = true;
});
inserirDB();
}else{
showSnackBar(context, 'Insira o uma senha com o mínimo de 6 caracteres', Colors.red);
}
setState(() {
carregando = true;
});
inserirDB(indice!);
}else{
showSnackBar(context, 'CPF inválido', Colors.red);
}
@@ -347,16 +358,6 @@ class _ResponsibleRegisterScreenState extends State<ResponsibleRegisterScreen> {
],
),
),
Container(
width: width>900? width * 0.18:width*0.4,
child: InputText(
inputFormatters: [],
controller: inputSenha,
title: 'Senha',
width: width * 0.18,
colorBorder: PaletteColors.white,
),
),
editando?Container(
width: width>900? width * 0.18:width*0.4,
child: InputText(
@@ -380,7 +381,6 @@ class _ResponsibleRegisterScreenState extends State<ResponsibleRegisterScreen> {
inputData.clear();
inputNome.clear();
inputParentesco.clear();
inputSenha.clear();
inputCpf.clear();
}),
text: 'Cancelar',
@@ -389,18 +389,21 @@ class _ResponsibleRegisterScreenState extends State<ResponsibleRegisterScreen> {
colorText: Colors.white,
colorBorder: PaletteColors.primaryColor,
colorButton: PaletteColors.primaryColor,
size: 15,
fontSize: 15,
),
SizedBox(width: 50,),
ButtonCustom(
onPressed:()=>salvarResponsavel(),
onPressed:(){
responsaveis[indice!].CPF = inputCpf.text;
salvarResponsavel();
},
text: 'Salvar',
widthCustom: 0.1,
heightCustom: 0.05,
colorText: Colors.white,
colorBorder: PaletteColors.green,
colorButton: PaletteColors.green,
size: 15,
fontSize: 15,
)
],
)
@@ -433,12 +436,10 @@ class _ResponsibleRegisterScreenState extends State<ResponsibleRegisterScreen> {
inputNome.text = responsaveis[index].NOME;
inputParentesco.text = responsaveis[index].PARENTESCO;
inputCpf.text = responsaveis[index].CPF;
inputSenha.text = responsaveis[index].SENHA;
inputData.text = responsaveis[index].DATA_CADASTRO;
setState(() {});
},
onTapDelete: (){
showDialog(
context: context,
builder: (BuildContext context){
@@ -454,7 +455,7 @@ class _ResponsibleRegisterScreenState extends State<ResponsibleRegisterScreen> {
colorText: Colors.white,
colorBorder: PaletteColors.bgColor,
colorButton: PaletteColors.bgColor,
size: 15,
fontSize: 15,
),
ButtonCustom(
onPressed:()=>excluirResponsavel(index, responsaveis[index].CPF),
@@ -464,7 +465,84 @@ class _ResponsibleRegisterScreenState extends State<ResponsibleRegisterScreen> {
colorText: Colors.white,
colorBorder: PaletteColors.primaryColor,
colorButton: PaletteColors.primaryColor,
size: 15,
fontSize: 15,
),
],
);
});
},
resetarSenha: (){
showDialog(
context: context,
builder: (BuildContext context){
return AlertDialog(
title: TextCustom(text: 'Resetar senha'),
content: TextCustom(text:'Deseja realmente resetar a senha desse responsável?',),
actions: [
ButtonCustom(
onPressed:()=>Navigator.pop(context),
text: 'NÃO',
widthCustom: 0.1,
heightCustom: 0.05,
colorText: Colors.white,
colorBorder: PaletteColors.bgColor,
colorButton: PaletteColors.bgColor,
fontSize: 15,
),
ButtonCustom(
onPressed:(){
Navigator.pop(context);
editando = true;
responsaveis[index].SENHA = responsaveis[index].CPF.toString().replaceAll('-', '').replaceAll('.', '');
carregando = true;
setState(() {});
inserirDB(index);
},
text: 'SIM',
widthCustom: 0.1,
heightCustom: 0.05,
colorText: Colors.white,
colorBorder: PaletteColors.primaryColor,
colorButton: PaletteColors.primaryColor,
fontSize: 15,
),
],
);
});
},
bloquearSenha: (){
showDialog(
context: context,
builder: (BuildContext context){
return AlertDialog(
title: TextCustom(text: 'Bloquear'),
content: TextCustom(text:'Deseja realmente bloquear esse responsável?',),
actions: [
ButtonCustom(
onPressed:()=>Navigator.pop(context),
text: 'NÃO',
widthCustom: 0.1,
heightCustom: 0.05,
colorText: Colors.white,
colorBorder: PaletteColors.bgColor,
colorButton: PaletteColors.bgColor,
fontSize: 15,
),
ButtonCustom(
onPressed:(){
Navigator.pop(context);
editando = true;
carregando = true;
setState(() {});
bloquearResponsavel(index);
},
text: 'SIM',
widthCustom: 0.1,
heightCustom: 0.05,
colorText: Colors.white,
colorBorder: PaletteColors.primaryColor,
colorButton: PaletteColors.primaryColor,
fontSize: 15,
),
],
);

View File

@@ -3,7 +3,7 @@ import 'package:flutter/material.dart';
class ButtonCustom extends StatelessWidget{
final VoidCallback onPressed;
final String text;
final double size;
final double fontSize;
final Color colorButton;
final Color colorText;
final Color colorBorder;
@@ -13,7 +13,7 @@ class ButtonCustom extends StatelessWidget{
ButtonCustom({
required this.onPressed,
required this.text,
required this.size,
required this.fontSize,
required this.colorButton,
required this.colorText,
required this.colorBorder,
@@ -35,7 +35,7 @@ ButtonCustom({
child: Text(text,
style: TextStyle(
color: colorText,
fontSize: size,
fontSize: fontSize,
fontWeight: FontWeight.bold
),
) ,

View File

@@ -4,6 +4,7 @@ import 'package:educa_controle_acesso/screens/responsible_register_screen.dart';
import 'package:educa_controle_acesso/widgets/text_custom.dart';
import 'package:flutter/material.dart';
import '../utils/colors.dart';
import 'buttom_custom.dart';
import 'caixa_texto_container.dart';
class DadosResponsaveisContainer extends StatelessWidget {
@@ -11,11 +12,15 @@ class DadosResponsaveisContainer extends StatelessWidget {
ResponsavelModel responsavelModel;
var onTapEdit;
var onTapDelete;
var resetarSenha;
var bloquearSenha;
DadosResponsaveisContainer({
required this.responsavelModel,
required this.onTapEdit,
required this.onTapDelete
required this.onTapDelete,
required this.resetarSenha,
required this.bloquearSenha
});
@override
@@ -32,7 +37,7 @@ class DadosResponsaveisContainer extends StatelessWidget {
icon: Icon(Icons.delete,color: PaletteColors.grey,),
),
Container(
width: width*0.35,
width: width*0.5,
padding: EdgeInsets.symmetric(vertical: 10,horizontal: 5),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
@@ -43,6 +48,27 @@ class DadosResponsaveisContainer extends StatelessWidget {
alignment: Alignment.bottomCenter,
margin: EdgeInsets.all(5),
child: Icon(Icons.check_circle,color: Colors.green,),
):Container(),
ButtonCustom(
text: 'Resetar Senha',
fontSize: 14.0,
colorButton: PaletteColors.grey,
colorText: PaletteColors.white,
colorBorder: PaletteColors.grey,
onPressed:resetarSenha,
heightCustom: 0.05,
widthCustom: 0.05,
),
SizedBox(width: 10,),
responsavelModel.CPF!='' && responsavelModel.SENHA!=''?ButtonCustom(
text: 'Bloquear Responsável',
fontSize: 14.0,
colorButton: PaletteColors.primaryColor,
colorText: PaletteColors.white,
colorBorder: PaletteColors.primaryColor,
onPressed:bloquearSenha,
heightCustom: 0.05,
widthCustom: 0.05,
):Container()
],
),