GSI - Employe Self Service Mobile
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

139 lines
5.9 KiB

2 months ago
  1. import 'package:employee_selfservice_mobile/Screens/Menu/EventCalendar/meeting_provider.dart';
  2. import 'package:flutter/material.dart';
  3. import 'package:google_fonts/google_fonts.dart';
  4. import 'package:provider/provider.dart';
  5. import 'package:syncfusion_flutter_calendar/calendar.dart';
  6. import '../SlipGaji/background.dart';
  7. import 'meeting.dart';
  8. import 'meeting_data_source.dart';
  9. class EventCalendarScreen extends StatefulWidget {
  10. const EventCalendarScreen({super.key});
  11. @override
  12. State<EventCalendarScreen> createState() => _EventCalendarScreen();
  13. }
  14. class _EventCalendarScreen extends State<EventCalendarScreen> {
  15. List<Meeting> _getDataSource() {
  16. final List<Meeting> meetings = <Meeting>[];
  17. final DateTime today = DateTime.now();
  18. final DateTime startTime = DateTime(today.year, today.month, today.day, 7);
  19. final DateTime endTime = startTime.add(const Duration(hours: 2));
  20. meetings.add(Meeting('Conference', startTime, endTime, const Color(0xFF0F8644), false));
  21. meetings.add(Meeting('Conference', startTime, endTime, const Color(0xFF0F8644), false));
  22. meetings.add(Meeting('Conference', startTime, endTime, const Color(0xFF0F8644), false));
  23. meetings.add(Meeting('Conference', startTime, endTime, const Color(0xFF0F8644), false));
  24. meetings.add(Meeting('Conference', startTime, endTime, const Color(0xFF0F8644), false));
  25. return meetings;
  26. }
  27. CalendarView calendarView = CalendarView.month;
  28. CalendarController calendarController = CalendarController();
  29. @override
  30. Widget build(BuildContext context) {
  31. //final provider = Provider.of<MeetingProvider>(context);
  32. return Scaffold(
  33. body: Stack(
  34. children: [
  35. WavyHeader(),
  36. Container(
  37. margin: EdgeInsets.only(top: MediaQuery
  38. .of(context)
  39. .size
  40. .height / 6 - 20),
  41. padding: EdgeInsets.fromLTRB(20, 5, 25, 5),
  42. child: Row(
  43. mainAxisAlignment: MainAxisAlignment.end,
  44. crossAxisAlignment: CrossAxisAlignment.end,
  45. children: [
  46. Text(
  47. 'Event Calendar\t\t',
  48. maxLines: 2,
  49. style: GoogleFonts.luckiestGuy(
  50. fontSize: 28,
  51. color: Color(0xFF4858A7),
  52. fontStyle: FontStyle.italic,
  53. ),
  54. ),
  55. Image.asset(
  56. "assets/icons/menu/ic_eventcalendar_2.png",
  57. width: 40,
  58. height: 40,
  59. ),
  60. ],
  61. )),
  62. SafeArea(
  63. child: Container(
  64. width: MediaQuery.of(context).size.width,
  65. height: MediaQuery.of(context).size.height,
  66. margin: EdgeInsets.only(top: MediaQuery.of(context).size.height / 5, left: 10, right: 10, bottom : 10,),
  67. padding: EdgeInsets.all(5),
  68. child: Card(
  69. elevation: 5,
  70. child: Column(
  71. children: [
  72. Container(
  73. margin: EdgeInsets.only(top: 10),
  74. ),
  75. Row(
  76. mainAxisAlignment: MainAxisAlignment.spaceEvenly,
  77. children: [
  78. OutlinedButton(onPressed: () {
  79. setState(() {
  80. calendarView = CalendarView.month;
  81. calendarController.view = calendarView;
  82. });
  83. }, child: Text("Month View")),
  84. OutlinedButton(onPressed: () {
  85. setState(() {
  86. calendarView = CalendarView.week;
  87. calendarController.view = calendarView;
  88. });
  89. }, child: Text("Week View")),
  90. OutlinedButton(onPressed: () {
  91. setState(() {
  92. calendarView = CalendarView.day;
  93. calendarController.view = calendarView;
  94. });
  95. }, child: Text("Day View")),
  96. ],
  97. ),
  98. Container(
  99. height: (MediaQuery.of(context).size.height * 0.65),
  100. child: SfCalendar(
  101. view: calendarView,
  102. controller: calendarController,
  103. initialSelectedDate: DateTime.now(),
  104. dataSource: MeetingDataSource(_getDataSource()),
  105. //dataSource: MeetingDataSource(provider.meetings),
  106. monthViewSettings: MonthViewSettings(appointmentDisplayMode: MonthAppointmentDisplayMode.indicator, showAgenda: true),
  107. cellBorderColor: Colors.black45,
  108. //cellBorderColor: Colors.transparent,
  109. /*blackoutDates: [
  110. DateTime.now().subtract(Duration(hours: 48)),
  111. DateTime.now().subtract(Duration(hours: 24)),
  112. ],*/
  113. selectionDecoration: BoxDecoration(
  114. color: Colors.transparent,
  115. border: Border.all(
  116. color: Colors.red, width: 2),
  117. borderRadius: BorderRadius.all(
  118. Radius.circular(4)),
  119. shape: BoxShape.rectangle
  120. ),
  121. ),
  122. )
  123. ],
  124. ),
  125. )
  126. ),
  127. ),
  128. ],
  129. )
  130. );
  131. }
  132. }