inserida as faltas na tela boletim e eventos na situacao escolar

This commit is contained in:
Reginaldo
2023-06-28 17:38:04 -03:00
parent f394c5cf32
commit d0596b2b51
5 changed files with 209 additions and 48 deletions

View File

@@ -1,4 +1,7 @@
import 'dart:convert';
import 'package:http/http.dart' as http;
import 'package:flutter/material.dart';
import 'package:rkm_educa_app/componentes/item_evento_home.dart';
import 'package:rkm_educa_app/modelos/estudante_modelo.dart';
import 'package:rkm_educa_app/telas/tela_avisos.dart';
import 'package:rkm_educa_app/utils/cores.dart';
@@ -6,6 +9,8 @@ import 'package:rkm_educa_app/componentes/text_custom.dart';
import 'package:rkm_educa_app/utils/dimensoes.dart';
import 'package:syncfusion_flutter_charts/charts.dart';
import '../componentes/drawer_custom.dart';
import '../componentes/snackBars.dart';
import '../modelos/evento_modelo.dart';
class TelaSituacaoEscolar extends StatefulWidget {
EstudanteModelo estudanteModelo;
@@ -22,15 +27,55 @@ class _TelaSituacaoEscolarState extends State<TelaSituacaoEscolar> {
late List<_ChartData> data;
late TooltipBehavior _tooltip;
List <EventoModelo>eventos = [];
List <EventoModelo>ocorrencias = [];
bool carregandoEventos = true;
bool carregandoOcorrencias = true;
buscarEventos()async{
final url = 'http://192.168.18.2:8000/calendario_home?'
'HOJE=${DateTime.now().year}-${DateTime.now().month}-${DateTime.now().day}&'
'COD_ESCOLA=${widget.estudanteModelo.dados[widget.estudanteModelo.nroAluno]['CD_CAD_DIVERSO']}&'
'CIDADE=${widget.estudanteModelo.cidade}';
print(url);
final response = await http.get(Uri.parse(url));
var map = json.decode(response.body);
print(map);
List list = map;
for(int i=0; list.length>i;i++){
List data = list[i]['DT_CALENDARIO'].toString().split('-');
eventos.add(EventoModelo(titulo: list[i]['NO_EVENTO'], data: '${data[2]}/${data[1]}/${data[0]}'));
}
carregandoEventos = false;
setState(() {});
}
buscarOcorrencia()async{
final url = 'http://192.168.18.2:8000/ocorrencia?'
'MATRICULA=${widget.estudanteModelo.dados[widget.estudanteModelo.nroAluno]['CD_MATRICULA']}&'
'CIDADE=${widget.estudanteModelo.cidade}';
print(url);
final response = await http.get(Uri.parse(url));
var map = json.decode(response.body);
if(map==false){
ocorrencias.add(EventoModelo(titulo: 'Nenhuma ocorrência', data: ''));
}else{
ocorrencias.add(EventoModelo(titulo: map['DESC_OCORRENCIA'], data: map['DATA']));
}
carregandoOcorrencias = false;
setState(() {});
}
@override
void initState() {
super.initState();
data = [
_ChartData('Faltas', 10,Color(0xffD9D9D9)),
_ChartData('Presenças', 90,Color(0xff43A65F)),
];
_tooltip = TooltipBehavior(enable: true);
buscarEventos();
buscarOcorrencia();
// data = [
// _ChartData('Faltas', 10,Color(0xffD9D9D9)),
// _ChartData('Presenças', 90,Color(0xff43A65F)),
// ];
// _tooltip = TooltipBehavior(enable: true);
}
Widget graph(BuildContext context) {
@@ -83,32 +128,26 @@ class _TelaSituacaoEscolarState extends State<TelaSituacaoEscolar> {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TextCustom(text: 'Próximos Eventos',fontWeight: FontWeight.bold,),
Row(
children: [
Container(
width: Dimensoes.width*0.5,
child: TextCustom(text: 'Viagem para o Museu',)
),
Container(
alignment: Alignment.center,
width: Dimensoes.width*0.3,
child: TextCustom(text: '01/06/2023',)
),
],
),
Row(
children: [
Container(
width: Dimensoes.width*0.5,
child: TextCustom(text: 'Apresentação dia dos pais',)
),
Container(
alignment: Alignment.center,
width: Dimensoes.width*0.3,
child: TextCustom(text: '13/08/2023',)
),
],
),
carregandoEventos?Container(
padding: EdgeInsets.all(50),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
CircularProgressIndicator(color: PaletaCores.cinzaClaro),
SizedBox(width: 20,),
TextCustom(text: 'Carregando Eventos')
],
),
):Container(
height: eventos.length*23,
child: ListView.builder(
physics: NeverScrollableScrollPhysics(),
itemCount: eventos.length,
itemBuilder: (context,index){
return ItemEventoHome(titulo: eventos[index].titulo,data: eventos[index].data,);
}
),
)
],
),
),
@@ -124,16 +163,26 @@ class _TelaSituacaoEscolarState extends State<TelaSituacaoEscolar> {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TextCustom(text: 'Última Ocorrência',fontWeight: FontWeight.bold,),
Row(
carregandoEventos?Container(
padding: EdgeInsets.all(50),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
CircularProgressIndicator(color: PaletaCores.cinzaClaro),
SizedBox(width: 20,),
TextCustom(text: 'Carregando Ocorrência')
],
),
):Row(
children: [
Container(
width: Dimensoes.width*0.5,
child: TextCustom(text: 'Aluno Ausente',)
child: TextCustom(text:ocorrencias.length==0?'': ocorrencias[0].titulo,)
),
Container(
alignment: Alignment.center,
width: Dimensoes.width*0.3,
child: TextCustom(text: '08/06/2023',)
child: TextCustom(text:ocorrencias.length==0?'': ocorrencias[0].data,)
),
],
),