166 lines
5.7 KiB
Dart
166 lines
5.7 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:rkm_educa_app/modelos/estudante_modelo.dart';
|
|
import 'package:rkm_educa_app/telas/tela_situacao_escolar.dart';
|
|
import 'package:rkm_educa_app/componentes/appbar_custom.dart';
|
|
import '../utils/cores.dart';
|
|
import '../componentes/buttom_custom.dart';
|
|
import '../componentes/snackBars.dart';
|
|
import '../componentes/text_custom.dart';
|
|
import '../utils/dimensoes.dart';
|
|
|
|
class TelaSelecionaFilho extends StatefulWidget {
|
|
List listAlunos;
|
|
String cidade;
|
|
String NO_USUARIO;
|
|
String CD_USUARIO;
|
|
String URL;
|
|
|
|
TelaSelecionaFilho({
|
|
required this.listAlunos,
|
|
required this.cidade,
|
|
required this.NO_USUARIO,
|
|
required this.CD_USUARIO,
|
|
required this.URL
|
|
});
|
|
|
|
@override
|
|
State<TelaSelecionaFilho> createState() => _TelaSelecionaFilhoState();
|
|
}
|
|
|
|
class _TelaSelecionaFilhoState extends State<TelaSelecionaFilho> {
|
|
|
|
EstudanteModelo? estudanteModelo;
|
|
|
|
List <EstudanteModelo>listAlunos = [];
|
|
|
|
carregarAlunos(){
|
|
//print(widget.listAlunos);
|
|
|
|
for(int i=0; widget.listAlunos.length>i;i++){
|
|
// print(widget.listAlunos[i]['NO_ALUNO']);
|
|
|
|
String dataBD = widget.listAlunos[i]['DT_NASCIMENTO'];
|
|
int dia = 00;
|
|
int mes = 00;
|
|
int ano = 0000;
|
|
int idade = 0;
|
|
if(dataBD!=''){
|
|
dia = int.parse(dataBD.substring(6,8));
|
|
mes = int.parse(dataBD.substring(4,6));
|
|
ano = int.parse(dataBD.substring(0,4));
|
|
final hoje = DateTime.now();
|
|
final nasc = DateTime.utc(ano,mes,dia);
|
|
idade = (hoje.difference(nasc).inDays/365).toInt();
|
|
}
|
|
|
|
listAlunos.add(
|
|
EstudanteModelo(
|
|
NO_ALUNO: widget.listAlunos[i]['NO_ALUNO'],
|
|
FOTO_ALUNO: '',
|
|
RA_ALUNO: widget.listAlunos[i]['NR_RA'],
|
|
ESCOLA: widget.listAlunos[i]['NO_FANTASIA']=='' || widget.listAlunos[i]['NO_FANTASIA']==null?widget.listAlunos[i]['NO_RAZAO_SOCIAL']:widget.listAlunos[i]['NO_FANTASIA'],
|
|
IDADE_ALUNO: idade,
|
|
ANO_LETIVO: DateTime.now().year,
|
|
dados: widget.listAlunos,
|
|
nroAluno: i,
|
|
cidade: widget.cidade,
|
|
CD_USUARIO: widget.CD_USUARIO,
|
|
NO_USUARIO: widget.NO_USUARIO,
|
|
URL: widget.URL
|
|
)
|
|
);
|
|
}
|
|
setState(() {});
|
|
}
|
|
|
|
@override
|
|
void initState() {
|
|
carregarAlunos();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
|
|
return Scaffold(
|
|
backgroundColor: PaletaCores.branco,
|
|
appBar: AppBarCustom().appbar(context, 'SELECIONAR FILHO'),
|
|
body: Center(
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Container(
|
|
child: Image.asset("assets/images/logoEduca.png",width: Dimensoes.width* 0.4,height: Dimensoes.height * 0.12)
|
|
),
|
|
SizedBox(height: Dimensoes.height * 0.02),
|
|
Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
TextCustom(text: 'Estudantes',fontWeight: FontWeight.bold,size: 14.0,),
|
|
Container(
|
|
width: Dimensoes.width*0.85,
|
|
decoration: BoxDecoration(
|
|
borderRadius: BorderRadius.circular(5),
|
|
border: Border.all(
|
|
color: Colors.white
|
|
),
|
|
color: PaletaCores.cinzaInput
|
|
),
|
|
child: DropdownButtonHideUnderline(
|
|
child: DropdownButton(
|
|
hint: Padding(
|
|
padding: const EdgeInsets.all(8.0),
|
|
child: TextCustom(text: 'Selecione'),
|
|
),
|
|
value: estudanteModelo,
|
|
items: listAlunos.map((value) => DropdownMenuItem(
|
|
value: value,
|
|
child: Container(
|
|
width: Dimensoes.width*0.75,
|
|
padding: const EdgeInsets.all(8.0),
|
|
child: TextCustom(
|
|
text: value.NO_ALUNO,
|
|
color: Colors.black54,
|
|
size: 14.0,
|
|
),
|
|
),
|
|
)
|
|
).toList(),
|
|
onChanged: (EstudanteModelo? value){
|
|
setState(() {
|
|
// print(value!.nome);
|
|
estudanteModelo = value;
|
|
});
|
|
},
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
SizedBox(height: Dimensoes.height * 0.02),
|
|
ButtonCustom(
|
|
widthCustom: 0.7,
|
|
heightCustom: 0.07,
|
|
text: "Avançar",
|
|
fontsize:14,
|
|
colorText: PaletaCores.branco,
|
|
colorButton: PaletaCores.corPrimaria,
|
|
colorBorder: PaletaCores.corPrimaria,
|
|
onPressed: () {
|
|
if(estudanteModelo!=null){
|
|
Navigator.push(
|
|
context,
|
|
MaterialPageRoute(builder: (context) => TelaSituacaoEscolar(estudanteModelo: estudanteModelo!,)),
|
|
);
|
|
}else{
|
|
showSnackBar(context, 'Selecione um estudante para avançar', Colors.red);
|
|
}
|
|
},
|
|
),
|
|
SizedBox(height: Dimensoes.height * 0.02),
|
|
],
|
|
),
|
|
)
|
|
);
|
|
}
|
|
}
|