143 lines
4.7 KiB
Dart
143 lines
4.7 KiB
Dart
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:rkm_educa_app/componentes/appbar_custom.dart';
|
|
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/utils/cores.dart';
|
|
import 'package:rkm_educa_app/utils/dimensoes.dart';
|
|
|
|
class TelaAgenda extends StatefulWidget {
|
|
EstudanteModelo estudanteModelo;
|
|
|
|
TelaAgenda({
|
|
required this.estudanteModelo
|
|
});
|
|
|
|
@override
|
|
State<TelaAgenda> createState() => _TelaAgendaState();
|
|
}
|
|
|
|
class _TelaAgendaState extends State<TelaAgenda> {
|
|
|
|
DateTime _currentDate = DateTime.now();
|
|
DateTime dataAtual = DateTime.now();
|
|
EventList<Event> _markedDateMap = new EventList<Event>(
|
|
events: {},
|
|
);
|
|
|
|
Widget _eventIcon(String dia) => Container(
|
|
decoration: BoxDecoration(
|
|
borderRadius: BorderRadius.circular(30),
|
|
color: PaletaCores.verdeCalendario,
|
|
),
|
|
width: 40,
|
|
height: 40,
|
|
child: Center(
|
|
child: TextCustom(text: dia,fontWeight: FontWeight.bold,size: 14.0,color: 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
|
|
);
|
|
|
|
@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(() {});
|
|
}
|
|
|
|
@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.40,
|
|
targetDateTime: dataAtual,
|
|
markedDateCustomTextStyle: textStyle,
|
|
markedDateMoreShowTotal: null,
|
|
showHeader: false,
|
|
todayTextStyle: textStyle,
|
|
isScrollable: false,
|
|
todayButtonColor: PaletaCores.calendario,
|
|
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, 'AGENDA ESCOLAR'),
|
|
drawer: DrawerCustom(estudanteModelo: widget.estudanteModelo),
|
|
body: ListView(
|
|
padding: EdgeInsets.all(10),
|
|
children: [
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
IconButton(
|
|
onPressed: () {
|
|
setState(() {
|
|
dataAtual = DateTime(dataAtual.year, dataAtual.month -1);
|
|
});
|
|
},
|
|
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);
|
|
});
|
|
},
|
|
icon: Icon(Icons.arrow_right,size: 30,color: PaletaCores.cinzaClaro,)
|
|
),
|
|
],
|
|
),
|
|
Container(
|
|
height: 300,
|
|
margin: EdgeInsets.symmetric(horizontal: 16.0),
|
|
child: _calendario,
|
|
),
|
|
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(),
|
|
],
|
|
),
|
|
)
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|