ajustada a tela de agenda com os dados do banco
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import 'dart:convert';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_calendar_carousel/classes/event.dart';
|
||||
import 'package:flutter_calendar_carousel/flutter_calendar_carousel.dart';
|
||||
@@ -7,8 +8,10 @@ import 'package:rkm_educa_app/componentes/drawer_custom.dart';
|
||||
import 'package:rkm_educa_app/componentes/item_agenda.dart';
|
||||
import 'package:rkm_educa_app/componentes/text_custom.dart';
|
||||
import 'package:rkm_educa_app/modelos/estudante_modelo.dart';
|
||||
import 'package:rkm_educa_app/modelos/evento_modelo.dart';
|
||||
import 'package:rkm_educa_app/utils/cores.dart';
|
||||
import 'package:rkm_educa_app/utils/dimensoes.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
|
||||
class TelaAgenda extends StatefulWidget {
|
||||
EstudanteModelo estudanteModelo;
|
||||
@@ -23,21 +26,23 @@ class TelaAgenda extends StatefulWidget {
|
||||
|
||||
class _TelaAgendaState extends State<TelaAgenda> {
|
||||
|
||||
List<EventoModelo> listDatas = [];
|
||||
bool carregandoEventos = true;
|
||||
DateTime _currentDate = DateTime.now();
|
||||
DateTime dataAtual = DateTime.now();
|
||||
EventList<Event> _markedDateMap = new EventList<Event>(
|
||||
events: {},
|
||||
);
|
||||
|
||||
Widget _eventIcon(String dia) => Container(
|
||||
Widget _eventIcon(String dia,Color cor) => Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(30),
|
||||
color: PaletaCores.verdeCalendario,
|
||||
color: cor,
|
||||
),
|
||||
width: 40,
|
||||
height: 40,
|
||||
child: Center(
|
||||
child: TextCustom(text: dia,fontWeight: FontWeight.bold,size: 14.0,color: PaletaCores.cinza),
|
||||
child: TextCustom(text: dia,fontWeight: FontWeight.bold,size: 14.0,color: cor==Color(0xffee1d24)?Colors.white:PaletaCores.cinza),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -55,13 +60,52 @@ class _TelaAgendaState extends State<TelaAgenda> {
|
||||
fontSize: 14
|
||||
);
|
||||
|
||||
buscarEventos()async{
|
||||
// int quantidadeDias = DateTime(dataAtual.year, dataAtual.month, 0).day;
|
||||
// print(quantidadeDias);
|
||||
_markedDateMap.clear();
|
||||
listDatas.clear();
|
||||
carregandoEventos = true;
|
||||
setState(() {});
|
||||
|
||||
final url = 'http://192.168.18.2:8000/calendario?'
|
||||
'MES=${dataAtual.year}-${dataAtual.month}-01&'
|
||||
'COD_ESCOLA=${widget.estudanteModelo.dados[widget.estudanteModelo.nroAluno]['CD_CAD_DIVERSO']}&'
|
||||
'QUANTIDADE=31&'
|
||||
'CIDADE=${widget.estudanteModelo.cidade}';
|
||||
print(url);
|
||||
final response = await http.get(Uri.parse(url));
|
||||
var map = json.decode(response.body);
|
||||
// print(map);
|
||||
if(map!=false){
|
||||
List list = map;
|
||||
for(int i = 0; list.length>i;i++){
|
||||
List data = list[i]['DT_CALENDARIO'].toString().split('-');
|
||||
listDatas.add(EventoModelo(titulo: list[i]['NO_EVENTO'], data: '${data[2]}/${data[1]}/${data[0]}'));
|
||||
|
||||
_markedDateMap.add(
|
||||
DateTime(int.parse(data[0]),int.parse(data[1]),int.parse(data[2])),
|
||||
Event(
|
||||
date: DateTime(int.parse(data[0]),int.parse(data[1]),int.parse(data[2])),
|
||||
icon: _eventIcon(data[2],list[i]['NO_COR'].toString().trim()=='#0ff'?Color(0xffe1e1e1)
|
||||
:Color(int.parse('0xff'+list[i]['NO_COR'].toString().replaceAll("#", '')))
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
carregandoEventos = false;
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_markedDateMap.add(DateTime(2023,5,1), Event(date: DateTime(2023,5,1),icon: _eventIcon('1')));
|
||||
_markedDateMap.add(DateTime(2023,5,15), Event(date: DateTime(2023,5,1),icon: _eventIcon('15')));
|
||||
_markedDateMap.add(DateTime(2023,6,30), Event(date: DateTime(2023,6,30),icon: _eventIcon('30')));
|
||||
setState(() {});
|
||||
// _markedDateMap.add(DateTime(2023,5,1), Event(date: DateTime(2023,5,1),icon: _eventIcon('1')));
|
||||
// _markedDateMap.add(DateTime(2023,5,15), Event(date: DateTime(2023,5,1),icon: _eventIcon('15')));
|
||||
// _markedDateMap.add(DateTime(2023,6,30), Event(date: DateTime(2023,6,30),icon: _eventIcon('30')));
|
||||
// setState(() {});
|
||||
buscarEventos();
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -82,7 +126,7 @@ class _TelaAgendaState extends State<TelaAgenda> {
|
||||
showHeader: false,
|
||||
todayTextStyle: textStyle,
|
||||
isScrollable: false,
|
||||
todayButtonColor: PaletaCores.calendario,
|
||||
todayButtonColor: PaletaCores.verdeCalendario,
|
||||
selectedDayTextStyle: textStyle,
|
||||
minSelectedDate: _currentDate.subtract(Duration(days: 360)),
|
||||
maxSelectedDate: _currentDate.add(Duration(days: 360)),
|
||||
@@ -94,7 +138,19 @@ class _TelaAgendaState extends State<TelaAgenda> {
|
||||
return Scaffold(
|
||||
appBar: AppBarCustom().appbar(context, 'AGENDA ESCOLAR'),
|
||||
drawer: DrawerCustom(estudanteModelo: widget.estudanteModelo),
|
||||
body: ListView(
|
||||
body: carregandoEventos?Center(
|
||||
child: Container(
|
||||
padding: EdgeInsets.all(80),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
CircularProgressIndicator(color: PaletaCores.cinzaClaro),
|
||||
SizedBox(width: 20,),
|
||||
TextCustom(text: 'Carregando Eventos')
|
||||
],
|
||||
),
|
||||
),
|
||||
):ListView(
|
||||
padding: EdgeInsets.all(10),
|
||||
children: [
|
||||
Row(
|
||||
@@ -104,6 +160,7 @@ class _TelaAgendaState extends State<TelaAgenda> {
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
dataAtual = DateTime(dataAtual.year, dataAtual.month -1);
|
||||
buscarEventos();
|
||||
});
|
||||
},
|
||||
icon: Icon(Icons.arrow_left,size: 30,color: PaletaCores.cinzaClaro,)
|
||||
@@ -113,6 +170,7 @@ class _TelaAgendaState extends State<TelaAgenda> {
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
dataAtual = DateTime(dataAtual.year, dataAtual.month +1);
|
||||
buscarEventos();
|
||||
});
|
||||
},
|
||||
icon: Icon(Icons.arrow_right,size: 30,color: PaletaCores.cinzaClaro,)
|
||||
@@ -120,19 +178,18 @@ class _TelaAgendaState extends State<TelaAgenda> {
|
||||
],
|
||||
),
|
||||
Container(
|
||||
height: 300,
|
||||
height: 325,
|
||||
margin: EdgeInsets.symmetric(horizontal: 16.0),
|
||||
child: _calendario,
|
||||
),
|
||||
Container(
|
||||
Container(
|
||||
padding: EdgeInsets.symmetric(vertical: 15),
|
||||
height: Dimensoes.height*0.60,
|
||||
child: ListView(
|
||||
children: [
|
||||
dataAtual.month==5?ItemAgenda(data: '01/05/2023', titulo: 'Feriado - Dia do Trabalhador',):Container(),
|
||||
dataAtual.month==5?ItemAgenda(data: '15/05/2023', titulo: 'Reunisão para os pais',):Container(),
|
||||
dataAtual.month==6?ItemAgenda(data: '30/06/2023', titulo: 'Início Férias',):Container(),
|
||||
],
|
||||
height: Dimensoes.height*0.45,
|
||||
child: ListView.builder(
|
||||
itemCount: listDatas.length,
|
||||
itemBuilder: (context,index){
|
||||
return ItemAgenda(data: listDatas[index].data, titulo: listDatas[index].titulo);
|
||||
},
|
||||
),
|
||||
)
|
||||
],
|
||||
|
||||
@@ -10,7 +10,7 @@ class PaletaCores{
|
||||
static const Color divider = Color (0xffc9c9c9);
|
||||
static const Color cinzaInput = Color (0xffE1E1E1);
|
||||
static const Color calendario = Color (0xffB1B1B1);
|
||||
static const Color verdeCalendario = Color (0xff84CB7E);
|
||||
static const Color verdeCalendario = Color (0xff4d7f49);
|
||||
static const Color notificacao = Color (0xffBB0202);
|
||||
static const Color appBar = Color(0xff3A3A3A);
|
||||
}
|
||||
Reference in New Issue
Block a user