-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathAlarm.tsx
More file actions
67 lines (60 loc) · 1.83 KB
/
Alarm.tsx
File metadata and controls
67 lines (60 loc) · 1.83 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
import { toAndroidDays, fromAndroidDays, getParam, fromIOSDays } from '../utils';
class Alarm {
uid?: string | undefined;
title?: string | undefined;
description?: string | undefined;
hour?: number | undefined;
minutes?: number | undefined;
showDismiss?: boolean | undefined;
dismissText?: string | undefined;
showSnooze?: boolean | undefined;
snoozeInterval?: number | undefined;
snoozeText?: string | undefined;
repeating?: boolean | undefined;
active?: boolean | undefined;
day?: string | Date | number[] | undefined;
sound?: string | undefined;
constructor(params: any = null) {
this.uid = getParam(params, 'uid');
this.title = getParam(params, 'title');
this.description = getParam(params, 'description');
this.hour = getParam(params, 'hour');
this.minutes = getParam(params, 'minutes');
this.showDismiss = getParam(params, 'showDismiss');
this.dismissText = getParam(params, 'dismissText');
this.showSnooze = getParam(params, 'showSnooze');
this.snoozeInterval = getParam(params, 'snoozeInterval');
this.snoozeText = getParam(params, 'snoozeText');
this.repeating = getParam(params, 'repeating');
this.active = getParam(params, 'active');
this.day = getParam(params, 'day');
this.sound = getParam(params, 'sound');
}
static getEmpty() {
return new Alarm({
title: '',
description: '',
hour: 0,
minutes: 0,
repeating: false,
day: [],
});
}
toAndroid() {
return {
...this,
day: toAndroidDays(this.day),
};
}
static fromAndroid(alarm: Alarm) {
alarm.day = fromAndroidDays(alarm.day);
return new Alarm(alarm);
}
static fromIos(alarm: Alarm) {
if (typeof alarm.day === 'number') {
alarm.day = fromIOSDays(alarm.day);
}
return new Alarm(alarm);
}
}
export default Alarm;