ajustado os dados do calendário;
do login com o cpf
This commit is contained in:
19
lib/componentes/appbar_custom.dart
Normal file
19
lib/componentes/appbar_custom.dart
Normal file
@@ -0,0 +1,19 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rkm_educa_prof_app/componentes/text_custom.dart';
|
||||
|
||||
import '../utils/cores.dart';
|
||||
|
||||
class AppBarCustom{
|
||||
@override
|
||||
PreferredSize appbar(BuildContext context,String title) {
|
||||
|
||||
return PreferredSize(
|
||||
preferredSize: Size.fromHeight(50),
|
||||
child: AppBar(
|
||||
backgroundColor: PaletaCores.appBar,
|
||||
centerTitle: true,
|
||||
title: TextCustom(text: title,color: Colors.white,fontWeight: FontWeight.bold,size: 20.0,),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rkm_educa_prof_app/componentes/text_custom.dart';
|
||||
import 'package:rkm_educa_prof_app/utils/cidades_db.dart';
|
||||
|
||||
import '../utils/cores.dart';
|
||||
|
||||
class DropDownButtonCity extends StatelessWidget {
|
||||
var onChanged;
|
||||
String? select;
|
||||
bool validator;
|
||||
String error;
|
||||
|
||||
DropDownButtonCity({
|
||||
required this.onChanged,
|
||||
required this.select,
|
||||
required this.error,
|
||||
required this.validator
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
double width = MediaQuery.of(context).size.width;
|
||||
|
||||
return Column(
|
||||
children: [
|
||||
Container(
|
||||
width: width,
|
||||
margin: EdgeInsets.symmetric(vertical: 5),
|
||||
padding: EdgeInsets.symmetric(vertical: 5),
|
||||
color:PaletaCores.cinzaInput,
|
||||
child: DropdownButtonHideUnderline(
|
||||
child: DropdownButton(
|
||||
hint: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8.0),
|
||||
child: TextCustom(text: 'Cidade',size: 15.0),
|
||||
),
|
||||
value: select,
|
||||
items: Cidades().listCidades.map((value) => DropdownMenuItem(
|
||||
value: value.cidadeFront,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8.0),
|
||||
child: TextCustom(
|
||||
text: value.cidadeFront,
|
||||
color: Colors.black54,
|
||||
),
|
||||
),
|
||||
)
|
||||
).toList(),
|
||||
onChanged:onChanged
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
46
lib/componentes/item_agenda.dart
Normal file
46
lib/componentes/item_agenda.dart
Normal file
@@ -0,0 +1,46 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rkm_educa_prof_app/componentes/text_custom.dart';
|
||||
import '../utils/cores.dart';
|
||||
import '../utils/dimensoes.dart';
|
||||
|
||||
class ItemAgenda extends StatelessWidget {
|
||||
|
||||
int cor;
|
||||
String titulo;
|
||||
|
||||
ItemAgenda({
|
||||
required this.cor,
|
||||
required this.titulo,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
return Container(
|
||||
color: PaletaCores.branco,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 5.0,vertical: 0),
|
||||
child: Column(
|
||||
children: [
|
||||
Container(
|
||||
width: Dimensoes.width*0.95,
|
||||
height: 30,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 0.0),
|
||||
child: Padding(
|
||||
padding: EdgeInsets.symmetric(vertical: 5),
|
||||
child: Row(
|
||||
children: [
|
||||
Container(
|
||||
width: Dimensoes.width*0.2,
|
||||
child: Icon(Icons.circle,color: Color(cor),)
|
||||
),
|
||||
TextCustom(text: titulo),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
Container(width: double.infinity,height: 2,color: PaletaCores.divider,)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
class CidadeModel{
|
||||
String codigo;
|
||||
String cidadeQuery;
|
||||
String cidadeFront;
|
||||
|
||||
CidadeModel({
|
||||
required this.codigo,
|
||||
required this.cidadeQuery,
|
||||
required this.cidadeFront
|
||||
});
|
||||
}
|
||||
11
lib/modelos/evento_modelo.dart
Normal file
11
lib/modelos/evento_modelo.dart
Normal file
@@ -0,0 +1,11 @@
|
||||
class EventoModelo{
|
||||
String titulo;
|
||||
String data;
|
||||
int cor;
|
||||
|
||||
EventoModelo({
|
||||
required this.titulo,
|
||||
required this.data,
|
||||
this.cor = 0
|
||||
});
|
||||
}
|
||||
217
lib/telas/tela_calendario.dart
Normal file
217
lib/telas/tela_calendario.dart
Normal file
@@ -0,0 +1,217 @@
|
||||
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';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:rkm_educa_prof_app/utils/fixos.dart';
|
||||
import '../componentes/appbar_custom.dart';
|
||||
import '../componentes/drawer_custom.dart';
|
||||
import '../componentes/item_agenda.dart';
|
||||
import '../componentes/text_custom.dart';
|
||||
import '../modelos/evento_modelo.dart';
|
||||
import '../utils/cores.dart';
|
||||
import '../utils/dimensoes.dart';
|
||||
|
||||
class TelaCalendario extends StatefulWidget {
|
||||
|
||||
List dados;
|
||||
|
||||
TelaCalendario({
|
||||
required this.dados
|
||||
});
|
||||
|
||||
@override
|
||||
State<TelaCalendario> createState() => _TelaCalendarioState();
|
||||
}
|
||||
|
||||
class _TelaCalendarioState extends State<TelaCalendario> {
|
||||
|
||||
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,Color cor) => Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(30),
|
||||
color: cor,
|
||||
),
|
||||
width: 40,
|
||||
height: 40,
|
||||
child: Center(
|
||||
child: TextCustom(text: dia,fontWeight: FontWeight.bold,size: 14.0,color: cor==Color(0xffee1d24)?Colors.white:PaletaCores.cinza),
|
||||
),
|
||||
);
|
||||
|
||||
TextStyle textStyle = TextStyle(
|
||||
color: PaletaCores.cinza,
|
||||
fontWeight: FontWeight.bold,
|
||||
fontFamily: 'Nunito',
|
||||
fontSize: 14
|
||||
);
|
||||
|
||||
TextStyle textStyleFDS = TextStyle(
|
||||
color: Colors.red,
|
||||
fontWeight: FontWeight.bold,
|
||||
fontFamily: 'Nunito',
|
||||
fontSize: 14
|
||||
);
|
||||
|
||||
buscarEventos()async{
|
||||
// int quantidadeDias = DateTime(dataAtual.year, dataAtual.month, 0).day;
|
||||
// print(quantidadeDias);
|
||||
_markedDateMap.clear();
|
||||
listDatas.clear();
|
||||
carregandoEventos = true;
|
||||
setState(() {});
|
||||
|
||||
final url = '${Fixos.LINK_API_CONTAINER}/calendario?'
|
||||
'MES=${dataAtual.year}-${dataAtual.month}-01&'
|
||||
'COD_ESCOLA=${widget.dados[4]}&'
|
||||
'QUANTIDADE=31&'
|
||||
'CIDADE=${widget.dados[0]}';
|
||||
print(url);
|
||||
final response = await http.get(Uri.parse(url));
|
||||
var map = json.decode(response.body);
|
||||
// print(map);
|
||||
if(map!=false){
|
||||
List list = map;
|
||||
List titulo = [];
|
||||
List<EventoModelo> listD = [];
|
||||
for(int i = 0; list.length>i;i++){
|
||||
List data = list[i]['DT_CALENDARIO'].toString().split('-');
|
||||
titulo.add(list[i]['NO_EVENTO'].toString().trim());
|
||||
|
||||
listD.add(EventoModelo(
|
||||
titulo: list[i]['NO_EVENTO'].toString().trim(),
|
||||
data: '${data[2]}/${data[1]}/${data[0]}',
|
||||
cor: int.parse(list[i]['NO_COR'].toString().trim()=='#0ff'?'0xffe1e1a1':'0xff'+list[i]['NO_COR'].toString().replaceAll("#", ''))));
|
||||
|
||||
_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(0xffe1e1a1)
|
||||
:Color(int.parse('0xff'+list[i]['NO_COR'].toString().replaceAll("#", '')))
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
List limpando = titulo.toSet().toList();
|
||||
|
||||
for(int i = 0; limpando.length>i;i++){
|
||||
int index = 0;
|
||||
index = titulo.indexOf(limpando[i]);
|
||||
listDatas.add(listD[index]);
|
||||
}
|
||||
}
|
||||
carregandoEventos = false;
|
||||
setState(() {});
|
||||
print(widget.dados);
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
buscarEventos();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
final _calendario = CalendarCarousel<Event>(
|
||||
locale: 'pt',
|
||||
weekdayTextStyle: TextStyle(color: PaletaCores.cinza,fontSize: 14,fontFamily: 'Nunito',),
|
||||
disableDayPressed: true,
|
||||
daysTextStyle: textStyle,
|
||||
selectedDayButtonColor: Colors.red,
|
||||
weekendTextStyle: textStyleFDS,
|
||||
markedDatesMap: _markedDateMap,
|
||||
height: Dimensoes.height*0.45,
|
||||
targetDateTime: dataAtual,
|
||||
markedDateCustomTextStyle: textStyle,
|
||||
markedDateMoreShowTotal: null,
|
||||
showHeader: false,
|
||||
todayTextStyle: textStyle,
|
||||
isScrollable: false,
|
||||
todayButtonColor: PaletaCores.verdeCalendario,
|
||||
selectedDayTextStyle: textStyle,
|
||||
minSelectedDate: _currentDate.subtract(Duration(days: 360)),
|
||||
maxSelectedDate: _currentDate.add(Duration(days: 360)),
|
||||
markedDateIconBuilder: (event){
|
||||
return event.icon;
|
||||
},
|
||||
);
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBarCustom().appbar(context, 'CALENDÁRIO ESCOLAR'),
|
||||
drawer: DrawerCustom(dados: widget.dados,),
|
||||
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(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
dataAtual = DateTime(dataAtual.year, dataAtual.month -1);
|
||||
buscarEventos();
|
||||
});
|
||||
},
|
||||
icon: Icon(Icons.arrow_left,size: 30,color: PaletaCores.cinzaClaro,)
|
||||
),
|
||||
TextCustom(text: DateFormat('MMMM / yyyy','pt_Br').format(dataAtual),fontWeight: FontWeight.bold),
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
dataAtual = DateTime(dataAtual.year, dataAtual.month +1);
|
||||
buscarEventos();
|
||||
});
|
||||
},
|
||||
icon: Icon(Icons.arrow_right,size: 30,color: PaletaCores.cinzaClaro,)
|
||||
),
|
||||
],
|
||||
),
|
||||
_calendario,
|
||||
Container(
|
||||
width: Dimensoes.width*0.8,
|
||||
height: 30,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 5.0),
|
||||
child: Padding(
|
||||
padding: EdgeInsets.symmetric(vertical: 0),
|
||||
child: TextCustom(text: 'LEGENDA',size: 14.0,fontWeight: FontWeight.bold),
|
||||
),
|
||||
),
|
||||
Container(width: double.infinity,height: 2,color: PaletaCores.divider,),
|
||||
Container(
|
||||
padding: EdgeInsets.symmetric(vertical: 0),
|
||||
height: Dimensoes.height*0.38,
|
||||
child: ListView.builder(
|
||||
itemCount: listDatas.length,
|
||||
itemBuilder: (context,index){
|
||||
return ItemAgenda(cor: listDatas[index].cor, titulo: listDatas[index].titulo);
|
||||
},
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
import '../modelos/cidade_model.dart';
|
||||
|
||||
class Cidades{
|
||||
List <CidadeModel> listCidades =[
|
||||
CidadeModel(codigo: 'E001', cidadeQuery: 'aguasdelindoia',cidadeFront: 'Águas de Lindóia'),
|
||||
CidadeModel(codigo: 'E002', cidadeQuery: 'corumbatai', cidadeFront: 'Corumbataí'),
|
||||
CidadeModel(codigo: 'E003',cidadeQuery: 'iracemapolis', cidadeFront: 'Iracemápolis'),
|
||||
];
|
||||
}
|
||||
@@ -1,5 +1,3 @@
|
||||
import '../modelos/cidade_model.dart';
|
||||
|
||||
class Fixos{
|
||||
static const String LINK_API_LOCAL = 'http://192.168.18.2:8000';
|
||||
static const String LINK_API_CONTAINER = 'http://192.168.0.42:8013';
|
||||
|
||||
Reference in New Issue
Block a user