@umituz/react-native-notifications 1.1.7 → 1.3.1
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 +18 -40
- package/src/index.ts +84 -13
- package/src/infrastructure/config/reminderPresets.ts +120 -0
- package/src/infrastructure/hooks/useQuietHoursActions.ts +52 -0
- package/src/infrastructure/hooks/useReminderActions.ts +147 -0
- package/src/infrastructure/services/types.ts +137 -44
- package/src/infrastructure/storage/RemindersStore.ts +150 -0
- package/src/presentation/components/FormButton.tsx +66 -0
- package/src/presentation/components/FrequencySelector.tsx +72 -0
- package/src/presentation/components/NotificationsSection.tsx +95 -160
- package/src/presentation/components/QuietHoursCard.tsx +105 -0
- package/src/presentation/components/ReminderForm.tsx +165 -0
- package/src/presentation/components/ReminderItem.tsx +124 -0
- package/src/presentation/components/TimePresetSelector.tsx +100 -0
- package/src/presentation/components/WeekdaySelector.tsx +61 -0
- package/src/presentation/screens/NotificationSettingsScreen.tsx +210 -0
- package/src/presentation/screens/NotificationsScreen.tsx +1 -1
- package/src/presentation/screens/ReminderListScreen.tsx +138 -0
- package/src/types/global.d.ts +11 -8
- package/lib/index.d.ts +0 -16
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js +0 -23
- package/lib/index.js.map +0 -1
- package/lib/infrastructure/config/notificationsConfig.d.ts +0 -20
- package/lib/infrastructure/config/notificationsConfig.d.ts.map +0 -1
- package/lib/infrastructure/config/notificationsConfig.js +0 -81
- package/lib/infrastructure/config/notificationsConfig.js.map +0 -1
- package/lib/infrastructure/hooks/actions/useNotificationActions.d.ts +0 -7
- package/lib/infrastructure/hooks/actions/useNotificationActions.d.ts.map +0 -1
- package/lib/infrastructure/hooks/actions/useNotificationActions.js +0 -75
- package/lib/infrastructure/hooks/actions/useNotificationActions.js.map +0 -1
- package/lib/infrastructure/hooks/actions/useNotificationManagementActions.d.ts +0 -8
- package/lib/infrastructure/hooks/actions/useNotificationManagementActions.d.ts.map +0 -1
- package/lib/infrastructure/hooks/actions/useNotificationManagementActions.js +0 -78
- package/lib/infrastructure/hooks/actions/useNotificationManagementActions.js.map +0 -1
- package/lib/infrastructure/hooks/state/useNotificationsState.d.ts +0 -12
- package/lib/infrastructure/hooks/state/useNotificationsState.d.ts.map +0 -1
- package/lib/infrastructure/hooks/state/useNotificationsState.js +0 -30
- package/lib/infrastructure/hooks/state/useNotificationsState.js.map +0 -1
- package/lib/infrastructure/hooks/types.d.ts +0 -87
- package/lib/infrastructure/hooks/types.d.ts.map +0 -1
- package/lib/infrastructure/hooks/types.js +0 -8
- package/lib/infrastructure/hooks/types.js.map +0 -1
- package/lib/infrastructure/hooks/useNotificationSettings.d.ts +0 -10
- package/lib/infrastructure/hooks/useNotificationSettings.d.ts.map +0 -1
- package/lib/infrastructure/hooks/useNotificationSettings.js +0 -43
- package/lib/infrastructure/hooks/useNotificationSettings.js.map +0 -1
- package/lib/infrastructure/hooks/useNotifications.d.ts +0 -24
- package/lib/infrastructure/hooks/useNotifications.d.ts.map +0 -1
- package/lib/infrastructure/hooks/useNotifications.js +0 -72
- package/lib/infrastructure/hooks/useNotifications.js.map +0 -1
- package/lib/infrastructure/hooks/utils/useNotificationRefresh.d.ts +0 -8
- package/lib/infrastructure/hooks/utils/useNotificationRefresh.d.ts.map +0 -1
- package/lib/infrastructure/hooks/utils/useNotificationRefresh.js +0 -99
- package/lib/infrastructure/hooks/utils/useNotificationRefresh.js.map +0 -1
- package/lib/infrastructure/services/NotificationBadgeManager.d.ts +0 -5
- package/lib/infrastructure/services/NotificationBadgeManager.d.ts.map +0 -1
- package/lib/infrastructure/services/NotificationBadgeManager.js +0 -29
- package/lib/infrastructure/services/NotificationBadgeManager.js.map +0 -1
- package/lib/infrastructure/services/NotificationManager.d.ts +0 -59
- package/lib/infrastructure/services/NotificationManager.d.ts.map +0 -1
- package/lib/infrastructure/services/NotificationManager.js +0 -118
- package/lib/infrastructure/services/NotificationManager.js.map +0 -1
- package/lib/infrastructure/services/NotificationPermissions.d.ts +0 -6
- package/lib/infrastructure/services/NotificationPermissions.d.ts.map +0 -1
- package/lib/infrastructure/services/NotificationPermissions.js +0 -75
- package/lib/infrastructure/services/NotificationPermissions.js.map +0 -1
- package/lib/infrastructure/services/NotificationScheduler.d.ts +0 -8
- package/lib/infrastructure/services/NotificationScheduler.d.ts.map +0 -1
- package/lib/infrastructure/services/NotificationScheduler.js +0 -72
- package/lib/infrastructure/services/NotificationScheduler.js.map +0 -1
- package/lib/infrastructure/services/NotificationService.d.ts +0 -30
- package/lib/infrastructure/services/NotificationService.d.ts.map +0 -1
- package/lib/infrastructure/services/NotificationService.js +0 -41
- package/lib/infrastructure/services/NotificationService.js.map +0 -1
- package/lib/infrastructure/services/channels/ChannelManager.d.ts +0 -18
- package/lib/infrastructure/services/channels/ChannelManager.d.ts.map +0 -1
- package/lib/infrastructure/services/channels/ChannelManager.js +0 -87
- package/lib/infrastructure/services/channels/ChannelManager.js.map +0 -1
- package/lib/infrastructure/services/delivery/NotificationDelivery.d.ts +0 -10
- package/lib/infrastructure/services/delivery/NotificationDelivery.d.ts.map +0 -1
- package/lib/infrastructure/services/delivery/NotificationDelivery.js +0 -71
- package/lib/infrastructure/services/delivery/NotificationDelivery.js.map +0 -1
- package/lib/infrastructure/services/preferences/PreferencesManager.d.ts +0 -18
- package/lib/infrastructure/services/preferences/PreferencesManager.d.ts.map +0 -1
- package/lib/infrastructure/services/preferences/PreferencesManager.js +0 -65
- package/lib/infrastructure/services/preferences/PreferencesManager.js.map +0 -1
- package/lib/infrastructure/services/types.d.ts +0 -89
- package/lib/infrastructure/services/types.d.ts.map +0 -1
- package/lib/infrastructure/services/types.js +0 -7
- package/lib/infrastructure/services/types.js.map +0 -1
- package/lib/infrastructure/storage/NotificationsStore.d.ts +0 -23
- package/lib/infrastructure/storage/NotificationsStore.d.ts.map +0 -1
- package/lib/infrastructure/storage/NotificationsStore.js +0 -26
- package/lib/infrastructure/storage/NotificationsStore.js.map +0 -1
- package/lib/infrastructure/utils/dev.d.ts +0 -5
- package/lib/infrastructure/utils/dev.d.ts.map +0 -1
- package/lib/infrastructure/utils/dev.js +0 -24
- package/lib/infrastructure/utils/dev.js.map +0 -1
- package/lib/presentation/components/NotificationsSection.d.ts +0 -17
- package/lib/presentation/components/NotificationsSection.d.ts.map +0 -1
- package/lib/presentation/components/NotificationsSection.js +0 -133
- package/lib/presentation/components/NotificationsSection.js.map +0 -1
- package/lib/presentation/screens/NotificationsScreen.d.ts +0 -20
- package/lib/presentation/screens/NotificationsScreen.d.ts.map +0 -1
- package/lib/presentation/screens/NotificationsScreen.js +0 -74
- package/lib/presentation/screens/NotificationsScreen.js.map +0 -1
- package/src/__tests__/NotificationManager.test.ts +0 -215
- package/src/__tests__/useNotificationActions.test.ts +0 -189
- package/src/__tests__/useNotificationRefresh.test.ts +0 -213
- package/src/infrastructure/hooks/actions/useNotificationActions.ts +0 -131
- package/src/infrastructure/hooks/actions/useNotificationManagementActions.ts +0 -131
- package/src/infrastructure/hooks/state/useNotificationsState.ts +0 -46
- package/src/infrastructure/hooks/types.ts +0 -83
- package/src/infrastructure/hooks/useNotifications.ts +0 -96
- package/src/infrastructure/hooks/utils/useNotificationRefresh.ts +0 -131
- package/src/infrastructure/services/channels/ChannelManager.ts +0 -111
- package/src/infrastructure/services/delivery/NotificationDelivery.ts +0 -83
- package/src/infrastructure/services/preferences/PreferencesManager.ts +0 -77
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import AsyncStorage from '@react-native-async-storage/async-storage';
|
|
2
|
-
import * as Notifications from 'expo-notifications';
|
|
3
|
-
/**
|
|
4
|
-
* ChannelManager - Offline Notification Channel Management
|
|
5
|
-
*
|
|
6
|
-
* Manages push notification tokens and preferences in AsyncStorage.
|
|
7
|
-
* Only supports local push and in-app notifications.
|
|
8
|
-
*
|
|
9
|
-
* NO backend, NO email/SMS - pure offline.
|
|
10
|
-
*/
|
|
11
|
-
export class ChannelManager {
|
|
12
|
-
async register(channelType, preferences = {}) {
|
|
13
|
-
try {
|
|
14
|
-
// Get push token for local notifications
|
|
15
|
-
const token = channelType === 'push'
|
|
16
|
-
? (await Notifications.getExpoPushTokenAsync()).data
|
|
17
|
-
: 'in_app';
|
|
18
|
-
const channel = {
|
|
19
|
-
id: `${channelType}_${Date.now()}`,
|
|
20
|
-
channel_type: channelType,
|
|
21
|
-
channel_address: token,
|
|
22
|
-
preferences,
|
|
23
|
-
is_verified: true, // Local channels always verified
|
|
24
|
-
is_active: true,
|
|
25
|
-
created_at: new Date().toISOString(),
|
|
26
|
-
};
|
|
27
|
-
// Store in AsyncStorage
|
|
28
|
-
const channels = await this.getAllChannels();
|
|
29
|
-
channels.push(channel);
|
|
30
|
-
await AsyncStorage.setItem(ChannelManager.STORAGE_KEY, JSON.stringify(channels));
|
|
31
|
-
return channel;
|
|
32
|
-
}
|
|
33
|
-
catch (error) {
|
|
34
|
-
return null;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
async verify(channelId) {
|
|
38
|
-
try {
|
|
39
|
-
const channels = await this.getAllChannels();
|
|
40
|
-
const index = channels.findIndex((c) => c.id === channelId);
|
|
41
|
-
if (index !== -1) {
|
|
42
|
-
channels[index].is_verified = true;
|
|
43
|
-
await AsyncStorage.setItem(ChannelManager.STORAGE_KEY, JSON.stringify(channels));
|
|
44
|
-
return true;
|
|
45
|
-
}
|
|
46
|
-
return false;
|
|
47
|
-
}
|
|
48
|
-
catch (error) {
|
|
49
|
-
return false;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
async getActiveChannels() {
|
|
53
|
-
try {
|
|
54
|
-
const channels = await this.getAllChannels();
|
|
55
|
-
return channels.filter((c) => c.is_active && c.is_verified);
|
|
56
|
-
}
|
|
57
|
-
catch (error) {
|
|
58
|
-
return [];
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
async getAllChannels() {
|
|
62
|
-
try {
|
|
63
|
-
const data = await AsyncStorage.getItem(ChannelManager.STORAGE_KEY);
|
|
64
|
-
return data ? JSON.parse(data) : [];
|
|
65
|
-
}
|
|
66
|
-
catch (error) {
|
|
67
|
-
return [];
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
async update(channelId, updates) {
|
|
71
|
-
try {
|
|
72
|
-
const channels = await this.getAllChannels();
|
|
73
|
-
const index = channels.findIndex((c) => c.id === channelId);
|
|
74
|
-
if (index !== -1) {
|
|
75
|
-
channels[index] = { ...channels[index], ...updates };
|
|
76
|
-
await AsyncStorage.setItem(ChannelManager.STORAGE_KEY, JSON.stringify(channels));
|
|
77
|
-
return channels[index];
|
|
78
|
-
}
|
|
79
|
-
return null;
|
|
80
|
-
}
|
|
81
|
-
catch (error) {
|
|
82
|
-
return null;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
ChannelManager.STORAGE_KEY = '@notifications:channels';
|
|
87
|
-
//# sourceMappingURL=ChannelManager.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ChannelManager.js","sourceRoot":"","sources":["../../../../src/infrastructure/services/channels/ChannelManager.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,2CAA2C,CAAC;AACrE,OAAO,KAAK,aAAa,MAAM,oBAAoB,CAAC;AAGpD;;;;;;;GAOG;AACH,MAAM,OAAO,cAAc;IAGzB,KAAK,CAAC,QAAQ,CACZ,WAA8B,EAC9B,cAAmC,EAAE;QAErC,IAAI,CAAC;YACH,yCAAyC;YACzC,MAAM,KAAK,GACT,WAAW,KAAK,MAAM;gBACpB,CAAC,CAAC,CAAC,MAAM,aAAa,CAAC,qBAAqB,EAAE,CAAC,CAAC,IAAI;gBACpD,CAAC,CAAC,QAAQ,CAAC;YAEf,MAAM,OAAO,GAAwB;gBACnC,EAAE,EAAE,GAAG,WAAW,IAAI,IAAI,CAAC,GAAG,EAAE,EAAE;gBAClC,YAAY,EAAE,WAAW;gBACzB,eAAe,EAAE,KAAK;gBACtB,WAAW;gBACX,WAAW,EAAE,IAAI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';
|
|
2
|
-
export declare class NotificationDelivery {
|
|
3
|
-
private static STORAGE_KEY;
|
|
4
|
-
deliver(notification: Notification): Promise<void>;
|
|
5
|
-
private updateStatus;
|
|
6
|
-
private getDelivered;
|
|
7
|
-
getDeliveryStatus(notificationId: string): Promise<string | null>;
|
|
8
|
-
clearDeliveryHistory(): Promise<void>;
|
|
9
|
-
}
|
|
10
|
-
//# sourceMappingURL=NotificationDelivery.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NotificationDelivery.d.ts","sourceRoot":"","sources":["../../../../src/infrastructure/services/delivery/NotificationDelivery.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAG7C,qBAAa,oBAAoB;IAC/B,OAAO,CAAC,MAAM,CAAC,WAAW,CAA8B;IAElD,OAAO,CAAC,YAAY,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;YAwB1C,YAAY;YAqBZ,YAAY;IAUpB,iBAAiB,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAUjE,oBAAoB,IAAI,OAAO,CAAC,IAAI,CAAC;CAS5C"}
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import * as Notifications from 'expo-notifications';
|
|
2
|
-
import AsyncStorage from '@react-native-async-storage/async-storage';
|
|
3
|
-
import { devLog, devError } from '../../utils/dev';
|
|
4
|
-
export class NotificationDelivery {
|
|
5
|
-
async deliver(notification) {
|
|
6
|
-
try {
|
|
7
|
-
await Notifications.scheduleNotificationAsync({
|
|
8
|
-
content: {
|
|
9
|
-
title: notification.title,
|
|
10
|
-
body: notification.body,
|
|
11
|
-
data: { notificationId: notification.id },
|
|
12
|
-
},
|
|
13
|
-
trigger: notification.scheduled_for
|
|
14
|
-
? { date: new Date(notification.scheduled_for) }
|
|
15
|
-
: null,
|
|
16
|
-
});
|
|
17
|
-
await this.updateStatus(notification.id, 'delivered');
|
|
18
|
-
devLog('[NotificationDelivery] Notification delivered:', notification.id);
|
|
19
|
-
}
|
|
20
|
-
catch (error) {
|
|
21
|
-
await this.updateStatus(notification.id, 'failed');
|
|
22
|
-
devError('[NotificationDelivery] Delivery failed:', notification.id, error);
|
|
23
|
-
throw error;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
async updateStatus(notificationId, status) {
|
|
27
|
-
try {
|
|
28
|
-
const delivered = await this.getDelivered();
|
|
29
|
-
delivered[notificationId] = {
|
|
30
|
-
status,
|
|
31
|
-
delivered_at: new Date().toISOString(),
|
|
32
|
-
};
|
|
33
|
-
await AsyncStorage.setItem(NotificationDelivery.STORAGE_KEY, JSON.stringify(delivered));
|
|
34
|
-
devLog('[NotificationDelivery] Status updated:', notificationId, status);
|
|
35
|
-
}
|
|
36
|
-
catch (error) {
|
|
37
|
-
devError('[NotificationDelivery] Status update failed:', notificationId, error);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
async getDelivered() {
|
|
41
|
-
try {
|
|
42
|
-
const data = await AsyncStorage.getItem(NotificationDelivery.STORAGE_KEY);
|
|
43
|
-
return data ? JSON.parse(data) : {};
|
|
44
|
-
}
|
|
45
|
-
catch (error) {
|
|
46
|
-
devError('[NotificationDelivery] Failed to get delivered notifications:', error);
|
|
47
|
-
return {};
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
async getDeliveryStatus(notificationId) {
|
|
51
|
-
try {
|
|
52
|
-
const delivered = await this.getDelivered();
|
|
53
|
-
return delivered[notificationId]?.status || null;
|
|
54
|
-
}
|
|
55
|
-
catch (error) {
|
|
56
|
-
devError('[NotificationDelivery] Failed to get delivery status:', notificationId, error);
|
|
57
|
-
return null;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
async clearDeliveryHistory() {
|
|
61
|
-
try {
|
|
62
|
-
await AsyncStorage.removeItem(NotificationDelivery.STORAGE_KEY);
|
|
63
|
-
devLog('[NotificationDelivery] Delivery history cleared');
|
|
64
|
-
}
|
|
65
|
-
catch (error) {
|
|
66
|
-
devError('[NotificationDelivery] Failed to clear delivery history:', error);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
NotificationDelivery.STORAGE_KEY = '@notifications:delivered';
|
|
71
|
-
//# sourceMappingURL=NotificationDelivery.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NotificationDelivery.js","sourceRoot":"","sources":["../../../../src/infrastructure/services/delivery/NotificationDelivery.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,aAAa,MAAM,oBAAoB,CAAC;AACpD,OAAO,YAAY,MAAM,2CAA2C,CAAC;AAErE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAEnD,MAAM,OAAO,oBAAoB;IAG/B,KAAK,CAAC,OAAO,CAAC,YAA0B;QACtC,IAAI,CAAC;YACH,MAAM,aAAa,CAAC,yBAAyB,CAAC;gBAC5C,OAAO,EAAE;oBACP,KAAK,EAAE,YAAY,CAAC,KAAK;oBACzB,IAAI,EAAE,YAAY,CAAC,IAAI;oBACvB,IAAI,EAAE,EAAE,cAAc,EAAE,YAAY,CAAC,EAAE,EAAE;iBAC1C;gBACD,OAAO,EAAE,YAAY,CAAC,aAAa;oBACjC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,IAAI,CAAC,YAAY,CAAC,aAAa,CAAC,EAAE;oBAChD,CAAC,CAAC,IAAI;aACT,CAAC,CAAC;YAEH,MAAM,IAAI,CAAC,YAAY,CAAC,YAAY,CAAC,EAAE,EAAE,WAAW,CAAC,CAAC;YAEtD,MAAM,CAAC,gDAAgD,EAAE,YAAY,CAAC,EAAE,CAAC,CAAC;QAC5E,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,IAAI,CAAC,YAAY,CAAC,YAAY,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC;YAEnD,QAAQ,CAAC,yCA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,EAAE,CAAC;YACf,QAAQ,CAAC,uDAAuD,EAAE,cAAc,EAAE,KAAK,CAAC,CAAC;YACzF,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;IAED,KAAK,CAAC,oBAAoB;QACxB,IAAI,CAAC;YACH,MAAM,YAAY,CAAC,UAAU,CAAC,oBAAoB,CAAC,WAAW,CAAC,CAAC;YAEhE,MAAM,CAAC,iDAAiD,CAAC,CAAC;QAC5D,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,QAAQ,CAAC,0DAA0D,EAAE,KAAK,CAAC,CAAC;QAC9E,CAAC;IACH,CAAC;;AA3Ec,gCAAW,GAAG,0BAA0B,CAAC"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { NotificationPreferences } from '../types';
|
|
2
|
-
/**
|
|
3
|
-
* PreferencesManager - Offline Notification Preferences
|
|
4
|
-
*
|
|
5
|
-
* Stores preferences in AsyncStorage (offline-capable).
|
|
6
|
-
* Only supports local push and in-app notifications.
|
|
7
|
-
*
|
|
8
|
-
* NO backend, NO email/SMS - pure offline.
|
|
9
|
-
*/
|
|
10
|
-
export declare class PreferencesManager {
|
|
11
|
-
private static STORAGE_KEY;
|
|
12
|
-
get(): Promise<NotificationPreferences>;
|
|
13
|
-
update(preferences: Partial<NotificationPreferences>): Promise<boolean>;
|
|
14
|
-
isChannelEnabled(channelType: 'push' | 'in_app', prefs: NotificationPreferences): boolean;
|
|
15
|
-
isInQuietHours(quietHours: NotificationPreferences['quiet_hours']): boolean;
|
|
16
|
-
private getDefaults;
|
|
17
|
-
}
|
|
18
|
-
//# sourceMappingURL=PreferencesManager.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PreferencesManager.d.ts","sourceRoot":"","sources":["../../../../src/infrastructure/services/preferences/PreferencesManager.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AAExD;;;;;;;GAOG;AACH,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,MAAM,CAAC,WAAW,CAAgC;IAEpD,GAAG,IAAI,OAAO,CAAC,uBAAuB,CAAC;IASvC,MAAM,CAAC,WAAW,EAAE,OAAO,CAAC,uBAAuB,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC;IAoB7E,gBAAgB,CACd,WAAW,EAAE,MAAM,GAAG,QAAQ,EAC9B,KAAK,EAAE,uBAAuB,GAC7B,OAAO;IAKV,cAAc,CAAC,UAAU,EAAE,uBAAuB,CAAC,aAAa,CAAC,GAAG,OAAO;IAS3E,OAAO,CAAC,WAAW;CAgBpB"}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import AsyncStorage from '@react-native-async-storage/async-storage';
|
|
2
|
-
/**
|
|
3
|
-
* PreferencesManager - Offline Notification Preferences
|
|
4
|
-
*
|
|
5
|
-
* Stores preferences in AsyncStorage (offline-capable).
|
|
6
|
-
* Only supports local push and in-app notifications.
|
|
7
|
-
*
|
|
8
|
-
* NO backend, NO email/SMS - pure offline.
|
|
9
|
-
*/
|
|
10
|
-
export class PreferencesManager {
|
|
11
|
-
async get() {
|
|
12
|
-
try {
|
|
13
|
-
const data = await AsyncStorage.getItem(PreferencesManager.STORAGE_KEY);
|
|
14
|
-
return data ? JSON.parse(data) : this.getDefaults();
|
|
15
|
-
}
|
|
16
|
-
catch (error) {
|
|
17
|
-
return this.getDefaults();
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
async update(preferences) {
|
|
21
|
-
try {
|
|
22
|
-
const current = await this.get();
|
|
23
|
-
const updated = {
|
|
24
|
-
...current,
|
|
25
|
-
...preferences,
|
|
26
|
-
categories: { ...current.categories, ...preferences.categories },
|
|
27
|
-
};
|
|
28
|
-
await AsyncStorage.setItem(PreferencesManager.STORAGE_KEY, JSON.stringify(updated));
|
|
29
|
-
return true;
|
|
30
|
-
}
|
|
31
|
-
catch (error) {
|
|
32
|
-
return false;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
isChannelEnabled(channelType, prefs) {
|
|
36
|
-
if (channelType === 'in_app')
|
|
37
|
-
return true;
|
|
38
|
-
return prefs.push_enabled ?? true;
|
|
39
|
-
}
|
|
40
|
-
isInQuietHours(quietHours) {
|
|
41
|
-
if (!quietHours.enabled)
|
|
42
|
-
return false;
|
|
43
|
-
const currentTime = new Date().toTimeString().slice(0, 5);
|
|
44
|
-
return (currentTime >= quietHours.start_time ||
|
|
45
|
-
currentTime <= quietHours.end_time);
|
|
46
|
-
}
|
|
47
|
-
getDefaults() {
|
|
48
|
-
return {
|
|
49
|
-
push_enabled: true,
|
|
50
|
-
quiet_hours: {
|
|
51
|
-
enabled: false,
|
|
52
|
-
start_time: '22:00',
|
|
53
|
-
end_time: '08:00',
|
|
54
|
-
timezone: 'UTC',
|
|
55
|
-
},
|
|
56
|
-
categories: {
|
|
57
|
-
reminders: { push: true, in_app: true },
|
|
58
|
-
updates: { push: true, in_app: true },
|
|
59
|
-
alerts: { push: true, in_app: true },
|
|
60
|
-
},
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
PreferencesManager.STORAGE_KEY = '@notifications:preferences';
|
|
65
|
-
//# sourceMappingURL=PreferencesManager.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PreferencesManager.js","sourceRoot":"","sources":["../../../../src/infrastructure/services/preferences/PreferencesManager.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,2CAA2C,CAAC;AAGrE;;;;;;;GAOG;AACH,MAAM,OAAO,kBAAkB;IAG7B,KAAK,CAAC,GAAG;QACP,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,MAAM,YAAY,CAAC,OAAO,CAAC,kBAAkB,CAAC,WAAW,CAAC,CAAC;YACxE,OAAO,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;Q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D,UAAU,EAAE;gBACV,SAAS,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE;gBACvC,OAAO,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE;gBACrC,MAAM,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE;aACrC;SACF,CAAC;IACJ,CAAC;;AA/Dc,8BAAW,GAAG,4BAA4B,CAAC"}
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Offline-First Notification Types
|
|
3
|
-
* Uses expo-notifications for local device notifications
|
|
4
|
-
* NO backend, NO user IDs, NO push notifications
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* Notification channel for managing notification delivery
|
|
8
|
-
*/
|
|
9
|
-
export interface NotificationChannel {
|
|
10
|
-
id: string;
|
|
11
|
-
channel_type: 'push' | 'in_app';
|
|
12
|
-
channel_address: string;
|
|
13
|
-
preferences: Record<string, any>;
|
|
14
|
-
is_verified: boolean;
|
|
15
|
-
is_active: boolean;
|
|
16
|
-
created_at: string;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Notification data structure
|
|
20
|
-
*/
|
|
21
|
-
export interface Notification {
|
|
22
|
-
id: string;
|
|
23
|
-
title: string;
|
|
24
|
-
body: string;
|
|
25
|
-
scheduled_for?: string;
|
|
26
|
-
data?: Record<string, any>;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* User notification preferences
|
|
30
|
-
*/
|
|
31
|
-
export interface NotificationPreferences {
|
|
32
|
-
push_enabled: boolean;
|
|
33
|
-
quiet_hours: {
|
|
34
|
-
enabled: boolean;
|
|
35
|
-
start_time: string;
|
|
36
|
-
end_time: string;
|
|
37
|
-
timezone: string;
|
|
38
|
-
};
|
|
39
|
-
categories: Record<string, {
|
|
40
|
-
push: boolean;
|
|
41
|
-
in_app: boolean;
|
|
42
|
-
}>;
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Trigger types for scheduling notifications
|
|
46
|
-
*/
|
|
47
|
-
export type NotificationTrigger = {
|
|
48
|
-
type: 'date';
|
|
49
|
-
date: Date;
|
|
50
|
-
} | {
|
|
51
|
-
type: 'daily';
|
|
52
|
-
hour: number;
|
|
53
|
-
minute: number;
|
|
54
|
-
} | {
|
|
55
|
-
type: 'weekly';
|
|
56
|
-
weekday: number;
|
|
57
|
-
hour: number;
|
|
58
|
-
minute: number;
|
|
59
|
-
} | {
|
|
60
|
-
type: 'monthly';
|
|
61
|
-
day: number;
|
|
62
|
-
hour: number;
|
|
63
|
-
minute: number;
|
|
64
|
-
};
|
|
65
|
-
/**
|
|
66
|
-
* Options for scheduling a notification
|
|
67
|
-
*/
|
|
68
|
-
export interface ScheduleNotificationOptions {
|
|
69
|
-
title: string;
|
|
70
|
-
body: string;
|
|
71
|
-
data?: Record<string, any>;
|
|
72
|
-
trigger: NotificationTrigger;
|
|
73
|
-
sound?: boolean | string;
|
|
74
|
-
badge?: number;
|
|
75
|
-
categoryIdentifier?: string;
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Scheduled notification details
|
|
79
|
-
*/
|
|
80
|
-
export interface ScheduledNotification {
|
|
81
|
-
identifier: string;
|
|
82
|
-
content: {
|
|
83
|
-
title: string;
|
|
84
|
-
body: string;
|
|
85
|
-
data: Record<string, any>;
|
|
86
|
-
};
|
|
87
|
-
trigger: any;
|
|
88
|
-
}
|
|
89
|
-
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/services/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,YAAY,EAAE,MAAM,GAAG,QAAQ,CAAC;IAChC,eAAe,EAAE,MAAM,CAAC;IAC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ACH,MAAM,WAAW,2BAA2B;IAC1C,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC3B,OAAO,EAAE,mBAAmB,CAAC;IAC7B,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE;QACP,KAAK,EAAE,MAAM,CAAC;QACd,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;KAC3B,CAAC;IACF,OAAO,EAAE,GAAG,CAAC;CACd"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/infrastructure/services/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Notifications Store - Zustand State Management
|
|
3
|
-
* Simple offline-first notification state
|
|
4
|
-
* NO backend, NO user IDs, NO notification history
|
|
5
|
-
*/
|
|
6
|
-
interface NotificationsStore {
|
|
7
|
-
hasPermissions: boolean;
|
|
8
|
-
isInitialized: boolean;
|
|
9
|
-
setPermissions: (granted: boolean) => void;
|
|
10
|
-
setInitialized: (initialized: boolean) => void;
|
|
11
|
-
}
|
|
12
|
-
export declare const useNotificationsStore: import("zustand").StoreApi<NotificationsStore> & ((selector?: ((state: NotificationsStore) => any) | undefined) => any);
|
|
13
|
-
/**
|
|
14
|
-
* Hook for accessing notifications state
|
|
15
|
-
*/
|
|
16
|
-
export declare const useNotifications: () => {
|
|
17
|
-
hasPermissions: any;
|
|
18
|
-
isInitialized: any;
|
|
19
|
-
setPermissions: any;
|
|
20
|
-
setInitialized: any;
|
|
21
|
-
};
|
|
22
|
-
export {};
|
|
23
|
-
//# sourceMappingURL=NotificationsStore.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NotificationsStore.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/storage/NotificationsStore.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,UAAU,kBAAkB;IAE1B,cAAc,EAAE,OAAO,CAAC;IACxB,aAAa,EAAE,OAAO,CAAC;IAGvB,cAAc,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IAC3C,cAAc,EAAE,CAAC,WAAW,EAAE,OAAO,KAAK,IAAI,CAAC;CAChD;AAED,eAAO,MAAM,qBAAqB,yHAM/B,CAAC;AAEJ;;GAEG;AACH,eAAO,MAAM,gBAAgB;;;;;CAU5B,CAAC"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Notifications Store - Zustand State Management
|
|
3
|
-
* Simple offline-first notification state
|
|
4
|
-
* NO backend, NO user IDs, NO notification history
|
|
5
|
-
*/
|
|
6
|
-
import { create } from 'zustand';
|
|
7
|
-
export const useNotificationsStore = create((set) => ({
|
|
8
|
-
hasPermissions: false,
|
|
9
|
-
isInitialized: false,
|
|
10
|
-
setPermissions: (granted) => set({ hasPermissions: granted }),
|
|
11
|
-
setInitialized: (initialized) => set({ isInitialized: initialized }),
|
|
12
|
-
}));
|
|
13
|
-
/**
|
|
14
|
-
* Hook for accessing notifications state
|
|
15
|
-
*/
|
|
16
|
-
export const useNotifications = () => {
|
|
17
|
-
const store = useNotificationsStore();
|
|
18
|
-
const { hasPermissions, isInitialized, setPermissions, setInitialized } = store;
|
|
19
|
-
return {
|
|
20
|
-
hasPermissions,
|
|
21
|
-
isInitialized,
|
|
22
|
-
setPermissions,
|
|
23
|
-
setInitialized,
|
|
24
|
-
};
|
|
25
|
-
};
|
|
26
|
-
//# sourceMappingURL=NotificationsStore.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NotificationsStore.js","sourceRoot":"","sources":["../../../src/infrastructure/storage/NotificationsStore.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAYjC,MAAM,CAAC,MAAM,qBAAqB,GAAG,MAAM,CAAqB,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;IACxE,cAAc,EAAE,KAAK;IACrB,aAAa,EAAE,KAAK;IAEpB,cAAc,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,GAAG,CAAC,EAAE,cAAc,EAAE,OAAO,EAAE,CAAC;IAC7D,cAAc,EAAE,CAAC,WAAW,EAAE,EAAE,CAAC,GAAG,CAAC,EAAE,aAAa,EAAE,WAAW,EAAE,CAAC;CACrE,CAAC,CAAC,CAAC;AAEJ;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAG,EAAE;IACnC,MAAM,KAAK,GAAG,qBAAqB,EAAE,CAAC;IACtC,MAAM,EAAE,cAAc,EAAE,aAAa,EAAE,cAAc,EAAE,cAAc,EAAE,GAAG,KAAK,CAAC;IAEhF,OAAO;QACL,cAAc;QACd,aAAa;QACb,cAAc;QACd,cAAc;KACf,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export declare const isDev: () => boolean;
|
|
2
|
-
export declare const devLog: (message: string, ...args: any[]) => void;
|
|
3
|
-
export declare const devError: (message: string, ...args: any[]) => void;
|
|
4
|
-
export declare const devWarn: (message: string, ...args: any[]) => void;
|
|
5
|
-
//# sourceMappingURL=dev.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/utils/dev.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,KAAK,eAMjB,CAAC;AAEF,eAAO,MAAM,MAAM,GAAI,SAAS,MAAM,EAAE,GAAG,MAAM,GAAG,EAAE,SAIrD,CAAC;AAEF,eAAO,MAAM,QAAQ,GAAI,SAAS,MAAM,EAAE,GAAG,MAAM,GAAG,EAAE,SAIvD,CAAC;AAEF,eAAO,MAAM,OAAO,GAAI,SAAS,MAAM,EAAE,GAAG,MAAM,GAAG,EAAE,SAItD,CAAC"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
export const isDev = () => {
|
|
2
|
-
try {
|
|
3
|
-
return typeof __DEV__ !== 'undefined' && __DEV__;
|
|
4
|
-
}
|
|
5
|
-
catch {
|
|
6
|
-
return false;
|
|
7
|
-
}
|
|
8
|
-
};
|
|
9
|
-
export const devLog = (message, ...args) => {
|
|
10
|
-
if (isDev()) {
|
|
11
|
-
console.log(message, ...args);
|
|
12
|
-
}
|
|
13
|
-
};
|
|
14
|
-
export const devError = (message, ...args) => {
|
|
15
|
-
if (isDev()) {
|
|
16
|
-
console.error(message, ...args);
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
export const devWarn = (message, ...args) => {
|
|
20
|
-
if (isDev()) {
|
|
21
|
-
console.warn(message, ...args);
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
//# sourceMappingURL=dev.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dev.js","sourceRoot":"","sources":["../../../src/infrastructure/utils/dev.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,KAAK,GAAG,GAAG,EAAE;IACxB,IAAI,CAAC;QACH,OAAO,OAAO,OAAO,KAAK,WAAW,IAAI,OAAO,CAAC;IACnD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,OAAe,EAAE,GAAG,IAAW,EAAE,EAAE;IACxD,IAAI,KAAK,EAAE,EAAE,CAAC;QACZ,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;IAChC,CAAC;AACH,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,OAAe,EAAE,GAAG,IAAW,EAAE,EAAE;IAC1D,IAAI,KAAK,EAAE,EAAE,CAAC;QACZ,OAAO,CAAC,KAAK,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;IAClC,CAAC;AACH,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,OAAe,EAAE,GAAG,IAAW,EAAE,EAAE;IACzD,IAAI,KAAK,EAAE,EAAE,CAAC;QACZ,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;IACjC,CAAC;AACH,CAAC,CAAC"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import type { StyleProp, ViewStyle } from 'react-native';
|
|
3
|
-
export interface NotificationsSectionConfig {
|
|
4
|
-
initialValue?: boolean;
|
|
5
|
-
onToggleChange?: (value: boolean) => void;
|
|
6
|
-
route?: string;
|
|
7
|
-
defaultRoute?: string;
|
|
8
|
-
title?: string;
|
|
9
|
-
description?: string;
|
|
10
|
-
showToggle?: boolean;
|
|
11
|
-
}
|
|
12
|
-
export interface NotificationsSectionProps {
|
|
13
|
-
config?: NotificationsSectionConfig;
|
|
14
|
-
containerStyle?: StyleProp<ViewStyle>;
|
|
15
|
-
}
|
|
16
|
-
export declare const NotificationsSection: React.FC<NotificationsSectionProps>;
|
|
17
|
-
//# sourceMappingURL=NotificationsSection.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NotificationsSection.d.ts","sourceRoot":"","sources":["../../../src/presentation/components/NotificationsSection.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA2C,MAAM,OAAO,CAAC;AAChE,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAQzD,MAAM,WAAW,0BAA0B;IACvC,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IAC1C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,yBAAyB;IACtC,MAAM,CAAC,EAAE,0BAA0B,CAAC;IACpC,cAAc,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;CACzC;AAED,eAAO,MAAM,oBAAoB,EAAE,KAAK,CAAC,EAAE,CAAC,yBAAyB,CAgHpE,CAAC"}
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
import React, { useState, useEffect, useCallback } from 'react';
|
|
2
|
-
import { View, Text, Pressable, StyleSheet, Switch } from 'react-native';
|
|
3
|
-
import { Feather } from '@expo/vector-icons';
|
|
4
|
-
// @ts-ignore - Optional peer dependency
|
|
5
|
-
import { useNavigation } from '@react-navigation/native';
|
|
6
|
-
import { useAppDesignTokens } from '@umituz/react-native-design-system-theme';
|
|
7
|
-
import { notificationService } from '../../infrastructure/services/NotificationService';
|
|
8
|
-
export const NotificationsSection = ({ config, containerStyle, }) => {
|
|
9
|
-
const navigation = useNavigation();
|
|
10
|
-
const tokens = useAppDesignTokens();
|
|
11
|
-
const colors = tokens.colors;
|
|
12
|
-
const [notificationsEnabled, setNotificationsEnabled] = useState(config?.initialValue ?? true);
|
|
13
|
-
useEffect(() => {
|
|
14
|
-
if (config?.initialValue !== undefined) {
|
|
15
|
-
setNotificationsEnabled(config.initialValue);
|
|
16
|
-
}
|
|
17
|
-
}, [config?.initialValue]);
|
|
18
|
-
const handleToggle = useCallback(async (value) => {
|
|
19
|
-
if (!value) {
|
|
20
|
-
// When turning ON (value is false -> true? Wait. onChange value is the NEW value)
|
|
21
|
-
// If value is true (turning on)
|
|
22
|
-
}
|
|
23
|
-
// Logic from settings:
|
|
24
|
-
/*
|
|
25
|
-
if (notificationService && !value) { // Wait, logic in settings was: if (!value) ...?
|
|
26
|
-
// Actually typically we request permissions when enabling.
|
|
27
|
-
// Settings code:
|
|
28
|
-
// if (notificationService && !value) { ... } -> This implies when value is FALSE?
|
|
29
|
-
// Ah, maybe the switch value logic was inverted or I misread.
|
|
30
|
-
// Let's re-read settings code.
|
|
31
|
-
}
|
|
32
|
-
*/
|
|
33
|
-
if (value) { // Enabling
|
|
34
|
-
const hasPermissions = await notificationService.hasPermissions();
|
|
35
|
-
if (!hasPermissions) {
|
|
36
|
-
const granted = await notificationService.requestPermissions();
|
|
37
|
-
if (!granted) {
|
|
38
|
-
// Permission denied, maybe don't enable switch?
|
|
39
|
-
// For now just allow toggle and let app handle it or sync with state
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
setNotificationsEnabled(value);
|
|
44
|
-
config?.onToggleChange?.(value);
|
|
45
|
-
}, [config]);
|
|
46
|
-
const handlePress = useCallback(async () => {
|
|
47
|
-
const hasPermissions = await notificationService.hasPermissions();
|
|
48
|
-
if (!hasPermissions) {
|
|
49
|
-
await notificationService.requestPermissions();
|
|
50
|
-
}
|
|
51
|
-
navigation.navigate((config?.route || config?.defaultRoute || 'Notifications'));
|
|
52
|
-
}, [navigation, config?.route, config?.defaultRoute]);
|
|
53
|
-
const title = config?.title || 'Notifications';
|
|
54
|
-
const description = config?.description || 'Manage notification preferences';
|
|
55
|
-
const showToggle = config?.showToggle ?? true;
|
|
56
|
-
return (<View style={[styles.sectionContainer, { backgroundColor: colors.surface }, containerStyle]}>
|
|
57
|
-
<Text style={[styles.sectionTitle, { color: colors.textPrimary }]}>General</Text>
|
|
58
|
-
|
|
59
|
-
<Pressable style={({ pressed }) => [
|
|
60
|
-
styles.itemContainer,
|
|
61
|
-
{
|
|
62
|
-
backgroundColor: pressed && !showToggle ? `${colors.primary}08` : 'transparent',
|
|
63
|
-
},
|
|
64
|
-
]} onPress={showToggle ? undefined : handlePress} disabled={showToggle}>
|
|
65
|
-
<View style={styles.content}>
|
|
66
|
-
<View style={[
|
|
67
|
-
styles.iconContainer,
|
|
68
|
-
{ backgroundColor: `${colors.primary}15` },
|
|
69
|
-
]}>
|
|
70
|
-
<Feather name="bell" size={24} color={colors.primary}/>
|
|
71
|
-
</View>
|
|
72
|
-
<View style={styles.textContainer}>
|
|
73
|
-
<Text style={[styles.title, { color: colors.textPrimary }]}>{title}</Text>
|
|
74
|
-
{!showToggle && (<Text style={[styles.description, { color: colors.textSecondary }]}>
|
|
75
|
-
{description}
|
|
76
|
-
</Text>)}
|
|
77
|
-
</View>
|
|
78
|
-
|
|
79
|
-
{showToggle ? (<Switch value={notificationsEnabled} onValueChange={handleToggle} trackColor={{
|
|
80
|
-
false: `${colors.textSecondary}30`,
|
|
81
|
-
true: colors.primary,
|
|
82
|
-
}} thumbColor={"#FFFFFF"} ios_backgroundColor={`${colors.textSecondary}30`}/>) : (<Feather name="chevron-right" size={20} color={colors.textSecondary}/>)}
|
|
83
|
-
</View>
|
|
84
|
-
</Pressable>
|
|
85
|
-
</View>);
|
|
86
|
-
};
|
|
87
|
-
const styles = StyleSheet.create({
|
|
88
|
-
sectionContainer: {
|
|
89
|
-
marginBottom: 16,
|
|
90
|
-
borderRadius: 12,
|
|
91
|
-
overflow: 'hidden',
|
|
92
|
-
},
|
|
93
|
-
sectionTitle: {
|
|
94
|
-
fontSize: 18,
|
|
95
|
-
fontWeight: '600',
|
|
96
|
-
paddingHorizontal: 16,
|
|
97
|
-
paddingTop: 16,
|
|
98
|
-
paddingBottom: 8,
|
|
99
|
-
},
|
|
100
|
-
itemContainer: {
|
|
101
|
-
flexDirection: 'row',
|
|
102
|
-
alignItems: 'center',
|
|
103
|
-
paddingHorizontal: 16,
|
|
104
|
-
paddingVertical: 16,
|
|
105
|
-
minHeight: 72,
|
|
106
|
-
},
|
|
107
|
-
content: {
|
|
108
|
-
flex: 1,
|
|
109
|
-
flexDirection: 'row',
|
|
110
|
-
alignItems: 'center',
|
|
111
|
-
},
|
|
112
|
-
iconContainer: {
|
|
113
|
-
width: 48,
|
|
114
|
-
height: 48,
|
|
115
|
-
borderRadius: 12,
|
|
116
|
-
justifyContent: 'center',
|
|
117
|
-
alignItems: 'center',
|
|
118
|
-
marginRight: 16,
|
|
119
|
-
},
|
|
120
|
-
textContainer: {
|
|
121
|
-
flex: 1,
|
|
122
|
-
marginRight: 8,
|
|
123
|
-
},
|
|
124
|
-
title: {
|
|
125
|
-
fontSize: 16,
|
|
126
|
-
fontWeight: '500',
|
|
127
|
-
marginBottom: 4,
|
|
128
|
-
},
|
|
129
|
-
description: {
|
|
130
|
-
fontSize: 14,
|
|
131
|
-
},
|
|
132
|
-
});
|
|
133
|
-
//# sourceMappingURL=NotificationsSection.js.map
|