-
Notifications
You must be signed in to change notification settings - Fork 5
/
index.js
38 lines (29 loc) · 1.15 KB
/
index.js
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
import { NativeModules, requireNativeComponent } from 'react-native';
const { ScreenTimeAPI } = NativeModules;
const ScreenTime = ScreenTimeAPI;
export const activitySelectionIsEmpty = (selection) => {
if (!selection) return true;
return Object.values(selection).every((v) => !v || (Array.isArray(v) && v.length === 0));
}
const FamilyActivityPickerView = requireNativeComponent('RNTFamilyActivityPickerView');
export class DateInterval {
startDate;
endDate;
duration;
constructor(startDate, durationOrEndDate) {
if (!(startDate instanceof Date)) {
throw new Error('Invalid argument startDate must be a Date objec');
}
this.startDate = startDate;
if (durationOrEndDate instanceof Date) {
this.endDate = durationOrEndDate;
this.duration = durationOrEndDate.valueOf() - startDate.valueOf();
} else if (typeof durationOrEndDate === 'number') {
this.duration = durationOrEndDate;
this.endDate = new Date(startDate.valueOf() + durationOrEndDate);
} else {
throw new Error('Invalid argument durationOrEndDate must be a Date object or a number');
}
}
}
export { FamilyActivityPickerView, ScreenTime };