@fto-consult/expo-ui 6.8.1 → 6.9.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/appConfig.txt CHANGED
@@ -20,4 +20,7 @@
20
20
  handleHelpScreen : {boolean}, //if Help screen will be added on navigation's main drawer
21
21
 
22
22
  checkNavigationPermsOnTableOrStructData : {boolean}, si le test de la permission sur la table data où sur la struct data sera effectuée lorsqu'on appelera la fonction navigateToTableData ou navigateToStructData
23
- }
23
+ }
24
+
25
+ la routine useMainNavigation de $enavigation/hooks, renvoie toutes les propriétés passées à l'objet principal MainNavoigationProvider, nottement,
26
+ la fonction onGetStart, qui est appélé après initialisation de l'application, mais aussi l'état du composant App de $expoUI/src/index
@@ -70,21 +70,11 @@ module.exports = (opts)=>{
70
70
  opts.mutator(r);
71
71
  }
72
72
  r.$eutils = path.resolve(expo,"utils");
73
- r.$ehooks = path.resolve(expo,"hooks");
73
+ r.$ehooks = path.resolve(expo,"context","hooks");
74
74
  ///le chemin racine du projet expo-ui
75
75
  r["$expo-ui-root-path"] = r["$expo-ui-root"]= path.resolve(expo,"..");
76
76
 
77
77
  const HelpScreen = path.resolve(r["$escreens"],"Help");
78
- /*** alias des termsOfUses */
79
- r.$eTermsOfUses = path.resolve(HelpScreen,"TermsOfUses","content");
80
- if(!r.$TermsOfUses){
81
- r.$TermsOfUses = r.$eTermsOfUses;
82
- }
83
- /*** alias des privacyPolicy */
84
- r.$ePrivacyPolicy = path.resolve(HelpScreen,"PrivacyPolicy","content");
85
- if(!r.$PrivacyPolicy){
86
- r.$PrivacyPolicy = r.$ePrivacyPolicy;
87
- }
88
78
  ///on génère les librairies open sources utilisées par l'application
89
79
  const root = path.resolve(r.$src,"..");
90
80
  const nModulePath = fs.existsSync(path.resolve(root,"node_modules")) && path.resolve(root,"node_modules") || fs.existsSync(path.resolve(r.$src,"node_modules")) && path.resolve(r.$src,"node_modules") || path.resolve(base,"node_modules");
package/babel.config.js CHANGED
@@ -51,7 +51,7 @@ module.exports = function(api,opts) {
51
51
  if(!indexContent || (!indexContent.includes("table") && !indexContent.includes("tableName"))){
52
52
  return;
53
53
  }
54
- getTableJSContent+=`\n\t\tif(tableName === "${tableName}"){return require("./${table}").default;}`;
54
+ getTableJSContent+=`\t\tif(tableName === "${tableName}"){return require("./${table}").default;}\n`;
55
55
  });
56
56
  //on génère le fichier getTable des tables data de l'application
57
57
  if(getTableJSContent){
package/index.js CHANGED
@@ -1,9 +1,8 @@
1
1
  import { registerRootComponent } from "expo";
2
2
  import {Platform } from 'react-native';
3
3
  import App from "./src/App";
4
- import { Provider } from "$econtext";
4
+ import Provider from "$econtext/Provider";
5
5
  const isWeb = Platform.OS === "web";
6
- import {isObj} from "$cutils";
7
6
 
8
7
  /****
9
8
  * les options sont de la forme :
@@ -17,10 +16,9 @@ import {isObj} from "$cutils";
17
16
  * les écrans d'initialisation doivent garder la propriété Start à true ou doivent avoir le groupe INTALL, pour spécifier que ce sont es écrans qui apparaissent lorsque l'application n'est pas initialisée
18
17
  * }
19
18
  */
20
- export default function registerApp (options){
21
- const {onMount,onUnmount,onRender,render,swrConfig,...rest} = isObj(options)? options : {};
19
+ export default function registerApp ({onMount,onUnmount,onRender,render,swrConfig,init,...rest}){
22
20
  registerRootComponent(function(props){
23
- return <Provider {...props} {...rest} swrConfig={isObj(swrConfig) && swrConfig || {}} children={<App render={render} onMount={onMount} onUnmount={onUnmount} onRender={onRender}/>}/>
21
+ return <Provider {...props} {...rest} swrConfig={isObj(swrConfig) && swrConfig || {}} children={<App init={init} render={render} onMount={onMount} onUnmount={onUnmount} onRender={onRender}/>}/>
24
22
  });
25
23
  }
26
24
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fto-consult/expo-ui",
3
- "version": "6.8.1",
3
+ "version": "6.9.0",
4
4
  "description": "Bibliothèque de composants UI Expo,react-native",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -41,7 +41,7 @@
41
41
  "fix-dependencies": "expo-cli doctor --fix-dependencies",
42
42
  "delete-node-modules": "rimraf ./**/node_modules",
43
43
  "modifier-url-remote-git": "git remote set-url origin 'https://borispipo@github.com/borispipo/smart-eneo.git'",
44
- "update": "npm i expo @emotion/native@latest apexcharts@latest file-saver@latest fs-extra@latest google-libphonenumber@latest @pchmn/expo-material3-theme@latest @gorhom/portal@latest @emotion/native@latest @fto-consult/common@latest react-native-blob-util react-native-gesture-handler@latest react-native-iphone-x-helper@latest react-native-mime-types@latest react-native-paper@latest react-native-paper-dates@latest @react-navigation/native@latest @react-navigation/native-stack@latest react-virtuoso@latest sharp-cli@latest tippy.js@latest websql@latest xlsx@latest && npx expo install --fix"
44
+ "update": "npm i expo @emotion/native@latest react-native-big-list@latest apexcharts@latest file-saver@latest fs-extra@latest google-libphonenumber@latest @pchmn/expo-material3-theme@latest @gorhom/portal@latest @emotion/native@latest @fto-consult/common@latest react-native-blob-util react-native-gesture-handler@latest react-native-iphone-x-helper@latest react-native-mime-types@latest react-native-paper@latest react-native-safe-area-context@latest react-native-paper-dates@latest @react-navigation/native@latest @react-navigation/native-stack@latest react-native-screens@latest react-virtuoso@latest sharp-cli@latest tippy.js@latest websql@latest xlsx@latest && npx expo install --fix"
45
45
  },
46
46
  "bin": "./bin/index.js",
47
47
  "repository": {
@@ -94,7 +94,7 @@
94
94
  "react-dom": "^18.2.0",
95
95
  "react-native": "0.72.3",
96
96
  "react-native-big-list": "^1.6.1",
97
- "react-native-blob-util": "^0.18.3",
97
+ "react-native-blob-util": "^0.18.4",
98
98
  "react-native-gesture-handler": "^2.12.0",
99
99
  "react-native-iphone-x-helper": "^1.3.1",
100
100
  "react-native-mime-types": "^2.4.0",
@@ -102,7 +102,7 @@
102
102
  "react-native-paper-dates": "^0.18.12",
103
103
  "react-native-reanimated": "~3.3.0",
104
104
  "react-native-safe-area-context": "4.6.3",
105
- "react-native-screens": "~3.22.0",
105
+ "react-native-screens": "^3.22.1",
106
106
  "react-native-svg": "13.9.0",
107
107
  "react-native-web": "~0.19.6",
108
108
  "react-native-webview": "13.2.2",
package/src/App.js CHANGED
@@ -26,7 +26,7 @@ Object.map(Utils,(v,i)=>{
26
26
  }
27
27
  });
28
28
 
29
- export default function getIndex({onMount,onUnmount,render,onRender}){
29
+ export default function getIndex({onMount,onUnmount,render,onRender,init}){
30
30
  const {swrConfig} = useContext();
31
31
  const isScreenFocusedRef = React.useRef(true);
32
32
  ///garde pour chaque écran sa date de dernière activité
@@ -141,7 +141,7 @@ export default function getIndex({onMount,onUnmount,render,onRender}){
141
141
  >
142
142
  <GestureHandlerRootView style={{ flex: 1 }}>
143
143
  <SafeAreaProvider>
144
- <Index onMount={onMount} render={render} onUnmount={onUnmount} onRender={onRender}/>
144
+ <Index onMount={onMount} render={render} onUnmount={onUnmount} onRender={onRender} init={init}/>
145
145
  </SafeAreaProvider>
146
146
  </GestureHandlerRootView>
147
147
  </SWRConfig>
@@ -2,5 +2,5 @@ import React from "$react";
2
2
  export const DrawerContext = React.createContext(null);
3
3
 
4
4
  export const useDrawer = ()=>{
5
- return React.useContext(DrawerContext) || {};
5
+ return React.useContext(DrawerContext) || {hasContext:x=>false};
6
6
  }
@@ -166,6 +166,7 @@ const DrawerComponent = React.forwardRef((props,ref)=>{
166
166
  context.isMinimized = ()=>{
167
167
  return minimizable !== false && canBeMinimizedOrPermanent() && isDesktopMedia() && session.get("minimized")? true : false;
168
168
  }
169
+ const hasContext = ()=>drawerRef && isObj(drawerRef?.current) && Object.size(drawerRef?.current,true);
169
170
  context.canBeMinimizedOrPermanent = canBeMinimizedOrPermanent;
170
171
  context.isPermanent = x=>{
171
172
  if(!drawerRef.current || !drawerRef.current.isOpen()) return false;
@@ -247,8 +248,11 @@ const DrawerComponent = React.forwardRef((props,ref)=>{
247
248
  }
248
249
  return (
249
250
  <DrawerContext.Provider value={{
250
- context,drawerRef,
251
+ ...context,
252
+ context,
253
+ drawerRef,
251
254
  session,
255
+ hasContext,
252
256
  close : (cb,force) =>closeDrawer(drawerRef,cb,force),
253
257
  sessionName,
254
258
  isItemActive : (opts)=>{
@@ -1,6 +1,6 @@
1
1
  import PropTypes from "prop-types";
2
2
  import KeyboardEventHandler from "../KeyboardEventHandler";
3
- import { addMediaQueryUpdateStyeSubscription } from "$ehooks";
3
+ import { addMediaQueryUpdateStyeSubscription } from "$context/hooks";
4
4
  import Dimensions from "$cdimensions";
5
5
  const {getActions,getFormFields,Forms} = require("../utils")
6
6
  import TextField,{parseDecimal} from "$ecomponents/TextField";
@@ -26,9 +26,6 @@ export * from "./utils";
26
26
  //const isNative = isNativeMobile();
27
27
  const isAndroid = _isAndroid() //|| isAndroidMobileBrowser();
28
28
  const isWeb = _isWeb();
29
- const isIos = _isIos();
30
-
31
-
32
29
 
33
30
  const TextFieldComponent = React.forwardRef((componentProps,inputRef)=>{
34
31
  let {defaultValue,toCase:toCustomCase,color,validType,validRule,placeholder,outlined,placeholderColor,
@@ -136,6 +133,8 @@ const TextFieldComponent = React.forwardRef((componentProps,inputRef)=>{
136
133
  const isNormalMode = mode == normalMode ? true : false;
137
134
  const isFlatMode = mode == flatMode ? true : false;
138
135
 
136
+ const MULTIPLE_HEIGHT = isShadowMode ? HEIGHT : HEIGHT;
137
+
139
138
  const [inputState, setInputState] = React.useState({
140
139
  focused : false,
141
140
  touched: false,
@@ -287,7 +286,7 @@ const TextFieldComponent = React.forwardRef((componentProps,inputRef)=>{
287
286
  const borderWidth = outlined !== false ? (isFocused ? 2: 1):0;
288
287
  const _height = typeof flattenStyle.height == 'number' && flattenStyle.height > 20 ? flattenStyle.height : HEIGHT;
289
288
  const tHeight = _height;//isShadowMode ? (_height+(isMobileNative()?10:0)) : isNormalMode ? (_height-10) : _height;
290
- const heightRef = React.useRef(tHeight);
289
+ const heightRef = React.useRef(multiline?MULTIPLE_HEIGHT:tHeight);
291
290
  //const lineHeightRef = React.useRef(0);
292
291
  roundness = typeof roundness =='number'? roundness : undefined;
293
292
  const borderRadius = isShadowMode ? (roundness || Math.max(tHeight/3,10)) : isOutlinedMode ? (roundness || 10) : 0;
@@ -357,6 +356,7 @@ const TextFieldComponent = React.forwardRef((componentProps,inputRef)=>{
357
356
  inputStyle2,
358
357
  isNormalMode && styles.inputNormalMode,
359
358
  isShadowMode && styles.inputShadowMode,
359
+ isShadowMode && multiline && {minHeight:heightRef.current},
360
360
  multiline && {paddingTop : isFlatMode? 12 : 7},
361
361
  ],
362
362
  secureTextEntry,
@@ -377,10 +377,10 @@ const TextFieldComponent = React.forwardRef((componentProps,inputRef)=>{
377
377
  }
378
378
  if(multiline){
379
379
  if(!text2 || text2.length < 30){
380
- heightRef.current = HEIGHT;
380
+ heightRef.current = MULTIPLE_HEIGHT;
381
381
  setToggle(!toggle);
382
382
  } else if(target.scrollHeight > heightRef.current){
383
- heightRef.current = target.scrollHeight;
383
+ heightRef.current = Math.max(target.scrollHeight,MULTIPLE_HEIGHT);
384
384
  setToggle(!toggle);
385
385
  }
386
386
  }
@@ -3,7 +3,7 @@ import PropTypes from "prop-types";
3
3
  import React from "$react";
4
4
  import {isMobileNative} from "$cplatform";
5
5
  import {debounce,isNumber} from "$cutils";
6
- import {useMediaQueryUpdateStyle} from "$ehooks";
6
+ import {useMediaQueryUpdateStyle} from "$context/hooks";
7
7
 
8
8
 
9
9
  const ViewComponent = React.forwardRef(({onRender,onLayoutTimeout,onLayout,autoHeight,autoWidth,elevation,...props},ref)=>{
@@ -41,15 +41,8 @@ const Provider = ({children,getTableData,navigation,components,getStructData,tab
41
41
  structsData = isObj(structsData)? structsData : null;
42
42
  appConfig.tablesData = tablesData;
43
43
  appConfig.structsData = appConfig.structsData = isObj(structsData)? structsData : null;
44
- if(isObj(tablesData) && Object.size(tablesData,true)){
45
- appConfig.getTableData = (tableName)=>{
46
- if(!isNonNullString(tableName)) return null;
47
- tableName = tableName.trim();
48
- }
49
- } else if(typeof getTableData =='function'){
50
- appConfig.getTableData = getTableData;
51
- }
52
- appConfig.getStructData = getStructData;
44
+ getTableData = appConfig.getTable = appConfig.getTableData = getTableOrStructDataCall(tablesData,getTableData);
45
+ getStructData = appConfig.getStructData = getTableOrStructDataCall(structsData,getStructData);
53
46
  appConfig.LoginComponent = Login;
54
47
  //const colorScheme = useColorScheme();
55
48
  appConfig.extendAppTheme = (theme)=>{
@@ -93,12 +86,28 @@ const Provider = ({children,getTableData,navigation,components,getStructData,tab
93
86
  return extendProps(components.tableLinkPropsMutator,props);
94
87
  }
95
88
  },
96
- getTableData,getStructData,tablesData,structsData,appConfig
89
+ getTableData,
90
+ getTable : getTableData,
91
+ getStructData,
92
+ tablesData,
93
+ structsData,
94
+ appConfig
97
95
  }}
98
96
  children={children}
99
97
  />;
100
98
  }
101
-
99
+ const getTableOrStructDataCall = (tablesOrStructDatas,getTableOrStructDataFunc)=>{
100
+ return (tableName,...rest)=>{
101
+ if(!isNonNullString(tableName)) return null;
102
+ tableName = tableName.trim();
103
+ const ret2 = typeof getTableOrStructDataFunc ==='function' ? getTableOrStructDataFunc (tableName,...rest) : null;
104
+ if(isObj(ret2) && Object.size(ret2,true)) return ret2;
105
+ if(!isObj(tablesOrStructDatas)) return null;
106
+ const ret = tablesOrStructDatas[tableName] || tablesOrStructDatas[tableName.toLowerCase()] || tablesOrStructDatas[tableName.toUpperCase];
107
+ if(isObj(ret)) return ret;
108
+ return null;
109
+ }
110
+ }
102
111
  const extendProps = (cb,props)=>{
103
112
  const prs = defaultObj(props);
104
113
  const o = typeof cb ==='function'? cb(props) : null;
@@ -1,3 +1,11 @@
1
+
2
+
3
+ import Dimensions from "$cplatform/dimensions";
4
+ import useStableMemo from "$react/useStableMemo";
5
+ import { useWindowDimensions } from "$cdimensions";
6
+ import {isObj,isNonNullString} from "$cutils";
7
+ import { StyleSheet } from "react-native";
8
+
1
9
  import { createContext,useContext as useReactContext } from "react";
2
10
 
3
11
  export const ExpoUIContext = createContext(null);
@@ -8,4 +16,51 @@ export default useExpoUI;
8
16
 
9
17
  export const useContext = useExpoUI;
10
18
 
11
- export const useApp = useContext;
19
+ export const useApp = useContext;
20
+
21
+ /**** retourne un composant définit dans la props
22
+ components de la fonction registerApp appelée pour l'initialisation de l'application
23
+ @param {string} componentName : le nom du composant que l'on veut recupérer
24
+ */
25
+ export const useAppGetComponent = (componentName)=>{
26
+ if(!isNonNullString(componentName)) return null;
27
+ componentName = componentName.trim();
28
+ const {components} = useExpoUI();
29
+ const camCase = componentName.toCamelCase();
30
+ const lowerFirst = camCase.lowerFirst();
31
+ return components[componentName] || components[componentName.toLowerCase()] || components[componentName.ucFirst()] || components[camCase] || components[lowerFirst] || components[componentName.toUpperCase()] || null;
32
+ }
33
+
34
+ /*** permet d'attacher un lister sur la modification des props de manière responsive :
35
+ permet de récupérer la fonction à attacher par défaut au listener DimensionChange, pour la mise à jour automatique de la propriété style
36
+ * @param mediaQueryUpdateStyleCb{function}, la fonction permettant de mettre à jour les props lorsque la taille de l'écran change
37
+ * @param timeout {number}, le délai d'attente à passer à la fonction debounce, pour pouvoir appeler la fonction de mise à jour des props lorsque la taile de l'écran change
38
+ * @return {object{remove:function}||null} l'objet null ou ayan la fonction remove permettant de suprimer le listerner lorsque le composant est démonté
39
+ */
40
+ export const addMediaQueryUpdateStyeSubscription = (mediaQueryUpdateStyleCb,timeout)=>{
41
+ if(typeof mediaQueryUpdateStyleCb !='function') return null;
42
+ const options = isObj(timeout)? timeout : {};
43
+ timeout = typeof timeout =='number'? timeout : typeof options.timeout =='number'? options.timeout : 200;
44
+ return Dimensions.addEventListener("change",debounce((dimensions)=>{
45
+ return mediaQueryUpdateStyleCb(Dimensions.getDimensionsProps(dimensions));
46
+ },timeout));
47
+ }
48
+
49
+ /*** met à jour dynamiquemnet les propriétés style d'un objet en fonction du changement de la taille de l'objet
50
+ * @param {useCurrentMedia} {boolean} si true, alors les propriétés sont mis à jour uniquement si le current media change
51
+ @param {mediaQueryUpdateStyle}, la fonction permettant d'obtenir les propriétés css du composant à retourner
52
+ @return {object}, le flatten style des propriétés css associés aux props du composant react l'object
53
+ */
54
+ export function useMediaQueryUpdateStyle({useCurrentMedia,target,mediaQueryUpdateStyle,...props}){
55
+ if(typeof mediaQueryUpdateStyle !=='function') return props.style;
56
+ const dimensions = useWindowDimensions();
57
+ const handleProps = dimensions && useCurrentMedia === true ? Dimensions.getCurrentMedia() : dimensions;
58
+ return useStableMemo(()=>{
59
+ const args = Dimensions.getDimensionsProps();
60
+ args.props = props,
61
+ args.target = target;
62
+ const nStyle = mediaQueryUpdateStyle(args);
63
+ if(isObj(nStyle) || Array.isArray(nStyle)) return StyleSheet.flatten([props.style,nStyle]);
64
+ return StyleSheet.flatten(props.style)||{};
65
+ },[handleProps,useCurrentMedia,dimensions,props.style]);
66
+ }
package/src/index.js CHANGED
@@ -273,7 +273,7 @@ function App({init:initApp,initialRouteName:appInitialRouteName,render,onMount})
273
273
  initialRouteName = {defaultStr(hasGetStarted ? appInitialRouteName : getStartedRouteName,"Home")}
274
274
  state = {state}
275
275
  hasGetStarted = {hasGetStarted}
276
- isInitialized = {!isLoading}
276
+ isInitialized = {isInitialized}
277
277
  onGetStart = {(e)=>{
278
278
  setState({...state,hasGetStarted:true})
279
279
  }}
@@ -282,7 +282,7 @@ function App({init:initApp,initialRouteName:appInitialRouteName,render,onMount})
282
282
  </PortalProvider>
283
283
  </NavigationContainer> : null;
284
284
  const content = isLoaded ? typeof render == 'function'? render({children:child,appConfig,config:appConfig}) : child : null;
285
- return (<SplashScreen isLoaded={!isLoading}>
285
+ return (<SplashScreen isLoaded={isLoaded}>
286
286
  <AuthProvider>
287
287
  <PaperProvider
288
288
  theme={theme}
@@ -10,11 +10,32 @@ export * from "./utils";
10
10
 
11
11
  const AppBarLayout = React.forwardRef(({backActionProps,withDrawer,backAction,backActionRef,options,...props},ref)=>{
12
12
  const innerRef = React.useRef(null);
13
+ const {drawerRef} = useDrawer();
13
14
  options = defaultObj(options);
14
15
  const mergedRef = React.useMergeRefs(innerRef,ref);
15
16
  return <AppBar
16
17
  backAction = {getBackActionComponent({backAction,backActionProps,withDrawer})}
17
18
  {...props}
19
+ onBackActionPress = {(args)=>{
20
+ const {canGoBack,goBack} = args;
21
+ if(typeof props.onPress ==='function' && props.onPress(args) === false) return false;
22
+ if((backAction === true || backActionProps?.back === true) && canGoBack()){
23
+ goBack();
24
+ return false;
25
+ }
26
+ if(drawerRef && drawerRef?.current){
27
+ if(drawerRef?.current?.isMinimized() && drawerRef?.current?.isOpen()){
28
+ drawerRef?.current?.restore();
29
+ return false;
30
+ }
31
+ if(!drawerRef?.current?.isPermanent()){
32
+ drawerRef?.current?.toggle();
33
+ } else if(!drawerRef?.current?.isOpen()){
34
+ drawerRef?.current?.open();
35
+ }
36
+ }
37
+ return false;
38
+ }}
18
39
  ref = {mergedRef}
19
40
  />
20
41
  });
@@ -28,32 +49,12 @@ export const getBackActionComponent = ({backAction,backActionProps,withDrawer})=
28
49
  size,
29
50
  ...backActionProps,
30
51
  ...props,
31
- onPress : (args)=>{
32
- const {canGoBack,goBack} = args;
33
- if(typeof props.onPress ==='function' && props.onPress(args) === false) return false;
34
- if(backAction === true && canGoBack()){
35
- goBack();
36
- return false;
37
- }
38
- if(drawerRef && drawerRef.current){
39
- if(drawerRef.current.isMinimized() && drawerRef.current.isOpen()){
40
- drawerRef.current.restore();
41
- return false;
42
- }
43
- if(!drawerRef.current.isPermanent()){
44
- drawerRef.current.toggle();
45
- } else if(!drawerRef.current.isOpen()){
46
- drawerRef.current.open();
47
- }
48
- }
49
- return false;
50
- },
51
52
  }
52
53
  if(backAction === true) return <Appbar.BackAction {...bProps}/>;
53
- const isPermanent = typeof drawerRef.current?.isPermanent =='function' && drawerRef?.current?.isPermanent();
54
- const isMinimized = typeof drawerRef.current?.isMinimized =="function" && drawerRef.current.isMinimized();
54
+ const isPermanent = typeof drawerRef?.current?.isPermanent =='function' && drawerRef?.current?.isPermanent();
55
+ const isMinimized = typeof drawerRef?.current?.isMinimized =="function" && drawerRef?.current?.isMinimized();
55
56
  if(backAction === false || withDrawer === false) return null;
56
- const hasRightPosition = typeof drawerRef.current?.hasRightPosition =="function" && drawerRef.current?.hasRightPosition();
57
+ const hasRightPosition = typeof drawerRef?.current?.hasRightPosition =="function" && drawerRef?.current?.hasRightPosition();
57
58
  if(isMinimized){
58
59
  bProps.style =[bProps.style];
59
60
  if(hasRightPosition){
@@ -0,0 +1,11 @@
1
+ import {createContext,useContext} from "react";
2
+
3
+ const MainNavigationContext = createContext(null);
4
+
5
+ export const useMainNavigation = ()=>{
6
+ return useContext(MainNavigationContext);
7
+ }
8
+
9
+ export const MainNavigationProvider = ({children,...props})=>{
10
+ return <MainNavigationContext.Provider value = {props} children={children}/>
11
+ }
@@ -4,6 +4,9 @@ import {Stack,setInitialRouteName } from "$cnavigation";
4
4
  import React from "$react";
5
5
  import DrawerNavigator from "./Drawer";
6
6
  import useContext from "$econtext/hooks";
7
+ import { MainNavigationProvider } from "./hooks";
8
+
9
+ export * from "./hooks";
7
10
 
8
11
  export * from "./utils";
9
12
 
@@ -11,15 +14,9 @@ export * from "./utils";
11
14
  * lorsque hasGetStarted est à false, celle-ci rend l'écran Start permettant de rendre le contenu GetStarted
12
15
  */
13
16
  export default function NavigationComponent (props){
14
- let {state,hasGetStarted,onGetStart,initialRouteName,extra} = props;
17
+ let {state,hasGetStarted,onGetStart,initialRouteName,...rest} = props;
15
18
  const {navigation:{screens}} = useContext();
16
19
  const allScreens = initScreens({Factory:Stack,screens,ModalFactory:Stack,filter:({name})=>{
17
- if(name === initialRouteName){
18
- extra = defaultObj(extra);
19
- extra.onGetStart = onGetStart;
20
- extra.state = state;
21
- return extra;
22
- }
23
20
  return true;
24
21
  }});
25
22
  initialRouteName = sanitizeName(initialRouteName);
@@ -33,25 +30,27 @@ export default function NavigationComponent (props){
33
30
  headerShown : false,
34
31
  header : ()=> null,
35
32
  }
36
- return <DrawerNavigator {...props}>
33
+ return <MainNavigationProvider {...rest} onGetStart={onGetStart} state={state} initialRouteName={initialRouteName}>
34
+ <DrawerNavigator {...props}>
37
35
  {<Stack.Navigator
38
- initialRouteName={initialRouteName}
39
- screenOptions={opts}
40
- >
41
- {<Stack.Group screenOptions={{...opts}}>
42
- {drawerScreens}
43
- </Stack.Group>}
44
- <Stack.Group
45
- key = {"MODAL-DRAWERS-SCREENS"}
46
- screenOptions={{
47
- ...opts,
48
- presentation: 'transparentModal',
49
- }}
36
+ initialRouteName={initialRouteName}
37
+ screenOptions={opts}
50
38
  >
51
- {stackScreens}
52
- </Stack.Group>
53
- </Stack.Navigator> }
54
- </DrawerNavigator>
39
+ {<Stack.Group screenOptions={{...opts}}>
40
+ {drawerScreens}
41
+ </Stack.Group>}
42
+ <Stack.Group
43
+ key = {"MODAL-DRAWERS-SCREENS"}
44
+ screenOptions={{
45
+ ...opts,
46
+ presentation: 'transparentModal',
47
+ }}
48
+ >
49
+ {stackScreens}
50
+ </Stack.Group>
51
+ </Stack.Navigator> }
52
+ </DrawerNavigator>
53
+ </MainNavigationProvider>
55
54
  }
56
55
 
57
56
  export * from "$cnavigation";
@@ -1,13 +1,16 @@
1
1
  // Copyright 2022 @fto-consult/Boris Fouomene. All rights reserved.
2
2
  // Use of this source code is governed by a BSD-style
3
3
  // license that can be found in the LICENSE file.
4
-
4
+ import {useAppGetComponent} from "$econtext/hooks";
5
5
  import Label from "$ecomponents/Label";
6
+ import React from "$react";
6
7
 
7
8
  export default function ContentPrivacy (){
8
- return <Label primary style={{fontSize:15,fontWeight:'bold',padding:10}}>
9
- Pour modifier le contenu de la politique de confidentialité, il suffit de déclarer dans les alias, l'alias
10
- $PrivacyPolicy prointant vers un fichier javascript dans lequel on exporte par défaut, soit un composant React
11
- encore un élément react valide dont le rendu remplacera ledit contenu.
12
- </Label>
9
+ const PrivacyPolicy = useAppGetComponent("PrivacyPolicy");
10
+ return React.isComponent(PrivacyPolicy) ? <PrivacyPolicy/>
11
+ : React.isValidElement(PrivacyPolicy) ? PrivacyPolicy :
12
+ <Label primary style={{fontSize:15,fontWeight:'bold',padding:10}}>
13
+ Pour modifier le contenu de la politique de confidentialité, il suffit de déclarer dans la propriété "components"
14
+ de la fonction "registerApp", initialisant l'application, un attribut "PrivacyPolicy|privacyPolicy", pointant vers le composant/l'élément react, dont le contenu , une fois rendu devra remplacer celui ci (le décrivant);
15
+ </Label>
13
16
  }
@@ -2,7 +2,7 @@ import {PRIVACY_POLICY} from "./routes";
2
2
  import title from "./title"
3
3
  import Screen from "$screen";
4
4
  import Link from "./Link";
5
- import Content from "$PrivacyPolicy";
5
+ import Content from "./content";
6
6
  import React from "$react";
7
7
 
8
8
  export default function PrivacyPolicy(props){
@@ -3,11 +3,15 @@
3
3
  // license that can be found in the LICENSE file.
4
4
 
5
5
  import Label from "$ecomponents/Label";
6
+ import {useAppGetComponent} from "$econtext/hooks";
7
+ import React from "$react";
6
8
 
7
9
  export default function ContentTermsOfUses (){
8
- return <Label primary style={{fontSize:15,fontWeight:'bold',padding:10}}>
9
- Pour modifier le contenu des Termes et contrat d'utilisation, il suffit de déclarer dans les alias, l'alias
10
- $TermsOfUses prointant vers un fichier javascript dans lequel on exporte par défaut, soit un composant React
11
- encore un élément react valide dont le rendu remplacera ledit contenu.
10
+ const TermsOfUses = useAppGetComponent("TermsOfUses");
11
+ return React.isComponent(TermsOfUses) ? <TermsOfUses/>
12
+ : React.isValidElement(TermsOfUses) ? TermsOfUses :
13
+ <Label primary style={{fontSize:15,fontWeight:'bold',padding:10}}>
14
+ Pour modifier le contenu des Termes et contrat d'utilisation, il suffit de déclarer dans la propriété "components"
15
+ de la fonction "registerApp", initialisant l'application, un attribut "TermsOfUses|termsOfUses", pointant vers le composant/l'élément react, dont le contenu, une fois rendu devra remplacer celui ci (le décrivant);
12
16
  </Label>
13
17
  }
@@ -2,7 +2,7 @@ import {TERMS_OF_USES} from "./routes";
2
2
  import title from "./title";
3
3
  import Screen from "$screen";
4
4
  import Link from "./Link";
5
- import Content from "$TermsOfUses";
5
+ import Content from "./content";
6
6
  import {extendObj} from "$cutils";
7
7
  import React from "$react";
8
8
 
@@ -5,4 +5,10 @@ export default [
5
5
  TermsOfUses,
6
6
  PrivacyPolicy,
7
7
  About,
8
- ]
8
+ ]
9
+
10
+ export {PrivacyPolicy};
11
+
12
+ export {About};
13
+
14
+ export {TermsOfUses};
@@ -109,7 +109,7 @@ export default function initScreens ({Factory,ModalFactory,screens,result,filter
109
109
  return result;
110
110
  }
111
111
 
112
- export const handleContent = ({screens,hasGetStarted,onGetStart,state,Factory})=>{
112
+ export const handleContent = ({screens,hasGetStarted,state,Factory})=>{
113
113
  const content = [];
114
114
  state = defaultObj(state);
115
115
  screens = defaultObj(screens);
@@ -1,41 +0,0 @@
1
-
2
- import Dimensions from "$cplatform/dimensions";
3
- import useStableMemo from "$react/useStableMemo";
4
- import { useWindowDimensions } from "$cdimensions";
5
- import {isObj} from "$cutils";
6
- import { StyleSheet } from "react-native";
7
-
8
-
9
- /*** permet d'attacher un lister sur la modification des props de manière responsive :
10
- permet de récupérer la fonction à attacher par défaut au listener DimensionChange, pour la mise à jour automatique de la propriété style
11
- * @param mediaQueryUpdateStyleCb{function}, la fonction permettant de mettre à jour les props lorsque la taille de l'écran change
12
- * @param timeout {number}, le délai d'attente à passer à la fonction debounce, pour pouvoir appeler la fonction de mise à jour des props lorsque la taile de l'écran change
13
- * @return {object{remove:function}||null} l'objet null ou ayan la fonction remove permettant de suprimer le listerner lorsque le composant est démonté
14
- */
15
- export const addMediaQueryUpdateStyeSubscription = (mediaQueryUpdateStyleCb,timeout)=>{
16
- if(typeof mediaQueryUpdateStyleCb !='function') return null;
17
- const options = isObj(timeout)? timeout : {};
18
- timeout = typeof timeout =='number'? timeout : typeof options.timeout =='number'? options.timeout : 200;
19
- return Dimensions.addEventListener("change",debounce((dimensions)=>{
20
- return mediaQueryUpdateStyleCb(Dimensions.getDimensionsProps(dimensions));
21
- },timeout));
22
- }
23
-
24
- /*** met à jour dynamiquemnet les propriétés style d'un objet en fonction du changement de la taille de l'objet
25
- * @param {useCurrentMedia} {boolean} si true, alors les propriétés sont mis à jour uniquement si le current media change
26
- @param {mediaQueryUpdateStyle}, la fonction permettant d'obtenir les propriétés css du composant à retourner
27
- @return {object}, le flatten style des propriétés css associés aux props du composant react l'object
28
- */
29
- export function useMediaQueryUpdateStyle({useCurrentMedia,target,mediaQueryUpdateStyle,...props}){
30
- if(typeof mediaQueryUpdateStyle !=='function') return props.style;
31
- const dimensions = useWindowDimensions();
32
- const handleProps = dimensions && useCurrentMedia === true ? Dimensions.getCurrentMedia() : dimensions;
33
- return useStableMemo(()=>{
34
- const args = Dimensions.getDimensionsProps();
35
- args.props = props,
36
- args.target = target;
37
- const nStyle = mediaQueryUpdateStyle(args);
38
- if(isObj(nStyle) || Array.isArray(nStyle)) return StyleSheet.flatten([props.style,nStyle]);
39
- return StyleSheet.flatten(props.style)||{};
40
- },[handleProps,useCurrentMedia,dimensions,props.style]);
41
- }