Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added images/calendar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/dark_theme_gauge.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed images/image_nav_banner_white.png
Binary file not shown.
9 changes: 6 additions & 3 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import 'package:flutter/material.dart';
import 'package:flutter_examples/model/model.dart';
import 'package:flutter_examples/sample_browser.dart';
import 'package:syncfusion_flutter_core/core.dart';

void main() {
// Register your license here
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await updateControl();
// Register your license here
SyncfusionLicense.registerLicense(null);
return runApp(SampleBrowser());
runApp(SampleBrowser());
}
1,483 changes: 226 additions & 1,257 deletions lib/model/helper.dart

Large diffs are not rendered by default.

1,586 changes: 184 additions & 1,402 deletions lib/model/model.dart

Large diffs are not rendered by default.

422 changes: 422 additions & 0 deletions lib/model/view.dart

Large diffs are not rendered by default.

827 changes: 378 additions & 449 deletions lib/sample_browser.dart

Large diffs are not rendered by default.

1,273 changes: 1,273 additions & 0 deletions lib/sample_details.json

Large diffs are not rendered by default.

320 changes: 320 additions & 0 deletions lib/sample_list.dart

Large diffs are not rendered by default.

229 changes: 229 additions & 0 deletions lib/samples/calendar/agenda_view/agenda_view.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,229 @@
import 'dart:math';

import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart';
import 'package:flutter_examples/model/model.dart';
import 'package:syncfusion_flutter_calendar/calendar.dart';

//ignore: must_be_immutable
class AgendaViewCalendar extends StatefulWidget {
AgendaViewCalendar({this.sample, Key key}) : super(key: key);
SubItem sample;

@override
_AgendaViewCalendarState createState() => _AgendaViewCalendarState(sample);
}

class _AgendaViewCalendarState extends State<AgendaViewCalendar> {
_AgendaViewCalendarState(this.sample);

final SubItem sample;
bool panelOpen;
final ValueNotifier<bool> frontPanelVisible = ValueNotifier<bool>(true);
List<String> subjectCollection;
List<Color> colorCollection;
List<Meeting> meetings;
MeetingDataSource events;
DateTime selectedDate;

@override
void initState() {
panelOpen = frontPanelVisible.value;
frontPanelVisible.addListener(_subscribeToValueNotifier);
meetings = <Meeting>[];
selectedDate = DateTime.now();
addAppointmentDetails();
addAppointments();
events = MeetingDataSource(meetings);
super.initState();
}

void _subscribeToValueNotifier() => panelOpen = frontPanelVisible.value;

@override
void didUpdateWidget(AgendaViewCalendar oldWidget) {
super.didUpdateWidget(oldWidget);
frontPanelVisible.removeListener(_subscribeToValueNotifier);
frontPanelVisible.addListener(_subscribeToValueNotifier);
}

@override
Widget build(BuildContext context) {
return getAgendaViewCalendar(events, onViewChanged, selectedDate);
}

void addAppointmentDetails() {
subjectCollection = <String>[];
subjectCollection.add('General Meeting');
subjectCollection.add('Plan Execution');
subjectCollection.add('Project Plan');
subjectCollection.add('Consulting');
subjectCollection.add('Support');
subjectCollection.add('Development Meeting');
subjectCollection.add('Scrum');
subjectCollection.add('Project Completion');
subjectCollection.add('Release updates');
subjectCollection.add('Performance Check');

colorCollection = <Color>[];
colorCollection.add(const Color(0xFF0F8644));
colorCollection.add(const Color(0xFF8B1FA9));
colorCollection.add(const Color(0xFFD20100));
colorCollection.add(const Color(0xFFFC571D));
colorCollection.add(const Color(0xFF36B37B));
colorCollection.add(const Color(0xFF01A1EF));
colorCollection.add(const Color(0xFF3D4FB5));
colorCollection.add(const Color(0xFFE47C73));
colorCollection.add(const Color(0xFF636363));
colorCollection.add(const Color(0xFF0A8043));
}

void addAppointments() {
final Random random = Random();
final DateTime rangeStartDate =
DateTime.now().add(const Duration(days: -(365 ~/ 2)));
final DateTime rangeEndDate = DateTime.now().add(const Duration(days: 365));
for (DateTime i = rangeStartDate;
i.isBefore(rangeEndDate);
i = i.add(const Duration(days: 1))) {
final DateTime date = i;
final int count = 1 + random.nextInt(3);
for (int j = 0; j < count; j++) {
final DateTime startDate = DateTime(
date.year, date.month, date.day, 8 + random.nextInt(8), 0, 0);
meetings.add(Meeting(
subjectCollection[random.nextInt(7)],
'',
'',
null,
startDate,
startDate.add(Duration(hours: random.nextInt(3))),
colorCollection[random.nextInt(9)],
false,
'',
'',
''));
}
}

// added recurrence appointment
meetings.add(Meeting(
'Development status',
'',
'',
null,
DateTime.now(),
DateTime.now().add(const Duration(hours: 2)),
colorCollection[random.nextInt(9)],
false,
'',
'',
'FREQ=WEEKLY;BYDAY=FR;INTERVAL=1'));
}

void onViewChanged(ViewChangedDetails visibleDatesChangedDetails) {
SchedulerBinding.instance.addPostFrameCallback((_) {
final DateTime currentViewDate = visibleDatesChangedDetails
.visibleDates[visibleDatesChangedDetails.visibleDates.length ~/ 2];
if (currentViewDate.month == DateTime.now().month &&
currentViewDate.year == DateTime.now().year) {
selectedDate = DateTime.now();
} else {
selectedDate =
DateTime(currentViewDate.year, currentViewDate.month, 01);
}
setState(() {});
});
}
}

SfCalendar getAgendaViewCalendar(
[CalendarDataSource _calendarDataSource,
ViewChangedCallback onViewChanged,
DateTime selectedDate]) {
return SfCalendar(
view: CalendarView.month,
initialSelectedDate: selectedDate,
onViewChanged: onViewChanged,
dataSource: _calendarDataSource,
monthViewSettings: MonthViewSettings(showAgenda: true),
timeSlotViewSettings: TimeSlotViewSettings(
minimumAppointmentDuration: const Duration(minutes: 60)),
);
}

class MeetingDataSource extends CalendarDataSource {
MeetingDataSource(this.source);

List<Meeting> source;

@override
List<dynamic> get appointments => source;

@override
DateTime getStartTime(int index) {
return source[index].from;
}

@override
DateTime getEndTime(int index) {
return source[index].to;
}

@override
bool isAllDay(int index) {
return source[index].isAllDay;
}

@override
String getSubject(int index) {
return source[index].eventName;
}

@override
String getStartTimeZone(int index) {
return source[index].startTimeZone;
}

@override
String getEndTimeZone(int index) {
return source[index].endTimeZone;
}

@override
Color getColor(int index) {
return source[index].background;
}

@override
String getRecurrenceRule(int index) {
return source[index].recurrenceRule;
}
}

class Meeting {
Meeting(
this.eventName,
this.organizer,
this.contactID,
this.capacity,
this.from,
this.to,
this.background,
this.isAllDay,
this.startTimeZone,
this.endTimeZone,
this.recurrenceRule);

String eventName;
String organizer;
String contactID;
int capacity;
DateTime from;
DateTime to;
Color background;
bool isAllDay;
String startTimeZone;
String endTimeZone;
String recurrenceRule;
}
Loading