-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy patheventide_platform_interface.dart
174 lines (150 loc) · 4.21 KB
/
eventide_platform_interface.dart
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
import 'dart:ui';
import 'package:eventide/src/eventide.dart';
import 'package:equatable/equatable.dart';
import 'package:flutter/services.dart';
import 'package:plugin_platform_interface/plugin_platform_interface.dart';
abstract class EventidePlatform extends PlatformInterface {
EventidePlatform() : super(token: _token);
static final Object _token = Object();
static EventidePlatform _instance = Eventide();
static EventidePlatform get instance => _instance;
static set instance(EventidePlatform instance) {
PlatformInterface.verify(instance, _token);
_instance = instance;
}
Future<bool> requestCalendarPermission();
Future<ETCalendar> createCalendar({
required String title,
required Color color,
ETAccount? account,
});
Future<List<ETCalendar>> retrieveCalendars({
bool onlyWritableCalendars = true,
ETAccount? fromAccount,
});
Future<void> deleteCalendar({
required String calendarId,
});
Future<ETEvent> createEvent({
required String calendarId,
required String title,
required DateTime startDate,
required DateTime endDate,
String? description,
String? url,
List<Duration>? reminders,
});
Future<List<ETEvent>> retrieveEvents({
required String calendarId,
DateTime? startDate,
DateTime? endDate,
});
Future<void> deleteEvent({
required String eventId,
});
Future<ETEvent> createReminder({
required Duration durationBeforeEvent,
required String eventId,
});
Future<ETEvent> deleteReminder({
required Duration durationBeforeEvent,
required String eventId,
});
}
/// Represents a calendar.
///
/// [id] is a unique identifier for the calendar.
///
/// [title] is the title of the calendar.
///
/// [color] is the color of the calendar.
///
/// [isWritable] is a boolean to indicate if the calendar is writable.
///
/// [sourceName] is the name of the source of the calendar.
final class ETCalendar extends Equatable {
final String id;
final String title;
final Color color;
final bool isWritable;
final ETAccount account;
@override
List<Object?> get props => [id, title, color, isWritable, account];
const ETCalendar({
required this.id,
required this.title,
required this.color,
required this.isWritable,
required this.account,
});
}
/// Represents an event.
///
/// [id] is a unique identifier for the event.
///
/// [title] is the title of the event.
///
/// [startDate] is the start date of the event in milliseconds since epoch.
///
/// [endDate] is the end date of the event in milliseconds since epoch.
///
/// [calendarId] is the id of the calendar that the event belongs to.
///
/// [description] is the description of the event.
///
/// [url] is the url of the event.
///
/// [reminders] is a list of [Duration] before the event.
final class ETEvent extends Equatable {
final String id;
final String title;
final bool isAllDay;
final DateTime startDate;
final DateTime endDate;
final String calendarId;
final String? description;
final String? url;
final List<Duration>? reminders;
@override
List<Object?> get props => [
id,
title,
isAllDay,
startDate,
endDate,
calendarId,
description,
url,
reminders
];
const ETEvent({
required this.id,
required this.title,
required this.isAllDay,
required this.startDate,
required this.endDate,
required this.calendarId,
this.description,
this.url,
this.reminders,
});
}
/// Represents an account.
///
/// [name] is the name of the account. It corresponds to CalendarContract.Calendars.ACCOUNT_NAME on Android and EKSource.sourceIdentifier on iOS.
///
/// [type] is the type of the account. It corresponds to CalendarContract.Calendars.ACCOUNT_TYPE on Android and EKSource.sourceType on iOS.
///
/// This class is used to represent the account that the calendar belongs to.
///
/// For example, if the calendar belongs to a Google account, the account name will be the email address of the Google account.
final class ETAccount extends Equatable {
final String name;
final String type;
@override
List<Object?> get props => [name, type];
const ETAccount({
required this.name,
required this.type,
});
}