@alveole/components 2.0.0-alpha.13 → 2.0.0-alpha.14
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.
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const ALVEOLE_COMPONENTS_VERSION: "2.0.0-alpha.
|
|
1
|
+
export declare const ALVEOLE_COMPONENTS_VERSION: "2.0.0-alpha.14";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const ALVEOLE_COMPONENTS_VERSION = "2.0.0-alpha.
|
|
1
|
+
export const ALVEOLE_COMPONENTS_VERSION = "2.0.0-alpha.14";
|
|
@@ -3,7 +3,7 @@ import { format } from 'date-fns/format';
|
|
|
3
3
|
import { enUS } from 'date-fns/locale/en-US';
|
|
4
4
|
import { fr } from 'date-fns/locale/fr';
|
|
5
5
|
import React from 'react';
|
|
6
|
-
import { ScrollView } from 'react-native';
|
|
6
|
+
import { ScrollView } from 'react-native-gesture-handler';
|
|
7
7
|
import { Box } from '../../core/Box';
|
|
8
8
|
import { Grid } from '../../core/Grid';
|
|
9
9
|
import { Typography } from '../../core/Typography';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useChoixDeFichier.d.ts","sourceRoot":"","sources":["../../../src/ui/FormControl/useChoixDeFichier.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAGL,eAAe,EAKhB,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"useChoixDeFichier.d.ts","sourceRoot":"","sources":["../../../src/ui/FormControl/useChoixDeFichier.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAGL,eAAe,EAKhB,MAAM,mBAAmB,CAAC;AAmD3B,KAAK,OAAO,GAAG,IAAI,CAAC,cAAc,EAAE,OAAO,GAAG,UAAU,GAAG,MAAM,GAAG,UAAU,GAAG,aAAa,CAAC,GAAG;IAChG,QAAQ,EAAE,OAAO,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,eAAe,CAAC;CACzB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,GAAI,SAAS,OAAO,wBA6DjD,CAAC"}
|
|
@@ -2,10 +2,17 @@ import { useTheme } from '@alveole/theme';
|
|
|
2
2
|
import * as DocumentPicker from 'expo-document-picker';
|
|
3
3
|
import * as ImagePicker from 'expo-image-picker';
|
|
4
4
|
import React from 'react';
|
|
5
|
-
import { Platform } from 'react-native';
|
|
5
|
+
import { ActionSheetIOS, Platform } from 'react-native';
|
|
6
6
|
import { Alert } from '../../core/Alert';
|
|
7
7
|
import { ajoute, imagesSeulement, libelleDeLaSource, sourcesProposees, } from './fichiersDuChamp';
|
|
8
8
|
import { valideLeType } from './valideLeType';
|
|
9
|
+
const showActionSheetIOS = ({ sources, lancer, titre, labels, type, grandEcran }) => {
|
|
10
|
+
const options = [...sources.map(s => libelleDeLaSource(s, labels, { type, grandEcran })), labels.cancel];
|
|
11
|
+
ActionSheetIOS.showActionSheetWithOptions({ title: titre, options, cancelButtonIndex: options.length - 1 }, index => {
|
|
12
|
+
if (index < sources.length)
|
|
13
|
+
lancer(sources[index]);
|
|
14
|
+
});
|
|
15
|
+
};
|
|
9
16
|
const enFichier = (asset) => ({
|
|
10
17
|
uri: asset.uri,
|
|
11
18
|
name: asset.fileName ?? 'image.jpg',
|
|
@@ -56,16 +63,21 @@ export const useChoixDeFichier = (options) => {
|
|
|
56
63
|
const ouvrirLaFeuille = React.useCallback(() => {
|
|
57
64
|
const lancer = (source) => (source === 'document' ? choisirUnDocument() : choisirUneImage(source));
|
|
58
65
|
const images = imagesSeulement(type);
|
|
66
|
+
const sources = sourcesProposees(type, grandEcran);
|
|
67
|
+
const titre = images ? labels.chooseImageTitle : labels.chooseDocumentTitle;
|
|
68
|
+
if (Platform.OS === 'ios')
|
|
69
|
+
return showActionSheetIOS({ sources, lancer, titre, labels, type, grandEcran });
|
|
59
70
|
Alert.alert({
|
|
60
|
-
title:
|
|
71
|
+
title: titre,
|
|
61
72
|
message: images ? labels.chooseImageMessage : undefined,
|
|
62
73
|
buttons: [
|
|
63
|
-
...
|
|
74
|
+
...sources.map(source => ({
|
|
64
75
|
text: libelleDeLaSource(source, labels, { type, grandEcran }),
|
|
65
76
|
onPress: () => lancer(source),
|
|
66
77
|
})),
|
|
67
78
|
{ text: labels.cancel, style: 'cancel' },
|
|
68
79
|
],
|
|
80
|
+
options: { cancelable: true },
|
|
69
81
|
});
|
|
70
82
|
}, [type, labels, grandEcran, choisirUnDocument, choisirUneImage]);
|
|
71
83
|
return React.useCallback(async () => {
|