Files
smart-city-digital-twin-mar…/smart-app-city/frontend/node_modules/expo-image-picker/build/ExponentImagePicker.web.js
Eric FELIXINE e30ae8ed09 feat(smart-app): implement complete mobile app MVP
- 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
2026-06-01 18:00:35 -04:00

126 lines
4.8 KiB
JavaScript

import { PermissionStatus, Platform } from 'expo-modules-core';
import { MediaTypeOptions, } from './ImagePicker.types';
const MediaTypeInput = {
[MediaTypeOptions.All]: 'video/mp4,video/quicktime,video/x-m4v,video/*,image/*',
[MediaTypeOptions.Images]: 'image/*',
[MediaTypeOptions.Videos]: 'video/mp4,video/quicktime,video/x-m4v,video/*',
};
export default {
async launchImageLibraryAsync({ mediaTypes = MediaTypeOptions.Images, allowsMultipleSelection = false, base64 = false, }) {
// SSR guard
if (!Platform.isDOMAvailable) {
return { canceled: true, assets: null };
}
return await openFileBrowserAsync({
mediaTypes,
allowsMultipleSelection,
base64,
});
},
async launchCameraAsync({ mediaTypes = MediaTypeOptions.Images, allowsMultipleSelection = false, base64 = false, }) {
// SSR guard
if (!Platform.isDOMAvailable) {
return { canceled: true, assets: null };
}
return await openFileBrowserAsync({
mediaTypes,
allowsMultipleSelection,
capture: true,
base64,
});
},
/*
* Delegate to expo-permissions to request camera permissions
*/
async getCameraPermissionsAsync() {
return permissionGrantedResponse();
},
async requestCameraPermissionsAsync() {
return permissionGrantedResponse();
},
/*
* Camera roll permissions don't need to be requested on web, so we always
* respond with granted.
*/
async getMediaLibraryPermissionsAsync(_writeOnly) {
return permissionGrantedResponse();
},
async requestMediaLibraryPermissionsAsync(_writeOnly) {
return permissionGrantedResponse();
},
};
function permissionGrantedResponse() {
return {
status: PermissionStatus.GRANTED,
expires: 'never',
granted: true,
canAskAgain: true,
};
}
function openFileBrowserAsync({ mediaTypes, capture = false, allowsMultipleSelection = false, base64, }) {
const mediaTypeFormat = MediaTypeInput[mediaTypes];
const input = document.createElement('input');
input.style.display = 'none';
input.setAttribute('type', 'file');
input.setAttribute('accept', mediaTypeFormat);
input.setAttribute('id', String(Math.random()));
if (allowsMultipleSelection) {
input.setAttribute('multiple', 'multiple');
}
if (capture) {
input.setAttribute('capture', 'camera');
}
document.body.appendChild(input);
return new Promise((resolve) => {
input.addEventListener('change', async () => {
if (input.files) {
const files = allowsMultipleSelection ? input.files : [input.files[0]];
const assets = await Promise.all(Array.from(files).map((file) => readFile(file, { base64 })));
resolve({ canceled: false, assets });
}
else {
resolve({ canceled: true, assets: null });
}
document.body.removeChild(input);
});
const event = new MouseEvent('click');
input.dispatchEvent(event);
});
}
function readFile(targetFile, options) {
return new Promise((resolve, reject) => {
const reader = new FileReader();
reader.onerror = () => {
reject(new Error(`Failed to read the selected media because the operation failed.`));
};
reader.onload = ({ target }) => {
const uri = target.result;
const returnRaw = () => resolve({ uri, width: 0, height: 0 });
if (typeof uri === 'string') {
const image = new Image();
image.src = uri;
image.onload = () => {
resolve({
uri,
width: image.naturalWidth ?? image.width,
height: image.naturalHeight ?? image.height,
mimeType: targetFile.type,
fileName: targetFile.name,
// The blob's result cannot be directly decoded as Base64 without
// first removing the Data-URL declaration preceding the
// Base64-encoded data. To retrieve only the Base64 encoded string,
// first remove data:*/*;base64, from the result.
// https://developer.mozilla.org/en-US/docs/Web/API/FileReader/readAsDataURL
...(options.base64 && { base64: uri.substr(uri.indexOf(',') + 1) }),
});
};
image.onerror = () => returnRaw();
}
else {
returnRaw();
}
};
reader.readAsDataURL(targetFile);
});
}
//# sourceMappingURL=ExponentImagePicker.web.js.map