@umituz/react-native-notifications 1.4.0 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Clean presentation-only screen for notification settings
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import React, { useMemo } from 'react';
|
|
6
|
+
import React, { useMemo, useState } from 'react';
|
|
7
7
|
import { View, StyleSheet, ActivityIndicator, TouchableOpacity } from 'react-native';
|
|
8
8
|
import { AtomicText, AtomicIcon, AtomicCard, ScreenLayout } from '@umituz/react-native-design-system';
|
|
9
9
|
import { useAppDesignTokens } from '@umituz/react-native-design-system';
|
|
@@ -11,28 +11,29 @@ import { QuietHoursCard } from '../../domains/quietHours/presentation/components
|
|
|
11
11
|
import { SettingRow } from '../components/SettingRow';
|
|
12
12
|
import { useNotificationSettingsUI } from '../hooks/useNotificationSettingsUI';
|
|
13
13
|
import { useReminders } from '../../domains/reminders/infrastructure/storage/RemindersStore';
|
|
14
|
+
import { useQuietHoursActions } from '../../domains/quietHours/infrastructure/hooks/useQuietHoursActions';
|
|
14
15
|
import type { NotificationSettingsTranslations, QuietHoursTranslations } from '../../infrastructure/services/types';
|
|
16
|
+
// @ts-ignore - Optional peer dependency
|
|
17
|
+
import DateTimePicker from '@react-native-community/datetimepicker';
|
|
18
|
+
|
|
19
|
+
type PickerMode = 'start' | 'end' | null;
|
|
15
20
|
|
|
16
21
|
export interface NotificationSettingsScreenProps {
|
|
17
22
|
translations: NotificationSettingsTranslations;
|
|
18
23
|
quietHoursTranslations: QuietHoursTranslations;
|
|
19
|
-
onRemindersPress: () => void;
|
|
20
|
-
onStartTimePress: () => void;
|
|
21
|
-
onEndTimePress: () => void;
|
|
22
24
|
onHapticFeedback?: () => void;
|
|
23
25
|
}
|
|
24
26
|
|
|
25
27
|
export const NotificationSettingsScreen: React.FC<NotificationSettingsScreenProps> = ({
|
|
26
28
|
translations,
|
|
27
29
|
quietHoursTranslations,
|
|
28
|
-
onRemindersPress,
|
|
29
|
-
onStartTimePress,
|
|
30
|
-
onEndTimePress,
|
|
31
30
|
onHapticFeedback,
|
|
32
31
|
}) => {
|
|
33
32
|
const tokens = useAppDesignTokens();
|
|
34
33
|
const styles = useMemo(() => createStyles(tokens), [tokens]);
|
|
35
34
|
const reminders = useReminders();
|
|
35
|
+
const { setStartTime, setEndTime } = useQuietHoursActions();
|
|
36
|
+
const [pickerMode, setPickerMode] = useState<PickerMode>(null);
|
|
36
37
|
|
|
37
38
|
const {
|
|
38
39
|
preferences,
|
|
@@ -44,6 +45,42 @@ export const NotificationSettingsScreen: React.FC<NotificationSettingsScreenProp
|
|
|
44
45
|
handleQuietHoursToggle,
|
|
45
46
|
} = useNotificationSettingsUI();
|
|
46
47
|
|
|
48
|
+
const handleRemindersPress = () => {
|
|
49
|
+
// Navigate to reminders screen when implemented
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const handleStartTimePress = () => {
|
|
53
|
+
setPickerMode('start');
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const handleEndTimePress = () => {
|
|
57
|
+
setPickerMode('end');
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const handleTimeChange = (event: any, selectedDate?: Date) => {
|
|
61
|
+
if (event.type === 'set' && selectedDate) {
|
|
62
|
+
const hours = selectedDate.getHours();
|
|
63
|
+
const minutes = selectedDate.getMinutes();
|
|
64
|
+
|
|
65
|
+
if (pickerMode === 'start') {
|
|
66
|
+
setStartTime(hours, minutes);
|
|
67
|
+
} else if (pickerMode === 'end') {
|
|
68
|
+
setEndTime(hours, minutes);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
setPickerMode(null);
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const getPickerDate = () => {
|
|
75
|
+
const date = new Date();
|
|
76
|
+
if (pickerMode === 'start') {
|
|
77
|
+
date.setHours(quietHours.startHour, quietHours.startMinute);
|
|
78
|
+
} else if (pickerMode === 'end') {
|
|
79
|
+
date.setHours(quietHours.endHour, quietHours.endMinute);
|
|
80
|
+
}
|
|
81
|
+
return date;
|
|
82
|
+
};
|
|
83
|
+
|
|
47
84
|
if (isLoading) {
|
|
48
85
|
return (
|
|
49
86
|
<ScreenLayout>
|
|
@@ -118,12 +155,20 @@ export const NotificationSettingsScreen: React.FC<NotificationSettingsScreenProp
|
|
|
118
155
|
config={quietHours}
|
|
119
156
|
translations={quietHoursTranslations}
|
|
120
157
|
onToggle={handleQuietHoursToggle}
|
|
121
|
-
onStartTimePress={
|
|
122
|
-
onEndTimePress={
|
|
158
|
+
onStartTimePress={handleStartTimePress}
|
|
159
|
+
onEndTimePress={handleEndTimePress}
|
|
123
160
|
/>
|
|
124
161
|
</>
|
|
125
162
|
)}
|
|
126
163
|
</View>
|
|
164
|
+
{pickerMode && (
|
|
165
|
+
<DateTimePicker
|
|
166
|
+
value={getPickerDate()}
|
|
167
|
+
mode="time"
|
|
168
|
+
is24Hour={true}
|
|
169
|
+
onChange={handleTimeChange}
|
|
170
|
+
/>
|
|
171
|
+
)}
|
|
127
172
|
</ScreenLayout>
|
|
128
173
|
);
|
|
129
174
|
};
|