Skip to content

Commit 501bdb5

Browse files
authored
Merge pull request #415 from SimformSolutionsPvtLtd/feature/reoccurrence_event
feat: Fixes issue #378: ✨ Add support for single day & full day recurring events
2 parents 16ff6dc + 1f93153 commit 501bdb5

14 files changed

+1056
-18
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
- Fixes tap `onTileDoubleTap` & `onTileLongTap` issue for `hideDaysNotInMonth` in month view. [#435](https://github.com/SimformSolutionsPvtLtd/flutter_calendar_view/issues/435)
99
- Fixes `startHour` and `endHour` not updating when rebuilding in week view. [#410](https://github.com/SimformSolutionsPvtLtd/flutter_calendar_view/issues/410)
1010
- Fixes issue of header icon `color` property in `IconDataConfig`.
11+
- Adds support for single day & full day recurring events. [#378](https://github.com/SimformSolutionsPvtLtd/flutter_calendar_view/issues/378)
1112

1213
# [1.3.0 - 12 Nov 2024](https://github.com/SimformSolutionsPvtLtd/flutter_calendar_view/tree/1.3.0)
1314

example/lib/constants.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import 'app_colors.dart';
55
class AppConstants {
66
AppConstants._();
77

8+
static final List<String> weekTitles = ['M', 'T', 'W', 'T', 'F', 'S', 'S'];
9+
810
static OutlineInputBorder inputBorder = OutlineInputBorder(
911
borderRadius: BorderRadius.circular(7),
1012
borderSide: BorderSide(

example/lib/main.dart

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,36 @@ List<CalendarEventData> _events = [
4242
startTime: DateTime(_now.year, _now.month, _now.day, 18, 30),
4343
endTime: DateTime(_now.year, _now.month, _now.day, 22),
4444
),
45+
CalendarEventData(
46+
date: _now.subtract(Duration(days: 3)),
47+
recurrenceSettings: RecurrenceSettings.withCalculatedEndDate(
48+
startDate: _now.subtract(Duration(days: 3)),
49+
),
50+
title: 'Leetcode Contest',
51+
description: 'Give leetcode contest',
52+
),
53+
CalendarEventData(
54+
date: _now.subtract(Duration(days: 3)),
55+
recurrenceSettings: RecurrenceSettings.withCalculatedEndDate(
56+
startDate: _now.subtract(Duration(days: 3)),
57+
frequency: RepeatFrequency.daily,
58+
recurrenceEndOn: RecurrenceEnd.after,
59+
occurrences: 5,
60+
),
61+
title: 'Physics test prep',
62+
description: 'Prepare for physics test',
63+
),
4564
CalendarEventData(
4665
date: _now.add(Duration(days: 1)),
4766
startTime: DateTime(_now.year, _now.month, _now.day, 18),
4867
endTime: DateTime(_now.year, _now.month, _now.day, 19),
68+
recurrenceSettings: RecurrenceSettings(
69+
startDate: _now,
70+
endDate: _now.add(Duration(days: 5)),
71+
frequency: RepeatFrequency.daily,
72+
recurrenceEndOn: RecurrenceEnd.after,
73+
occurrences: 5,
74+
),
4975
title: "Wedding anniversary",
5076
description: "Attend uncle's wedding anniversary.",
5177
),

example/lib/pages/event_details_page.dart

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
11
import 'package:calendar_view/calendar_view.dart';
2+
import 'package:example/widgets/delete_event_dialog.dart';
23
import 'package:flutter/material.dart';
34

45
import '../extension.dart';
56
import 'create_event_page.dart';
67

78
class DetailsPage extends StatelessWidget {
89
final CalendarEventData event;
10+
final DateTime date;
11+
12+
const DetailsPage({
13+
required this.event,
14+
required this.date,
15+
super.key,
16+
});
917

10-
const DetailsPage({super.key, required this.event});
1118
@override
1219
Widget build(BuildContext context) {
1320
return Scaffold(
@@ -83,17 +90,15 @@ class DetailsPage extends StatelessWidget {
8390
SizedBox(
8491
height: 10.0,
8592
),
86-
Text(event.description!),
93+
Text(event.description!)
8794
],
8895
const SizedBox(height: 50),
8996
Row(
9097
children: [
9198
Expanded(
9299
child: ElevatedButton(
93-
onPressed: () {
94-
CalendarControllerProvider.of(context)
95-
.controller
96-
.remove(event);
100+
onPressed: () async {
101+
await _handleDeleteEvent(context);
97102
Navigator.of(context).pop();
98103
},
99104
child: Text('Delete Event'),
@@ -111,7 +116,7 @@ class DetailsPage extends StatelessWidget {
111116
),
112117
);
113118

114-
if (result) {
119+
if (result != null) {
115120
Navigator.of(context).pop();
116121
}
117122
},
@@ -124,4 +129,31 @@ class DetailsPage extends StatelessWidget {
124129
),
125130
);
126131
}
132+
133+
/// Handles the deletion of an event, showing a dialog for repeating events.
134+
///
135+
/// This method checks if the event is a repeating event. If it is, it shows
136+
/// a dialog to the user to choose the deletion type (e.g., delete this
137+
/// event, delete following events, delete all events).
138+
/// If the event is not repeating, it defaults to deleting all occurrences
139+
/// of the event.
140+
Future<void> _handleDeleteEvent(BuildContext context) async {
141+
DeleteEvent? result;
142+
143+
if (event.isRecurringEvent) {
144+
result = await showDialog(
145+
context: context,
146+
builder: (_) => DeleteEventDialog(),
147+
);
148+
} else {
149+
result = DeleteEvent.all;
150+
}
151+
if (result != null) {
152+
CalendarControllerProvider.of(context).controller.deleteRecurrenceEvent(
153+
date: date,
154+
event: event,
155+
deleteEventType: result,
156+
);
157+
}
158+
}
127159
}

0 commit comments

Comments
 (0)