From 6c329f17b021967e2dd01bf7f2fd2ee27ecd9b74 Mon Sep 17 00:00:00 2001 From: Aryaman Raina Date: Tue, 5 Dec 2023 23:27:39 +0530 Subject: [PATCH] feat: show today's events by default --- lib/app/views/screens/schedule/schedule.dart | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/app/views/screens/schedule/schedule.dart b/lib/app/views/screens/schedule/schedule.dart index 2aea149..95e9e5d 100644 --- a/lib/app/views/screens/schedule/schedule.dart +++ b/lib/app/views/screens/schedule/schedule.dart @@ -10,11 +10,14 @@ import 'meeting_details_page.dart'; class MySchedulesScreen extends StatefulWidget { const MySchedulesScreen({super.key, required this.title}); final String title; + @override State createState() => _MySchedulesScreenState(); } class _MySchedulesScreenState extends State { + DateTime _initialSelectedDate = DateTime.now(); + @override Widget build(BuildContext context) { return Scaffold( @@ -31,6 +34,8 @@ class _MySchedulesScreenState extends State { return SfCalendar( view: CalendarView.month, dataSource: MeetingServiceRepository(snapshot.data!), + initialSelectedDate: _initialSelectedDate, + initialDisplayDate: _initialSelectedDate, monthViewSettings: const MonthViewSettings(showAgenda: true), onTap: (CalendarTapDetails details) { if (details.targetElement == CalendarElement.appointment || @@ -52,7 +57,13 @@ class _MySchedulesScreenState extends State { await Navigator.push( context, MaterialPageRoute( - builder: (context) => const ScheduleMeetingScreen())); + builder: (context) => const ScheduleMeetingScreen() + ) + ); + setState(() { + // Update the calendar to reflect new meetings + _initialSelectedDate = DateTime.now(); + }); }, child: const Icon(Icons.add), ),