- App.tsx: full navigation (Auth stack + Main tabs with 5 screens) - Auth: LoginScreen, RegisterScreen, ForgotPasswordScreen - HomeScreen: dashboard with IoT metrics, weather widget, alerts, quick actions, sensors - MapScreen: interactive map with layer toggles (6 layers) - MarketplaceScreen: categories (6), products (5), search - ChatScreen: AI chat with quick prompts (4), bot responses - ProfileScreen: user info, stats, menu (9 items), logout - AlertsScreen: alert list with severity, acknowledge - SensorsScreen: sensor list with type filters (6 types), search - ZonesScreen: zone cards with stats - SettingsScreen: language picker (FR/EN/ES/DE), privacy, about - Stores: iotStore (sensors, zones, alerts), notificationStore, uiStore + i18n - Hooks: useSensors, useAlerts, useNotifications, useLocation - Components: Card, Button, LoadingSpinner, ErrorBoundary, Header - Services: iotService, notificationService (with axios API client) - Utils: formatters (temp, AQI, noise, dates), validators (email, password, IBAN) - Theme: colors.ts with full design system (Blue Ocean palette) - Ditto: fixed MongoDB connection, new JWT secrets, official gateway image
67 lines
2.4 KiB
JavaScript
67 lines
2.4 KiB
JavaScript
import { PermissionStatus, Platform } from 'expo-modules-core';
|
|
function convertPermissionStatus(status) {
|
|
switch (status) {
|
|
case 'granted':
|
|
return {
|
|
status: PermissionStatus.GRANTED,
|
|
expires: 'never',
|
|
canAskAgain: false,
|
|
granted: true,
|
|
};
|
|
case 'denied':
|
|
return {
|
|
status: PermissionStatus.DENIED,
|
|
expires: 'never',
|
|
canAskAgain: false,
|
|
granted: false,
|
|
};
|
|
default:
|
|
return {
|
|
status: PermissionStatus.UNDETERMINED,
|
|
expires: 'never',
|
|
canAskAgain: true,
|
|
granted: false,
|
|
};
|
|
}
|
|
}
|
|
async function resolvePermissionAsync({ shouldAsk, }) {
|
|
if (!Platform.isDOMAvailable) {
|
|
return convertPermissionStatus('denied');
|
|
}
|
|
const { Notification = {} } = window;
|
|
if (typeof Notification.requestPermission !== 'undefined') {
|
|
let status = Notification.permission;
|
|
if (shouldAsk) {
|
|
status = await new Promise((resolve, reject) => {
|
|
let resolved = false;
|
|
function resolveOnce(status) {
|
|
if (!resolved) {
|
|
resolved = true;
|
|
resolve(status);
|
|
}
|
|
}
|
|
// Some browsers require a callback argument and some return a Promise
|
|
Notification.requestPermission(resolveOnce)?.then(resolveOnce)?.catch(reject);
|
|
});
|
|
}
|
|
return convertPermissionStatus(status);
|
|
}
|
|
else if (typeof navigator !== 'undefined' && navigator?.permissions?.query) {
|
|
// TODO(Bacon): Support `push` in the future when it's stable.
|
|
const query = await navigator.permissions.query({ name: 'notifications' });
|
|
return convertPermissionStatus(query.state);
|
|
}
|
|
// Platforms like iOS Safari don't support Notifications so return denied.
|
|
return convertPermissionStatus('denied');
|
|
}
|
|
export default {
|
|
addListener: () => { },
|
|
removeListeners: () => { },
|
|
async getPermissionsAsync() {
|
|
return resolvePermissionAsync({ shouldAsk: false });
|
|
},
|
|
async requestPermissionsAsync(request) {
|
|
return resolvePermissionAsync({ shouldAsk: true });
|
|
},
|
|
};
|
|
//# sourceMappingURL=NotificationPermissionsModule.js.map
|