criada a tela responsible_register_screen.dart, o model responsavel_model.dart e feitos outros ajustes
This commit is contained in:
@@ -27,7 +27,6 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
|
||||
pesquisa(){
|
||||
pesquisarAluno();
|
||||
|
||||
}
|
||||
|
||||
pesquisarAluno()async{
|
||||
@@ -35,7 +34,13 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
if(controllerPesquisa.text.isNotEmpty){
|
||||
for (int i =0;alunos.length>i;i++) {
|
||||
String nome = alunos[i].nome.toUpperCase();
|
||||
if(nome.contains(controllerPesquisa.text.toUpperCase())){
|
||||
String data = alunos[i].data_nasc.toUpperCase();
|
||||
String ra = alunos[i].ra.toUpperCase();
|
||||
|
||||
if(nome.contains(controllerPesquisa.text.toUpperCase()) ||
|
||||
data.contains(controllerPesquisa.text.toUpperCase()) ||
|
||||
ra.contains(controllerPesquisa.text.toUpperCase())
|
||||
){
|
||||
if(resultadoPesquisa.length<10){
|
||||
resultadoPesquisa.add(alunos[i]);
|
||||
}
|
||||
@@ -63,7 +68,17 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
double height = MediaQuery.of(context).size.height;
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: TextCustom(text: 'Cadastrar responsável',color: Colors.white,),backgroundColor: PaletteColors.grey),
|
||||
appBar: AppBar(
|
||||
title: Row(
|
||||
children: [
|
||||
Container(
|
||||
child: Image.asset("assets/images/logoEduca.png",width:width * 0.08,height: height * 0.12)
|
||||
),
|
||||
TextCustom(text: '- Pesquisar aluno',color: Colors.white,),
|
||||
],
|
||||
),
|
||||
backgroundColor: PaletteColors.grey,
|
||||
),
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: ListView(
|
||||
@@ -71,7 +86,7 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
SizedBox(height: height*0.05),
|
||||
Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: width>900?width*0.3:width*0.05),
|
||||
child: InputText(controller: controllerPesquisa, width: width*0.2,title: 'Pesquisar Aluno(a)',)
|
||||
child: InputText(controller: controllerPesquisa, width: width*0.2,title: 'Pesquisar Aluno(a)',inputFormatters: [],)
|
||||
),
|
||||
Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: width>900?width*0.3:width*0.05),
|
||||
|
||||
@@ -4,7 +4,6 @@ import 'package:flutter/material.dart';
|
||||
import '../utils/colors.dart';
|
||||
import '../widgets/buttom_custom.dart';
|
||||
import '../widgets/snackBars.dart';
|
||||
import '../widgets/text_custom.dart';
|
||||
|
||||
class LoginScreen extends StatefulWidget {
|
||||
const LoginScreen({Key? key}) : super(key: key);
|
||||
@@ -54,11 +53,12 @@ class _LoginScreenState extends State<LoginScreen> {
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Container(
|
||||
child: Image.asset("assets/image/logo.PNG",width:width * 0.2 ,height: height * 0.12)
|
||||
child: Image.asset("assets/images/logoEduca.png",width:width * 0.15,height: height * 0.12)
|
||||
),
|
||||
Container(
|
||||
width: width>900? width * 0.18:width*0.5,
|
||||
child: InputText(
|
||||
inputFormatters: [],
|
||||
controller: inputEmail,
|
||||
title: 'E-mail',
|
||||
width: width>900? width * 0.18:width*0.5,
|
||||
@@ -69,6 +69,7 @@ class _LoginScreenState extends State<LoginScreen> {
|
||||
Container(
|
||||
width: width>900? width * 0.18:width*0.5,
|
||||
child: InputText(
|
||||
inputFormatters: [],
|
||||
controller: inputSenha,
|
||||
title: 'Senha',
|
||||
obscure: true,
|
||||
@@ -86,7 +87,6 @@ class _LoginScreenState extends State<LoginScreen> {
|
||||
colorButton: PaletteColors.primaryColor,
|
||||
colorBorder: PaletteColors.primaryColor,
|
||||
onPressed: ()=>verificacao(),
|
||||
font: 'Nunito',
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
288
lib/screens/responsible_register_screen.dart
Normal file
288
lib/screens/responsible_register_screen.dart
Normal file
@@ -0,0 +1,288 @@
|
||||
import 'package:brasil_fields/brasil_fields.dart';
|
||||
import 'package:educa_controle_acesso/models/aluno_model.dart';
|
||||
import 'package:educa_controle_acesso/models/responsavel_model.dart';
|
||||
import 'package:educa_controle_acesso/widgets/dados_responsaveis_container.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import '../utils/colors.dart';
|
||||
import '../widgets/buttom_custom.dart';
|
||||
import '../widgets/input_text.dart';
|
||||
import '../widgets/snackBars.dart';
|
||||
import '../widgets/text_custom.dart';
|
||||
|
||||
class ResponsibleRegisterScreen extends StatefulWidget {
|
||||
AlunoModel alunoModel;
|
||||
|
||||
ResponsibleRegisterScreen({required this.alunoModel});
|
||||
|
||||
@override
|
||||
State<ResponsibleRegisterScreen> createState() => _ResponsibleRegisterScreenState();
|
||||
}
|
||||
|
||||
class _ResponsibleRegisterScreenState extends State<ResponsibleRegisterScreen> {
|
||||
|
||||
List <ResponsavelModel> responsaveis = [];
|
||||
bool showRegister = false;
|
||||
bool editando = false;
|
||||
int? indice;
|
||||
var inputNome = TextEditingController();
|
||||
var inputParentesco = TextEditingController();
|
||||
var inputCpf = TextEditingController();
|
||||
var inputSenha = TextEditingController();
|
||||
var inputData = TextEditingController();
|
||||
|
||||
salvarResponsavel() {
|
||||
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){
|
||||
if(editando && indice!=null){
|
||||
responsaveis[indice!] = ResponsavelModel(
|
||||
nomeAluno: widget.alunoModel.nome,
|
||||
raAluno: widget.alunoModel.ra,
|
||||
escola: widget.alunoModel.escola,
|
||||
serie: widget.alunoModel.serie,
|
||||
turma: widget.alunoModel.turma,
|
||||
nomeResponsavel: inputNome.text,
|
||||
parentesco: inputParentesco.text,
|
||||
cpf: inputCpf.text,
|
||||
senha: inputSenha.text,
|
||||
dataCadastro: DateFormat('dd/MM/yyyy HH:mm').format(DateTime.now())
|
||||
);
|
||||
}else{
|
||||
responsaveis.add(
|
||||
ResponsavelModel(
|
||||
nomeAluno: widget.alunoModel.nome.toUpperCase(),
|
||||
raAluno: widget.alunoModel.ra.toUpperCase(),
|
||||
escola: widget.alunoModel.escola.toUpperCase(),
|
||||
serie: widget.alunoModel.serie.toUpperCase(),
|
||||
turma: widget.alunoModel.turma.toUpperCase(),
|
||||
nomeResponsavel: inputNome.text.toUpperCase(),
|
||||
parentesco: inputParentesco.text.toUpperCase(),
|
||||
cpf: inputCpf.text,
|
||||
senha: inputSenha.text.toUpperCase(),
|
||||
dataCadastro: DateFormat('dd/MM/yyyy HH:mm').format(DateTime.now())
|
||||
)
|
||||
);
|
||||
}
|
||||
editando?
|
||||
showSnackBar(context, 'Responsável alterado!', Colors.green):
|
||||
showSnackBar(context, 'Responsável adicionado!', Colors.green);
|
||||
inputNome.clear();
|
||||
inputParentesco.clear();
|
||||
inputCpf.clear();
|
||||
inputSenha.clear();
|
||||
showRegister = false;
|
||||
editando = false;
|
||||
indice = null;
|
||||
inputData.clear();
|
||||
setState((){});
|
||||
}else{
|
||||
showSnackBar(context, 'Insira o uma senha com o mínimo de 6 caracteres', Colors.red);
|
||||
}
|
||||
}else{
|
||||
showSnackBar(context, 'CPF inválido', Colors.red);
|
||||
}
|
||||
}else{
|
||||
showSnackBar(context, 'Insira o parentesco do responsável', Colors.red);
|
||||
}
|
||||
}else{
|
||||
showSnackBar(context, 'Insira o nome completo do responsável', Colors.red);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
double width = MediaQuery.of(context).size.width;
|
||||
double height = MediaQuery.of(context).size.height;
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Row(
|
||||
children: [
|
||||
Container(
|
||||
child: Image.asset("assets/images/logoEduca.png",width:width * 0.08,height: height * 0.12)
|
||||
),
|
||||
TextCustom(text: '- Cadastrar Responsável',color: Colors.white,),
|
||||
],
|
||||
),
|
||||
backgroundColor: PaletteColors.grey,
|
||||
),
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.all(30.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
TextCustom(text: 'Aluno(a): ${widget.alunoModel.nome}'),
|
||||
TextCustom(text: 'Turma: ${widget.alunoModel.serie}° ANO ${widget.alunoModel.turma}'),
|
||||
TextCustom(text: 'RA: ${widget.alunoModel.ra}'),
|
||||
TextCustom(text: 'Escola: ${widget.alunoModel.escola}'),
|
||||
SizedBox(height: 50,),
|
||||
Row(
|
||||
children: [
|
||||
TextCustom(text: 'Responsáveis Cadastrados:'),
|
||||
IconButton(
|
||||
icon: Icon(Icons.add_circle,color: PaletteColors.primaryColor),
|
||||
onPressed: ()=>setState(()=>showRegister = true),
|
||||
)
|
||||
],
|
||||
),
|
||||
showRegister?Container(
|
||||
alignment: Alignment.center,
|
||||
padding: EdgeInsets.symmetric(horizontal: width*0.35),
|
||||
width: width,
|
||||
child: Card(
|
||||
elevation: 10,
|
||||
child: Padding(
|
||||
padding: EdgeInsets.only(bottom: 20),
|
||||
child: Column(
|
||||
children: [
|
||||
Container(
|
||||
width: width*0.30,
|
||||
padding: EdgeInsets.all(10),
|
||||
color: Colors.black54,
|
||||
child: TextCustom(
|
||||
text: 'Novo responsável',
|
||||
color: Colors.white,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 15.0),
|
||||
child: TextCustom(text: 'Prencha os campos todos os campos para adicionar.'),
|
||||
),
|
||||
Container(
|
||||
width: width>900? width * 0.18:width*0.4,
|
||||
child: InputText(
|
||||
inputFormatters: [],
|
||||
controller: inputNome,
|
||||
title: 'Nome Completo',
|
||||
width: width * 0.18,
|
||||
colorBorder: PaletteColors.white,
|
||||
),
|
||||
),
|
||||
Container(
|
||||
width: width>900? width * 0.18:width*0.4,
|
||||
child: InputText(
|
||||
inputFormatters: [],
|
||||
controller: inputParentesco,
|
||||
title: 'Parentesco',
|
||||
width: width * 0.18,
|
||||
colorBorder: PaletteColors.white,
|
||||
),
|
||||
),
|
||||
Container(
|
||||
width: width>900? width * 0.18:width*0.4,
|
||||
child: InputText(
|
||||
controller: inputCpf,
|
||||
title: 'CPF',
|
||||
width: width * 0.18,
|
||||
colorBorder: PaletteColors.white,
|
||||
inputFormatters: [
|
||||
FilteringTextInputFormatter.digitsOnly,
|
||||
CpfInputFormatter(),
|
||||
],
|
||||
),
|
||||
),
|
||||
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(
|
||||
inputFormatters: [],
|
||||
controller: inputData,
|
||||
title: 'Data de Cadastro',
|
||||
width: width * 0.18,
|
||||
colorBorder: PaletteColors.white,
|
||||
enable: false,
|
||||
),
|
||||
):Container(),
|
||||
SizedBox(height: 50,),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
ButtonCustom(
|
||||
onPressed:()=>setState((){
|
||||
showRegister = false;
|
||||
editando = false;
|
||||
indice = null;
|
||||
inputData.clear();
|
||||
inputNome.clear();
|
||||
inputParentesco.clear();
|
||||
inputSenha.clear();
|
||||
inputCpf.clear();
|
||||
}),
|
||||
text: 'Cancelar',
|
||||
widthCustom: 0.1,
|
||||
heightCustom: 0.05,
|
||||
colorText: Colors.white,
|
||||
colorBorder: PaletteColors.primaryColor,
|
||||
colorButton: PaletteColors.primaryColor,
|
||||
size: 15,
|
||||
),
|
||||
SizedBox(width: 50,),
|
||||
ButtonCustom(
|
||||
onPressed:()=>salvarResponsavel(),
|
||||
text: 'Salvar',
|
||||
widthCustom: 0.1,
|
||||
heightCustom: 0.05,
|
||||
colorText: Colors.white,
|
||||
colorBorder: PaletteColors.green,
|
||||
colorButton: PaletteColors.green,
|
||||
size: 15,
|
||||
)
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
):Container(),
|
||||
showRegister?Container():Container(
|
||||
width: width*0.3,
|
||||
height: height*0.3,
|
||||
child: ListView.separated(
|
||||
itemCount: responsaveis.length,
|
||||
separatorBuilder: (context,index){
|
||||
return Divider();
|
||||
},
|
||||
itemBuilder: (context,index){
|
||||
return DadosResponsaveisContainer(
|
||||
responsavelModel: responsaveis[index],
|
||||
onTapEdit: (){
|
||||
showRegister = true;
|
||||
editando = true;
|
||||
indice = index;
|
||||
inputNome.text = responsaveis[index].nomeResponsavel;
|
||||
inputParentesco.text = responsaveis[index].parentesco;
|
||||
inputCpf.text = responsaveis[index].cpf;
|
||||
inputSenha.text = responsaveis[index].senha;
|
||||
inputData.text = responsaveis[index].dataCadastro;
|
||||
setState(() {});
|
||||
},
|
||||
onTapDelete: (){
|
||||
responsaveis.removeAt(index);
|
||||
setState(() {});
|
||||
showSnackBar(context, 'Responsável deletado!', Colors.green);
|
||||
},
|
||||
);
|
||||
}
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user