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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
- Fixes tap `onTileDoubleTap` & `onTileLongTap` issue for `hideDaysNotInMonth` in month view. [#435](https://github.com/SimformSolutionsPvtLtd/flutter_calendar_view/issues/435)
- Fixes `startHour` and `endHour` not updating when rebuilding in week view. [#410](https://github.com/SimformSolutionsPvtLtd/flutter_calendar_view/issues/410)
- Fixes issue of header icon `color` property in `IconDataConfig`.
- Adds support for single day & full day recurring events. [#378](https://github.com/SimformSolutionsPvtLtd/flutter_calendar_view/issues/378)

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

Expand Down
2 changes: 2 additions & 0 deletions example/lib/constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import 'app_colors.dart';
class AppConstants {
AppConstants._();

static final List<String> weekTitles = ['M', 'T', 'W', 'T', 'F', 'S', 'S'];

static OutlineInputBorder inputBorder = OutlineInputBorder(
borderRadius: BorderRadius.circular(7),
borderSide: BorderSide(
Expand Down
26 changes: 26 additions & 0 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,36 @@ List<CalendarEventData> _events = [
startTime: DateTime(_now.year, _now.month, _now.day, 18, 30),
endTime: DateTime(_now.year, _now.month, _now.day, 22),
),
CalendarEventData(
date: _now.subtract(Duration(days: 3)),
recurrenceSettings: RecurrenceSettings.withCalculatedEndDate(
startDate: _now.subtract(Duration(days: 3)),
),
title: 'Leetcode Contest',
description: 'Give leetcode contest',
),
CalendarEventData(
date: _now.subtract(Duration(days: 3)),
recurrenceSettings: RecurrenceSettings.withCalculatedEndDate(
startDate: _now.subtract(Duration(days: 3)),
frequency: RepeatFrequency.daily,
recurrenceEndOn: RecurrenceEnd.after,
occurrences: 5,
),
title: 'Physics test prep',
description: 'Prepare for physics test',
),
CalendarEventData(
date: _now.add(Duration(days: 1)),
startTime: DateTime(_now.year, _now.month, _now.day, 18),
endTime: DateTime(_now.year, _now.month, _now.day, 19),
recurrenceSettings: RecurrenceSettings(
startDate: _now,
endDate: _now.add(Duration(days: 5)),
frequency: RepeatFrequency.daily,
recurrenceEndOn: RecurrenceEnd.after,
occurrences: 5,
),
title: "Wedding anniversary",
description: "Attend uncle's wedding anniversary.",
),
Expand Down
46 changes: 39 additions & 7 deletions example/lib/pages/event_details_page.dart
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
import 'package:calendar_view/calendar_view.dart';
import 'package:example/widgets/delete_event_dialog.dart';
import 'package:flutter/material.dart';

import '../extension.dart';
import 'create_event_page.dart';

class DetailsPage extends StatelessWidget {
final CalendarEventData event;
final DateTime date;

const DetailsPage({
required this.event,
required this.date,
super.key,
});

const DetailsPage({super.key, required this.event});
@override
Widget build(BuildContext context) {
return Scaffold(
Expand Down Expand Up @@ -83,17 +90,15 @@ class DetailsPage extends StatelessWidget {
SizedBox(
height: 10.0,
),
Text(event.description!),
Text(event.description!)
],
const SizedBox(height: 50),
Row(
children: [
Expanded(
child: ElevatedButton(
onPressed: () {
CalendarControllerProvider.of(context)
.controller
.remove(event);
onPressed: () async {
await _handleDeleteEvent(context);
Navigator.of(context).pop();
},
child: Text('Delete Event'),
Expand All @@ -111,7 +116,7 @@ class DetailsPage extends StatelessWidget {
),
);

if (result) {
if (result != null) {
Navigator.of(context).pop();
}
},
Expand All @@ -124,4 +129,31 @@ class DetailsPage extends StatelessWidget {
),
);
}

/// Handles the deletion of an event, showing a dialog for repeating events.
///
/// This method checks if the event is a repeating event. If it is, it shows
/// a dialog to the user to choose the deletion type (e.g., delete this
/// event, delete following events, delete all events).
/// If the event is not repeating, it defaults to deleting all occurrences
/// of the event.
Future<void> _handleDeleteEvent(BuildContext context) async {
DeleteEvent? result;

if (event.isRecurringEvent) {
result = await showDialog(
context: context,
builder: (_) => DeleteEventDialog(),
);
} else {
result = DeleteEvent.all;
}
if (result != null) {
CalendarControllerProvider.of(context).controller.deleteRecurrenceEvent(
date: date,
event: event,
deleteEventType: result,
);
}
}
}
Loading
Loading