@fto-consult/expo-ui 8.23.1 → 8.24.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/babel.config.js CHANGED
@@ -20,6 +20,7 @@ module.exports = function(api,opts) {
20
20
  options.aliasMutator({...options,alias});
21
21
  }
22
22
  require(`${path.resolve(__dirname,"bin","generate-tables")}`)();//génère les tables des bases de données
23
+ require(`${path.resolve(__dirname,"bin","find-licenses")}`); //met à jour les licenses de l'application
23
24
  const plugins = (Array.isArray(opts.plugins) ? options.plugins : []);
24
25
  let reanimated = "react-native-reanimated/plugin";
25
26
  const filteredPlugins = plugins.filter((p)=>{
@@ -11,7 +11,6 @@ module.exports = {
11
11
  "@react-navigation/stack": "^6.3.20",
12
12
  "@shopify/flash-list": "1.6.3",
13
13
  "expo": "~50.0.5",
14
- "expo-barcode-scanner": "~12.9.2",
15
14
  "expo-camera": "~14.0.3",
16
15
  "expo-clipboard": "~5.0.1",
17
16
  "expo-font": "~11.10.2",
package/bin/create-app.js CHANGED
@@ -116,13 +116,10 @@ const createAPPJSONFile = (projectRoot,{name,version})=>{
116
116
  "cameraPermission" : `Autoriser $(PRODUCT_NAME) à accéder à votre camera`
117
117
  }, cameraPluginsOptions = {
118
118
  "cameraPermission" : `Autoriser $(PRODUCT_NAME) à accéder à votre camera`
119
- }, barCodePermission = {
120
- "cameraPermission": "Autoriser $(PRODUCT_NAME) à accéder à la caméra."
121
- };
119
+ }
122
120
  const plugins = [
123
121
  ["expo-image-picker",imagePluginOptions],
124
122
  ["expo-camera",cameraPluginsOptions],
125
- ["expo-barcode-scanner",barCodePermission]
126
123
  ];
127
124
  appSheme = name? sanitizeFileName(name).replace(/ /g, '') : null;
128
125
  const appJSONPath = path.join(projectRoot,"app.json");
@@ -179,15 +176,13 @@ const createAPPJSONFile = (projectRoot,{name,version})=>{
179
176
  if(!Array.isArray(appPlugins)){
180
177
  appPlugins = plugins;
181
178
  } else {
182
- let hasFoundCamera = false, hasFoundImagePicker = false,hasFoundBarCode = false;
179
+ let hasFoundCamera = false, hasFoundImagePicker = false;
183
180
  appPlugins.map(pl=>{
184
181
  if(Array.isArray(pl)){
185
182
  if(typeof pl[0] ==="expo-image-picker"){
186
183
  hasFoundImagePicker = true;
187
184
  } else if(pl[0] === "expo-camera"){
188
185
  hasFoundCamera = true;
189
- } else if(pl[0] =="expo-barcode-scanner"){
190
- hasFoundBarCode = true;
191
186
  }
192
187
  }
193
188
  });
@@ -197,9 +192,6 @@ const createAPPJSONFile = (projectRoot,{name,version})=>{
197
192
  if(!hasFoundCamera){
198
193
  appPlugins.push(plugins[1]);
199
194
  }
200
- if(!hasFoundBarCode){
201
- appPlugins.push(plugins[2]);
202
- }
203
195
  }
204
196
  appJSONManager.set({
205
197
  expo : {plugins:appPlugins}
@@ -84,7 +84,7 @@ const findLicencesMain = (options)=>{
84
84
  if (a.toLowerCase() > b.toLowerCase()) return 1;
85
85
  return 0;
86
86
  });
87
- const packageJSON = require("./package.json");
87
+ const packageJSON = require("../package.json");
88
88
  const content = {
89
89
  [packageJSON.name] : {
90
90
  name : packageJSON.name,
@@ -108,7 +108,7 @@ const findLicencesMain = (options)=>{
108
108
  module.exports = ()=>{
109
109
  ///on génère les librairies open sources utilisées par l'application
110
110
  const root = path.resolve(process.cwd());
111
- const expoUI = require("./expo-ui-path")();
111
+ const expoUI = require("../expo-ui-path")();
112
112
  const localNodeModule = path.resolve(root,"node_modules");
113
113
  const HelpScreen = path.resolve(expoUI,"src","screens","Help");
114
114
  const outputPath = path.resolve(HelpScreen,"openLibraries.js");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fto-consult/expo-ui",
3
- "version": "8.23.1",
3
+ "version": "8.24.0",
4
4
  "description": "Bibliothèque de composants UI Expo,react-native",
5
5
  "scripts": {
6
6
  "clear-npx-cache": "npx clear-npx-cache",
@@ -46,7 +46,7 @@
46
46
  "delete-node-modules": "rimraf ./**/node_modules",
47
47
  "dev": "npx expo start --no-dev --minify -c",
48
48
  "modifier-url-remote-git": "git remote set-url origin 'https://borispipo@github.com/borispipo/smart-eneo.git'",
49
- "update": "npm i @fto-consult/common@latest @fto-consult/node-utils@latest react-native-web react-native-blob-util@latest react-native-big-list@latest apexcharts@latest file-saver@latest google-libphonenumber@latest react-native-iphone-x-helper@latest react-native-mime-types@latest react-native-paper@5 react-native-paper-dates@latest react-virtuoso@latest tippy.js@latest xlsx@latest && npm run update-apexchart && npm run find-licenses"
49
+ "update": "npm i @fto-consult/common@latest @fto-consult/node-utils@latest react-native-web react-native-big-list@latest apexcharts@latest file-saver@latest google-libphonenumber@latest react-native-iphone-x-helper@latest react-native-mime-types@latest react-native-paper@5 react-native-paper-dates@latest react-virtuoso@latest tippy.js@latest xlsx@latest && npm run update-apexchart && npm run find-licenses"
50
50
  },
51
51
  "bin": {
52
52
  "expo-ui": "./bin/index.js"
@@ -68,7 +68,7 @@
68
68
  "dependencies": {
69
69
  "@emotion/react": "^11.11.1",
70
70
  "@faker-js/faker": "^8.0.2",
71
- "@fto-consult/common": "^4.23.1",
71
+ "@fto-consult/common": "^4.24.0",
72
72
  "@fto-consult/node-utils": "^1.4.7",
73
73
  "apexcharts": "^3.45.2",
74
74
  "crypto-browserify": "^3.12.0",
@@ -82,7 +82,6 @@
82
82
  "react-content-loader": "^6.2.1",
83
83
  "react-dom": "^18.2.0",
84
84
  "react-native-big-list": "^1.6.1",
85
- "react-native-blob-util": "^0.19.6",
86
85
  "react-native-iphone-x-helper": "^1.3.1",
87
86
  "react-native-mime-types": "^2.4.0",
88
87
  "react-native-paper": "^5.12.3",
@@ -1,23 +1,69 @@
1
1
  import React, { useState, useEffect,useMemo } from '$react';
2
2
  import { View, StyleSheet} from 'react-native';
3
- import { BarCodeScanner } from 'expo-barcode-scanner';
3
+ import { CameraView, Camera } from "expo-camera/next";
4
4
  import theme from "$theme";
5
5
  import ActivityIndicator from "$ecomponents/ActivityIndicator";
6
6
  import Label from "$ecomponents/Label";
7
7
  import PropTypes from "prop-types";
8
- import { isNonNullString,defaultStr } from '$cutils';
8
+ import { isNonNullString,defaultStr,defaultObj } from '$cutils';
9
9
  import Button from "$ecomponents/Button";
10
10
  import Dialog from "$ecomponents/Dialog";
11
+ import {DialogProvider} from "$ecomponents/Form/FormData";
11
12
 
12
- export const scannerTypes = {back:"back",front:"front"};
13
+ export const cameraTypes = {back:"back",front:"front"};
14
+ export const flashModes = {off:{code:"off",label:"Inactif"},on:{code:"on",label:"Actif"},auto:{code:"auto",label:"Automatique"}}
15
+ export const cameraSetingsFields = {
16
+ enableTorch : {
17
+ type : "switch",
18
+ label : "Allumer la torche",
19
+ defaultValue : false,
20
+ checkedValue : true,
21
+ uncheckedValue : false,
22
+ },
23
+ flash : {
24
+ label : "Flash",
25
+ type : "select",
26
+ required : true,
27
+ items : flashModes,
28
+ defaultValue : flashModes.auto.code,
29
+ },
30
+ }
13
31
 
14
32
  /***@see : https://docs.expo.dev/versions/latest/sdk/bar-code-scanner/ */
15
- export default function App({onScan,onGrantAccess,testID,onDenyAccess,scannerProps,onCancel,dialogProps}) {
33
+ export default function App({onScan,onGrantAccess,testID,onDenyAccess,cameraProps,onCancel,dialogProps}) {
16
34
  testID = defaultStr(testID,"RN_BarCodeScanner");
17
35
  const [hasPermission, setHasPermission] = useState(null);
18
36
  const [visible,setVisible] = useState(true);
19
37
  dialogProps = Object.assign({},dialogProps);
20
- scannerProps = Object.assign({},scannerProps);
38
+ cameraProps = Object.assign({},cameraProps);
39
+ const barCodeScannerSettings = defaultObj(cameraProps.barCodeScannerSettings);
40
+ const getFlashMode = ()=>{
41
+ let {flash} = cameraProps;
42
+ if(isNonNullString(flash)){
43
+ flash = flash.toLowerCase().trim();
44
+ if(flashModes[flash]) return flashModes[flash].code;
45
+ }
46
+ return flashModes.auto.code;
47
+ }
48
+ const isTorchEnabled = ()=>{
49
+ return !!cameraProps.enableTorch;
50
+ }
51
+ const [cameraSetting,setCameraSetting] = useState({
52
+ enableTorch : isTorchEnabled(),
53
+ flash : getFlashMode(cameraProps.flash),
54
+ });
55
+ useEffect(()=>{
56
+ const flash = getFlashMode();
57
+ if(flash !== cameraSetting.flash){
58
+ setCameraSetting({...cameraSetting,flash});
59
+ }
60
+ },[cameraProps.flash]);
61
+ useEffect(()=>{
62
+ const enableTorch = isTorchEnabled();
63
+ if(enableTorch !== cameraSetting.enableTorch){
64
+ setCameraSetting({...cameraSetting,enableTorch});
65
+ }
66
+ },[cameraProps.enableTorch]);
21
67
  const prevVisible = React.usePrevious(visible);
22
68
  const cancelRef = React.useRef(false);
23
69
  const cancel = ()=>{
@@ -25,37 +71,41 @@ export default function App({onScan,onGrantAccess,testID,onDenyAccess,scannerPro
25
71
  setVisible(false);
26
72
  }
27
73
  const getCameraType = ()=>{
28
- let {type} = scannerProps;
74
+ let {type,facing} = cameraProps;
75
+ if(isNonNullString(facing)){
76
+ facing = facing.toLowerCase();
77
+ }
78
+ if(facing && (isNonNullString(facing) || typeof facing =="number") && cameraType[facing]){
79
+ return cameraType[facing]
80
+ }
29
81
  if(isNonNullString(type)){
30
82
  type = type.toLowerCase().trim();
31
- } else type = scannerTypes.back;
32
- if(!scannerTypes[type]){
33
- type = scannerTypes.back;
83
+ } else type = cameraTypes.back;
84
+ if(!cameraTypes[type]){
85
+ type = cameraTypes.back;
34
86
  }
35
87
  return type;
36
88
  }
37
89
  const sType = useMemo(()=>{
38
90
  return getCameraType();
39
- },[scannerProps.type]);
40
- const [scannerType,setScannerType] = useState(sType);
91
+ },[cameraProps.type,cameraProps.facing]);
92
+ const [cameraType,setCameraType] = useState(sType);
41
93
  useEffect(()=>{
42
94
  const type = getCameraType();
43
- if(type !== scannerType){
44
- setScannerType(type);
95
+ if(type !== cameraType){
96
+ setCameraType(type);
45
97
  }
46
- },scannerProps.type)
47
- const isBack = scannerType === scannerTypes.back;
98
+ },cameraProps.type)
99
+ const isBack = cameraType === cameraTypes.back;
48
100
  useEffect(() => {
49
- const getBarCodeScannerPermissions = async () => {
50
- const { status } = await BarCodeScanner.requestPermissionsAsync();
51
- setHasPermission(status === 'granted');
101
+ const getCameraPermissions = async () => {
102
+ const { status } = await Camera.requestCameraPermissionsAsync();
103
+ setHasPermission(status === "granted");
52
104
  };
53
-
54
- getBarCodeScannerPermissions();
105
+ getCameraPermissions();
55
106
  }, []);
56
107
 
57
108
  const handleBarCodeScanned = ({ type, data,...rest }) => {
58
- //setScanned(true);
59
109
  if(typeof onScan =="function"){
60
110
  onScan({type,data,code:data,barCode:data,...rest});
61
111
  }
@@ -84,12 +134,29 @@ export default function App({onScan,onGrantAccess,testID,onDenyAccess,scannerPro
84
134
  icon : "camera-flip",
85
135
  tooltip : `Cliquez pour basculer à la camera ${isBack ? "frontable":"arrière"}`,
86
136
  onPress : ()=>{
87
- setScannerType(isBack ? scannerTypes.front : scannerTypes.back);
137
+ setCameraType(isBack ? cameraTypes.front : cameraTypes.back);
88
138
  }
89
139
  };
90
140
  return <Dialog
91
141
  fullPage
92
- actions={[switchCameraBtn]}
142
+ actions={[
143
+ switchCameraBtn,
144
+ {
145
+ text : "Options de la camera",
146
+ icon : "material-settings",
147
+ tooltip : `Définir les options de la camera`,
148
+ onPress : ()=>{
149
+ DialogProvider.open({
150
+ tile : "Options de la camera",
151
+ data : cameraSetting,
152
+ fields : cameraSetingsFields,
153
+ onSuccess : ({data})=>{
154
+ setCameraSetting(data);
155
+ },
156
+ })
157
+ }
158
+ }
159
+ ]}
93
160
  title = {`Scanner un code barre`}
94
161
  {...dialogProps}
95
162
  onBackActionPress={cancel}
@@ -102,13 +169,15 @@ export default function App({onScan,onGrantAccess,testID,onDenyAccess,scannerPro
102
169
  <ActivityIndicator size={'large'}/>
103
170
  </View>}
104
171
  </View> : <View style={[theme.styles.flex1]} testID={testID}>
105
- <BarCodeScanner
172
+ <CameraView
106
173
  ratio='16:9'
107
174
  testID={testID+"_ScannerContent"}
108
- {...scannerProps}
109
- type={scannerType}
110
- style={[theme.styles.flex1,{width:"100%",height:"100%"},scannerProps.style]}
111
- onBarCodeScanned={handleBarCodeScanned}
175
+ {...cameraProps}
176
+ barCodeScannerSettings = {barCodeScannerSettings}
177
+ {...cameraSetting}
178
+ facing = {cameraProps.facing}
179
+ style={[theme.styles.flex1,{width:"100%",height:"100%"},cameraProps.style]}
180
+ onBarcodeScanned={handleBarCodeScanned}
112
181
  />
113
182
  <View style={[styles.row,theme.styles.w100]}>
114
183
  <Button
@@ -1,7 +1,7 @@
1
1
  module.exports = {
2
2
  "@fto-consult/expo-ui": {
3
3
  "name": "@fto-consult/expo-ui",
4
- "version": "8.19.0",
4
+ "version": "8.24.0",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/borispipo/expo-ui.git"
@@ -34,7 +34,7 @@ module.exports = {
34
34
  "license": "MIT"
35
35
  },
36
36
  "@fto-consult/common": {
37
- "version": "4.19.4",
37
+ "version": "4.24.0",
38
38
  "url": "https://github.com/borispipo/common#readme",
39
39
  "license": "ISC"
40
40
  },
@@ -135,6 +135,11 @@ module.exports = {
135
135
  "url": "https://github.com/web-ridge/react-native-paper-dates#readme",
136
136
  "license": "MIT"
137
137
  },
138
+ "react-native-uuid": {
139
+ "version": "2.0.1",
140
+ "url": "https://github.com/eugenehp/react-native-uuid#readme",
141
+ "license": "MIT"
142
+ },
138
143
  "react-native-web": {
139
144
  "version": "0.19.10",
140
145
  "url": "git://github.com/necolas/react-native-web.git",