-
Notifications
You must be signed in to change notification settings - Fork 310
Expand file tree
/
Copy pathhome_page.dart
More file actions
141 lines (130 loc) · 5.44 KB
/
home_page.dart
File metadata and controls
141 lines (130 loc) · 5.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
import 'package:calendar_view/calendar_view.dart';
import 'package:example/extension.dart';
import 'package:flutter/material.dart';
import '../widgets/responsive_widget.dart';
import 'mobile/mobile_home_page.dart';
import 'web/web_home_page.dart';
DateTime get _now => DateTime.now();
class HomePage extends StatefulWidget {
const HomePage({this.onChangeTheme, super.key});
/// Return true for dark mode
/// false for light mode
final void Function(bool)? onChangeTheme;
@override
State<HomePage> createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
EventController? _controller;
@override
void didChangeDependencies() {
super.didChangeDependencies();
final controller = CalendarControllerProvider.of(context).controller;
// Initialize events only when controller is first accessed
if (_controller != controller) {
_controller = controller;
final translate = context.translate;
final events = [
// Example of timeRanged event - for events with specific start/end times on a single day
CalendarEventData.timeRanged(
title: translate.projectMeetingTitle,
description: translate.projectMeetingDesc,
date: _now,
startTime: const TimeOfDay(hour: 18, minute: 30),
endTime: const TimeOfDay(hour: 22, minute: 0),
),
// Example of wholeDay event with recurrence - for all-day events
CalendarEventData.wholeDay(
title: translate.leetcodeContestTitle,
description: translate.leetcodeContestDesc,
date: _now.subtract(const Duration(days: 3)),
recurrenceSettings: RecurrenceSettings.withCalculatedEndDate(
startDate: _now.subtract(const Duration(days: 3)),
),
),
// Example of wholeDay event with daily recurrence
CalendarEventData.wholeDay(
title: translate.physicsTestTitle,
description: translate.physicsTestDesc,
date: _now.subtract(const Duration(days: 3)),
recurrenceSettings: RecurrenceSettings.withCalculatedEndDate(
startDate: _now.subtract(const Duration(days: 3)),
frequency: RepeatFrequency.daily,
recurrenceEndOn: RecurrenceEnd.after,
occurrences: 5,
),
),
// Example of timeRanged event with recurrence
CalendarEventData.timeRanged(
title: translate.weddingAnniversaryTitle,
description: translate.weddingAnniversaryDesc,
date: _now.add(const Duration(days: 1)),
startTime: const TimeOfDay(hour: 18, minute: 0),
endTime: const TimeOfDay(hour: 19, minute: 0),
recurrenceSettings: RecurrenceSettings(
startDate: _now,
endDate: _now.add(const Duration(days: 5)),
frequency: RepeatFrequency.daily,
recurrenceEndOn: RecurrenceEnd.after,
occurrences: 5,
),
),
// Example of timeRanged event - afternoon tournament
CalendarEventData.timeRanged(
title: translate.footballTournamentTitle,
description: translate.footballTournamentDesc,
date: _now,
startTime: const TimeOfDay(hour: 14, minute: 0),
endTime: const TimeOfDay(hour: 17, minute: 0),
),
// Example of timeRanged event - morning meeting
CalendarEventData.timeRanged(
title: translate.sprintMeetingTitle,
description: translate.sprintMeetingDesc,
date: _now.add(const Duration(days: 3)),
startTime: const TimeOfDay(hour: 10, minute: 0),
endTime: const TimeOfDay(hour: 14, minute: 0),
),
// Example of timeRanged event - 2 hour meeting
CalendarEventData.timeRanged(
title: translate.teamMeetingTitle,
description: translate.teamMeetingDesc,
date: _now.subtract(const Duration(days: 2)),
startTime: const TimeOfDay(hour: 14, minute: 0),
endTime: const TimeOfDay(hour: 16, minute: 0),
),
// Example of timeRanged event - chemistry viva
CalendarEventData.timeRanged(
title: translate.chemistryVivaTitle,
description: translate.chemistryVivaDesc,
date: _now.subtract(const Duration(days: 2)),
startTime: const TimeOfDay(hour: 10, minute: 0),
endTime: const TimeOfDay(hour: 12, minute: 0),
),
// Example of multiDay event - spanning multiple days without specific times
CalendarEventData.multiDay(
title: translate.annualTechConferenceTitle,
description: translate.annualTechConferenceDesc,
startDate: _now.add(const Duration(days: 5)),
endDate: _now.add(const Duration(days: 7)),
),
// Example of multiDay event with specific times - workshop spanning multiple days
CalendarEventData.multiDay(
title: translate.extendedWorkshopTitle,
description: translate.extendedWorkshopDesc,
startDate: _now.add(const Duration(days: 10)),
endDate: _now.add(const Duration(days: 12)),
startTime: const TimeOfDay(hour: 9, minute: 0),
endTime: const TimeOfDay(hour: 17, minute: 0),
),
];
_controller!.addAll(events);
}
}
@override
Widget build(BuildContext context) {
return ResponsiveWidget(
mobileWidget: MobileHomePage(onChangeTheme: widget.onChangeTheme),
webWidget: WebHomePage(onThemeChange: widget.onChangeTheme),
);
}
}